shopify_api 5.0.0 → 5.1.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: 55a5fb52fc6aa176717a301e7a52d015b54a7128
4
- data.tar.gz: 7318df185fd7cfe2272a3b5078900beea9831eb4
3
+ metadata.gz: 613f6d8028571843ca524cae058a468ec0e496b6
4
+ data.tar.gz: b410fefaab43e2afe984aa7b50c019e15dea4a64
5
5
  SHA512:
6
- metadata.gz: 8b0eeef0481961159424da00239ac3f9bfbc4709ccc169f592bdd4a385c15ea27a1efe2cd083737c5a36a13d2be8a6687cd5b44b4ad0d69903a1cbcf34440414
7
- data.tar.gz: 2b0c63f6db528a3c721c2ddf9e30ed5e79976e8570c0ec7a9f03bfde173c90230e5af3979b16f7a49a001ab9ce90ad4d68920d03e291487340215506c9d70653
6
+ metadata.gz: 38de7545efafa728e251353506d6078a263af09a4b72504356394d5e35dcc08532ee5662c8edf132a2eacfe0d2c2ea213e9d4a97bbedf298d58d463cce1dbbee
7
+ data.tar.gz: 0c1e77dafdb01ec104f9345fab05be9c6c47e80357879f12709946fcb5d2872a9ae47109d3ac3daa48a8e80b9cace6f94f97f9a72e58af127aabded28dc2a2f1
data/.gitignore CHANGED
@@ -6,5 +6,6 @@ doc
6
6
  pkg
7
7
  .ruby-version
8
8
  *.lock
9
+ *.gem
9
10
  .idea
10
11
  .dev/
data/CHANGELOG CHANGED
@@ -1,9 +1,24 @@
1
+ == Version 5.1.0
2
+
3
+ * Added `ShopifyAPI::Publications`
4
+ * Added `ShopifyAPI::ProductPublications`
5
+ * Added `ShopifyAPI::CollectionPublications`
6
+ * Added support for new collection products endpoint from `ShopifyAPI::Collection#products`
7
+
1
8
  == Version 5.0.0
2
9
 
10
+ * Breaking change: `ShopifyAPI::Checkout` now maps to the Checkout API, rather than the Abandoned Checkouts API
11
+ * See the README for more details
3
12
  * Added `ShopifyAPI::AbandonedCheckout`
4
13
  * Added support for X-Shopify-Checkout-Version header on `ShopifyAPI::Checkout`
5
14
  * Added `ShopifyAPI::ShippingRate`
6
- * Added support for Checkout::complete endpoint
15
+ * Added `ShopifyAPI::Payment`
16
+ * Added support for `Checkout::complete` endpoint
17
+ * Fixed session handling support for Rails 5.2.1
18
+
19
+ == Version 4.13.0
20
+ * Added `ShopifyAPI::ApiPermission` resource for uninstalling an application
21
+ * Added a deprecation warning to `ShopifyAPI::OAuth`
7
22
 
8
23
  == Version 4.12.0
9
24
 
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ module ShopifyAPI
3
+ class CollectionPublication < Base
4
+ init_prefix :publication
5
+
6
+ def publication_id
7
+ @prefix_options[:publication_id]
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ module ShopifyAPI
3
+ class ProductPublication < Base
4
+ init_prefix :publication
5
+
6
+ def publication_id
7
+ @prefix_options[:publication_id]
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+ module ShopifyAPI
3
+ class Publication < Base
4
+ end
5
+ end
@@ -3,8 +3,12 @@ module ShopifyAPI
3
3
  include Events
4
4
  include Metafields
5
5
 
6
- def products
7
- Product.find(:all, :params => {:collection_id => self.id})
6
+ def products(options = {})
7
+ if options.present?
8
+ Product.find(:all, from: "/admin/smart_collections/#{id}/products.json", params: options)
9
+ else
10
+ Product.find(:all, params: { collection_id: id })
11
+ end
8
12
  end
9
13
 
10
14
  def order(options={})
@@ -1,3 +1,3 @@
1
1
  module ShopifyAPI
2
- VERSION = "5.0.0"
2
+ VERSION = "5.1.0"
3
3
  end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+ require 'test_helper'
3
+
4
+ class CollectionPublicationTest < Test::Unit::TestCase
5
+ def test_get_all_collection_publications
6
+ fake 'publications/55650051/collection_publications', body: load_fixture('collection_publications')
7
+ collection_publications = ShopifyAPI::CollectionPublication.find(:all, params: { publication_id: 55650051 })
8
+
9
+ assert_equal 96062799894, collection_publications.first.id
10
+ assert_equal 55650051, collection_publications.first.publication_id
11
+ end
12
+
13
+ def test_get_collection_publication
14
+ fake 'publications/55650051/collection_publications/647162527768', body: load_fixture('collection_publication')
15
+ collection_publication = ShopifyAPI::CollectionPublication.find(647162527768, params: { publication_id: 55650051 })
16
+
17
+ assert_equal 96062799894, collection_publication.id
18
+ assert_equal 55650051, collection_publication.publication_id
19
+ end
20
+
21
+ def test_create_collection_publication
22
+ fake 'publications/55650051/collection_publications', method: :post, body: load_fixture('collection_publication')
23
+ ShopifyAPI::CollectionPublication.create(
24
+ publication_id: 55650051,
25
+ published_at: "2018-01-29T14:06:08-05:00",
26
+ published: true,
27
+ collection_id: 8267093571
28
+ )
29
+
30
+ expected_body = {
31
+ collection_publication: {
32
+ published_at: "2018-01-29T14:06:08-05:00",
33
+ published: true,
34
+ collection_id: 8267093571,
35
+ },
36
+ }.to_json
37
+
38
+ assert_equal expected_body, FakeWeb.last_request.body
39
+ end
40
+ end
@@ -0,0 +1,11 @@
1
+ {
2
+ "collection_publication": {
3
+ "id": 96062799894,
4
+ "publication_id": 55650051,
5
+ "published_at": "2018-09-05T17:22:31-04:00",
6
+ "published": true,
7
+ "created_at": "2018-09-05T17:22:31-04:00",
8
+ "updated_at": "2018-09-14T14:31:19-04:00",
9
+ "collection_id": 60941828118
10
+ }
11
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "collection_publications": [
3
+ {
4
+ "id": 96062799894,
5
+ "publication_id": 55650051,
6
+ "published_at": "2018-09-05T17:22:31-04:00",
7
+ "published": true,
8
+ "created_at": "2018-09-05T17:22:31-04:00",
9
+ "updated_at": "2018-09-14T14:31:19-04:00",
10
+ "collection_id": 60941828118
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "product_publication": {
3
+ "id": 647162527768,
4
+ "publication_id": 55650051,
5
+ "published_at": "2018-01-29T14:06:08-05:00",
6
+ "published": true,
7
+ "created_at": "2018-01-29T14:06:08-05:00",
8
+ "updated_at": "2018-09-26T15:39:05-04:00",
9
+ "product_id": 8267093571
10
+ }
11
+ }
@@ -0,0 +1,13 @@
1
+ {
2
+ "product_publications": [
3
+ {
4
+ "id": 647162527768,
5
+ "publication_id": 55650051,
6
+ "published_at": "2018-01-29T14:06:08-05:00",
7
+ "published": true,
8
+ "created_at": "2018-01-29T14:06:08-05:00",
9
+ "updated_at": "2018-09-26T15:39:05-04:00",
10
+ "product_id": 8267093571
11
+ }
12
+ ]
13
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "publications": [
3
+ {
4
+ "id": 55650051,
5
+ "created_at": "2016-05-20T13:12:10-04:00",
6
+ "name": "Buy Button"
7
+ }
8
+ ]
9
+ }
@@ -0,0 +1,155 @@
1
+ {
2
+ "products": [
3
+ {
4
+ "product_type": "Cult Products",
5
+ "handle": "ipod-nano",
6
+ "created_at": "2011-10-20T14:05:13-04:00",
7
+ "body_html": "<p>It's the small iPod with one very big idea: Video. Now the world's most popular music player, available in 4GB and 8GB models, lets you enjoy TV shows, movies, video podcasts, and more. The larger, brighter display means amazing picture quality. In six eye-catching colors, iPod nano is stunning all around. And with models starting at just $149, little speaks volumes.</p>",
8
+ "title": "IPod Nano - 8GB",
9
+ "template_suffix": null,
10
+ "updated_at": "2011-10-20T14:05:13-04:00",
11
+ "id": 632910392,
12
+ "tags": "Emotive, Flash Memory, MP3, Music",
13
+ "images": [
14
+ {
15
+ "position": 1,
16
+ "created_at": "2011-10-20T14:05:13-04:00",
17
+ "product_id": 632910392,
18
+ "updated_at": "2011-10-20T14:05:13-04:00",
19
+ "src": "http://static.shopify.com/s/files/1/6909/3384/products/ipod-nano.png?0",
20
+ "id": 850703190
21
+ }
22
+ ],
23
+ "variants": [
24
+ {
25
+ "position": 1,
26
+ "price": "199.00",
27
+ "product_id": 632910392,
28
+ "created_at": "2011-10-20T14:05:13-04:00",
29
+ "requires_shipping": true,
30
+ "title": "Pink",
31
+ "inventory_quantity": 10,
32
+ "compare_at_price": null,
33
+ "inventory_policy": "continue",
34
+ "updated_at": "2011-10-20T14:05:13-04:00",
35
+ "inventory_management": "shopify",
36
+ "id": 808950810,
37
+ "taxable": true,
38
+ "grams": 200,
39
+ "sku": "IPOD2008PINK",
40
+ "option1": "Pink",
41
+ "fulfillment_service": "manual",
42
+ "option2": null,
43
+ "option3": null
44
+ },
45
+ {
46
+ "position": 2,
47
+ "price": "199.00",
48
+ "product_id": 632910392,
49
+ "created_at": "2011-10-20T14:05:13-04:00",
50
+ "requires_shipping": true,
51
+ "title": "Red",
52
+ "inventory_quantity": 20,
53
+ "compare_at_price": null,
54
+ "inventory_policy": "continue",
55
+ "updated_at": "2011-10-20T14:05:13-04:00",
56
+ "inventory_management": "shopify",
57
+ "id": 49148385,
58
+ "taxable": true,
59
+ "grams": 200,
60
+ "sku": "IPOD2008RED",
61
+ "option1": "Red",
62
+ "fulfillment_service": "manual",
63
+ "option2": null,
64
+ "option3": null
65
+ },
66
+ {
67
+ "position": 3,
68
+ "price": "199.00",
69
+ "product_id": 632910392,
70
+ "created_at": "2011-10-20T14:05:13-04:00",
71
+ "requires_shipping": true,
72
+ "title": "Green",
73
+ "inventory_quantity": 30,
74
+ "compare_at_price": null,
75
+ "inventory_policy": "continue",
76
+ "updated_at": "2011-10-20T14:05:13-04:00",
77
+ "inventory_management": "shopify",
78
+ "id": 39072856,
79
+ "taxable": true,
80
+ "grams": 200,
81
+ "sku": "IPOD2008GREEN",
82
+ "option1": "Green",
83
+ "fulfillment_service": "manual",
84
+ "option2": null,
85
+ "option3": null
86
+ },
87
+ {
88
+ "position": 4,
89
+ "price": "199.00",
90
+ "product_id": 632910392,
91
+ "created_at": "2011-10-20T14:05:13-04:00",
92
+ "requires_shipping": true,
93
+ "title": "Black",
94
+ "inventory_quantity": 40,
95
+ "compare_at_price": null,
96
+ "inventory_policy": "continue",
97
+ "updated_at": "2011-10-20T14:05:13-04:00",
98
+ "inventory_management": "shopify",
99
+ "id": 457924702,
100
+ "taxable": true,
101
+ "grams": 200,
102
+ "sku": "IPOD2008BLACK",
103
+ "option1": "Black",
104
+ "fulfillment_service": "manual",
105
+ "option2": null,
106
+ "option3": null
107
+ }
108
+ ],
109
+ "vendor": "Apple",
110
+ "published_at": "2007-12-31T19:00:00-05:00",
111
+ "manually_sorted": true,
112
+ "options": [
113
+ {
114
+ "name": "Title"
115
+ }
116
+ ]
117
+ },
118
+ {
119
+ "product_type": "Cult Products",
120
+ "handle": "ipod-touch",
121
+ "created_at": "2018-09-26T14:05:13-04:00",
122
+ "body_html": "<p>The iPod Touch has the iPhone's multi-touch interface, with a physical home button off the touch screen. The home screen has a list of buttons for the available applications.</p>",
123
+ "title": "IPod Touch 8GB",
124
+ "template_suffix": null,
125
+ "updated_at": "2018-09-26T14:05:13-04:00",
126
+ "id": 921728736,
127
+ "tags": null,
128
+ "variants": [
129
+ {
130
+ "id": 447654529,
131
+ "title": "Black",
132
+ "price": "199.00",
133
+ "sku": "IPOD2009BLACK",
134
+ "position": 1,
135
+ "inventory_policy": "continue",
136
+ "compare_at_price": null,
137
+ "fulfillment_service": "manual",
138
+ "inventory_management": "shopify",
139
+ "option1": "Black",
140
+ "option2": null,
141
+ "option3": null,
142
+ "created_at": "2018-09-26T14:05:13-04:00",
143
+ "updated_at": "2018-09-26T14:05:13-04:00",
144
+ "taxable": true,
145
+ "grams": 567,
146
+ "inventory_quantity": 13,
147
+ "requires_shipping": true
148
+ }
149
+ ],
150
+ "vendor": "Apple",
151
+ "published_at": "2018-09-26T14:05:13-04:00",
152
+ "manually_sorted": true
153
+ }
154
+ ]
155
+ }
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+ require 'test_helper'
3
+
4
+ class ProductPublicationTest < Test::Unit::TestCase
5
+ def test_get_all_product_publications
6
+ fake 'publications/55650051/product_publications', body: load_fixture('product_publications')
7
+ product_publications = ShopifyAPI::ProductPublication.find(:all, params: { publication_id: 55650051 })
8
+
9
+ assert_equal 647162527768, product_publications.first.id
10
+ assert_equal 55650051, product_publications.first.publication_id
11
+ end
12
+
13
+ def test_get_product_publication
14
+ fake 'publications/55650051/product_publications/647162527768', body: load_fixture('product_publication')
15
+ product_publication = ShopifyAPI::ProductPublication.find(647162527768, params: { publication_id: 55650051 })
16
+
17
+ assert_equal 647162527768, product_publication.id
18
+ assert_equal 55650051, product_publication.publication_id
19
+ end
20
+
21
+ def test_create_product_publication
22
+ fake 'publications/55650051/product_publications', method: :post, body: load_fixture('product_publication')
23
+ ShopifyAPI::ProductPublication.create(
24
+ publication_id: 55650051,
25
+ published_at: "2018-01-29T14:06:08-05:00",
26
+ published: true,
27
+ product_id: 8267093571
28
+ )
29
+
30
+ expected_body = {
31
+ product_publication: {
32
+ published_at: "2018-01-29T14:06:08-05:00",
33
+ published: true,
34
+ product_id: 8267093571,
35
+ },
36
+ }.to_json
37
+
38
+ assert_equal expected_body, FakeWeb.last_request.body
39
+ end
40
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+ require 'test_helper'
3
+
4
+ class PublicationTest < Test::Unit::TestCase
5
+ def test_find_all_publications
6
+ fake 'publications'
7
+ publications = ShopifyAPI::Publication.find(:all)
8
+
9
+ assert_equal 55650051, publications.first.id
10
+ assert_equal "Buy Button", publications.first.name
11
+ end
12
+ end
@@ -7,4 +7,29 @@ class SmartCollectionTest < Test::Unit::TestCase
7
7
  smart_collection = ShopifyAPI::SmartCollection.create(:title => "Macbooks", :rules => rules)
8
8
  assert_equal 1063001432, smart_collection.id
9
9
  end
10
+
11
+ test "Smart Collection get products gets all products in a smart collection" do
12
+ fake "smart_collections/1063001432", method: :get, status: 200, body: load_fixture('smart_collection')
13
+ smart_collection = ShopifyAPI::SmartCollection.find(1063001432)
14
+
15
+ fake "products.json?collection_id=1063001432",
16
+ method: :get,
17
+ status: 200,
18
+ body:
19
+ load_fixture('smart_collection_products'),
20
+ extension: false
21
+ assert_equal [632910392, 921728736], smart_collection.products.map(&:id)
22
+ end
23
+
24
+ test "Smart Collection get products with only_sorted=only_manual gets only manually sorted products" do
25
+ fake "smart_collections/1063001432", method: :get, status: 200, body: load_fixture('smart_collection')
26
+ smart_collection = ShopifyAPI::SmartCollection.find(1063001432)
27
+
28
+ fake "smart_collections/1063001432/products.json?only_sorted=only_manual",
29
+ method: :get,
30
+ status: 200,
31
+ body: load_fixture('smart_collection_products'),
32
+ extension: false
33
+ assert_equal [632910392, 921728736], smart_collection.products(only_sorted: "only_manual").map(&:id)
34
+ end
10
35
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: shopify_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shopify
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-01 00:00:00.000000000 Z
11
+ date: 2018-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeresource
@@ -184,6 +184,7 @@ files:
184
184
  - lib/shopify_api/resources/checkout.rb
185
185
  - lib/shopify_api/resources/collect.rb
186
186
  - lib/shopify_api/resources/collection_listing.rb
187
+ - lib/shopify_api/resources/collection_publication.rb
187
188
  - lib/shopify_api/resources/comment.rb
188
189
  - lib/shopify_api/resources/country.rb
189
190
  - lib/shopify_api/resources/custom_collection.rb
@@ -223,7 +224,9 @@ files:
223
224
  - lib/shopify_api/resources/price_rule.rb
224
225
  - lib/shopify_api/resources/product.rb
225
226
  - lib/shopify_api/resources/product_listing.rb
227
+ - lib/shopify_api/resources/product_publication.rb
226
228
  - lib/shopify_api/resources/province.rb
229
+ - lib/shopify_api/resources/publication.rb
227
230
  - lib/shopify_api/resources/receipt.rb
228
231
  - lib/shopify_api/resources/recurring_application_charge.rb
229
232
  - lib/shopify_api/resources/redirect.rb
@@ -266,6 +269,7 @@ files:
266
269
  - test/checkouts_test.rb
267
270
  - test/collect_test.rb
268
271
  - test/collection_listing_test.rb
272
+ - test/collection_publication_test.rb
269
273
  - test/countable_test.rb
270
274
  - test/custom_collection_test.rb
271
275
  - test/customer_saved_search_test.rb
@@ -295,6 +299,8 @@ files:
295
299
  - test/fixtures/collection_listing.json
296
300
  - test/fixtures/collection_listing_product_ids.json
297
301
  - test/fixtures/collection_listings.json
302
+ - test/fixtures/collection_publication.json
303
+ - test/fixtures/collection_publications.json
298
304
  - test/fixtures/custom_collection.json
299
305
  - test/fixtures/customer_invite.json
300
306
  - test/fixtures/customer_saved_search.json
@@ -341,6 +347,9 @@ files:
341
347
  - test/fixtures/product_listing.json
342
348
  - test/fixtures/product_listing_product_ids.json
343
349
  - test/fixtures/product_listings.json
350
+ - test/fixtures/product_publication.json
351
+ - test/fixtures/product_publications.json
352
+ - test/fixtures/publications.json
344
353
  - test/fixtures/recurring_application_charge.json
345
354
  - test/fixtures/recurring_application_charge_adjustment.json
346
355
  - test/fixtures/recurring_application_charges.json
@@ -354,6 +363,7 @@ files:
354
363
  - test/fixtures/shipping_zones.json
355
364
  - test/fixtures/shop.json
356
365
  - test/fixtures/smart_collection.json
366
+ - test/fixtures/smart_collection_products.json
357
367
  - test/fixtures/storefront_access_token.json
358
368
  - test/fixtures/storefront_access_tokens.json
359
369
  - test/fixtures/tags.json
@@ -386,7 +396,9 @@ files:
386
396
  - test/policy_test.rb
387
397
  - test/price_rule_test.rb
388
398
  - test/product_listing_test.rb
399
+ - test/product_publication_test.rb
389
400
  - test/product_test.rb
401
+ - test/publication_test.rb
390
402
  - test/recurring_application_charge_test.rb
391
403
  - test/redirect_test.rb
392
404
  - test/refund_test.rb