Class: Suretax::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/suretax/connection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ Connection

Returns a new instance of Connection.



9
10
11
12
# File 'lib/suretax/connection.rb', line 9

def initialize(args = {})
  @link = Excon.new(args[:base_url] || api_host)
  @headers = { 'Content-Type' => 'application/x-www-form-urlencoded' }
end

Instance Attribute Details

#headersObject

Returns the value of attribute headers.



7
8
9
# File 'lib/suretax/connection.rb', line 7

def headers
  @headers
end

Instance Method Details

#cancel(body = {}) ⇒ Object



20
21
22
23
24
# File 'lib/suretax/connection.rb', line 20

def cancel(body = {})
  Response.new(@link.post(path: cancel_path,
                          headers: headers,
                          body: "requestCancel=#{encode_body(body)}"))
end

#post(body = {}) ⇒ Object



14
15
16
17
18
# File 'lib/suretax/connection.rb', line 14

def post(body = {})
  Response.new(@link.post(path: post_path,
                          headers: headers,
                          body: "request=#{encode_body(body)}"))
end