avatax-ruby 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rubocop.yml +248 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +157 -0
- data/Rakefile +9 -0
- data/avatax.gemspec +42 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/circle.yml +6 -0
- data/lib/avatax.rb +30 -0
- data/lib/avatax/api/accounts.rb +86 -0
- data/lib/avatax/api/addresses.rb +14 -0
- data/lib/avatax/api/base.rb +18 -0
- data/lib/avatax/api/batches.rb +6 -0
- data/lib/avatax/api/companies.rb +6 -0
- data/lib/avatax/api/contacts.rb +6 -0
- data/lib/avatax/api/definitions.rb +6 -0
- data/lib/avatax/api/items.rb +6 -0
- data/lib/avatax/api/locations.rb +6 -0
- data/lib/avatax/api/nexus.rb +6 -0
- data/lib/avatax/api/settings.rb +6 -0
- data/lib/avatax/api/subscriptions.rb +6 -0
- data/lib/avatax/api/tax_codes.rb +6 -0
- data/lib/avatax/api/tax_rates.rb +28 -0
- data/lib/avatax/api/tax_rules.rb +6 -0
- data/lib/avatax/api/transactions.rb +171 -0
- data/lib/avatax/api/upcs.rb +6 -0
- data/lib/avatax/api/users.rb +6 -0
- data/lib/avatax/api/utilities.rb +6 -0
- data/lib/avatax/client.rb +81 -0
- data/lib/avatax/code.rb +13 -0
- data/lib/avatax/configuration.rb +35 -0
- data/lib/avatax/response.rb +8 -0
- data/lib/avatax/version.rb +3 -0
- metadata +236 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 8cd145141172657e1cff1479fffb4ca51ed0724f
|
|
4
|
+
data.tar.gz: afa91da4845f340b0cbc00596f2fee25fcc22ad5
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 8bd160627ebd839166ef0e8aad8f9777f8517baaf27f88898df3fb856d8eae7e2a7a1f99cafb50d58de8b9a46f15ded001b32ce7dfeb688daa60e64a9beff013
|
|
7
|
+
data.tar.gz: 6c6baa7cd30609171adfe276f901e13a14e10bfa322b48951749d8a3daaa14f34ec107249aa9e1f0a8bf5bfd38cb7592e1fa24bed15c7f08a028477a40252346
|
data/.gitignore
ADDED
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
Exclude:
|
|
3
|
+
- 'Rakefile'
|
|
4
|
+
- 'Gemfile'
|
|
5
|
+
- 'bin/**/*'
|
|
6
|
+
- 'avatax.gemspec'
|
|
7
|
+
- 'example.rb'
|
|
8
|
+
- 'vendor/**/*'
|
|
9
|
+
|
|
10
|
+
# Block length was set to 25, we currently don't have a rule for this
|
|
11
|
+
BlockLength:
|
|
12
|
+
Enabled: false
|
|
13
|
+
|
|
14
|
+
# Changing this was causing the route not found error in specs
|
|
15
|
+
HttpPositionalArguments:
|
|
16
|
+
Enabled: false
|
|
17
|
+
|
|
18
|
+
# We are going to use .html_safe for the time being
|
|
19
|
+
Rails/OutputSafety:
|
|
20
|
+
Enabled: false
|
|
21
|
+
|
|
22
|
+
# Disabling this until we remove all references to it in all our code bases
|
|
23
|
+
Rails/HasAndBelongsToMany:
|
|
24
|
+
Enabled: false
|
|
25
|
+
|
|
26
|
+
# Don't require Ruby 2.3 "frozen_string_literal" pragma comment, for now.
|
|
27
|
+
Style/FrozenStringLiteralComment:
|
|
28
|
+
Enabled: false
|
|
29
|
+
|
|
30
|
+
# We use class vars and will have to continue doing so for compatability
|
|
31
|
+
Style/ClassVars:
|
|
32
|
+
Enabled: false
|
|
33
|
+
|
|
34
|
+
# We need these names for backwards compatability
|
|
35
|
+
Style/PredicateName:
|
|
36
|
+
Enabled: false
|
|
37
|
+
|
|
38
|
+
Style/AccessorMethodName:
|
|
39
|
+
Enabled: false
|
|
40
|
+
|
|
41
|
+
# This has been used for customization
|
|
42
|
+
Style/MutableConstant:
|
|
43
|
+
Enabled: false
|
|
44
|
+
|
|
45
|
+
Style/ClassAndModuleChildren:
|
|
46
|
+
Enabled: false
|
|
47
|
+
|
|
48
|
+
Style/GuardClause:
|
|
49
|
+
Enabled: false
|
|
50
|
+
|
|
51
|
+
Style/WordArray:
|
|
52
|
+
Enabled: false
|
|
53
|
+
|
|
54
|
+
Style/ConditionalAssignment:
|
|
55
|
+
Enabled: false
|
|
56
|
+
|
|
57
|
+
Performance/Count:
|
|
58
|
+
Enabled: false
|
|
59
|
+
|
|
60
|
+
Style/RaiseArgs:
|
|
61
|
+
Enabled: false
|
|
62
|
+
|
|
63
|
+
Style/OpMethod:
|
|
64
|
+
Enabled: false
|
|
65
|
+
|
|
66
|
+
# We can use good judgement here
|
|
67
|
+
Style/RegexpLiteral:
|
|
68
|
+
Enabled: false
|
|
69
|
+
|
|
70
|
+
# Unicode comments are useful
|
|
71
|
+
Style/AsciiComments:
|
|
72
|
+
Enabled: false
|
|
73
|
+
|
|
74
|
+
Lint/EndAlignment:
|
|
75
|
+
Enabled: false
|
|
76
|
+
|
|
77
|
+
Style/ElseAlignment:
|
|
78
|
+
Enabled: false
|
|
79
|
+
|
|
80
|
+
Style/IndentationWidth:
|
|
81
|
+
Enabled: false
|
|
82
|
+
|
|
83
|
+
Style/AlignParameters:
|
|
84
|
+
Enabled: false
|
|
85
|
+
|
|
86
|
+
Style/ClosingParenthesisIndentation:
|
|
87
|
+
Enabled: false
|
|
88
|
+
|
|
89
|
+
Style/MultilineMethodCallIndentation:
|
|
90
|
+
Enabled: false
|
|
91
|
+
|
|
92
|
+
Style/IndentArray:
|
|
93
|
+
Enabled: false
|
|
94
|
+
|
|
95
|
+
Style/IndentHash:
|
|
96
|
+
Enabled: false
|
|
97
|
+
|
|
98
|
+
Style/AlignHash:
|
|
99
|
+
Enabled: false
|
|
100
|
+
|
|
101
|
+
# From http://relaxed.ruby.style/
|
|
102
|
+
|
|
103
|
+
Style/Alias:
|
|
104
|
+
Enabled: false
|
|
105
|
+
StyleGuide: http://relaxed.ruby.style/#stylealias
|
|
106
|
+
|
|
107
|
+
Style/BeginBlock:
|
|
108
|
+
Enabled: false
|
|
109
|
+
StyleGuide: http://relaxed.ruby.style/#stylebeginblock
|
|
110
|
+
|
|
111
|
+
Style/BlockDelimiters:
|
|
112
|
+
Enabled: false
|
|
113
|
+
StyleGuide: http://relaxed.ruby.style/#styleblockdelimiters
|
|
114
|
+
|
|
115
|
+
Style/Documentation:
|
|
116
|
+
Enabled: false
|
|
117
|
+
StyleGuide: http://relaxed.ruby.style/#styledocumentation
|
|
118
|
+
|
|
119
|
+
Style/DotPosition:
|
|
120
|
+
Enabled: false
|
|
121
|
+
StyleGuide: http://relaxed.ruby.style/#styledotposition
|
|
122
|
+
|
|
123
|
+
Style/DoubleNegation:
|
|
124
|
+
Enabled: false
|
|
125
|
+
StyleGuide: http://relaxed.ruby.style/#styledoublenegation
|
|
126
|
+
|
|
127
|
+
Style/EndBlock:
|
|
128
|
+
Enabled: false
|
|
129
|
+
StyleGuide: http://relaxed.ruby.style/#styleendblock
|
|
130
|
+
|
|
131
|
+
Style/FormatString:
|
|
132
|
+
Enabled: false
|
|
133
|
+
StyleGuide: http://relaxed.ruby.style/#styleformatstring
|
|
134
|
+
|
|
135
|
+
Style/IfUnlessModifier:
|
|
136
|
+
Enabled: false
|
|
137
|
+
StyleGuide: http://relaxed.ruby.style/#styleifunlessmodifier
|
|
138
|
+
|
|
139
|
+
Style/Lambda:
|
|
140
|
+
Enabled: false
|
|
141
|
+
StyleGuide: http://relaxed.ruby.style/#stylelambda
|
|
142
|
+
|
|
143
|
+
Style/ModuleFunction:
|
|
144
|
+
Enabled: false
|
|
145
|
+
StyleGuide: http://relaxed.ruby.style/#stylemodulefunction
|
|
146
|
+
|
|
147
|
+
Style/MultilineBlockChain:
|
|
148
|
+
Enabled: false
|
|
149
|
+
StyleGuide: http://relaxed.ruby.style/#stylemultilineblockchain
|
|
150
|
+
|
|
151
|
+
Style/NegatedIf:
|
|
152
|
+
Enabled: false
|
|
153
|
+
StyleGuide: http://relaxed.ruby.style/#stylenegatedif
|
|
154
|
+
|
|
155
|
+
Style/NegatedWhile:
|
|
156
|
+
Enabled: false
|
|
157
|
+
StyleGuide: http://relaxed.ruby.style/#stylenegatedwhile
|
|
158
|
+
|
|
159
|
+
Style/ParallelAssignment:
|
|
160
|
+
Enabled: false
|
|
161
|
+
StyleGuide: http://relaxed.ruby.style/#styleparallelassignment
|
|
162
|
+
|
|
163
|
+
Style/PercentLiteralDelimiters:
|
|
164
|
+
Enabled: false
|
|
165
|
+
StyleGuide: http://relaxed.ruby.style/#stylepercentliteraldelimiters
|
|
166
|
+
|
|
167
|
+
Style/PerlBackrefs:
|
|
168
|
+
Enabled: false
|
|
169
|
+
StyleGuide: http://relaxed.ruby.style/#styleperlbackrefs
|
|
170
|
+
|
|
171
|
+
Style/Semicolon:
|
|
172
|
+
Enabled: false
|
|
173
|
+
StyleGuide: http://relaxed.ruby.style/#stylesemicolon
|
|
174
|
+
|
|
175
|
+
Style/SignalException:
|
|
176
|
+
Enabled: false
|
|
177
|
+
StyleGuide: http://relaxed.ruby.style/#stylesignalexception
|
|
178
|
+
|
|
179
|
+
Style/SingleLineBlockParams:
|
|
180
|
+
Enabled: false
|
|
181
|
+
StyleGuide: http://relaxed.ruby.style/#stylesinglelineblockparams
|
|
182
|
+
|
|
183
|
+
Style/SingleLineMethods:
|
|
184
|
+
Enabled: false
|
|
185
|
+
StyleGuide: http://relaxed.ruby.style/#stylesinglelinemethods
|
|
186
|
+
|
|
187
|
+
Lint/RescueException:
|
|
188
|
+
Enabled: false
|
|
189
|
+
Style/NumericLiterals:
|
|
190
|
+
Enabled: false
|
|
191
|
+
|
|
192
|
+
Style/SpaceBeforeBlockBraces:
|
|
193
|
+
Enabled: false
|
|
194
|
+
StyleGuide: http://relaxed.ruby.style/#stylespacebeforeblockbraces
|
|
195
|
+
|
|
196
|
+
Style/SpaceInsideParens:
|
|
197
|
+
Enabled: false
|
|
198
|
+
StyleGuide: http://relaxed.ruby.style/#stylespaceinsideparens
|
|
199
|
+
|
|
200
|
+
Style/SpecialGlobalVars:
|
|
201
|
+
Enabled: false
|
|
202
|
+
StyleGuide: http://relaxed.ruby.style/#stylespecialglobalvars
|
|
203
|
+
|
|
204
|
+
Style/StringLiterals:
|
|
205
|
+
Enabled: false
|
|
206
|
+
StyleGuide: http://relaxed.ruby.style/#stylestringliterals
|
|
207
|
+
|
|
208
|
+
Style/SymbolProc:
|
|
209
|
+
Enabled: false
|
|
210
|
+
|
|
211
|
+
Style/WhileUntilModifier:
|
|
212
|
+
Enabled: false
|
|
213
|
+
StyleGuide: http://relaxed.ruby.style/#stylewhileuntilmodifier
|
|
214
|
+
|
|
215
|
+
Lint/AmbiguousRegexpLiteral:
|
|
216
|
+
Enabled: false
|
|
217
|
+
StyleGuide: http://relaxed.ruby.style/#lintambiguousregexpliteral
|
|
218
|
+
|
|
219
|
+
Lint/AssignmentInCondition:
|
|
220
|
+
Enabled: false
|
|
221
|
+
StyleGuide: http://relaxed.ruby.style/#lintassignmentincondition
|
|
222
|
+
|
|
223
|
+
Metrics/AbcSize:
|
|
224
|
+
Enabled: false
|
|
225
|
+
|
|
226
|
+
Metrics/BlockNesting:
|
|
227
|
+
Enabled: false
|
|
228
|
+
|
|
229
|
+
Metrics/ClassLength:
|
|
230
|
+
Enabled: false
|
|
231
|
+
|
|
232
|
+
Metrics/ModuleLength:
|
|
233
|
+
Enabled: false
|
|
234
|
+
|
|
235
|
+
Metrics/CyclomaticComplexity:
|
|
236
|
+
Enabled: false
|
|
237
|
+
|
|
238
|
+
Metrics/LineLength:
|
|
239
|
+
Enabled: false
|
|
240
|
+
|
|
241
|
+
Metrics/MethodLength:
|
|
242
|
+
Enabled: false
|
|
243
|
+
|
|
244
|
+
Metrics/ParameterLists:
|
|
245
|
+
Enabled: false
|
|
246
|
+
|
|
247
|
+
Metrics/PerceivedComplexity:
|
|
248
|
+
Enabled: false
|
data/.ruby-gemset
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
avatax
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.3.1
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Taylor Scott
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# Avatax
|
|
2
|
+
[](https://circleci.com/gh/skukx/avatax)
|
|
3
|
+
|
|
4
|
+
This gem is a work in progress for providing a ruby client for Avatax REST api v2.
|
|
5
|
+
See: http://developer.avalara.com/avatax/api-reference/tax/v2/
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
Add this line to your application's Gemfile:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
gem 'avatax-ruby', git: 'git@github.com:skukx/avatax.git', require: 'avatax'
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Or
|
|
16
|
+
|
|
17
|
+
```ruby
|
|
18
|
+
gem 'avatax-ruby', require: 'avatax'
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
And then execute:
|
|
22
|
+
|
|
23
|
+
$ bundle
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
### Setting Up the client
|
|
28
|
+
```ruby
|
|
29
|
+
client = Avatax::Client.new(
|
|
30
|
+
username: 'avatax_user',
|
|
31
|
+
password: 'avatax_password',
|
|
32
|
+
env: :sandbox
|
|
33
|
+
)
|
|
34
|
+
```
|
|
35
|
+
The `env` can be set to `:sandbox` or `:production`.
|
|
36
|
+
|
|
37
|
+
### Estimating Taxes
|
|
38
|
+
```ruby
|
|
39
|
+
##
|
|
40
|
+
# Estimate by address
|
|
41
|
+
# @see http://developer.avalara.com/avatax/api-reference/tax/v2/TaxRates/#ApiV2TaxratesByaddressGet
|
|
42
|
+
#
|
|
43
|
+
params = {
|
|
44
|
+
line1: '350 State St.',
|
|
45
|
+
city: 'Salt Lake City',
|
|
46
|
+
region: 'CA',
|
|
47
|
+
postalCode: '84111',
|
|
48
|
+
country: 'US'
|
|
49
|
+
}
|
|
50
|
+
resp = client.tax_rates.get(:by_address, params)
|
|
51
|
+
|
|
52
|
+
##
|
|
53
|
+
# Estimate by postal code
|
|
54
|
+
# @see http://developer.avalara.com/avatax/api-reference/tax/v2/TaxRates/#ApiV2TaxratesBypostalcodeGet
|
|
55
|
+
#
|
|
56
|
+
params = { country: 'US', postalCode: '84111' }
|
|
57
|
+
resp = client.tax_rates.get(:by_postal_code, params)
|
|
58
|
+
|
|
59
|
+
resp.success? # => true
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Transactions
|
|
63
|
+
|
|
64
|
+
#### Get all transactions within a company.
|
|
65
|
+
```ruby
|
|
66
|
+
client.transactions.all('my_company')
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
#### Find a transaction by code
|
|
70
|
+
```ruby
|
|
71
|
+
client.transactions.find_by_code('my_company', 'transaction_code')
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
#### Find a transaction by avatax id.
|
|
75
|
+
```ruby
|
|
76
|
+
client.transactions.find_by_id('my_company', '123')
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
#### Adjust an existing transaction.
|
|
80
|
+
```ruby
|
|
81
|
+
params = {
|
|
82
|
+
adjustmentReason: 8,
|
|
83
|
+
adjustmentDescription: 'New line item.',
|
|
84
|
+
new_transaction: { ... }
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
client.transactions.adjust('my_company', 'my_code', params)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
#### Change a transaction code
|
|
91
|
+
```ruby
|
|
92
|
+
params = { newCode: 'my_new_code' }
|
|
93
|
+
client.transactions.change_code('my_company', 'my_code', params)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
#### Commit a transaction
|
|
97
|
+
By default, if not present, the post request will contain the body `{ commit: true }`
|
|
98
|
+
|
|
99
|
+
```ruby
|
|
100
|
+
client.transactions.commit('my_company', 'my_code')
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
#### Settle a transaction
|
|
104
|
+
This call can perform multiple actions on a transaction. See [avatax docs](https://developer.avalara.com/avatax/api-reference/tax/v2/Transactions/#SettleTransaction) for more information.
|
|
105
|
+
```ruby
|
|
106
|
+
params = { ... }
|
|
107
|
+
client.transactions.settle('my_company', 'my_code', params)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
#### Void a transaction.
|
|
111
|
+
```ruby
|
|
112
|
+
client.transactions.void('my_company', 'my_code')
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
#### Create a transaction
|
|
116
|
+
```ruby
|
|
117
|
+
params = {
|
|
118
|
+
code: 'my_code',
|
|
119
|
+
type: 'SalesInvoice',
|
|
120
|
+
companyCode: 'my_company',
|
|
121
|
+
date: Date.current.to_s,
|
|
122
|
+
customerCode: 1,
|
|
123
|
+
discount: 0.00,
|
|
124
|
+
addresses: {
|
|
125
|
+
ShipTo: {
|
|
126
|
+
line1: '50 Main street',
|
|
127
|
+
city: 'Salt Lake City',
|
|
128
|
+
region: 'UT',
|
|
129
|
+
country: 'US',
|
|
130
|
+
postalCode: '84144'
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
lines: [
|
|
134
|
+
{
|
|
135
|
+
amount: 9.99,
|
|
136
|
+
quantity: 1
|
|
137
|
+
}
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
client.transactions.create(params)
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
## Development
|
|
145
|
+
|
|
146
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
147
|
+
|
|
148
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
149
|
+
|
|
150
|
+
## Contributing
|
|
151
|
+
|
|
152
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/avatax.
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
## License
|
|
156
|
+
|
|
157
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|