taxjar-ruby 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 57abdd838dccafdd3d06963feeb4300dcc50cf12
4
- data.tar.gz: f9bd34f1b42043934a40f340616233165bb45c64
3
+ metadata.gz: f0124865033d49c8769192fb6b83f1e665dcf3ee
4
+ data.tar.gz: 9951d91514a63cedb64a949fb4d6c971696cce84
5
5
  SHA512:
6
- metadata.gz: 3d40feec61b61684a9041eb88480674a096c75d4b8fce5dd4ab0b33283835cd956d3f9883dcde20e7ca92914bc69702149d18ceb224fef992c3bafe997318570
7
- data.tar.gz: c985406fd1c1970628252a3a0a769df953db871fd318f03aea8232fb8f7bdfd0e1d3d9511078eb436cc9aecd505b995180534a1be4102960e33978ff3bd14667
6
+ metadata.gz: 75c264a26b5a1c199bb37aaf6206543fe7787a34177d67eb5b5ffa0fda9a458c02b4d695293735d153d7ad102056a598a36e02d0d82d6cac7ceeb0803f73a6f5
7
+ data.tar.gz: f69d0358b7e13c78570491fb808a61bc68c3a4449ff839f59d93ba2b5b3c04daa490fec73e6b0d2807b68d96bc876f2ba1084c9342f7a4a9008705d17eec6fb6
@@ -1,3 +1,6 @@
1
+ # 2.4.0 (2018-10-31)
2
+ * Address validation for TaxJar Plus customers
3
+
1
4
  # 2.3.0 (2018-09-17)
2
5
  * Provide access to new jurisdiction names via `tax_for_order`
3
6
 
data/README.md CHANGED
@@ -2,8 +2,7 @@
2
2
 
3
3
  <a href="http://developers.taxjar.com"><img src="http://www.taxjar.com/img/TJ_logo_color_office_png.png" alt="TaxJar" width="220"></a>
4
4
 
5
- A Ruby interface to the TaxJar [Sales Tax API](https://developers.taxjar.com/api/reference/). TaxJar makes sales tax filing easier for online sellers and merchants.
6
- See local jurisdictional tax reports, get payment reminders, and more. You can use our API to access TaxJar API endpoints, which can get information on sales tax rates, categories or upload transactions.
5
+ A Ruby interface to the TaxJar [Sales Tax API](https://developers.taxjar.com/api/reference/). TaxJar makes sales tax filing easier for online sellers and merchants. See local jurisdictional tax reports, get payment reminders, and more. You can use our API to access TaxJar API endpoints, which can get information on sales tax rates, categories or upload transactions.
7
6
 
8
7
  * This wrapper supports 100% of [SmartCalcs v2](http://developers.taxjar.com/api/#introduction)
9
8
  * Data returned from API calls are mapped to Ruby objects
@@ -76,18 +75,18 @@ client.categories
76
75
  ```ruby
77
76
  [
78
77
  #<Taxjar::Category:0x00000a @attrs={
79
- :name => 'Digital Goods',
80
- :product_tax_code => 31000,
78
+ :name => 'Digital Goods',
79
+ :product_tax_code => 31000,
81
80
  :description => 'Digital products transferred electronically.'
82
- }>,
81
+ }>,
83
82
  #<Taxjar::Category:0x00000a @attrs={
84
- :name => 'Clothing',
85
- :product_tax_code => 20010,
83
+ :name => 'Clothing',
84
+ :product_tax_code => 20010,
86
85
  :description => 'All human wearing apparel suitable for general use'
87
- }>,
86
+ }>,
88
87
  #<Taxjar::Category:0x00000a @attrs={
89
88
  :name => 'Non-Prescription',
90
- :product_tax_code => 51010,
89
+ :product_tax_code => 51010,
91
90
  :description => 'Drugs for human use without a prescription'
92
91
  }>
93
92
  ]
@@ -132,7 +131,7 @@ rates = client.rates_for_location('00150', {
132
131
 
133
132
  ```ruby
134
133
  #<Taxjar::Rate:0x00000a @attrs={
135
- :zip => '90002',
134
+ :zip => '90002',
136
135
  :state => 'CA',
137
136
  :state_rate => 0.065,
138
137
  :county => 'LOS ANGELES',
@@ -186,7 +185,7 @@ client.tax_for_order({
186
185
  :to_state => 'CA',
187
186
  :from_country => 'US',
188
187
  :from_zip => '92093',
189
- :from_city => 'San Diego',
188
+ :from_city => 'San Diego',
190
189
  :amount => 15,
191
190
  :shipping => 1.5,
192
191
  :nexus_addresses => [{:address_id => 1,
@@ -210,6 +209,12 @@ client.tax_for_order({
210
209
  :has_nexus => true,
211
210
  :freight_taxable => false,
212
211
  :tax_source => 'destination',
212
+ :jurisdictions => #<Taxjar::Jurisdictions:0x00000a @attrs={
213
+ :country => 'US',
214
+ :state => 'CA',
215
+ :county => 'LOS ANGELES',
216
+ :city => 'LOS ANGELES'
217
+ }>,
213
218
  :breakdown => #<Taxjar::Breakdown:0x00000a @attrs={
214
219
  :state_taxable_amount => 15,
215
220
  :state_tax_collectable => 0.98,
@@ -234,17 +239,6 @@ client.tax_for_order({
234
239
  ]
235
240
  }>
236
241
  }>
237
-
238
- #<Taxjar::Tax:0x00000a @attrs={
239
- :order_total_amount => 27.12,
240
- :shipping => 1.5,
241
- :taxable_amount => 27.12,
242
- :amount_to_collect => 5.42,
243
- :rate => 0.2,
244
- :has_nexus => true,
245
- :freight_taxable => true,
246
- :tax_source => 'origin'
247
- }>
248
242
  ```
249
243
 
250
244
  ### List order transactions
@@ -1148,7 +1142,7 @@ summarized_rates = client.summary_rates
1148
1142
  ]
1149
1143
  ```
1150
1144
 
1151
- ### Custom Options
1145
+ ## Custom Options
1152
1146
 
1153
1147
  Pass a hash to any API method above for the following options:
1154
1148
 
@@ -1222,7 +1216,7 @@ TaxJar is released under the [MIT License](https://github.com/taxjar/taxjar-ruby
1222
1216
 
1223
1217
  ## Support
1224
1218
 
1225
- Bug reports and feature requests should be filed on the [GitHub issue tracking page](https://github.com/taxjar/taxjar-ruby/issues).
1219
+ Bug reports and feature requests should be filed on the [GitHub issue tracking page](https://github.com/taxjar/taxjar-ruby/issues).
1226
1220
 
1227
1221
  ## Contributing
1228
1222
 
@@ -1,4 +1,5 @@
1
1
  require "taxjar/base"
2
+ require "taxjar/address"
2
3
  require "taxjar/breakdown"
3
4
  require "taxjar/breakdown_line_item"
4
5
  require "taxjar/category"
@@ -0,0 +1,13 @@
1
+ require 'taxjar/base'
2
+
3
+ module Taxjar
4
+ class Address < Taxjar::Base
5
+ extend ModelAttribute
6
+
7
+ attribute :country, :string
8
+ attribute :state, :string
9
+ attribute :zip, :string
10
+ attribute :city, :string
11
+ attribute :street, :string
12
+ end
13
+ end
@@ -19,7 +19,11 @@ module Taxjar
19
19
  def nexus_regions(options = {})
20
20
  perform_get_with_objects("/v2/nexus/regions", 'regions', options, Taxjar::NexusRegion)
21
21
  end
22
-
22
+
23
+ def validate_address(options = {})
24
+ perform_post_with_objects("/v2/addresses/validate", 'addresses', options, Taxjar::Address)
25
+ end
26
+
23
27
  def validate(options = {})
24
28
  perform_get_with_object("/v2/validation", 'validation', options, Taxjar::Validation)
25
29
  end
@@ -23,6 +23,10 @@ module Taxjar
23
23
  perform_request_with_object(:post, path, object_key, options, klass)
24
24
  end
25
25
 
26
+ def perform_post_with_objects(path, object_key, options, klass)
27
+ perform_request_with_objects(:post, path, object_key, options, klass)
28
+ end
29
+
26
30
  def perform_put_with_object(path, object_key, options, klass)
27
31
  perform_request_with_object(:put, path, object_key, options, klass)
28
32
  end
@@ -6,7 +6,7 @@ module Taxjar
6
6
  end
7
7
 
8
8
  def minor
9
- 3
9
+ 4
10
10
  end
11
11
 
12
12
  def patch
@@ -0,0 +1,11 @@
1
+ {
2
+ "addresses": [
3
+ {
4
+ "zip": "85297-2176",
5
+ "street": "3301 S Greenfield Rd",
6
+ "state": "AZ",
7
+ "country": "US",
8
+ "city": "Gilbert"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "addresses": [
3
+ {
4
+ "zip": "85007-3646",
5
+ "street": "1109 S 9th Ave",
6
+ "state": "AZ",
7
+ "country": "US",
8
+ "city": "Phoenix"
9
+ },
10
+ {
11
+ "zip": "85006-2734",
12
+ "street": "1109 N 9th St",
13
+ "state": "AZ",
14
+ "country": "US",
15
+ "city": "Phoenix"
16
+ }
17
+ ]
18
+ }
@@ -125,7 +125,7 @@ describe Taxjar::API do
125
125
  expect(rates.freight_taxable).to eq(true)
126
126
  end
127
127
  end
128
-
128
+
129
129
  describe '#rate_for_location (eu)' do
130
130
  before do
131
131
  @postal_code = "00150"
@@ -219,7 +219,7 @@ describe Taxjar::API do
219
219
  expect(tax.breakdown.special_tax_rate).to eq(0)
220
220
  expect(tax.breakdown.special_district_tax_collectable).to eq(0)
221
221
  end
222
-
222
+
223
223
  it 'allows access to breakdown.shipping' do
224
224
  tax = @client.tax_for_order(@order)
225
225
  expect(tax.breakdown.shipping.taxable_amount).to eq(1.5)
@@ -291,7 +291,7 @@ describe Taxjar::API do
291
291
  expect(tax.breakdown.country_tax_rate).to eq(0.24)
292
292
  expect(tax.breakdown.country_tax_collectable).to eq(6.47)
293
293
  end
294
-
294
+
295
295
  it 'allows access to breakdown.shipping' do
296
296
  tax = @client.tax_for_order(@order)
297
297
  expect(tax.breakdown.shipping.taxable_amount).to eq(10)
@@ -353,7 +353,7 @@ describe Taxjar::API do
353
353
  expect(tax.breakdown.qst_tax_rate).to eq(0)
354
354
  expect(tax.breakdown.qst).to eq(0)
355
355
  end
356
-
356
+
357
357
  it 'allows access to breakdown.shipping' do
358
358
  tax = @client.tax_for_order(@order)
359
359
  expect(tax.breakdown.shipping.taxable_amount).to eq(10)
@@ -388,12 +388,12 @@ describe Taxjar::API do
388
388
  end
389
389
  end
390
390
  end
391
-
391
+
392
392
  describe '#nexus_regions' do
393
393
  before do
394
394
  stub_get('/v2/nexus/regions').to_return(body: fixture('nexus_regions.json'), headers: { content_type: 'application/json; charset=utf-8' })
395
395
  end
396
-
396
+
397
397
  it 'requests the right resource' do
398
398
  @client.nexus_regions
399
399
  expect(a_get('/v2/nexus/regions')).to have_been_made
@@ -410,6 +410,67 @@ describe Taxjar::API do
410
410
  end
411
411
  end
412
412
 
413
+ describe '#validate_address' do
414
+ before do
415
+ stub_post('/v2/addresses/validate').to_return(body: fixture('addresses.json'), headers: { content_type: 'application/json; charset=utf-8' })
416
+ end
417
+
418
+ it 'requests the right resource' do
419
+ @client.validate_address({
420
+ :country => 'US',
421
+ :state => 'AZ',
422
+ :zip => '85297',
423
+ :city => 'Gilbert',
424
+ :street => '3301 South Greenfield Rd'
425
+ })
426
+ expect(a_post('/v2/addresses/validate')).to have_been_made
427
+ end
428
+
429
+ it 'returns the requested address' do
430
+ addresses = @client.validate_address({
431
+ :country => 'US',
432
+ :state => 'AZ',
433
+ :zip => '85297',
434
+ :city => 'Gilbert',
435
+ :street => '3301 South Greenfield Rd'
436
+ })
437
+ expect(addresses).to be_an Array
438
+ expect(addresses.first).to be_a Taxjar::Address
439
+ expect(addresses.first.country).to eq('US')
440
+ expect(addresses.first.state).to eq('AZ')
441
+ expect(addresses.first.zip).to eq('85297-2176')
442
+ expect(addresses.first.city).to eq('Gilbert')
443
+ expect(addresses.first.street).to eq('3301 S Greenfield Rd')
444
+ end
445
+
446
+ describe 'multiple address matches' do
447
+ before do
448
+ stub_post('/v2/addresses/validate').to_return(body: fixture('addresses_multiple.json'), headers: { content_type: 'application/json; charset=utf-8' })
449
+ end
450
+
451
+ it 'returns the requested addresses' do
452
+ addresses = @client.validate_address({
453
+ :state => 'AZ',
454
+ :city => 'Phoenix',
455
+ :street => '1109 9th'
456
+ })
457
+ expect(addresses).to be_an Array
458
+ expect(addresses[0]).to be_a Taxjar::Address
459
+ expect(addresses[0].country).to eq('US')
460
+ expect(addresses[0].state).to eq('AZ')
461
+ expect(addresses[0].zip).to eq('85007-3646')
462
+ expect(addresses[0].city).to eq('Phoenix')
463
+ expect(addresses[0].street).to eq('1109 S 9th Ave')
464
+ expect(addresses[1]).to be_a Taxjar::Address
465
+ expect(addresses[1].country).to eq('US')
466
+ expect(addresses[1].state).to eq('AZ')
467
+ expect(addresses[1].zip).to eq('85006-2734')
468
+ expect(addresses[1].city).to eq('Phoenix')
469
+ expect(addresses[1].street).to eq('1109 N 9th St')
470
+ end
471
+ end
472
+ end
473
+
413
474
  describe '#validate' do
414
475
  before do
415
476
  @params = 'vat=FR40303265045'
@@ -437,7 +498,7 @@ describe Taxjar::API do
437
498
  expect(validation.vies_response.address).to eq("11 RUE AMPERE\n26600 PONT DE L ISERE")
438
499
  end
439
500
  end
440
-
501
+
441
502
  describe '#summary_rates' do
442
503
  before do
443
504
  stub_get('/v2/summary_rates').to_return(body: fixture('summary_rates.json'), headers: { content_type: 'application/json; charset=utf-8' })
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: 2.3.0
4
+ version: 2.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: 2018-09-18 00:00:00.000000000 Z
11
+ date: 2018-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -112,6 +112,7 @@ files:
112
112
  - README.md
113
113
  - Rakefile
114
114
  - lib/taxjar.rb
115
+ - lib/taxjar/address.rb
115
116
  - lib/taxjar/api/api.rb
116
117
  - lib/taxjar/api/customer.rb
117
118
  - lib/taxjar/api/order.rb
@@ -137,6 +138,8 @@ files:
137
138
  - lib/taxjar/tax.rb
138
139
  - lib/taxjar/validation.rb
139
140
  - lib/taxjar/version.rb
141
+ - spec/fixtures/addresses.json
142
+ - spec/fixtures/addresses_multiple.json
140
143
  - spec/fixtures/categories.json
141
144
  - spec/fixtures/customer.json
142
145
  - spec/fixtures/customers.json
@@ -190,6 +193,8 @@ signing_key:
190
193
  specification_version: 4
191
194
  summary: Ruby wrapper for Taxjar API
192
195
  test_files:
196
+ - spec/fixtures/addresses.json
197
+ - spec/fixtures/addresses_multiple.json
193
198
  - spec/fixtures/categories.json
194
199
  - spec/fixtures/customer.json
195
200
  - spec/fixtures/customers.json