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.



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

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.



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

def headers
  @headers
end

Instance Method Details

#cancel(body = {}) ⇒ Object



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

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

#post(body = {}) ⇒ Object



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

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