Module: Payoneer::Api::Core::ClassMethods
- Defined in:
- lib/payoneer/api/core.rb
Instance Method Summary collapse
- #config ⇒ Object
- #default_params ⇒ Object
- #get_method_name ⇒ Object
- #request(params = {}) ⇒ Object
- #to_api_params(params) ⇒ Object
- #to_response(response) ⇒ Object
Instance Method Details
#config ⇒ Object
34 35 36 |
# File 'lib/payoneer/api/core.rb', line 34 def config ::Payoneer.config end |
#default_params ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/payoneer/api/core.rb', line 38 def default_params { p1: config.partner_username, p2: config.partner_api_password, p3: config.partner_id, } end |
#get_method_name ⇒ Object
8 9 10 |
# File 'lib/payoneer/api/core.rb', line 8 def get_method_name self.name.split('::').last end |
#request(params = {}) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/payoneer/api/core.rb', line 20 def request(params = {}) params = to_api_params(params) method_name = get_method_name config.validate! request_params = default_params.merge(mname: method_name).merge(params) response = RestClient.post(config.api_url, request_params) fail Errors::ApiError.new(response.code, response.body) unless response.code == 200 to_response(response) end |
#to_api_params(params) ⇒ Object
11 12 13 |
# File 'lib/payoneer/api/core.rb', line 11 def to_api_params(params) params end |