Module: Avalara
- Defined in:
- lib/avalara.rb,
lib/avalara/api.rb,
lib/avalara/types.rb,
lib/avalara/errors.rb,
lib/avalara/request.rb,
lib/avalara/version.rb,
lib/avalara/response.rb,
lib/avalara/types/date.rb,
lib/avalara/types/stash.rb,
lib/avalara/request/line.rb,
lib/avalara/response/tax.rb,
lib/avalara/request/address.rb,
lib/avalara/request/invoice.rb,
lib/avalara/response/invoice.rb,
lib/avalara/response/message.rb,
lib/avalara/response/tax_line.rb,
lib/avalara/request/cancel_tax.rb,
lib/avalara/response/cancel_tax.rb,
lib/avalara/response/tax_detail.rb,
lib/avalara/request/detail_level.rb,
lib/avalara/response/tax_address.rb,
lib/avalara/request/invoice_address.rb,
lib/avalara/response/cancel_tax_result.rb,
lib/avalara/response/address_validation.rb,
lib/avalara/response/validation_address.rb
Defined Under Namespace
Modules: Request, Response, Types
Classes: API, ApiError, Configuration, Error, NotImplementedError, TimeoutError
Constant Summary
collapse
- VERSION =
'0.3.1'
Class Method Summary
collapse
Class Method Details
.cancel_tax(cancel_invoice) ⇒ Object
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/avalara.rb', line 65
def self.cancel_tax(cancel_invoice)
uri = [endpoint, version, 'tax', 'cancel'].join('/')
response = API.post(uri,
:body => cancel_invoice.to_json,
:headers => API.(cancel_invoice.to_json.length),
:basic_auth => authorization
)
Response::CancelTax.new(response)
rescue Timeout::Error => e
raise TimeoutError.new(e)
end
|
.company_code ⇒ Object
30
31
32
|
# File 'lib/avalara.rb', line 30
def self.company_code
configuration.company_code
end
|
.company_code=(value) ⇒ Object
33
34
35
|
# File 'lib/avalara.rb', line 33
def self.company_code=(value)
configuration.company_code = value
end
|
.configuration {|@@_configuration| ... } ⇒ Object
15
16
17
18
19
|
# File 'lib/avalara.rb', line 15
def self.configuration
@@_configuration ||= Avalara::Configuration.new
yield @@_configuration if block_given?
@@_configuration
end
|
.configuration=(configuration) ⇒ Object
21
22
23
24
|
# File 'lib/avalara.rb', line 21
def self.configuration=(configuration)
raise ArgumentError, 'Expected a Avalara::Configuration instance' unless configuration.kind_of?(Configuration)
@@_configuration = configuration
end
|
26
27
28
|
# File 'lib/avalara.rb', line 26
def self.configure(&block)
configuration(&block)
end
|
.endpoint ⇒ Object
37
38
39
|
# File 'lib/avalara.rb', line 37
def self.endpoint
configuration.endpoint
end
|
.endpoint=(endpoint) ⇒ Object
40
41
42
|
# File 'lib/avalara.rb', line 40
def self.endpoint=(endpoint)
configuration.endpoint = endpoint
end
|
.geographical_tax(latitude, longitude, sales_amount) ⇒ Object
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/avalara.rb', line 79
def self.geographical_tax(latitude, longitude, sales_amount)
uri = [endpoint, version, 'tax', "#{latitude},#{longitude}", 'get'].join('/')
response = API.get(uri,
:headers => API.(),
:query => {:saleamount => sales_amount},
:basic_auth => authorization
)
Response::Tax.new(response)
rescue Timeout::Error => e
raise TimeoutError.new(e)
end
|
.get_tax(invoice) ⇒ Object
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
# File 'lib/avalara.rb', line 93
def self.get_tax(invoice)
uri = [endpoint, version, 'tax', 'get'].join('/')
response = API.post(uri,
:body => invoice.to_json,
:headers => API.(invoice.to_json.length),
:basic_auth => authorization
)
Response::Invoice.new(response)
rescue Timeout::Error => e
raise TimeoutError.new(e)
rescue ApiError => e
raise e
rescue Exception => e
raise Error.new(e)
end
|
.password ⇒ Object
51
52
53
|
# File 'lib/avalara.rb', line 51
def self.password
configuration.password
end
|
.password=(password) ⇒ Object
54
55
56
|
# File 'lib/avalara.rb', line 54
def self.password=(password)
configuration.password = password
end
|
.username ⇒ Object
44
45
46
|
# File 'lib/avalara.rb', line 44
def self.username
configuration.username
end
|
.username=(username) ⇒ Object
47
48
49
|
# File 'lib/avalara.rb', line 47
def self.username=(username)
configuration.username = username
end
|
.validate_address(address) ⇒ Object
111
112
113
114
115
116
117
118
119
120
121
|
# File 'lib/avalara.rb', line 111
def self.validate_address(address)
uri = [endpoint, version, 'address', 'validate'].join('/')
response = API.get(uri,
:headers => API.(),
:query => address.to_hash,
:basic_auth => authorization
)
Response::AddressValidation.new(response)
rescue Timeout::Error => e
raise TimeoutError.new(e)
end
|
.version ⇒ Object
58
59
60
|
# File 'lib/avalara.rb', line 58
def self.version
configuration.version
end
|
.version=(version) ⇒ Object
61
62
63
|
# File 'lib/avalara.rb', line 61
def self.version=(version)
configuration.version = version
end
|