Module: Avalara
- Defined in:
- lib/avalara.rb,
lib/avalara/api.rb,
lib/avalara/types.rb,
lib/avalara/errors.rb,
lib/avalara/parser.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/response/tax_detail.rb,
lib/avalara/request/detail_level.rb,
lib/avalara/response/tax_address.rb
Defined Under Namespace
Modules: Request, Response, Types
Classes: API, ApiError, Configuration, Parser
Constant Summary
collapse
- Error =
Class.new(StandardError)
- TimeoutError =
Class.new(Error)
- NotImplementedError =
Class.new(Error)
- VERSION =
'0.1.0'
Class Method Summary
collapse
Class Method Details
.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
30
31
32
|
# File 'lib/avalara.rb', line 30
def self.endpoint
configuration.endpoint
end
|
.endpoint=(endpoint) ⇒ Object
33
34
35
|
# File 'lib/avalara.rb', line 33
def self.endpoint=(endpoint)
configuration.endpoint = endpoint
end
|
.geographical_tax(latitude, longitude, sales_amount) ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/avalara.rb', line 58
def self.geographical_tax(latitude, longitude, sales_amount)
uri = [
configuration.endpoint,
configuration.version,
"tax",
"#{latitude},#{longitude}",
"get"
].join("/")
response = API.get(uri,
:headers => API.('0'),
:query => {:saleamount => sales_amount},
:basic_auth => authentication
)
Avalara::Response::Tax.new(response)
rescue Timeout::Error
puts "Timed out"
raise TimeoutError
end
|
.get_tax(invoice) ⇒ Object
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/avalara.rb', line 79
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 => authentication
)
return case response.code
when 200..299
Response::Invoice.new(response)
when 400..599
raise ApiError.new(Response::Invoice.new(response))
else
raise ApiError.new(response)
end
rescue Timeout::Error => e
raise TimeoutError.new(e)
rescue ApiError => e
raise e
rescue Exception => e
raise Error.new(e)
end
|
.password ⇒ Object
44
45
46
|
# File 'lib/avalara.rb', line 44
def self.password
configuration.password
end
|
.password=(password) ⇒ Object
47
48
49
|
# File 'lib/avalara.rb', line 47
def self.password=(password)
configuration.password = password
end
|
.username ⇒ Object
37
38
39
|
# File 'lib/avalara.rb', line 37
def self.username
configuration.username
end
|
.username=(username) ⇒ Object
40
41
42
|
# File 'lib/avalara.rb', line 40
def self.username=(username)
configuration.username = username
end
|
.version ⇒ Object
51
52
53
|
# File 'lib/avalara.rb', line 51
def self.version
configuration.version
end
|
.version=(version) ⇒ Object
54
55
56
|
# File 'lib/avalara.rb', line 54
def self.version=(version)
configuration.version = version
end
|