Class: MHVAC::Client

Inherits:
Common::Client::Base show all
Defined in:
lib/mhv_ac/client.rb

Overview

Core class responsible for MHVAC API interface operations

Instance Method Summary collapse

Methods inherited from Common::Client::Base

configuration, #raise_backend_exception

Methods included from SentryLogging

#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger

Instance Method Details

#get_countriesHash

Note:

These two lists (state and country) should be cached for any given day.

Get a list of available countries (used for registraion)

Returns:

  • (Hash)

    an object containing the body of the response



49
50
51
# File 'lib/mhv_ac/client.rb', line 49

def get_countries
  perform(:get, 'enum/countries', nil, nonauth_headers).body
end

#get_statesHash

Note:

These two lists (state and country) should be cached for any given day

Get a list of available states (used for registration)

Returns:

  • (Hash)

    an object containing the body of the response



40
41
42
# File 'lib/mhv_ac/client.rb', line 40

def get_states
  perform(:get, 'enum/states', nil, nonauth_headers).body
end

#post_register(params) ⇒ Hash

Create an MHV account

Parameters:

  • params (Hash)

    A hash of user parameters

Returns:

  • (Hash)

    an object containing the body of the response



20
21
22
23
# File 'lib/mhv_ac/client.rb', line 20

def post_register(params)
  form = MHVAC::RegistrationForm.new(params)
  perform(:post, 'account/register', form.mhv_params, nonauth_headers).body
end

#post_upgrade(params) ⇒ Hash

Upgrade an MHV account

Parameters:

  • params (Hash)

    A hash of user parameters

Returns:

  • (Hash)

    an object containing the body of the response



30
31
32
33
# File 'lib/mhv_ac/client.rb', line 30

def post_upgrade(params)
  form = MHVAC::UpgradeForm.new(params)
  perform(:post, 'account/upgrade', form.mhv_params, nonauth_headers).body
end