Class: LemonWay::Client
- Inherits:
-
Object
- Object
- LemonWay::Client
- 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
-
#company ⇒ Object
readonly
Returns the value of attribute company.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#login ⇒ Object
readonly
Returns the value of attribute login.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #send_request(lw_method, version, params = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/lemon_way/client.rb', line 29 def initialize( = {}) if (.keys & REQUIRED_CONFIGURATION).size != REQUIRED_CONFIGURATION.size raise MissingConfigurationError.new end @login = [:login] @password = [:password] @company = [:company] @env = [:sandbox] ? 'dev' : 'prod' @options = .delete_if { |k, _v| REQUIRED_CONFIGURATION.include?(k) } end |
Instance Attribute Details
#company ⇒ Object (readonly)
Returns the value of attribute company.
12 13 14 |
# File 'lib/lemon_way/client.rb', line 12 def company @company end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
12 13 14 |
# File 'lib/lemon_way/client.rb', line 12 def env @env end |
#login ⇒ Object (readonly)
Returns the value of attribute login.
12 13 14 |
# File 'lib/lemon_way/client.rb', line 12 def login @login end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
12 13 14 |
# File 'lib/lemon_way/client.rb', line 12 def @options end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
12 13 14 |
# File 'lib/lemon_way/client.rb', line 12 def password @password 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 |