commerce 1.0.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 +7 -0
- data/LICENSE +21 -0
- data/lib/commerce.rb +38 -0
- data/lib/commerce/api_helper.rb +151 -0
- data/lib/commerce/base_controller.rb +19 -0
- data/lib/commerce/cart.rb +221 -0
- data/lib/commerce/checkout.rb +451 -0
- data/lib/commerce/exceptions/api_exception.rb +16 -0
- data/lib/commerce/http/auth/custom_header_auth.rb +11 -0
- data/lib/commerce/http/faraday_client.rb +41 -0
- data/lib/commerce/http/http_call_back.rb +17 -0
- data/lib/commerce/http/http_client.rb +82 -0
- data/lib/commerce/http/http_context.rb +15 -0
- data/lib/commerce/http/http_method_enum.rb +7 -0
- data/lib/commerce/http/http_request.rb +44 -0
- data/lib/commerce/http/http_response.rb +21 -0
- data/lib/commerce/order.rb +113 -0
- data/lib/commerce/product.rb +60 -0
- data/lib/commerce/service.rb +85 -0
- data/spec/api/cart_api_spec.rb +167 -0
- data/spec/api/checkout_api_spec.rb +309 -0
- data/spec/api/order_api_spec.rb +100 -0
- data/spec/api/product_api_spec.rb +69 -0
- data/spec/api/service_api_spec.rb +82 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/spec_helper.rb +111 -0
- metadata +119 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
Commerce js by Chec
|
|
3
|
+
|
|
4
|
+
Full-stack eCommerce API for developers & designers.
|
|
5
|
+
|
|
6
|
+
OpenAPI spec version: 1.0.0
|
|
7
|
+
|
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'spec_helper'
|
|
14
|
+
require 'json'
|
|
15
|
+
|
|
16
|
+
# Unit tests for Commerce::Cart
|
|
17
|
+
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
|
|
18
|
+
# Please update as you see appropriate
|
|
19
|
+
describe 'Cart' do
|
|
20
|
+
before do
|
|
21
|
+
# run before each test
|
|
22
|
+
@instance = Commerce::Cart.new
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
after do
|
|
26
|
+
# run after each test
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe 'test an instance of Cart' do
|
|
30
|
+
it 'should create an instact of Cart' do
|
|
31
|
+
@instance.should be_a(Commerce::Cart)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# unit tests for add
|
|
36
|
+
# ListProducts
|
|
37
|
+
# List
|
|
38
|
+
# @param id cart_id
|
|
39
|
+
# @param id2 id
|
|
40
|
+
# @param [Hash] opts the optional parameters
|
|
41
|
+
# @option opts [Integer] :quantity quantity
|
|
42
|
+
# @return [String]
|
|
43
|
+
describe 'add test' do
|
|
44
|
+
it "should work" do
|
|
45
|
+
# assertion here
|
|
46
|
+
# should be_a()
|
|
47
|
+
# should be_nil
|
|
48
|
+
# should ==
|
|
49
|
+
# should_not ==
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
# unit tests for contents
|
|
54
|
+
# ListProducts
|
|
55
|
+
# List
|
|
56
|
+
# @param id id
|
|
57
|
+
# @param [Hash] opts the optional parameters
|
|
58
|
+
# @return [String]
|
|
59
|
+
describe 'contents test' do
|
|
60
|
+
it "should work" do
|
|
61
|
+
# assertion here
|
|
62
|
+
# should be_a()
|
|
63
|
+
# should be_nil
|
|
64
|
+
# should ==
|
|
65
|
+
# should_not ==
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# unit tests for create
|
|
70
|
+
# ListProducts
|
|
71
|
+
# List
|
|
72
|
+
# @param [Hash] opts the optional parameters
|
|
73
|
+
# @return [String]
|
|
74
|
+
describe 'create test' do
|
|
75
|
+
it "should work" do
|
|
76
|
+
# assertion here
|
|
77
|
+
# should be_a()
|
|
78
|
+
# should be_nil
|
|
79
|
+
# should ==
|
|
80
|
+
# should_not ==
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
# unit tests for delete
|
|
85
|
+
# ListProducts
|
|
86
|
+
# List
|
|
87
|
+
# @param id id
|
|
88
|
+
# @param [Hash] opts the optional parameters
|
|
89
|
+
# @return [String]
|
|
90
|
+
describe 'delete test' do
|
|
91
|
+
it "should work" do
|
|
92
|
+
# assertion here
|
|
93
|
+
# should be_a()
|
|
94
|
+
# should be_nil
|
|
95
|
+
# should ==
|
|
96
|
+
# should_not ==
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
# unit tests for remove
|
|
101
|
+
# ListProducts
|
|
102
|
+
# List
|
|
103
|
+
# @param id cart_id
|
|
104
|
+
# @param line_item_id line_item_id
|
|
105
|
+
# @param [Hash] opts the optional parameters
|
|
106
|
+
# @return [String]
|
|
107
|
+
describe 'remove test' do
|
|
108
|
+
it "should work" do
|
|
109
|
+
# assertion here
|
|
110
|
+
# should be_a()
|
|
111
|
+
# should be_nil
|
|
112
|
+
# should ==
|
|
113
|
+
# should_not ==
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
# unit tests for reset
|
|
118
|
+
# ListProducts
|
|
119
|
+
# List
|
|
120
|
+
# @param id id
|
|
121
|
+
# @param [Hash] opts the optional parameters
|
|
122
|
+
# @return [String]
|
|
123
|
+
describe 'reset test' do
|
|
124
|
+
it "should work" do
|
|
125
|
+
# assertion here
|
|
126
|
+
# should be_a()
|
|
127
|
+
# should be_nil
|
|
128
|
+
# should ==
|
|
129
|
+
# should_not ==
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# unit tests for retrieve
|
|
134
|
+
# ListProducts
|
|
135
|
+
# List
|
|
136
|
+
# @param id id
|
|
137
|
+
# @param [Hash] opts the optional parameters
|
|
138
|
+
# @return [String]
|
|
139
|
+
describe 'retrieve test' do
|
|
140
|
+
it "should work" do
|
|
141
|
+
# assertion here
|
|
142
|
+
# should be_a()
|
|
143
|
+
# should be_nil
|
|
144
|
+
# should ==
|
|
145
|
+
# should_not ==
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
# unit tests for update
|
|
150
|
+
# ListProducts
|
|
151
|
+
# List
|
|
152
|
+
# @param id cart_id
|
|
153
|
+
# @param line_item_id line_item_id
|
|
154
|
+
# @param [Hash] opts the optional parameters
|
|
155
|
+
# @option opts [Integer] :quantity quantity
|
|
156
|
+
# @return [String]
|
|
157
|
+
describe 'update test' do
|
|
158
|
+
it "should work" do
|
|
159
|
+
# assertion here
|
|
160
|
+
# should be_a()
|
|
161
|
+
# should be_nil
|
|
162
|
+
# should ==
|
|
163
|
+
# should_not ==
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
end
|
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
=begin
|
|
2
|
+
Commerce js by Chec
|
|
3
|
+
|
|
4
|
+
Full-stack eCommerce API for developers & designers.
|
|
5
|
+
|
|
6
|
+
OpenAPI spec version: 1.0.0
|
|
7
|
+
|
|
8
|
+
Generated by: https://github.com/swagger-api/swagger-codegen.git
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
=end
|
|
12
|
+
|
|
13
|
+
require 'spec_helper'
|
|
14
|
+
require 'json'
|
|
15
|
+
|
|
16
|
+
# Unit tests for Commerce::Checkout
|
|
17
|
+
# Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
|
|
18
|
+
# Please update as you see appropriate
|
|
19
|
+
describe 'Checkout' do
|
|
20
|
+
before do
|
|
21
|
+
# run before each test
|
|
22
|
+
@instance = Commerce::Checkout.new
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
after do
|
|
26
|
+
# run after each test
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
describe 'test an instance of Checkout' do
|
|
30
|
+
it 'should create an instact of Checkout' do
|
|
31
|
+
@instance.should be_a(Commerce::Checkout)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
# unit tests for capture
|
|
36
|
+
# capture
|
|
37
|
+
# capture
|
|
38
|
+
# @param identifier identifier
|
|
39
|
+
# @param data data
|
|
40
|
+
# @param [Hash] opts the optional parameters
|
|
41
|
+
# @return [String]
|
|
42
|
+
describe 'capture test' do
|
|
43
|
+
it "should work" do
|
|
44
|
+
# assertion here
|
|
45
|
+
# should be_a()
|
|
46
|
+
# should be_nil
|
|
47
|
+
# should ==
|
|
48
|
+
# should_not ==
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# unit tests for check_discount
|
|
53
|
+
# ListProducts
|
|
54
|
+
# List
|
|
55
|
+
# @param id id
|
|
56
|
+
# @param code code
|
|
57
|
+
# @param [Hash] opts the optional parameters
|
|
58
|
+
# @return [String]
|
|
59
|
+
describe 'check_discount test' do
|
|
60
|
+
it "should work" do
|
|
61
|
+
# assertion here
|
|
62
|
+
# should be_a()
|
|
63
|
+
# should be_nil
|
|
64
|
+
# should ==
|
|
65
|
+
# should_not ==
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
# unit tests for check_pay_what_you_want
|
|
70
|
+
# ListProducts
|
|
71
|
+
# List
|
|
72
|
+
# @param id id
|
|
73
|
+
# @param customer_set_price customer_set_price
|
|
74
|
+
# @param [Hash] opts the optional parameters
|
|
75
|
+
# @return [String]
|
|
76
|
+
describe 'check_pay_what_you_want test' do
|
|
77
|
+
it "should work" do
|
|
78
|
+
# assertion here
|
|
79
|
+
# should be_a()
|
|
80
|
+
# should be_nil
|
|
81
|
+
# should ==
|
|
82
|
+
# should_not ==
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# unit tests for check_paypal_order_captured
|
|
87
|
+
# ListProducts
|
|
88
|
+
# List
|
|
89
|
+
# @param id id
|
|
90
|
+
# @param [Hash] opts the optional parameters
|
|
91
|
+
# @return [String]
|
|
92
|
+
describe 'check_paypal_order_captured test' do
|
|
93
|
+
it "should work" do
|
|
94
|
+
# assertion here
|
|
95
|
+
# should be_a()
|
|
96
|
+
# should be_nil
|
|
97
|
+
# should ==
|
|
98
|
+
# should_not ==
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# unit tests for check_paypal_status
|
|
103
|
+
# ListProducts
|
|
104
|
+
# List
|
|
105
|
+
# @param id id
|
|
106
|
+
# @param [Hash] opts the optional parameters
|
|
107
|
+
# @return [String]
|
|
108
|
+
describe 'check_paypal_status test' do
|
|
109
|
+
it "should work" do
|
|
110
|
+
# assertion here
|
|
111
|
+
# should be_a()
|
|
112
|
+
# should be_nil
|
|
113
|
+
# should ==
|
|
114
|
+
# should_not ==
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# unit tests for check_quantity
|
|
119
|
+
# ListProducts
|
|
120
|
+
# List
|
|
121
|
+
# @param id id
|
|
122
|
+
# @param line_item_id line_item_id
|
|
123
|
+
# @param amount amount
|
|
124
|
+
# @param [Hash] opts the optional parameters
|
|
125
|
+
# @return [String]
|
|
126
|
+
describe 'check_quantity test' do
|
|
127
|
+
it "should work" do
|
|
128
|
+
# assertion here
|
|
129
|
+
# should be_a()
|
|
130
|
+
# should be_nil
|
|
131
|
+
# should ==
|
|
132
|
+
# should_not ==
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
|
|
136
|
+
# unit tests for check_shipping_option
|
|
137
|
+
# ListProducts
|
|
138
|
+
# List
|
|
139
|
+
# @param id id
|
|
140
|
+
# @param country country
|
|
141
|
+
# @param id2 id
|
|
142
|
+
# @param [Hash] opts the optional parameters
|
|
143
|
+
# @return [String]
|
|
144
|
+
describe 'check_shipping_option test' do
|
|
145
|
+
it "should work" do
|
|
146
|
+
# assertion here
|
|
147
|
+
# should be_a()
|
|
148
|
+
# should be_nil
|
|
149
|
+
# should ==
|
|
150
|
+
# should_not ==
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
# unit tests for check_variant
|
|
155
|
+
# ListProducts
|
|
156
|
+
# List
|
|
157
|
+
# @param id id
|
|
158
|
+
# @param line_item_id line_item_id
|
|
159
|
+
# @param variant_id variant_id
|
|
160
|
+
# @param option_id option_id
|
|
161
|
+
# @param [Hash] opts the optional parameters
|
|
162
|
+
# @return [String]
|
|
163
|
+
describe 'check_variant test' do
|
|
164
|
+
it "should work" do
|
|
165
|
+
# assertion here
|
|
166
|
+
# should be_a()
|
|
167
|
+
# should be_nil
|
|
168
|
+
# should ==
|
|
169
|
+
# should_not ==
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
# unit tests for generate_token
|
|
174
|
+
# Generate id
|
|
175
|
+
# generateToken
|
|
176
|
+
# @param identifier identifier
|
|
177
|
+
# @param [Hash] opts the optional parameters
|
|
178
|
+
# @option opts [String] :type Id type
|
|
179
|
+
# @return [String]
|
|
180
|
+
describe 'generate_token test' do
|
|
181
|
+
it "should work" do
|
|
182
|
+
# assertion here
|
|
183
|
+
# should be_a()
|
|
184
|
+
# should be_nil
|
|
185
|
+
# should ==
|
|
186
|
+
# should_not ==
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
# unit tests for get_live
|
|
191
|
+
# ListProducts
|
|
192
|
+
# List
|
|
193
|
+
# @param id id
|
|
194
|
+
# @param [Hash] opts the optional parameters
|
|
195
|
+
# @return [String]
|
|
196
|
+
describe 'get_live test' do
|
|
197
|
+
it "should work" do
|
|
198
|
+
# assertion here
|
|
199
|
+
# should be_a()
|
|
200
|
+
# should be_nil
|
|
201
|
+
# should ==
|
|
202
|
+
# should_not ==
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
# unit tests for get_location_from_ip
|
|
207
|
+
# ListProducts
|
|
208
|
+
# List
|
|
209
|
+
# @param id id
|
|
210
|
+
# @param ip_address ip_address
|
|
211
|
+
# @param [Hash] opts the optional parameters
|
|
212
|
+
# @return [String]
|
|
213
|
+
describe 'get_location_from_ip test' do
|
|
214
|
+
it "should work" do
|
|
215
|
+
# assertion here
|
|
216
|
+
# should be_a()
|
|
217
|
+
# should be_nil
|
|
218
|
+
# should ==
|
|
219
|
+
# should_not ==
|
|
220
|
+
end
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
# unit tests for get_shipping_options
|
|
224
|
+
# ListProducts
|
|
225
|
+
# List
|
|
226
|
+
# @param id id
|
|
227
|
+
# @param country country
|
|
228
|
+
# @param [Hash] opts the optional parameters
|
|
229
|
+
# @return [String]
|
|
230
|
+
describe 'get_shipping_options test' do
|
|
231
|
+
it "should work" do
|
|
232
|
+
# assertion here
|
|
233
|
+
# should be_a()
|
|
234
|
+
# should be_nil
|
|
235
|
+
# should ==
|
|
236
|
+
# should_not ==
|
|
237
|
+
end
|
|
238
|
+
end
|
|
239
|
+
|
|
240
|
+
# unit tests for helper_validation
|
|
241
|
+
# ListProducts
|
|
242
|
+
# List
|
|
243
|
+
# @param id id
|
|
244
|
+
# @param [Hash] opts the optional parameters
|
|
245
|
+
# @return [String]
|
|
246
|
+
describe 'helper_validation test' do
|
|
247
|
+
it "should work" do
|
|
248
|
+
# assertion here
|
|
249
|
+
# should be_a()
|
|
250
|
+
# should be_nil
|
|
251
|
+
# should ==
|
|
252
|
+
# should_not ==
|
|
253
|
+
end
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
# unit tests for is_free
|
|
257
|
+
# ListProducts
|
|
258
|
+
# List
|
|
259
|
+
# @param id id
|
|
260
|
+
# @param [Hash] opts the optional parameters
|
|
261
|
+
# @return [String]
|
|
262
|
+
describe 'is_free test' do
|
|
263
|
+
it "should work" do
|
|
264
|
+
# assertion here
|
|
265
|
+
# should be_a()
|
|
266
|
+
# should be_nil
|
|
267
|
+
# should ==
|
|
268
|
+
# should_not ==
|
|
269
|
+
end
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
# unit tests for receipt
|
|
273
|
+
# ListProducts
|
|
274
|
+
# receipt
|
|
275
|
+
# @param id id
|
|
276
|
+
# @param [Hash] opts the optional parameters
|
|
277
|
+
# @option opts [String] :type Id type
|
|
278
|
+
# @return [String]
|
|
279
|
+
describe 'receipt test' do
|
|
280
|
+
it "should work" do
|
|
281
|
+
# assertion here
|
|
282
|
+
# should be_a()
|
|
283
|
+
# should be_nil
|
|
284
|
+
# should ==
|
|
285
|
+
# should_not ==
|
|
286
|
+
end
|
|
287
|
+
end
|
|
288
|
+
|
|
289
|
+
# unit tests for set_tax_zone
|
|
290
|
+
# ListProducts
|
|
291
|
+
# List
|
|
292
|
+
# @param id id
|
|
293
|
+
# @param [Hash] opts the optional parameters
|
|
294
|
+
# @option opts [String] :ip_address ip_address
|
|
295
|
+
# @option opts [String] :country country
|
|
296
|
+
# @option opts [String] :region region
|
|
297
|
+
# @option opts [String] :postal_zip_code postal_zip_code
|
|
298
|
+
# @return [String]
|
|
299
|
+
describe 'set_tax_zone test' do
|
|
300
|
+
it "should work" do
|
|
301
|
+
# assertion here
|
|
302
|
+
# should be_a()
|
|
303
|
+
# should be_nil
|
|
304
|
+
# should ==
|
|
305
|
+
# should_not ==
|
|
306
|
+
end
|
|
307
|
+
end
|
|
308
|
+
|
|
309
|
+
end
|