shopify_api 4.9.0 → 4.13.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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +8 -0
  3. data/.travis.yml +0 -4
  4. data/CHANGELOG +18 -0
  5. data/README.md +28 -12
  6. data/lib/shopify_api/limits.rb +1 -2
  7. data/lib/shopify_api/resources/access_scope.rb +5 -0
  8. data/lib/shopify_api/resources/api_permission.rb +9 -0
  9. data/lib/shopify_api/resources/asset.rb +8 -8
  10. data/lib/shopify_api/resources/billing_address.rb +1 -1
  11. data/lib/shopify_api/resources/custom_collection.rb +3 -3
  12. data/lib/shopify_api/resources/{customer_invite_message.rb → customer_invite.rb} +0 -0
  13. data/lib/shopify_api/resources/graphql.rb +22 -0
  14. data/lib/shopify_api/resources/image.rb +2 -2
  15. data/lib/shopify_api/resources/inventory_item.rb +6 -0
  16. data/lib/shopify_api/resources/inventory_level.rb +55 -0
  17. data/lib/shopify_api/resources/line_item.rb +9 -1
  18. data/lib/shopify_api/resources/location.rb +4 -0
  19. data/lib/shopify_api/resources/o_auth.rb +8 -0
  20. data/lib/shopify_api/resources/order.rb +7 -2
  21. data/lib/shopify_api/resources/ping.rb +3 -0
  22. data/lib/shopify_api/resources/ping/conversation.rb +18 -0
  23. data/lib/shopify_api/resources/ping/message.rb +9 -0
  24. data/lib/shopify_api/resources/product.rb +4 -4
  25. data/lib/shopify_api/resources/shipping_line.rb +1 -1
  26. data/lib/shopify_api/resources/shop.rb +4 -4
  27. data/lib/shopify_api/version.rb +1 -1
  28. data/shopify_api.gemspec +2 -1
  29. data/test/api_permission_test.rb +9 -0
  30. data/test/fixtures/inventory_level.json +7 -0
  31. data/test/fixtures/inventory_levels.json +24 -0
  32. data/test/fixtures/order_with_properties.json +373 -0
  33. data/test/fixtures/ping/conversation.json +1 -0
  34. data/test/fixtures/ping/message.json +1 -0
  35. data/test/inventory_level_test.rb +59 -0
  36. data/test/location_test.rb +14 -0
  37. data/test/order_test.rb +13 -1
  38. data/test/ping/conversation_test.rb +39 -0
  39. data/test/test_helper.rb +7 -5
  40. data/test/variant_test.rb +4 -1
  41. metadata +37 -10
  42. data/lib/shopify_api/resources/discount.rb +0 -11
  43. data/test/discount_test.rb +0 -52
  44. data/test/fixtures/discount.json +0 -17
  45. data/test/fixtures/discount_disabled.json +0 -17
  46. data/test/fixtures/discounts.json +0 -34
@@ -13,19 +13,19 @@ module ShopifyAPI
13
13
  format % prices.min
14
14
  end
15
15
  end
16
-
16
+
17
17
  def collections
18
18
  CustomCollection.find(:all, :params => {:product_id => self.id})
19
19
  end
20
-
20
+
21
21
  def smart_collections
22
22
  SmartCollection.find(:all, :params => {:product_id => self.id})
23
23
  end
24
-
24
+
25
25
  def add_to_collection(collection)
26
26
  collection.add_product(self)
27
27
  end
28
-
28
+
29
29
  def remove_from_collection(collection)
30
30
  collection.remove_product(self)
31
31
  end
@@ -1,4 +1,4 @@
1
1
  module ShopifyAPI
2
2
  class ShippingLine < Base
3
- end
3
+ end
4
4
  end
@@ -1,5 +1,5 @@
1
1
  module ShopifyAPI
2
- # Shop object. Use Shop.current to receive
2
+ # Shop object. Use Shop.current to receive
3
3
  # the shop.
4
4
  class Shop < Base
5
5
  def self.current(options={})
@@ -11,13 +11,13 @@ module ShopifyAPI
11
11
  end
12
12
 
13
13
  def add_metafield(metafield)
14
- raise ArgumentError, "You can only add metafields to resource that has been saved" if new?
14
+ raise ArgumentError, "You can only add metafields to resource that has been saved" if new?
15
15
  metafield.save
16
16
  metafield
17
17
  end
18
-
18
+
19
19
  def events
20
20
  Event.find(:all)
21
21
  end
22
- end
22
+ end
23
23
  end
@@ -1,3 +1,3 @@
1
1
  module ShopifyAPI
2
- VERSION = "4.9.0"
2
+ VERSION = "4.13.0"
3
3
  end
data/shopify_api.gemspec CHANGED
@@ -23,10 +23,11 @@ Gem::Specification.new do |s|
23
23
  s.summary = %q{ShopifyAPI is a lightweight gem for accessing the Shopify admin REST web services}
24
24
  s.license = "MIT"
25
25
 
26
- s.required_ruby_version = ">= 2.0"
26
+ s.required_ruby_version = ">= 2.1"
27
27
 
28
28
  s.add_runtime_dependency("activeresource", ">= 3.0.0")
29
29
  s.add_runtime_dependency("rack")
30
+ s.add_runtime_dependency("graphql-client")
30
31
 
31
32
  s.add_development_dependency("mocha", ">= 0.9.8")
32
33
  s.add_development_dependency("fakeweb")
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+ require 'test_helper'
3
+
4
+ class ApiPermissionTest < Test::Unit::TestCase
5
+ test "revoke access token" do
6
+ fake "api_permissions/current", method: :delete, status: 200, body: "{}"
7
+ assert ShopifyAPI::ApiPermission.destroy
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ {
2
+ "inventory_level" : {
3
+ "inventory_item_id": 808950810,
4
+ "location_id": 905684977,
5
+ "available": 1
6
+ }
7
+ }
@@ -0,0 +1,24 @@
1
+ {
2
+ "inventory_levels": [
3
+ {
4
+ "inventory_item_id": 39072856,
5
+ "location_id": 487838322,
6
+ "available": 27
7
+ },
8
+ {
9
+ "inventory_item_id": 808950810,
10
+ "location_id": 905684977,
11
+ "available": 1
12
+ },
13
+ {
14
+ "inventory_item_id": 808950810,
15
+ "location_id": 487838322,
16
+ "available": 9
17
+ },
18
+ {
19
+ "inventory_item_id": 39072856,
20
+ "location_id": 905684977,
21
+ "available": 3
22
+ }
23
+ ]
24
+ }
@@ -0,0 +1,373 @@
1
+ {
2
+ "order": {
3
+ "buyer_accepts_marketing": false,
4
+ "cancel_reason": null,
5
+ "cancelled_at": null,
6
+ "cart_token": "68778783ad298f1c80c3bafcddeea02f",
7
+ "checkout_token": null,
8
+ "closed_at": null,
9
+ "confirmed": false,
10
+ "created_at": "2008-01-10T11:00:00-05:00",
11
+ "currency": "USD",
12
+ "email": "bob.norman@hostmail.com",
13
+ "financial_status": "authorized",
14
+ "fulfillment_status": null,
15
+ "gateway": "authorize_net",
16
+ "id": 450789469,
17
+ "landing_site": "http://www.example.com?source=abc",
18
+ "location_id": null,
19
+ "name": "#1001",
20
+ "note": "Test note",
21
+ "number": 1,
22
+ "reference": "fhwdgads",
23
+ "referring_site": "http://www.otherexample.com",
24
+ "source": null,
25
+ "source_identifier": "fhwdgads",
26
+ "source_name": "web",
27
+ "source_url": null,
28
+ "subtotal_price": "398.00",
29
+ "taxes_included": false,
30
+ "test": false,
31
+ "token": "b1946ac92492d2347c6235b4d2611184",
32
+ "total_discounts": "0.00",
33
+ "total_line_items_price": "398.00",
34
+ "total_price": "409.94",
35
+ "total_price_usd": "409.94",
36
+ "total_tax": "11.94",
37
+ "total_weight": 0,
38
+ "updated_at": "2008-01-10T11:00:00-05:00",
39
+ "user_id": null,
40
+ "browser_ip": null,
41
+ "landing_site_ref": "abc",
42
+ "order_number": 1001,
43
+ "discount_codes": [],
44
+ "note_attributes": [],
45
+ "processing_method": "direct",
46
+ "checkout_id": 450789469,
47
+ "tax_lines": [
48
+ {
49
+ "price": "11.94",
50
+ "rate": 0.06,
51
+ "title": "State Tax"
52
+ }
53
+ ],
54
+ "tags": "",
55
+ "line_items": [
56
+ {
57
+ "fulfillment_service": "manual",
58
+ "fulfillment_status": null,
59
+ "grams": 1361,
60
+ "id": 466157049,
61
+ "price": "45.00",
62
+ "product_id": 632910392,
63
+ "quantity": 1,
64
+ "requires_shipping": true,
65
+ "sku": "",
66
+ "taxable": true,
67
+ "title": "Create Your Own Coffee 3 Pack",
68
+ "variant_id": 39072856,
69
+ "variant_title": "",
70
+ "vendor": "VCR",
71
+ "name": "Create Your Own Coffee 3 Pack",
72
+ "variant_inventory_management": null,
73
+ "properties": [
74
+ {
75
+ "name": "1st Coffee",
76
+ "value": "Coffee1"
77
+ },
78
+ {
79
+ "name": "2nd Coffee",
80
+ "value": "Coffee2"
81
+ },
82
+ {
83
+ "name": "3rd Coffee",
84
+ "value": "Coffee3"
85
+ },
86
+ {
87
+ "name": "Select Your Grind",
88
+ "value": "Ground"
89
+ }
90
+ ],
91
+ "product_exists": true,
92
+ "tax_lines": [
93
+
94
+ ]
95
+ },
96
+ {
97
+ "fulfillment_service": "manual",
98
+ "fulfillment_status": null,
99
+ "grams": 680,
100
+ "id": 641254555689,
101
+ "price": "24.00",
102
+ "product_id": 288331137065,
103
+ "quantity": 1,
104
+ "requires_shipping": true,
105
+ "sku": "",
106
+ "taxable": true,
107
+ "title": "Create Your Own Coffee 3 Pack (8oz bags)",
108
+ "variant_id": 4107806867497,
109
+ "variant_title": "",
110
+ "vendor": "OMC",
111
+ "name": "Create Your Own Coffee 3 Pack (8oz bags)",
112
+ "variant_inventory_management": null,
113
+ "properties": [
114
+ {
115
+ "name": "By default may label with \"Roasted for ",
116
+ "value": {
117
+ "Your First Name": {
118
+ "\". If you want something specific on the label, enter it here:": ""
119
+ }
120
+ }
121
+ },
122
+ {
123
+ "name": "Select Your Grind",
124
+ "value": "Ground"
125
+ },
126
+ {
127
+ "name": "Coffees",
128
+ "value": "Coffee blend 1"
129
+ },
130
+ {
131
+ "name": "Coffees",
132
+ "value": "Coffee blend 2"
133
+ },
134
+ {
135
+ "name": "Coffees",
136
+ "value": "Coffee blend 3"
137
+ }
138
+ ],
139
+ "product_exists": true,
140
+ "tax_lines": [
141
+
142
+ ]
143
+ }
144
+ ],
145
+ "shipping_lines": [
146
+ {
147
+ "code": "Free Shipping",
148
+ "price": "0.00",
149
+ "source": "shopify",
150
+ "title": "Free Shipping",
151
+ "tax_lines": [
152
+
153
+ ]
154
+ }
155
+ ],
156
+ "payment_details": {
157
+ "avs_result_code": null,
158
+ "credit_card_bin": null,
159
+ "cvv_result_code": null,
160
+ "credit_card_number": "XXXX-XXXX-XXXX-4242",
161
+ "credit_card_company": "Visa"
162
+ },
163
+ "billing_address": {
164
+ "address1": "Chestnut Street 92",
165
+ "address2": "",
166
+ "city": "Louisville",
167
+ "company": null,
168
+ "country": "United States",
169
+ "first_name": "Bob",
170
+ "last_name": "Norman",
171
+ "latitude": "45.41634",
172
+ "longitude": "-75.6868",
173
+ "phone": "555-625-1199",
174
+ "province": "Kentucky",
175
+ "zip": "40202",
176
+ "name": "Bob Norman",
177
+ "country_code": "US",
178
+ "province_code": "KY"
179
+ },
180
+ "shipping_address": {
181
+ "address1": "Chestnut Street 92",
182
+ "address2": "",
183
+ "city": "Louisville",
184
+ "company": null,
185
+ "country": "United States",
186
+ "first_name": "Bob",
187
+ "last_name": "Norman",
188
+ "latitude": "45.41634",
189
+ "longitude": "-75.6868",
190
+ "phone": "555-625-1199",
191
+ "province": "Kentucky",
192
+ "zip": "40202",
193
+ "name": "Bob Norman",
194
+ "country_code": "US",
195
+ "province_code": "KY"
196
+ },
197
+ "fulfillments": [
198
+ {
199
+ "created_at": "2014-03-07T16:14:08-05:00",
200
+ "id": 255858046,
201
+ "order_id": 450789469,
202
+ "service": "manual",
203
+ "status": "failure",
204
+ "tracking_company": null,
205
+ "updated_at": "2014-03-07T16:14:08-05:00",
206
+ "tracking_number": "1Z2345",
207
+ "tracking_numbers": [
208
+ "1Z2345"
209
+ ],
210
+ "tracking_url": "http://wwwapps.ups.com/etracking/tracking.cgi?InquiryNumber1=1Z2345&TypeOfInquiryNumber=T&AcceptUPSLicenseAgreement=yes&submit=Track",
211
+ "tracking_urls": [
212
+ "http://wwwapps.ups.com/etracking/tracking.cgi?InquiryNumber1=1Z2345&TypeOfInquiryNumber=T&AcceptUPSLicenseAgreement=yes&submit=Track"
213
+ ],
214
+ "receipt": {
215
+ "testcase": true,
216
+ "authorization": "123456"
217
+ },
218
+ "line_items": [
219
+ {
220
+ "fulfillment_service": "manual",
221
+ "fulfillment_status": null,
222
+ "grams": 680,
223
+ "id": 641254555689,
224
+ "price": "24.00",
225
+ "product_id": 288331137065,
226
+ "quantity": 1,
227
+ "requires_shipping": true,
228
+ "sku": "",
229
+ "taxable": true,
230
+ "title": "Create Your Own Coffee 3 Pack (8oz bags)",
231
+ "variant_id": 4107806867497,
232
+ "variant_title": "",
233
+ "vendor": "OMC",
234
+ "name": "Create Your Own Coffee 3 Pack (8oz bags)",
235
+ "variant_inventory_management": null,
236
+ "properties": [
237
+ {
238
+ "name": "By default may label with \"Roasted for ",
239
+ "value": {
240
+ "Your First Name": {
241
+ "\". If you want something specific on the label, enter it here:": ""
242
+ }
243
+ }
244
+ },
245
+ {
246
+ "name": "Select Your Grind",
247
+ "value": "Ground"
248
+ },
249
+ {
250
+ "name": "Coffees",
251
+ "value": "Coffee blend 1"
252
+ },
253
+ {
254
+ "name": "Coffees",
255
+ "value": "Coffee blend 2"
256
+ },
257
+ {
258
+ "name": "Coffees",
259
+ "value": "Coffee blend 3"
260
+ }
261
+ ],
262
+ "product_exists": true,
263
+ "tax_lines": [
264
+
265
+ ]
266
+ }
267
+ ]
268
+ },
269
+ {
270
+ "created_at": "2014-03-07T16:14:08-05:00",
271
+ "id": 255858046,
272
+ "order_id": 450789469,
273
+ "service": "manual",
274
+ "status": "failure",
275
+ "tracking_company": null,
276
+ "updated_at": "2014-03-07T16:14:08-05:00",
277
+ "tracking_number": "1Z2345",
278
+ "tracking_numbers": [
279
+ "1Z2345"
280
+ ],
281
+ "tracking_url": "http://wwwapps.ups.com/etracking/tracking.cgi?InquiryNumber1=1Z2345&TypeOfInquiryNumber=T&AcceptUPSLicenseAgreement=yes&submit=Track",
282
+ "tracking_urls": [
283
+ "http://wwwapps.ups.com/etracking/tracking.cgi?InquiryNumber1=1Z2345&TypeOfInquiryNumber=T&AcceptUPSLicenseAgreement=yes&submit=Track"
284
+ ],
285
+ "receipt": {},
286
+ "line_items": [
287
+ {
288
+ "fulfillment_service": "manual",
289
+ "fulfillment_status": null,
290
+ "grams": 1361,
291
+ "id": 466157049,
292
+ "price": "45.00",
293
+ "product_id": 632910392,
294
+ "quantity": 1,
295
+ "requires_shipping": true,
296
+ "sku": "",
297
+ "taxable": true,
298
+ "title": "Create Your Own Coffee 3 Pack",
299
+ "variant_id": 39072856,
300
+ "variant_title": "",
301
+ "vendor": "VCR",
302
+ "name": "Create Your Own Coffee 3 Pack",
303
+ "variant_inventory_management": null,
304
+ "properties": [
305
+ {
306
+ "name": "1st Coffee",
307
+ "value": "Coffee1"
308
+ },
309
+ {
310
+ "name": "2nd Coffee",
311
+ "value": "Coffee2"
312
+ },
313
+ {
314
+ "name": "3rd Coffee",
315
+ "value": "Coffee3"
316
+ },
317
+ {
318
+ "name": "Select Your Grind",
319
+ "value": "Ground"
320
+ }
321
+ ],
322
+ "product_exists": true,
323
+ "tax_lines": [
324
+
325
+ ]
326
+ }
327
+ ]
328
+ }
329
+ ],
330
+ "client_details": {
331
+ "accept_language": null,
332
+ "browser_ip": "0.0.0.0",
333
+ "session_hash": null,
334
+ "user_agent": null
335
+ },
336
+ "customer": {
337
+ "accepts_marketing": false,
338
+ "created_at": "2014-03-07T16:14:08-05:00",
339
+ "email": "bob.norman@hostmail.com",
340
+ "first_name": "Bob",
341
+ "id": 207119551,
342
+ "last_name": "Norman",
343
+ "last_order_id": null,
344
+ "multipass_identifier": null,
345
+ "note": null,
346
+ "orders_count": 0,
347
+ "state": "disabled",
348
+ "total_spent": "0.00",
349
+ "updated_at": "2014-03-07T16:14:08-05:00",
350
+ "verified_email": true,
351
+ "tags": "",
352
+ "last_order_name": null,
353
+ "default_address": {
354
+ "address1": "Chestnut Street 92",
355
+ "address2": "",
356
+ "city": "Louisville",
357
+ "company": null,
358
+ "country": "United States",
359
+ "first_name": null,
360
+ "id": 207119551,
361
+ "last_name": null,
362
+ "phone": "555-625-1199",
363
+ "province": "Kentucky",
364
+ "zip": "40202",
365
+ "name": null,
366
+ "province_code": "KY",
367
+ "country_code": "US",
368
+ "country_name": "United States",
369
+ "default": true
370
+ }
371
+ }
372
+ }
373
+ }