taxjar-ruby 1.0.1 → 1.1.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.
- data/.ruby-version +1 -0
- data/.travis.yml +9 -0
- data/README.md +574 -11
- data/lib/taxjar/api/api.rb +0 -18
- data/lib/taxjar/api/order.rb +29 -0
- data/lib/taxjar/api/refund.rb +29 -0
- data/lib/taxjar/api/utils.rb +12 -0
- data/lib/taxjar/base.rb +21 -0
- data/lib/taxjar/client.rb +5 -0
- data/lib/taxjar/version.rb +2 -2
- data/spec/fixtures/orders.json +6 -0
- data/spec/fixtures/refunds.json +6 -0
- data/spec/helper.rb +8 -0
- data/spec/taxjar/api/api_spec.rb +0 -130
- data/spec/taxjar/api/order_spec.rb +156 -0
- data/spec/taxjar/api/refund_spec.rb +157 -0
- data/spec/taxjar/api/request_spec.rb +3 -3
- metadata +49 -19
- checksums.yaml +0 -7
@@ -0,0 +1,157 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
describe Taxjar::API::Refund do
|
4
|
+
|
5
|
+
before do
|
6
|
+
@client = Taxjar::Client.new(api_key: 'AK')
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "#list_refunds" do
|
10
|
+
context "without parameters" do
|
11
|
+
before do
|
12
|
+
stub_get('/v2/transactions/refunds').to_return(body: fixture('refunds.json'),
|
13
|
+
headers: {content_type: 'application/json; charset=utf-8'})
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'requests the right resource' do
|
18
|
+
@client.list_refunds
|
19
|
+
expect(a_get('/v2/transactions/refunds')).to have_been_made
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'returns the requested refunds' do
|
23
|
+
refunds = @client.list_refunds
|
24
|
+
expect(refunds).to be_an Array
|
25
|
+
expect(refunds.first).to be_a String
|
26
|
+
expect(refunds.first).to eq('321')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context "with parameters" do
|
31
|
+
before do
|
32
|
+
stub_get('/v2/transactions/refunds?from_transaction_date=2015/05/01&to_transaction_date=2015/05/31').
|
33
|
+
to_return(body: fixture('refunds.json'),
|
34
|
+
headers: {content_type: 'application/json; charset=utf-8'})
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'requests the right resource' do
|
39
|
+
@client.list_refunds(from_transaction_date: '2015/05/01',
|
40
|
+
to_transaction_date: '2015/05/31')
|
41
|
+
expect(a_get('/v2/transactions/refunds?from_transaction_date=2015/05/01&to_transaction_date=2015/05/31')).to have_been_made
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'returns the requested refunds' do
|
45
|
+
refunds = @client.list_refunds(from_transaction_date: '2015/05/01',
|
46
|
+
to_transaction_date: '2015/05/31')
|
47
|
+
expect(refunds).to be_an Array
|
48
|
+
expect(refunds.first).to be_a String
|
49
|
+
expect(refunds.first).to eq('321')
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "#show_refund" do
|
55
|
+
before do
|
56
|
+
stub_get('/v2/transactions/refunds/321').
|
57
|
+
to_return(body: fixture('refund.json'),
|
58
|
+
headers: {content_type: 'application/json; charset=utf-8'})
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'requests the right resource' do
|
62
|
+
@client.show_refund('321')
|
63
|
+
expect(a_get('/v2/transactions/refunds/321')).to have_been_made
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'returns the requested refund' do
|
67
|
+
refund = @client.show_refund('321')
|
68
|
+
expect(refund).to be_an Taxjar::Refund
|
69
|
+
expect(refund.transaction_id).to eq(321)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
describe "#create_refund" do
|
74
|
+
before do
|
75
|
+
stub_post("/v2/transactions/refunds").to_return(body: fixture('refund.json'),
|
76
|
+
headers: {content_type: 'application/json; charset=utf-8'})
|
77
|
+
|
78
|
+
@refund = {:transaction_id => '321',
|
79
|
+
:transaction_date => '2015/05/14',
|
80
|
+
:transaction_reference_id => '123',
|
81
|
+
:to_country => 'US',
|
82
|
+
:to_zip => '90002',
|
83
|
+
:to_state => 'CA',
|
84
|
+
:to_city => 'Los Angeles',
|
85
|
+
:to_street => '123 Palm Grove Ln',
|
86
|
+
:amount => 17.45,
|
87
|
+
:shipping => 1.5,
|
88
|
+
:sales_tax => 0.95,
|
89
|
+
:line_items => [{:quantity => 1,
|
90
|
+
:product_identifier => '12-34243-9',
|
91
|
+
:descriptiion => 'Fuzzy Widget',
|
92
|
+
:unit_price => 15.0,
|
93
|
+
:sales_tax => 0.95}]
|
94
|
+
}
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'requests the right resource' do
|
98
|
+
@client.create_refund(@refund)
|
99
|
+
expect(a_post("/v2/transactions/refunds")).to have_been_made
|
100
|
+
end
|
101
|
+
|
102
|
+
it 'returns the created refund' do
|
103
|
+
refund = @client.create_refund(@refund)
|
104
|
+
expect(refund).to be_a Taxjar::Refund
|
105
|
+
expect(refund.transaction_id).to eq(321)
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe "#update_refund" do
|
110
|
+
before do
|
111
|
+
@refund_id = 321
|
112
|
+
stub_put("/v2/transactions/refunds/#{@refund_id}").to_return(body: fixture('refund.json'),
|
113
|
+
headers: {content_type: 'application/json; charset=utf-8'})
|
114
|
+
|
115
|
+
@refund = {:transaction_id => '321',
|
116
|
+
:amount => 17.95,
|
117
|
+
:shipping => 2.0,
|
118
|
+
:sales_tax => 0.95,
|
119
|
+
:line_items => [{:quantity => 1,
|
120
|
+
:product_identifier => '12-34243-9',
|
121
|
+
:descriptiion => 'Heavy Widget',
|
122
|
+
:unit_price => 15.0,
|
123
|
+
:sales_tax => 0.95}]
|
124
|
+
}
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'requests the right resource' do
|
128
|
+
@client.update_refund(@refund)
|
129
|
+
expect(a_put("/v2/transactions/refunds/#{@refund_id}")).to have_been_made
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'returns the updated refund' do
|
133
|
+
refund = @client.update_refund(@refund)
|
134
|
+
expect(refund).to be_a Taxjar::Refund
|
135
|
+
expect(refund.transaction_id).to eq(321)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
describe "#delete_refund" do
|
140
|
+
before do
|
141
|
+
stub_delete('/v2/transactions/refunds/321').
|
142
|
+
to_return(body: fixture('refund.json'),
|
143
|
+
headers: {content_type: 'application/json; charset=utf-8'})
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'requests the right resource' do
|
147
|
+
@client.delete_refund('321')
|
148
|
+
expect(a_delete('/v2/transactions/refunds/321')).to have_been_made
|
149
|
+
end
|
150
|
+
|
151
|
+
it 'returns the delete refund' do
|
152
|
+
refund = @client.delete_refund('321')
|
153
|
+
expect(refund).to be_an Taxjar::Refund
|
154
|
+
expect(refund.transaction_id).to eq(321)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
@@ -82,7 +82,7 @@ describe Taxjar::API::Request do
|
|
82
82
|
stub_request(:get, "https://api.taxjar.com/api_path").
|
83
83
|
with(:headers => {'Authorization'=>'Bearer AK', 'Connection'=>'close',
|
84
84
|
'Host'=>'api.taxjar.com',
|
85
|
-
'User-Agent'=>
|
85
|
+
'User-Agent'=>"TaxjarRubyGem/#{Taxjar::Version.to_s}"}).
|
86
86
|
to_return(:status => 200, :body => '{"object": {"id": "3"}}',
|
87
87
|
:headers => {content_type: 'application/json; charset utf-8'})
|
88
88
|
|
@@ -104,7 +104,7 @@ describe Taxjar::API::Request do
|
|
104
104
|
:headers => {'Authorization'=>'Bearer AK', 'Connection'=>'close',
|
105
105
|
'Content-Type'=>'application/json',
|
106
106
|
'Host'=>'api.taxjar.com',
|
107
|
-
'User-Agent'=>
|
107
|
+
'User-Agent'=>"TaxjarRubyGem/#{Taxjar::Version.to_s}"}).
|
108
108
|
to_return(:status => 200, :body => '{"object": {"id": "3"}}',
|
109
109
|
:headers => {content_type: 'application/json; charset utf-8'})
|
110
110
|
|
@@ -119,7 +119,7 @@ describe Taxjar::API::Request do
|
|
119
119
|
stub_request(:get, "https://api.taxjar.com/api_path").
|
120
120
|
with(:headers => {'Authorization'=>'Bearer AK', 'Connection'=>'close',
|
121
121
|
'Host'=>'api.taxjar.com',
|
122
|
-
'User-Agent'=>
|
122
|
+
'User-Agent'=>"TaxjarRubyGem/#{Taxjar::Version.to_s}"}).
|
123
123
|
to_return(:status => status, :body => '{}',
|
124
124
|
:body => '{"error": "Not Acceptable",
|
125
125
|
"detail": "error explanation",
|
metadata
CHANGED
@@ -1,83 +1,94 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: taxjar-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- TaxJar
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2015-
|
12
|
+
date: 2015-08-21 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: addressable
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
|
-
- -
|
19
|
+
- - ~>
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '2.3'
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
|
-
- -
|
27
|
+
- - ~>
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '2.3'
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: http
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
|
-
- -
|
35
|
+
- - ~>
|
32
36
|
- !ruby/object:Gem::Version
|
33
37
|
version: 0.8.12
|
34
38
|
type: :runtime
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
|
-
- -
|
43
|
+
- - ~>
|
39
44
|
- !ruby/object:Gem::Version
|
40
45
|
version: 0.8.12
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: memoizable
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
|
-
- -
|
51
|
+
- - ~>
|
46
52
|
- !ruby/object:Gem::Version
|
47
53
|
version: 0.4.0
|
48
54
|
type: :runtime
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
|
-
- -
|
59
|
+
- - ~>
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: 0.4.0
|
55
62
|
- !ruby/object:Gem::Dependency
|
56
63
|
name: bundler
|
57
64
|
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
58
66
|
requirements:
|
59
|
-
- -
|
67
|
+
- - ~>
|
60
68
|
- !ruby/object:Gem::Version
|
61
69
|
version: '1.7'
|
62
70
|
type: :development
|
63
71
|
prerelease: false
|
64
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
65
74
|
requirements:
|
66
|
-
- -
|
75
|
+
- - ~>
|
67
76
|
- !ruby/object:Gem::Version
|
68
77
|
version: '1.7'
|
69
78
|
- !ruby/object:Gem::Dependency
|
70
79
|
name: rake
|
71
80
|
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
72
82
|
requirements:
|
73
|
-
- -
|
83
|
+
- - ~>
|
74
84
|
- !ruby/object:Gem::Version
|
75
85
|
version: '10.0'
|
76
86
|
type: :development
|
77
87
|
prerelease: false
|
78
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
79
90
|
requirements:
|
80
|
-
- -
|
91
|
+
- - ~>
|
81
92
|
- !ruby/object:Gem::Version
|
82
93
|
version: '10.0'
|
83
94
|
description: Ruby wrapper for Taxjar API, more info at developer.taxjar.com
|
@@ -87,14 +98,18 @@ executables: []
|
|
87
98
|
extensions: []
|
88
99
|
extra_rdoc_files: []
|
89
100
|
files:
|
90
|
-
-
|
91
|
-
-
|
101
|
+
- .gitignore
|
102
|
+
- .rspec
|
103
|
+
- .ruby-version
|
104
|
+
- .travis.yml
|
92
105
|
- Gemfile
|
93
106
|
- LICENSE.txt
|
94
107
|
- README.md
|
95
108
|
- Rakefile
|
96
109
|
- lib/taxjar.rb
|
97
110
|
- lib/taxjar/api/api.rb
|
111
|
+
- lib/taxjar/api/order.rb
|
112
|
+
- lib/taxjar/api/refund.rb
|
98
113
|
- lib/taxjar/api/request.rb
|
99
114
|
- lib/taxjar/api/utils.rb
|
100
115
|
- lib/taxjar/base.rb
|
@@ -112,11 +127,15 @@ files:
|
|
112
127
|
- lib/taxjar/version.rb
|
113
128
|
- spec/fixtures/categories.json
|
114
129
|
- spec/fixtures/order.json
|
130
|
+
- spec/fixtures/orders.json
|
115
131
|
- spec/fixtures/rates.json
|
116
132
|
- spec/fixtures/refund.json
|
133
|
+
- spec/fixtures/refunds.json
|
117
134
|
- spec/fixtures/taxes.json
|
118
135
|
- spec/helper.rb
|
119
136
|
- spec/taxjar/api/api_spec.rb
|
137
|
+
- spec/taxjar/api/order_spec.rb
|
138
|
+
- spec/taxjar/api/refund_spec.rb
|
120
139
|
- spec/taxjar/api/request_spec.rb
|
121
140
|
- spec/taxjar/base_spec.rb
|
122
141
|
- spec/taxjar/client_spec.rb
|
@@ -126,35 +145,46 @@ files:
|
|
126
145
|
homepage: http://developers.taxjar.com
|
127
146
|
licenses:
|
128
147
|
- MIT
|
129
|
-
metadata: {}
|
130
148
|
post_install_message:
|
131
149
|
rdoc_options: []
|
132
150
|
require_paths:
|
133
151
|
- lib
|
134
152
|
required_ruby_version: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
135
154
|
requirements:
|
136
|
-
- -
|
155
|
+
- - ! '>='
|
137
156
|
- !ruby/object:Gem::Version
|
138
157
|
version: '0'
|
158
|
+
segments:
|
159
|
+
- 0
|
160
|
+
hash: 597971617682166633
|
139
161
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
|
+
none: false
|
140
163
|
requirements:
|
141
|
-
- -
|
164
|
+
- - ! '>='
|
142
165
|
- !ruby/object:Gem::Version
|
143
166
|
version: '0'
|
167
|
+
segments:
|
168
|
+
- 0
|
169
|
+
hash: 597971617682166633
|
144
170
|
requirements: []
|
145
171
|
rubyforge_project:
|
146
|
-
rubygems_version:
|
172
|
+
rubygems_version: 1.8.23
|
147
173
|
signing_key:
|
148
|
-
specification_version:
|
174
|
+
specification_version: 3
|
149
175
|
summary: Ruby wrapper for Taxjar API
|
150
176
|
test_files:
|
151
177
|
- spec/fixtures/categories.json
|
152
178
|
- spec/fixtures/order.json
|
179
|
+
- spec/fixtures/orders.json
|
153
180
|
- spec/fixtures/rates.json
|
154
181
|
- spec/fixtures/refund.json
|
182
|
+
- spec/fixtures/refunds.json
|
155
183
|
- spec/fixtures/taxes.json
|
156
184
|
- spec/helper.rb
|
157
185
|
- spec/taxjar/api/api_spec.rb
|
186
|
+
- spec/taxjar/api/order_spec.rb
|
187
|
+
- spec/taxjar/api/refund_spec.rb
|
158
188
|
- spec/taxjar/api/request_spec.rb
|
159
189
|
- spec/taxjar/base_spec.rb
|
160
190
|
- spec/taxjar/client_spec.rb
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 87a190a9235c2a2700a2982818d3140c53523d44
|
4
|
-
data.tar.gz: 33714a826f407017f66354dd8ee292f1c326842d
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 370543da7f55ea7307e52ed156cb50eb67c6457d6672df96b4564c41e9d5778c17bc4bb8bcca20a0f3ad21bb8a13bbce683b6bd3bca48d773a92b11055376c6d
|
7
|
-
data.tar.gz: d68ec3c6c5a678fd61ebe39354d06d2d7e0d68b80147531a039d0ac2a229ba948d62f4eef172cff2acdc7e10b741dc12bf84a77f7995bf103d61368b979287b6
|