Class: Taxjar::Client
- Inherits:
-
Object
- Object
- Taxjar::Client
- Defined in:
- lib/taxjar/client.rb
Instance Attribute Summary collapse
-
#conn ⇒ Object
readonly
Returns the value of attribute conn.
Instance Method Summary collapse
- #create_order_transaction(options = {}) ⇒ Object
- #create_refund_transaction(options = {}) ⇒ Object
- #delete_order_transaction(options = {}) ⇒ Object
- #delete_refund_transaction(options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #list_categories ⇒ Object
- #sales_tax(options = {}) ⇒ Object
- #tax_rate(options = {}) ⇒ Object
- #update_order_transaction(options = {}) ⇒ Object
- #update_refund_transaction(options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/taxjar/client.rb', line 11 def initialize(={}) = Taxjar..merge() Configuration::VALID_CONFIG_KEYS.each do |key| send("#{key}=", [key]) end check_configuration setup_conn end |
Instance Attribute Details
#conn ⇒ Object (readonly)
Returns the value of attribute conn.
9 10 11 |
# File 'lib/taxjar/client.rb', line 9 def conn @conn end |
Instance Method Details
#create_order_transaction(options = {}) ⇒ Object
48 49 50 51 52 |
# File 'lib/taxjar/client.rb', line 48 def create_order_transaction(={}) check_availability(method_api_version: 2, method_api_tier: 'enhanced') response = @conn.post api_path('transactions', 'orders'), response.body end |
#create_refund_transaction(options = {}) ⇒ Object
66 67 68 69 70 |
# File 'lib/taxjar/client.rb', line 66 def create_refund_transaction(={}) check_availability(method_api_version: 2, method_api_tier: 'enhanced') response = @conn.post api_path('transactions', 'refunds'), response.body end |
#delete_order_transaction(options = {}) ⇒ Object
60 61 62 63 64 |
# File 'lib/taxjar/client.rb', line 60 def delete_order_transaction(={}) check_availability(method_api_version: 2, method_api_tier: 'enhanced') response = @conn.delete api_path('transactions', 'orders', .delete(:transaction_id)), response.body end |
#delete_refund_transaction(options = {}) ⇒ Object
78 79 80 81 82 |
# File 'lib/taxjar/client.rb', line 78 def delete_refund_transaction(={}) check_availability(method_api_version: 2, method_api_tier: 'enhanced') response = @conn.delete api_path('transactions', 'refunds', .delete(:transaction_id)), response.body end |
#list_categories ⇒ Object
42 43 44 45 46 |
# File 'lib/taxjar/client.rb', line 42 def list_categories() check_availability(method_api_version: 2, method_api_tier: 'enhanced') response = @conn.get api_path('categories') response.body end |
#sales_tax(options = {}) ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/taxjar/client.rb', line 22 def sales_tax(={}) case api_version when 1 response = @conn.get api_path('sales_tax'), when 2 response = @conn.post api_path('taxes'), end response.body end |
#tax_rate(options = {}) ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/taxjar/client.rb', line 32 def tax_rate(={}) case api_version when 1 response = @conn.get "/locations/#{options.delete(:zip)}", when 2 response = @conn.get api_path('rates', .delete(:zip)), end response.body end |
#update_order_transaction(options = {}) ⇒ Object
54 55 56 57 58 |
# File 'lib/taxjar/client.rb', line 54 def update_order_transaction(={}) check_availability(method_api_version: 2, method_api_tier: 'enhanced') response = @conn.put api_path('transactions', 'orders', .delete(:transaction_id)), response.body end |
#update_refund_transaction(options = {}) ⇒ Object
72 73 74 75 76 |
# File 'lib/taxjar/client.rb', line 72 def update_refund_transaction(={}) check_availability(method_api_version: 2, method_api_tier: 'enhanced') response = @conn.put api_path('transactions', 'refunds', .delete(:transaction_id)), response.body end |