class Suretax::Connection
Attributes
headers[RW]
Public Class Methods
new(args = {})
click to toggle source
# 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
Public Instance Methods
cancel(body = {})
click to toggle source
# 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 = {})
click to toggle source
# 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
Private Instance Methods
api_host()
click to toggle source
# File lib/suretax/connection.rb, line 40 def api_host configuration.base_url end
cancel_path()
click to toggle source
# File lib/suretax/connection.rb, line 36 def cancel_path configuration.cancel_path end
configuration()
click to toggle source
# File lib/suretax/connection.rb, line 44 def configuration Suretax.configuration end
encode_body(request_hash)
click to toggle source
# File lib/suretax/connection.rb, line 27 def encode_body(request_hash) json_body = JSON.generate(request_hash) URI.encode_www_form_component(json_body) end
post_path()
click to toggle source
# File lib/suretax/connection.rb, line 32 def post_path configuration.request_path end