taxjar-ruby 1.3.2 → 1.4.0
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 +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +43 -2
- data/lib/taxjar/api/api.rb +4 -0
- data/lib/taxjar/nexus_region.rb +12 -0
- data/lib/taxjar/version.rb +2 -2
- data/lib/taxjar.rb +1 -0
- data/spec/fixtures/nexus_regions.json +22 -0
- data/spec/taxjar/api/api_spec.rb +26 -11
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b8f47a3dccc5ce41e6c36297953638274b5f1f4
|
4
|
+
data.tar.gz: ffb92cb9d29554225ee27380086850bd8763a688
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 101575da685631cd9554afd16fff94c3e21af3bc540844694224b779f67c95e06a4de76fc9e4c958f58cb162f08955d94a3256b3eb3642a9f8fd6e8ba746720c
|
7
|
+
data.tar.gz: 1ee17ce797f68e7d5521db14d3d257fa6c8b1eb51ce7bec999de1857f33560310ea2fc875586de954fcd96f0c5f6ba0bd656b1bed65d4fc8daddff47901a15c8
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -181,7 +181,7 @@ client.tax_for_order({
|
|
181
181
|
:from_country => 'US',
|
182
182
|
:from_zip => '92093',
|
183
183
|
:from_city => 'San Diego',
|
184
|
-
:amount =>
|
184
|
+
:amount => 15.0,
|
185
185
|
:shipping => 1.5,
|
186
186
|
:nexus_addresses => [{:address_id => 1,
|
187
187
|
:country => 'US',
|
@@ -191,7 +191,7 @@ client.tax_for_order({
|
|
191
191
|
:street => '1218 State St.'}],
|
192
192
|
:line_items => [{:quantity => 1,
|
193
193
|
:unit_price => 15.0,
|
194
|
-
:product_tax_code =>
|
194
|
+
:product_tax_code => 20010}]
|
195
195
|
})
|
196
196
|
```
|
197
197
|
|
@@ -775,6 +775,47 @@ client.delete_refund(321)
|
|
775
775
|
]
|
776
776
|
}>
|
777
777
|
```
|
778
|
+
### List nexus regions
|
779
|
+
|
780
|
+
#### Definition
|
781
|
+
|
782
|
+
```ruby
|
783
|
+
client.nexus_regions
|
784
|
+
```
|
785
|
+
|
786
|
+
#### Example Request
|
787
|
+
|
788
|
+
```ruby
|
789
|
+
require "taxjar"
|
790
|
+
client = Taxjar::Client.new(api_key: "9e0cd62a22f451701f29c3bde214")
|
791
|
+
|
792
|
+
nexus_regions = client.nexus_regions
|
793
|
+
```
|
794
|
+
|
795
|
+
#### Example Response
|
796
|
+
|
797
|
+
```ruby
|
798
|
+
[
|
799
|
+
{
|
800
|
+
:country_code => "US",
|
801
|
+
:country => "United States",
|
802
|
+
:region_code => "CA",
|
803
|
+
:region => "California"
|
804
|
+
},
|
805
|
+
{
|
806
|
+
:country_code => "US",
|
807
|
+
:country => "United States",
|
808
|
+
:region_code => "NY",
|
809
|
+
:region => "New York"
|
810
|
+
},
|
811
|
+
{
|
812
|
+
:country_code => "US",
|
813
|
+
:country => "United States",
|
814
|
+
:region_code => "WA",
|
815
|
+
:region => "Washington"
|
816
|
+
}
|
817
|
+
]
|
818
|
+
```
|
778
819
|
|
779
820
|
### Validate a VAT number
|
780
821
|
|
data/lib/taxjar/api/api.rb
CHANGED
@@ -16,6 +16,10 @@ module Taxjar
|
|
16
16
|
perform_post_with_object("/v2/taxes", 'tax', options, Taxjar::Tax)
|
17
17
|
end
|
18
18
|
|
19
|
+
def nexus_regions(options = {})
|
20
|
+
perform_get_with_objects("/v2/nexus/regions", 'regions', options, Taxjar::NexusRegion)
|
21
|
+
end
|
22
|
+
|
19
23
|
def validate(options = {})
|
20
24
|
perform_get_with_object("/v2/validation", 'validation', options, Taxjar::Validation)
|
21
25
|
end
|
data/lib/taxjar/version.rb
CHANGED
data/lib/taxjar.rb
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
{
|
2
|
+
"regions": [
|
3
|
+
{
|
4
|
+
"country_code": "US",
|
5
|
+
"country": "United States",
|
6
|
+
"region_code": "CA",
|
7
|
+
"region": "California"
|
8
|
+
},
|
9
|
+
{
|
10
|
+
"country_code": "US",
|
11
|
+
"country": "United States",
|
12
|
+
"region_code": "NY",
|
13
|
+
"region": "New York"
|
14
|
+
},
|
15
|
+
{
|
16
|
+
"country_code": "US",
|
17
|
+
"country": "United States",
|
18
|
+
"region_code": "WA",
|
19
|
+
"region": "Washington"
|
20
|
+
}
|
21
|
+
]
|
22
|
+
}
|
data/spec/taxjar/api/api_spec.rb
CHANGED
@@ -7,9 +7,7 @@ describe Taxjar::API do
|
|
7
7
|
|
8
8
|
describe '#categories' do
|
9
9
|
before do
|
10
|
-
stub_get('/v2/categories').to_return(body: fixture('categories.json'),
|
11
|
-
headers: {content_type: 'application/json; charset=utf-8'})
|
12
|
-
|
10
|
+
stub_get('/v2/categories').to_return(body: fixture('categories.json'), headers: { content_type: 'application/json; charset=utf-8' })
|
13
11
|
end
|
14
12
|
|
15
13
|
it 'requests the right resource' do
|
@@ -30,8 +28,7 @@ describe Taxjar::API do
|
|
30
28
|
describe '#rate_for_location' do
|
31
29
|
before do
|
32
30
|
@postal_code = "90210"
|
33
|
-
stub_get("/v2/rates/#{@postal_code}").to_return(body: fixture('rates.json'),
|
34
|
-
headers: { content_type: 'application/json; charset=utf-8' })
|
31
|
+
stub_get("/v2/rates/#{@postal_code}").to_return(body: fixture('rates.json'), headers: { content_type: 'application/json; charset=utf-8' })
|
35
32
|
end
|
36
33
|
|
37
34
|
it 'requests the right resource' do
|
@@ -58,8 +55,7 @@ describe Taxjar::API do
|
|
58
55
|
before do
|
59
56
|
@postal_code = "00150"
|
60
57
|
@params = "city=Helsinki&country=FI"
|
61
|
-
stub_get("/v2/rates/#{@postal_code}?#{@params}").to_return(body: fixture('rates_intl.json'),
|
62
|
-
headers: { content_type: 'application/json; charset=utf-8' })
|
58
|
+
stub_get("/v2/rates/#{@postal_code}?#{@params}").to_return(body: fixture('rates_intl.json'), headers: { content_type: 'application/json; charset=utf-8' })
|
63
59
|
end
|
64
60
|
|
65
61
|
it 'requests the right resource' do
|
@@ -157,11 +153,31 @@ describe Taxjar::API do
|
|
157
153
|
end
|
158
154
|
end
|
159
155
|
|
156
|
+
describe '#nexus_regions' do
|
157
|
+
before do
|
158
|
+
stub_get('/v2/nexus/regions').to_return(body: fixture('nexus_regions.json'), headers: { content_type: 'application/json; charset=utf-8' })
|
159
|
+
end
|
160
|
+
|
161
|
+
it 'requests the right resource' do
|
162
|
+
@client.nexus_regions
|
163
|
+
expect(a_get('/v2/nexus/regions')).to have_been_made
|
164
|
+
end
|
165
|
+
|
166
|
+
it 'returns the requested regions' do
|
167
|
+
regions = @client.nexus_regions
|
168
|
+
expect(regions).to be_an Array
|
169
|
+
expect(regions.first).to be_a Taxjar::NexusRegion
|
170
|
+
expect(regions.first.country_code).to eq('US')
|
171
|
+
expect(regions.first.country).to eq('United States')
|
172
|
+
expect(regions.first.region_code).to eq('CA')
|
173
|
+
expect(regions.first.region).to eq('California')
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
160
177
|
describe '#validate' do
|
161
178
|
before do
|
162
179
|
@params = 'vat=FR40303265045'
|
163
|
-
stub_get("/v2/validation?#{@params}").to_return(body: fixture('validation.json'),
|
164
|
-
headers: {content_type: 'application/json; charset=utf-8'})
|
180
|
+
stub_get("/v2/validation?#{@params}").to_return(body: fixture('validation.json'), headers: { content_type: 'application/json; charset=utf-8' })
|
165
181
|
@validation = {
|
166
182
|
:vat => 'FR40303265045'
|
167
183
|
}
|
@@ -188,8 +204,7 @@ describe Taxjar::API do
|
|
188
204
|
|
189
205
|
describe '#summary_rates' do
|
190
206
|
before do
|
191
|
-
stub_get('/v2/summary_rates').to_return(body: fixture('summary_rates.json'),
|
192
|
-
headers: {content_type: 'application/json; charset=utf-8'})
|
207
|
+
stub_get('/v2/summary_rates').to_return(body: fixture('summary_rates.json'), headers: { content_type: 'application/json; charset=utf-8' })
|
193
208
|
end
|
194
209
|
|
195
210
|
it 'requests the right resource' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: taxjar-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- TaxJar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -122,6 +122,7 @@ files:
|
|
122
122
|
- lib/taxjar/client.rb
|
123
123
|
- lib/taxjar/error.rb
|
124
124
|
- lib/taxjar/line_item.rb
|
125
|
+
- lib/taxjar/nexus_region.rb
|
125
126
|
- lib/taxjar/order.rb
|
126
127
|
- lib/taxjar/rate.rb
|
127
128
|
- lib/taxjar/refund.rb
|
@@ -131,6 +132,7 @@ files:
|
|
131
132
|
- lib/taxjar/validation.rb
|
132
133
|
- lib/taxjar/version.rb
|
133
134
|
- spec/fixtures/categories.json
|
135
|
+
- spec/fixtures/nexus_regions.json
|
134
136
|
- spec/fixtures/order.json
|
135
137
|
- spec/fixtures/orders.json
|
136
138
|
- spec/fixtures/rates.json
|
@@ -175,6 +177,7 @@ specification_version: 4
|
|
175
177
|
summary: Ruby wrapper for Taxjar API
|
176
178
|
test_files:
|
177
179
|
- spec/fixtures/categories.json
|
180
|
+
- spec/fixtures/nexus_regions.json
|
178
181
|
- spec/fixtures/order.json
|
179
182
|
- spec/fixtures/orders.json
|
180
183
|
- spec/fixtures/rates.json
|