taxjar-ruby 2.1.0 → 2.2.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: bf9845756bfeec2ace638f0e6414d73e2aeba0b9
4
- data.tar.gz: f1852b4526f2fe8fac2530324acee0ca41146a78
3
+ metadata.gz: 0fa1ef8cd573c3ec624180399c2a29ddccfcc82d
4
+ data.tar.gz: dc58878c74697adc26b9750f0a1a64bc4dc38df9
5
5
  SHA512:
6
- metadata.gz: b7dfb2ad328bc585763ca567f521a705fd799582ae32076051af68278dc618eae7593392a8b2c2af3c416685aa3c44878bb1660e55eb5b638b0152e908337df6
7
- data.tar.gz: 073e8445230a589b9d67721df6e6fad3a14e92aba7c5bfe4e440de7fc7ec6c925044877a72aac0c0524e643262d2b5125f90e8207b33032f2d88bd5ec2f57201
6
+ metadata.gz: ae413a7c6e7318eb960976f8236095b7e679afcafe241a284d8fdc5ee071a552df1cf87db42ac52afc03dbb39c2e3d3fb3963f7e60ca5825b670dfb8a27cb7ec
7
+ data.tar.gz: 2f9acee68886bc4fefe8645c7eca656a337624831df83c30f11f66725dbf36be70e76f18d33e1372aa2338c2a96ca22138b83299c0203aafe4d96fb7d8aa3029
@@ -0,0 +1,17 @@
1
+ # http://editorconfig.org/
2
+
3
+ root = true
4
+
5
+ [*]
6
+ end_of_line = lf
7
+ charset = utf-8
8
+
9
+ [Rakefile]
10
+ indent_style=space
11
+ indent_size=2
12
+ trim_trailing_whitespace = true
13
+
14
+ [*.rb]
15
+ indent_style=space
16
+ indent_size=2
17
+ trim_trailing_whitespace = true
@@ -0,0 +1,6 @@
1
+ # 2.1.0 (2018-03-21)
2
+ * Sandbox environment support with `api_url` and custom headers
3
+
4
+ # 2.0.0 (2017-10-30)
5
+ * Update minimum required Ruby version to 2.0
6
+ * Update HTTP (The Gem) to 2.2
data/README.md CHANGED
@@ -781,6 +781,228 @@ client.delete_refund('321')
781
781
  ]
782
782
  }>
783
783
  ```
784
+
785
+ ### List customers
786
+
787
+ #### Definition
788
+
789
+ ```ruby
790
+ client.list_customers
791
+ ```
792
+
793
+ #### Example Request
794
+
795
+ ```ruby
796
+ require 'taxjar'
797
+ client = Taxjar::Client.new(api_key: '48ceecccc8af930bd02597aec0f84a78')
798
+
799
+ client.list_customers
800
+ ```
801
+
802
+ #### Example Response
803
+
804
+ ```ruby
805
+ ['123', '124', '125']
806
+ ```
807
+
808
+ ### Show customer
809
+
810
+ #### Definition
811
+
812
+ ```ruby
813
+ client.show_customer
814
+ ```
815
+
816
+ #### Example Request
817
+
818
+ ```ruby
819
+ require 'taxjar'
820
+ client = Taxjar::Client.new(api_key: '48ceecccc8af930bd02597aec0f84a78')
821
+
822
+ client.show_customer('123')
823
+ ```
824
+
825
+ #### Example Response
826
+
827
+ ```ruby
828
+ #<Taxjar::Customer @attrs={
829
+ :customer_id => "123",
830
+ :exemption_type => "wholesale",
831
+ :exempt_regions => [
832
+ [0] {
833
+ :country => "US",
834
+ :state => "FL"
835
+ },
836
+ [1] {
837
+ :country => "US",
838
+ :state => "PA"
839
+ }
840
+ ],
841
+ :name => "Dunder Mifflin Paper Company",
842
+ :country => "US",
843
+ :state => "PA",
844
+ :zip => "18504",
845
+ :city => "Scranton",
846
+ :street => "1725 Slough Avenue"
847
+ }>
848
+ ```
849
+
850
+ ### Create customer
851
+
852
+ #### Definition
853
+
854
+ ```ruby
855
+ client.create_customer
856
+ ```
857
+
858
+ #### Example Request
859
+
860
+ ```ruby
861
+ require 'taxjar'
862
+ client = Taxjar::Client.new(api_key: '48ceecccc8af930bd02597aec0f84a78')
863
+
864
+ customer = client.create_customer({
865
+ :customer_id => '123',
866
+ :exemption_type => 'wholesale',
867
+ :name => 'Dunder Mifflin Paper Company',
868
+ :exempt_regions => [
869
+ {
870
+ :country => 'US',
871
+ :state => 'FL'
872
+ },
873
+ {
874
+ :country => 'US',
875
+ :state => 'PA'
876
+ }
877
+ ],
878
+ :country => 'US',
879
+ :state => 'PA',
880
+ :zip => '18504',
881
+ :city => 'Scranton',
882
+ :street => '1725 Slough Avenue'
883
+ })
884
+ ```
885
+
886
+ #### Example Response
887
+
888
+ ```ruby
889
+ #<Taxjar::Customer @attrs={
890
+ :customer_id => "123",
891
+ :exemption_type => "wholesale",
892
+ :exempt_regions => [
893
+ [0] {
894
+ :country => "US",
895
+ :state => "FL"
896
+ },
897
+ [1] {
898
+ :country => "US",
899
+ :state => "PA"
900
+ }
901
+ ],
902
+ :name => "Dunder Mifflin Paper Company",
903
+ :country => "US",
904
+ :state => "PA",
905
+ :zip => "18504",
906
+ :city => "Scranton",
907
+ :street => "1725 Slough Avenue"
908
+ }>
909
+ ```
910
+
911
+ ### Update customer
912
+
913
+ #### Definition
914
+
915
+ ```ruby
916
+ client.update_customer
917
+ ```
918
+
919
+ #### Example Request
920
+
921
+ ```ruby
922
+ require 'taxjar'
923
+ client = Taxjar::Client.new(api_key: '48ceecccc8af930bd02597aec0f84a78')
924
+
925
+ customer = client.update_customer({
926
+ :customer_id => '123',
927
+ :exemption_type => 'wholesale',
928
+ :name => 'Sterling Cooper',
929
+ :exempt_regions => [
930
+ {
931
+ :country => 'US',
932
+ :state => 'NY'
933
+ }
934
+ ],
935
+ :country => 'US',
936
+ :state => 'NY',
937
+ :zip => '10010',
938
+ :city => 'New York',
939
+ :street => '405 Madison Ave'
940
+ })
941
+ ```
942
+
943
+ #### Example Response
944
+
945
+ ```ruby
946
+ #<Taxjar::Customer @attrs={
947
+ :customer_id => "123",
948
+ :exemption_type => "wholesale",
949
+ :exempt_regions => [
950
+ [0] {
951
+ :country => "US",
952
+ :state => "NY"
953
+ }
954
+ ],
955
+ :name => "Sterling Cooper",
956
+ :country => "US",
957
+ :state => "NY",
958
+ :zip => "10010",
959
+ :city => "New York",
960
+ :street => "405 Madison Ave"
961
+ }>
962
+ ```
963
+
964
+ ### Delete customer
965
+
966
+ #### Definition
967
+
968
+ ```ruby
969
+ client.delete_customer
970
+ ```
971
+
972
+ #### Example Request
973
+
974
+ ```ruby
975
+ require 'taxjar'
976
+ client = Taxjar::Client.new(api_key: '48ceecccc8af930bd02597aec0f84a78')
977
+
978
+ client.delete_customer('123')
979
+ ```
980
+
981
+ #### Example Response
982
+
983
+ ```ruby
984
+ #<Taxjar::Customer @attrs={
985
+ :customer_id => "123",
986
+ :exemption_type => "wholesale",
987
+ :exempt_regions => [
988
+ [0] {
989
+ :country => "US",
990
+ :state => "FL"
991
+ },
992
+ [1] {
993
+ :country => "US",
994
+ :state => "PA"
995
+ }
996
+ ],
997
+ :name => "Dunder Mifflin Paper Company",
998
+ :country => "US",
999
+ :state => "PA",
1000
+ :zip => "18504",
1001
+ :city => "Scranton",
1002
+ :street => "1725 Slough Avenue"
1003
+ }>
1004
+ ```
1005
+
784
1006
  ### List nexus regions
785
1007
 
786
1008
  #### Definition
@@ -3,6 +3,8 @@ require "taxjar/breakdown"
3
3
  require "taxjar/breakdown_line_item"
4
4
  require "taxjar/category"
5
5
  require "taxjar/client"
6
+ require "taxjar/customer"
7
+ require "taxjar/exempt_region"
6
8
  require "taxjar/line_item"
7
9
  require "taxjar/nexus_region"
8
10
  require "taxjar/order"
@@ -0,0 +1,30 @@
1
+ require 'taxjar/api/utils'
2
+
3
+ module Taxjar
4
+ module API
5
+ module Customer
6
+ include Taxjar::API::Utils
7
+
8
+ def list_customers(options = {})
9
+ perform_get_with_array("/v2/customers", 'customers', options)
10
+ end
11
+
12
+ def show_customer(id, options = {})
13
+ perform_get_with_object("/v2/customers/#{id}", 'customer', options, Taxjar::Customer)
14
+ end
15
+
16
+ def create_customer(options = {})
17
+ perform_post_with_object("/v2/customers", 'customer', options, Taxjar::Customer)
18
+ end
19
+
20
+ def update_customer(options = {})
21
+ id = options.fetch(:customer_id)
22
+ perform_put_with_object("/v2/customers/#{id}", 'customer', options, Taxjar::Customer)
23
+ end
24
+
25
+ def delete_customer(id, options={})
26
+ perform_delete_with_object("/v2/customers/#{id}", 'customer', options, Taxjar::Customer)
27
+ end
28
+ end
29
+ end
30
+ end
@@ -1,4 +1,5 @@
1
1
  require 'taxjar/api/api'
2
+ require 'taxjar/api/customer'
2
3
  require 'taxjar/api/order'
3
4
  require 'taxjar/api/refund'
4
5
  require 'taxjar/error'
@@ -8,6 +9,7 @@ require 'taxjar/api/utils'
8
9
  module Taxjar
9
10
  class Client
10
11
  include Taxjar::API
12
+ include Taxjar::API::Customer
11
13
  include Taxjar::API::Order
12
14
  include Taxjar::API::Refund
13
15
 
@@ -0,0 +1,20 @@
1
+ require 'taxjar/base'
2
+
3
+ module Taxjar
4
+ class Customer < Taxjar::Base
5
+ extend ModelAttribute
6
+
7
+ attribute :customer_id, :string
8
+ attribute :exemption_type, :string
9
+ attribute :name, :string
10
+ attribute :country, :string
11
+ attribute :state, :string
12
+ attribute :zip, :string
13
+ attribute :city, :string
14
+ attribute :street, :string
15
+
16
+ def exempt_regions
17
+ map_collection(Taxjar::ExemptRegion, :exempt_regions)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,10 @@
1
+ require 'taxjar/base'
2
+
3
+ module Taxjar
4
+ class ExemptRegion < Taxjar::Base
5
+ extend ModelAttribute
6
+
7
+ attribute :country, :string
8
+ attribute :state, :string
9
+ end
10
+ end
@@ -6,7 +6,7 @@ module Taxjar
6
6
  end
7
7
 
8
8
  def minor
9
- 1
9
+ 2
10
10
  end
11
11
 
12
12
  def patch
@@ -0,0 +1,22 @@
1
+ {
2
+ "customer": {
3
+ "customer_id": "123",
4
+ "exemption_type": "wholesale",
5
+ "exempt_regions": [
6
+ {
7
+ "country": "US",
8
+ "state": "FL"
9
+ },
10
+ {
11
+ "country": "US",
12
+ "state": "PA"
13
+ }
14
+ ],
15
+ "name": "Dunder Mifflin Paper Company",
16
+ "country": "US",
17
+ "state": "PA",
18
+ "zip": "18504",
19
+ "city": "Scranton",
20
+ "street": "1725 Slough Avenue"
21
+ }
22
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "customers": [
3
+ "123",
4
+ "456"
5
+ ]
6
+ }
7
+
@@ -0,0 +1,202 @@
1
+ require 'helper'
2
+
3
+ describe Taxjar::API::Order do
4
+ before do
5
+ @client = Taxjar::Client.new(api_key: 'AK')
6
+ end
7
+
8
+ describe "#list_customers" do
9
+ context "without parameters" do
10
+ before do
11
+ stub_get('/v2/customers').to_return(body: fixture('customers.json'),
12
+ headers: {content_type: 'application/json; charset=utf-8'})
13
+ end
14
+
15
+ it 'requests the right resource' do
16
+ @client.list_customers
17
+ expect(a_get('/v2/customers')).to have_been_made
18
+ end
19
+
20
+ it 'returns the requested customers' do
21
+ customers = @client.list_customers
22
+ expect(customers).to be_an Array
23
+ expect(customers.first).to be_a String
24
+ expect(customers.first).to eq('123')
25
+ end
26
+ end
27
+ end
28
+
29
+ describe "#show_customer" do
30
+ before do
31
+ stub_get('/v2/customers/123').
32
+ to_return(body: fixture('customer.json'),
33
+ headers: {content_type: 'application/json; charset=utf-8'})
34
+ end
35
+
36
+ it 'requests the right resource' do
37
+ @client.show_customer('123')
38
+ expect(a_get('/v2/customers/123')).to have_been_made
39
+ end
40
+
41
+ it 'returns the requested customer' do
42
+ customer = @client.show_customer('123')
43
+ expect(customer).to be_an Taxjar::Customer
44
+ expect(customer.customer_id).to eq('123')
45
+ expect(customer.exemption_type).to eq('wholesale')
46
+ expect(customer.name).to eq('Dunder Mifflin Paper Company')
47
+ expect(customer.country).to eq('US')
48
+ expect(customer.state).to eq('PA')
49
+ expect(customer.zip).to eq('18504')
50
+ expect(customer.city).to eq('Scranton')
51
+ expect(customer.street).to eq('1725 Slough Avenue')
52
+ end
53
+
54
+ it 'allows access to exempt_regions' do
55
+ customer = @client.show_customer('123')
56
+ expect(customer.exempt_regions[0].country).to eq('US')
57
+ expect(customer.exempt_regions[0].state).to eq('FL')
58
+ expect(customer.exempt_regions[1].country).to eq('US')
59
+ expect(customer.exempt_regions[1].state).to eq('PA')
60
+ end
61
+ end
62
+
63
+ describe "#create_customer" do
64
+ before do
65
+ stub_post("/v2/customers").to_return(body: fixture('customer.json'),
66
+ headers: {content_type: 'application/json; charset=utf-8'})
67
+
68
+ @customer = {
69
+ :customer_id => '123',
70
+ :exemption_type => 'wholesale',
71
+ :name => 'Dunder Mifflin Paper Company',
72
+ :exempt_regions => [
73
+ {
74
+ :country => 'US',
75
+ :state => 'FL'
76
+ },
77
+ {
78
+ :country => 'US',
79
+ :state => 'PA'
80
+ }
81
+ ],
82
+ :country => 'US',
83
+ :state => 'PA',
84
+ :zip => '18504',
85
+ :city => 'Scranton',
86
+ :street => '1725 Slough Avenue'
87
+ }
88
+ end
89
+
90
+ it 'requests the right resource' do
91
+ @client.create_customer(@customer)
92
+ expect(a_post("/v2/customers")).to have_been_made
93
+ end
94
+
95
+ it 'returns the created customer' do
96
+ customer = @client.create_customer(@customer)
97
+ expect(customer.customer_id).to eq('123')
98
+ expect(customer.exemption_type).to eq('wholesale')
99
+ expect(customer.name).to eq('Dunder Mifflin Paper Company')
100
+ expect(customer.country).to eq('US')
101
+ expect(customer.state).to eq('PA')
102
+ expect(customer.zip).to eq('18504')
103
+ expect(customer.city).to eq('Scranton')
104
+ expect(customer.street).to eq('1725 Slough Avenue')
105
+ end
106
+
107
+ it 'allows access to exempt_regions' do
108
+ customer = @client.create_customer(@customer)
109
+ expect(customer.exempt_regions[0].country).to eq('US')
110
+ expect(customer.exempt_regions[0].state).to eq('FL')
111
+ expect(customer.exempt_regions[1].country).to eq('US')
112
+ expect(customer.exempt_regions[1].state).to eq('PA')
113
+ end
114
+ end
115
+
116
+ describe "#update_customer" do
117
+ before do
118
+ @customer_id = 123
119
+ stub_put("/v2/customers/#{@customer_id}").to_return(body: fixture('customer.json'),
120
+ headers: {content_type: 'application/json; charset=utf-8'})
121
+
122
+ @customer = {
123
+ :customer_id => '123',
124
+ :exemption_type => 'wholesale',
125
+ :name => 'Dunder Mifflin Paper Company',
126
+ :exempt_regions => [
127
+ {
128
+ :country => 'US',
129
+ :state => 'FL'
130
+ },
131
+ {
132
+ :country => 'US',
133
+ :state => 'PA'
134
+ }
135
+ ],
136
+ :country => 'US',
137
+ :state => 'PA',
138
+ :zip => '18504',
139
+ :city => 'Scranton',
140
+ :street => '1725 Slough Avenue'
141
+ }
142
+ end
143
+
144
+ it 'requests the right resource' do
145
+ @client.update_customer(@customer)
146
+ expect(a_put("/v2/customers/#{@customer_id}")).to have_been_made
147
+ end
148
+
149
+ it 'returns the updated customer' do
150
+ customer = @client.update_customer(@customer)
151
+ expect(customer.customer_id).to eq('123')
152
+ expect(customer.exemption_type).to eq('wholesale')
153
+ expect(customer.name).to eq('Dunder Mifflin Paper Company')
154
+ expect(customer.country).to eq('US')
155
+ expect(customer.state).to eq('PA')
156
+ expect(customer.zip).to eq('18504')
157
+ expect(customer.city).to eq('Scranton')
158
+ expect(customer.street).to eq('1725 Slough Avenue')
159
+ end
160
+
161
+ it 'allows access to exempt_regions' do
162
+ customer = @client.update_customer(@customer)
163
+ expect(customer.exempt_regions[0].country).to eq('US')
164
+ expect(customer.exempt_regions[0].state).to eq('FL')
165
+ expect(customer.exempt_regions[1].country).to eq('US')
166
+ expect(customer.exempt_regions[1].state).to eq('PA')
167
+ end
168
+ end
169
+
170
+ describe "#delete_customer" do
171
+ before do
172
+ stub_delete('/v2/customers/123').to_return(body: fixture('customer.json'),
173
+ headers: {content_type: 'application/json; charset=utf-8'})
174
+ end
175
+
176
+ it 'requests the right resource' do
177
+ @client.delete_customer('123')
178
+ expect(a_delete('/v2/customers/123')).to have_been_made
179
+ end
180
+
181
+ it 'returns the deleted customer' do
182
+ customer = @client.delete_customer('123')
183
+ expect(customer.customer_id).to eq('123')
184
+ expect(customer.exemption_type).to eq('wholesale')
185
+ expect(customer.name).to eq('Dunder Mifflin Paper Company')
186
+ expect(customer.country).to eq('US')
187
+ expect(customer.state).to eq('PA')
188
+ expect(customer.zip).to eq('18504')
189
+ expect(customer.city).to eq('Scranton')
190
+ expect(customer.street).to eq('1725 Slough Avenue')
191
+ end
192
+
193
+ it 'allows access to exempt_regions' do
194
+ customer = @client.delete_customer('123')
195
+ expect(customer.exempt_regions[0].country).to eq('US')
196
+ expect(customer.exempt_regions[0].state).to eq('FL')
197
+ expect(customer.exempt_regions[1].country).to eq('US')
198
+ expect(customer.exempt_regions[1].state).to eq('PA')
199
+ end
200
+ end
201
+
202
+ end
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.1.0
4
+ version: 2.2.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-03-21 00:00:00.000000000 Z
11
+ date: 2018-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -101,16 +101,19 @@ executables: []
101
101
  extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
+ - ".editorconfig"
104
105
  - ".gitignore"
105
106
  - ".rspec"
106
107
  - ".ruby-version"
107
108
  - ".travis.yml"
109
+ - CHANGELOG.md
108
110
  - Gemfile
109
111
  - LICENSE.txt
110
112
  - README.md
111
113
  - Rakefile
112
114
  - lib/taxjar.rb
113
115
  - lib/taxjar/api/api.rb
116
+ - lib/taxjar/api/customer.rb
114
117
  - lib/taxjar/api/order.rb
115
118
  - lib/taxjar/api/refund.rb
116
119
  - lib/taxjar/api/request.rb
@@ -120,7 +123,9 @@ files:
120
123
  - lib/taxjar/breakdown_line_item.rb
121
124
  - lib/taxjar/category.rb
122
125
  - lib/taxjar/client.rb
126
+ - lib/taxjar/customer.rb
123
127
  - lib/taxjar/error.rb
128
+ - lib/taxjar/exempt_region.rb
124
129
  - lib/taxjar/line_item.rb
125
130
  - lib/taxjar/nexus_region.rb
126
131
  - lib/taxjar/order.rb
@@ -132,6 +137,8 @@ files:
132
137
  - lib/taxjar/validation.rb
133
138
  - lib/taxjar/version.rb
134
139
  - spec/fixtures/categories.json
140
+ - spec/fixtures/customer.json
141
+ - spec/fixtures/customers.json
135
142
  - spec/fixtures/nexus_regions.json
136
143
  - spec/fixtures/order.json
137
144
  - spec/fixtures/orders.json
@@ -149,6 +156,7 @@ files:
149
156
  - spec/fixtures/validation.json
150
157
  - spec/helper.rb
151
158
  - spec/taxjar/api/api_spec.rb
159
+ - spec/taxjar/api/customer_spec.rb
152
160
  - spec/taxjar/api/order_spec.rb
153
161
  - spec/taxjar/api/refund_spec.rb
154
162
  - spec/taxjar/api/request_spec.rb
@@ -176,12 +184,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
184
  version: '0'
177
185
  requirements: []
178
186
  rubyforge_project:
179
- rubygems_version: 2.6.13
187
+ rubygems_version: 2.6.8
180
188
  signing_key:
181
189
  specification_version: 4
182
190
  summary: Ruby wrapper for Taxjar API
183
191
  test_files:
184
192
  - spec/fixtures/categories.json
193
+ - spec/fixtures/customer.json
194
+ - spec/fixtures/customers.json
185
195
  - spec/fixtures/nexus_regions.json
186
196
  - spec/fixtures/order.json
187
197
  - spec/fixtures/orders.json
@@ -199,6 +209,7 @@ test_files:
199
209
  - spec/fixtures/validation.json
200
210
  - spec/helper.rb
201
211
  - spec/taxjar/api/api_spec.rb
212
+ - spec/taxjar/api/customer_spec.rb
202
213
  - spec/taxjar/api/order_spec.rb
203
214
  - spec/taxjar/api/refund_spec.rb
204
215
  - spec/taxjar/api/request_spec.rb