Class: SbrfMerchant::Api::Client
- Inherits:
-
Object
- Object
- SbrfMerchant::Api::Client
- Defined in:
- lib/sbrf_merchant/api/client.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#http_client ⇒ Object
readonly
Returns the value of attribute http_client.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#request_body_preprocessor ⇒ Object
readonly
Returns the value of attribute request_body_preprocessor.
-
#response_body_postprocessor ⇒ Object
readonly
Returns the value of attribute response_body_postprocessor.
-
#uri_builder ⇒ Object
readonly
Returns the value of attribute uri_builder.
-
#user_name ⇒ Object
readonly
Returns the value of attribute user_name.
Instance Method Summary collapse
- #call(method_name, **params) ⇒ Object
-
#initialize(user_name:, password:, host:, response_body_postprocessor: SbrfMerchant::Api::Response::BodyPostProcessor.new, request_body_preprocessor: SbrfMerchant::Api::Request::BodyPreProcessor.new, http_client: SbrfMerchant::Utils::Http::Client.new, uri_builder: SbrfMerchant::Api::Request::UriBuilder.new) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(user_name:, password:, host:, response_body_postprocessor: SbrfMerchant::Api::Response::BodyPostProcessor.new, request_body_preprocessor: SbrfMerchant::Api::Request::BodyPreProcessor.new, http_client: SbrfMerchant::Utils::Http::Client.new, uri_builder: SbrfMerchant::Api::Request::UriBuilder.new) ⇒ Client
Returns a new instance of Client.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/sbrf_merchant/api/client.rb', line 19 def initialize( user_name:, password:, host:, response_body_postprocessor: SbrfMerchant::Api::Response::BodyPostProcessor.new, request_body_preprocessor: SbrfMerchant::Api::Request::BodyPreProcessor.new, http_client: SbrfMerchant::Utils::Http::Client.new, uri_builder: SbrfMerchant::Api::Request::UriBuilder.new ) @user_name = user_name @password = password @host = host @response_body_postprocessor = response_body_postprocessor @http_client = http_client @uri_builder = uri_builder @request_body_preprocessor = request_body_preprocessor end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
11 12 13 |
# File 'lib/sbrf_merchant/api/client.rb', line 11 def host @host end |
#http_client ⇒ Object (readonly)
Returns the value of attribute http_client.
11 12 13 |
# File 'lib/sbrf_merchant/api/client.rb', line 11 def http_client @http_client end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
11 12 13 |
# File 'lib/sbrf_merchant/api/client.rb', line 11 def password @password end |
#request_body_preprocessor ⇒ Object (readonly)
Returns the value of attribute request_body_preprocessor.
11 12 13 |
# File 'lib/sbrf_merchant/api/client.rb', line 11 def request_body_preprocessor @request_body_preprocessor end |
#response_body_postprocessor ⇒ Object (readonly)
Returns the value of attribute response_body_postprocessor.
11 12 13 |
# File 'lib/sbrf_merchant/api/client.rb', line 11 def response_body_postprocessor @response_body_postprocessor end |
#uri_builder ⇒ Object (readonly)
Returns the value of attribute uri_builder.
11 12 13 |
# File 'lib/sbrf_merchant/api/client.rb', line 11 def uri_builder @uri_builder end |
#user_name ⇒ Object (readonly)
Returns the value of attribute user_name.
11 12 13 |
# File 'lib/sbrf_merchant/api/client.rb', line 11 def user_name @user_name end |
Instance Method Details
#call(method_name, **params) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/sbrf_merchant/api/client.rb', line 37 def call(method_name, **params) prepared_params = request_body_preprocessor.call(auth_params.merge(params)) uri = uri_builder.call(host, method_name) response = http_client.call(uri, prepared_params) response_body_postprocessor.call(response.body) end |