Class: ActiveMerchant::Billing::Integrations::MollieIdeal::API
- Inherits:
-
Object
- Object
- ActiveMerchant::Billing::Integrations::MollieIdeal::API
- Includes:
- PostsData
- Defined in:
- lib/active_merchant/billing/integrations/mollie_ideal.rb
Instance Attribute Summary collapse
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
- #get_request(resource, params = nil) ⇒ Object
-
#initialize(token) ⇒ API
constructor
A new instance of API.
- #post_request(resource, params = nil) ⇒ Object
Constructor Details
#initialize(token) ⇒ API
Returns a new instance of API.
14 15 16 |
# File 'lib/active_merchant/billing/integrations/mollie_ideal.rb', line 14 def initialize(token) @token = token end |
Instance Attribute Details
#token ⇒ Object (readonly)
Returns the value of attribute token.
12 13 14 |
# File 'lib/active_merchant/billing/integrations/mollie_ideal.rb', line 12 def token @token end |
Instance Method Details
#get_request(resource, params = nil) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/active_merchant/billing/integrations/mollie_ideal.rb', line 18 def get_request(resource, params = nil) uri = URI.parse(MOLLIE_API_V1_URI + resource) uri.query = params.map { |k,v| "#{CGI.escape(k)}=#{CGI.escape(v)}}"}.join('&') if params headers = { "Authorization" => "Bearer #{token}", "Content-Type" => "application/json" } JSON.parse(ssl_get(uri.to_s, headers)) end |
#post_request(resource, params = nil) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/active_merchant/billing/integrations/mollie_ideal.rb', line 25 def post_request(resource, params = nil) uri = URI.parse(MOLLIE_API_V1_URI + resource) headers = { "Authorization" => "Bearer #{token}", "Content-Type" => "application/json" } data = params.nil? ? nil : JSON.dump(params) JSON.parse(ssl_post(uri.to_s, data, headers)) end |