Class: LemonWay::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/lemon_way/client.rb

Constant Summary collapse

DIRECTKIT_URL =
'https://sandbox-api.lemonway.fr/mb/{company_name}/{env}/directkitjson2/Service.asmx'.freeze
REQUIRED_CONFIGURATION =
%i[login password company].freeze
DEFAULT_LANGUAGE =
'fr'.freeze
DEFAULT_HEADERS =
{
  'Content-Type' => 'application/json; charset=utf-8',
  'Accept' => 'application/json',
  'Cache-Control' => 'no-cache',
  'Pragma' => 'no-cache'
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/lemon_way/client.rb', line 28

def initialize(options = {})
  if (options.keys & REQUIRED_CONFIGURATION).size != REQUIRED_CONFIGURATION.size
    raise MissingConfigurationError.new
  end

  %i[login password company society_wallet_id].each do |key|
    instance_variable_set("@#{key}".to_sym, options.delete(key))
  end

  @env = options[:sandbox] ? 'dev' : 'prod'
  @options = options
end

Instance Attribute Details

#companyObject (readonly)

Returns the value of attribute company.



23
24
25
# File 'lib/lemon_way/client.rb', line 23

def company
  @company
end

#envObject (readonly)

Returns the value of attribute env.



23
24
25
# File 'lib/lemon_way/client.rb', line 23

def env
  @env
end

#loginObject (readonly)

Returns the value of attribute login.



23
24
25
# File 'lib/lemon_way/client.rb', line 23

def 
  @login
end

#optionsObject (readonly)

Returns the value of attribute options.



23
24
25
# File 'lib/lemon_way/client.rb', line 23

def options
  @options
end

#passwordObject (readonly)

Returns the value of attribute password.



23
24
25
# File 'lib/lemon_way/client.rb', line 23

def password
  @password
end

#society_wallet_idObject (readonly)

Returns the value of attribute society_wallet_id.



23
24
25
# File 'lib/lemon_way/client.rb', line 23

def society_wallet_id
  @society_wallet_id
end

Instance Method Details

#send_request(lw_method, version, params = {}) ⇒ Object



41
42
43
44
45
# File 'lib/lemon_way/client.rb', line 41

def send_request(lw_method, version, params = {})
  response = perform_request(lw_method, version, params)

  ResponseAdapter.new(response)
end