Module: Taxjar::API::Utils
- Included in:
- Taxjar::API, Customer, Order, Refund
- Defined in:
- lib/taxjar/api/utils.rb
Instance Method Summary collapse
- #perform_delete_with_object(path, object_key, options, klass) ⇒ Object
- #perform_get_with_array(path, object_key, options) ⇒ Object
- #perform_get_with_object(path, object_key, options, klass) ⇒ Object
- #perform_get_with_objects(path, object_key, options, klass) ⇒ Object
- #perform_post_with_object(path, object_key, options, klass) ⇒ Object
- #perform_post_with_objects(path, object_key, options, klass) ⇒ Object
- #perform_put_with_object(path, object_key, options, klass) ⇒ Object
- #perform_request(request_method, path, object_key, options = {}) ⇒ Object
- #perform_request_with_array(request_method, path, object_key, options) ⇒ Object
- #perform_request_with_object(request_method, path, object_key, options, klass) ⇒ Object
- #perform_request_with_objects(request_method, path, object_key, options, klass) ⇒ Object
Instance Method Details
#perform_delete_with_object(path, object_key, options, klass) ⇒ Object
34 35 36 |
# File 'lib/taxjar/api/utils.rb', line 34 def perform_delete_with_object(path, object_key, , klass) perform_request_with_object(:delete, path, object_key, , klass) end |
#perform_get_with_array(path, object_key, options) ⇒ Object
18 19 20 |
# File 'lib/taxjar/api/utils.rb', line 18 def perform_get_with_array(path, object_key, ) perform_request_with_array(:get, path, object_key, ) end |
#perform_get_with_object(path, object_key, options, klass) ⇒ Object
10 11 12 |
# File 'lib/taxjar/api/utils.rb', line 10 def perform_get_with_object(path, object_key, , klass) perform_request_with_object(:get, path, object_key, , klass) end |
#perform_get_with_objects(path, object_key, options, klass) ⇒ Object
14 15 16 |
# File 'lib/taxjar/api/utils.rb', line 14 def perform_get_with_objects(path, object_key, , klass) perform_request_with_objects(:get, path, object_key, , klass) end |
#perform_post_with_object(path, object_key, options, klass) ⇒ Object
22 23 24 |
# File 'lib/taxjar/api/utils.rb', line 22 def perform_post_with_object(path, object_key, , klass) perform_request_with_object(:post, path, object_key, , klass) end |
#perform_post_with_objects(path, object_key, options, klass) ⇒ Object
26 27 28 |
# File 'lib/taxjar/api/utils.rb', line 26 def perform_post_with_objects(path, object_key, , klass) perform_request_with_objects(:post, path, object_key, , klass) end |
#perform_put_with_object(path, object_key, options, klass) ⇒ Object
30 31 32 |
# File 'lib/taxjar/api/utils.rb', line 30 def perform_put_with_object(path, object_key, , klass) perform_request_with_object(:put, path, object_key, , klass) end |
#perform_request(request_method, path, object_key, options = {}) ⇒ Object
6 7 8 |
# File 'lib/taxjar/api/utils.rb', line 6 def perform_request(request_method, path, object_key, = {}) Taxjar::API::Request.new(self, request_method, path, object_key, ).perform end |
#perform_request_with_array(request_method, path, object_key, options) ⇒ Object
50 51 52 |
# File 'lib/taxjar/api/utils.rb', line 50 def perform_request_with_array(request_method, path, object_key, ) perform_request(request_method, path, object_key, ) || [] end |
#perform_request_with_object(request_method, path, object_key, options, klass) ⇒ Object
38 39 40 41 |
# File 'lib/taxjar/api/utils.rb', line 38 def perform_request_with_object(request_method, path, object_key, , klass) response = perform_request(request_method, path, object_key, ) klass.new(response) end |
#perform_request_with_objects(request_method, path, object_key, options, klass) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/taxjar/api/utils.rb', line 43 def perform_request_with_objects(request_method, path, object_key, , klass) response_array = perform_request(request_method, path, object_key, ) || [] response_array.collect do |element| klass.new(element) end end |