Class: Taxjar::Client

Inherits:
Object
  • Object
show all
Includes:
API, API::Customer, API::Order, API::Refund
Defined in:
lib/taxjar/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from API::Refund

#create_refund, #delete_refund, #list_refunds, #show_refund, #update_refund

Methods included from API::Utils

#perform_delete_with_object, #perform_get_with_array, #perform_get_with_object, #perform_get_with_objects, #perform_post_with_object, #perform_post_with_objects, #perform_put_with_object, #perform_request, #perform_request_with_array, #perform_request_with_object, #perform_request_with_objects

Methods included from API::Order

#create_order, #delete_order, #list_orders, #show_order, #update_order

Methods included from API::Customer

#create_customer, #delete_customer, #list_customers, #show_customer, #update_customer

Methods included from API

#categories, #nexus_regions, #rates_for_location, #summary_rates, #tax_for_order, #validate, #validate_address

Constructor Details

#initialize(options = {}) {|_self| ... } ⇒ Client

Returns a new instance of Client.

Yields:

  • (_self)

Yield Parameters:



21
22
23
24
25
26
# File 'lib/taxjar/client.rb', line 21

def initialize(options = {})
  options.each do |key, value|
    instance_variable_set("@#{key}", value)
  end
  yield(self) if block_given?
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



16
17
18
# File 'lib/taxjar/client.rb', line 16

def api_key
  @api_key
end

#api_urlObject

Returns the value of attribute api_url.



17
18
19
# File 'lib/taxjar/client.rb', line 17

def api_url
  @api_url
end

#headersObject

Returns the value of attribute headers.



18
19
20
# File 'lib/taxjar/client.rb', line 18

def headers
  @headers
end

#http_proxyObject

Returns the value of attribute http_proxy.



19
20
21
# File 'lib/taxjar/client.rb', line 19

def http_proxy
  @http_proxy
end

Instance Method Details

#api_key?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/taxjar/client.rb', line 28

def api_key?
  !!@api_key
end

#get_api_config(key) ⇒ Object



36
37
38
# File 'lib/taxjar/client.rb', line 36

def get_api_config(key)
  instance_variable_get("@#{key}")
end

#platformObject



41
42
43
44
45
# File 'lib/taxjar/client.rb', line 41

def platform
  (`uname -a` || '').strip
rescue Errno::ENOENT, Errno::ENOMEM
  ''
end

#set_api_config(key, value) ⇒ Object



32
33
34
# File 'lib/taxjar/client.rb', line 32

def set_api_config(key, value)
  instance_variable_set("@#{key}", value)
end

#user_agentObject



40
41
42
43
44
45
46
47
48
49
# File 'lib/taxjar/client.rb', line 40

def user_agent
  def platform
    (`uname -a` || '').strip
  rescue Errno::ENOENT, Errno::ENOMEM
    ''
  end
  ruby_version = "ruby #{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
  openSSL_version = OpenSSL::OPENSSL_LIBRARY_VERSION
  "TaxJar/Ruby (#{platform}; #{ruby_version}; #{openSSL_version}) taxjar-ruby/#{Taxjar::Version}".encode("ISO-8859-1", invalid: :replace, undef: :replace)
end