Class: Tappay::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/tappay/client.rb

Direct Known Subclasses

PaymentBase, Refund

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



10
11
12
13
# File 'lib/tappay/client.rb', line 10

def initialize(options = {})
  @options = options
  @timeout = options.fetch(:timeout, 25)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/tappay/client.rb', line 8

def options
  @options
end

Instance Method Details

#post(url, data) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/tappay/client.rb', line 15

def post(url, data)
  @response = self.class.post(
    url,
    body: data.to_json,
    headers: headers,
    timeout: timeout
  )

  validate_response
  @response
rescue HTTParty::Error, Timeout::Error, Net::OpenTimeout => e
  raise ConnectionError, "HTTP Request failed: #{e.message}"
end