Class: PaymentsApi::HttpClient

Inherits:
Object
  • Object
show all
Includes:
Errors
Defined in:
lib/payments_api/http_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Errors

#raise_error!

Constructor Details

#initialize(options = {}) ⇒ HttpClient

Returns a new instance of HttpClient.



11
12
13
# File 'lib/payments_api/http_client.rb', line 11

def initialize(options = {})
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



9
10
11
# File 'lib/payments_api/http_client.rb', line 9

def options
  @options
end

Instance Method Details

#get(href, query = {}) ⇒ Object

Only GET and POST verbs are used with Payments API, but more verbs can be easily added as needed.



18
19
20
21
22
# File 'lib/payments_api/http_client.rb', line 18

def get(href, query = {})
  execute_request!(:get, href) do |req|
    req.params.update(query)
  end
end

#post(href, payload = {}) ⇒ Object



24
25
26
27
28
# File 'lib/payments_api/http_client.rb', line 24

def post(href, payload = {})
  execute_request!(:post, href) do |req|
    req.body = JSON.dump(payload)
  end
end