Class: Taxjar::API::Request
- Inherits:
-
Object
- Object
- Taxjar::API::Request
- Defined in:
- lib/taxjar/api/request.rb
Constant Summary collapse
- BASE_URL =
'https://api.taxjar.com'
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#object_key ⇒ Object
readonly
Returns the value of attribute object_key.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#request_method ⇒ Object
readonly
Returns the value of attribute request_method.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
-
#initialize(client, request_method, path, object_key, options = {}) ⇒ Request
constructor
A new instance of Request.
- #perform ⇒ Object
Constructor Details
#initialize(client, request_method, path, object_key, options = {}) ⇒ Request
Returns a new instance of Request.
15 16 17 18 19 20 21 22 23 |
# File 'lib/taxjar/api/request.rb', line 15 def initialize(client, request_method, path, object_key, = {}) @client = client @request_method = request_method @path = path @uri = Addressable::URI.parse(BASE_URL + path) set_request_headers @object_key = object_key @options = end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
9 10 11 |
# File 'lib/taxjar/api/request.rb', line 9 def client @client end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
9 10 11 |
# File 'lib/taxjar/api/request.rb', line 9 def headers @headers end |
#object_key ⇒ Object (readonly)
Returns the value of attribute object_key.
9 10 11 |
# File 'lib/taxjar/api/request.rb', line 9 def object_key @object_key end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/taxjar/api/request.rb', line 9 def @options end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
9 10 11 |
# File 'lib/taxjar/api/request.rb', line 9 def path @path end |
#request_method ⇒ Object (readonly)
Returns the value of attribute request_method.
9 10 11 |
# File 'lib/taxjar/api/request.rb', line 9 def request_method @request_method end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
9 10 11 |
# File 'lib/taxjar/api/request.rb', line 9 def uri @uri end |
Instance Method Details
#perform ⇒ Object
25 26 27 28 29 30 |
# File 'lib/taxjar/api/request.rb', line 25 def perform = @request_method == :get ? :params : :json response = HTTP.with(headers).public_send(request_method, uri.to_s, => @options) response_body = symbolize_keys!(response.parse) fail_or_return_response_body(response.code, response_body) end |