taxjar-ruby 1.2.0 → 1.2.1

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: 638c573bdfd19c15d48c1cc87d79fb2292a8f031
4
- data.tar.gz: b3382222c75bc4b8299d8d8aee75ae3ba919b40b
3
+ metadata.gz: bf003c0f0010cd3ea52b16c2912aec7bdd4bc772
4
+ data.tar.gz: d8a1dbbad9c575c73b1c30bd777c266b44572a8c
5
5
  SHA512:
6
- metadata.gz: 0bdbf7a23361f1caa03825f8561e95dd88495bd29d4627a21e6049b4fcdf436430bb3578db00a88a6c05caa5a89a91ac4bfbc7bef24697546448d1df37e35127
7
- data.tar.gz: 2271da6641e398fbb4f7e16b87cd563503f07e4be5f9d347d1ec6e3760bd3bd0da121300732938f416e5eccc5fba9a9eaf08e46174a20538c0e591998677ba75
6
+ metadata.gz: bfcef7a90b1f9d3e95411ad22a776ad17bb7b4a1d664a4179c3d361f148187bc41156383bd706b66d02eb04f1b6f5e1c48ba5f356ee541c782e0db4471078164
7
+ data.tar.gz: efc83610b58e8b2b3860b4ad0a9e8763c87370f08969e692bb7a8ea45869a4764f768163c6566d94a632759a4c253360ecdd9455668a8d2d91bf346a78dad4a9
data/README.md CHANGED
@@ -20,6 +20,7 @@ Installing this gem also installs the following gems:
20
20
  * [http](https://github.com/httprb/http.rb) Fast Ruby HTTP client with a chainable API and full streaming support.
21
21
  * [addressable](https://github.com/sporkmonger/addressable) Replacement for the URI implementation that is part of Ruby's standard library. It more closely conforms to the relevant RFCs and adds support for IRIs and URI templates.
22
22
  * [memoizable](https://github.com/dkubb/memoizable) Memoize method return values.
23
+ * [model_attribute](https://github.com/yammer/model_attribute) Type casted attributes for non-ActiveRecord models. [Forked](https://github.com/taxjar/model_attribute) to handle floats and more types.
23
24
 
24
25
  ## Installation
25
26
 
@@ -45,7 +46,6 @@ $ gem install taxjar-ruby
45
46
 
46
47
  First, [get an API key from TaxJar](https://app.taxjar.com/api_sign_up/plus/). Copy and paste in your API key:
47
48
 
48
-
49
49
  You are now ready to use TaxJar!
50
50
 
51
51
  ## Usage
@@ -138,6 +138,25 @@ rates = client.rates_for_location('00150', {
138
138
  :combined_district_rate => 0.015,
139
139
  :combined_rate => 0.09
140
140
  }>
141
+
142
+ #<Taxjar::Rate:0x007fc47056a928 @attrs={
143
+ :zip => "V5K0A1",
144
+ :city => "Vancouver",
145
+ :state => "BC",
146
+ :country => "CA",
147
+ :combined_rate => "0.12"
148
+ }>
149
+
150
+ #<Taxjar::Rate:0x007fc47056a928 @attrs={
151
+ :country => "FI",
152
+ :name => "Finland",
153
+ :standard_rate => "0.24",
154
+ :reduced_rate => nil,
155
+ :super_reduced_rate => nil,
156
+ :parking_rate => nil,
157
+ :distance_sale_threshold => nil,
158
+ :freight_taxable => true
159
+ }>
141
160
  ```
142
161
 
143
162
  ### Calculate Sales tax for an order
@@ -209,6 +228,17 @@ client.tax_for_order({
209
228
  ]
210
229
  }
211
230
  }>
231
+
232
+ #<Taxjar::Tax:0x007f3945688fc8 @attrs={
233
+ :order_total_amount => 27.12,
234
+ :shipping => 1.5,
235
+ :taxable_amount => 27.12,
236
+ :amount_to_collect => 5.42,
237
+ :rate => 0.2,
238
+ :has_nexus => true,
239
+ :freight_taxable => true,
240
+ :tax_source => "origin"
241
+ }>
212
242
  ```
213
243
 
214
244
  ### List order transactions
data/lib/taxjar/rate.rb CHANGED
@@ -4,14 +4,26 @@ module Taxjar
4
4
  class Rate < Taxjar::Base
5
5
  extend ModelAttribute
6
6
 
7
- attribute :zip, :string
8
- attribute :state, :string
9
- attribute :state_rate, :float
10
- attribute :county, :string
11
- attribute :county_rate, :float
12
- attribute :city, :string
13
- attribute :city_rate, :float
14
- attribute :combined_district_rate, :float
15
- attribute :combined_rate, :float
7
+ attribute :zip, :string
8
+ attribute :state, :string
9
+ attribute :state_rate, :float
10
+ attribute :county, :string
11
+ attribute :county_rate, :float
12
+ attribute :city, :string
13
+ attribute :city_rate, :float
14
+ attribute :combined_district_rate, :float
15
+ attribute :combined_rate, :float
16
+
17
+ # International
18
+ attribute :country, :string
19
+ attribute :name, :string
20
+
21
+ # European Union
22
+ attribute :standard_rate, :float
23
+ attribute :reduced_rate, :float
24
+ attribute :super_reduced_rate, :float
25
+ attribute :parking_rate, :float
26
+ attribute :distance_sale_threshold, :float
27
+ attribute :freight_taxable, :boolean
16
28
  end
17
29
  end
@@ -10,7 +10,7 @@ module Taxjar
10
10
  end
11
11
 
12
12
  def patch
13
- 0
13
+ 1
14
14
  end
15
15
 
16
16
  def pre
@@ -0,0 +1,12 @@
1
+ {
2
+ "rate": {
3
+ "country": "FI",
4
+ "name": "Finland",
5
+ "standard_rate": "0.24",
6
+ "reduced_rate": "0.0",
7
+ "super_reduced_rate": "0.0",
8
+ "parking_rate": "0.0",
9
+ "distance_sale_threshold": "0.0",
10
+ "freight_taxable": true
11
+ }
12
+ }
@@ -31,8 +31,7 @@ describe Taxjar::API do
31
31
  before do
32
32
  @postal_code = "90210"
33
33
  stub_get("/v2/rates/#{@postal_code}").to_return(body: fixture('rates.json'),
34
- headers: {content_type: 'application/json; charset=utf-8'})
35
-
34
+ headers: { content_type: 'application/json; charset=utf-8' })
36
35
  end
37
36
 
38
37
  it 'requests the right resource' do
@@ -54,6 +53,39 @@ describe Taxjar::API do
54
53
  expect(rates.combined_rate).to eq(0.09)
55
54
  end
56
55
  end
56
+
57
+ describe '#rate_for_location (international)' do
58
+ before do
59
+ @postal_code = "00150"
60
+ @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' })
63
+ end
64
+
65
+ it 'requests the right resource' do
66
+ @client.rates_for_location('00150', {
67
+ :city => 'Helsinki',
68
+ :country => 'FI'
69
+ })
70
+ expect(a_get("/v2/rates/#{@postal_code}?#{@params}")).to have_been_made
71
+ end
72
+
73
+ it 'returns the requested rates' do
74
+ rates = @client.rates_for_location(@postal_code, {
75
+ :city => 'Helsinki',
76
+ :country => 'FI'
77
+ })
78
+ expect(rates).to be_a Taxjar::Rate
79
+ expect(rates.country).to eq('FI')
80
+ expect(rates.name).to eq('Finland')
81
+ expect(rates.standard_rate).to eq(0.24)
82
+ expect(rates.reduced_rate).to eq(0)
83
+ expect(rates.super_reduced_rate).to eq(0)
84
+ expect(rates.parking_rate).to eq(0)
85
+ expect(rates.distance_sale_threshold).to eq(0)
86
+ expect(rates.freight_taxable).to eq(true)
87
+ end
88
+ end
57
89
 
58
90
  describe "#tax_for_order" do
59
91
  before 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.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - TaxJar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-25 00:00:00.000000000 Z
11
+ date: 2015-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -132,6 +132,7 @@ files:
132
132
  - spec/fixtures/order.json
133
133
  - spec/fixtures/orders.json
134
134
  - spec/fixtures/rates.json
135
+ - spec/fixtures/rates_intl.json
135
136
  - spec/fixtures/refund.json
136
137
  - spec/fixtures/refunds.json
137
138
  - spec/fixtures/taxes.json
@@ -173,6 +174,7 @@ test_files:
173
174
  - spec/fixtures/order.json
174
175
  - spec/fixtures/orders.json
175
176
  - spec/fixtures/rates.json
177
+ - spec/fixtures/rates_intl.json
176
178
  - spec/fixtures/refund.json
177
179
  - spec/fixtures/refunds.json
178
180
  - spec/fixtures/taxes.json