shopify_api 8.1.0 → 9.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 +4 -4
- data/CHANGELOG.md +25 -0
- data/README.md +22 -10
- data/docs/graphql.md +191 -0
- data/lib/shopify_api.rb +2 -0
- data/lib/shopify_api/api_version.rb +1 -1
- data/lib/shopify_api/graphql.rb +79 -0
- data/lib/shopify_api/graphql/http_client.rb +22 -0
- data/lib/shopify_api/graphql/railtie.rb +17 -0
- data/lib/shopify_api/graphql/task.rake +100 -0
- data/lib/shopify_api/resources/assigned_fulfillment_order.rb +16 -0
- data/lib/shopify_api/resources/base.rb +8 -0
- data/lib/shopify_api/resources/fulfillment.rb +34 -0
- data/lib/shopify_api/resources/fulfillment_order.rb +137 -0
- data/lib/shopify_api/resources/fulfillment_order_locations_for_move.rb +4 -0
- data/lib/shopify_api/resources/fulfillment_v2.rb +20 -0
- data/lib/shopify_api/resources/order.rb +7 -0
- data/lib/shopify_api/session.rb +3 -3
- data/lib/shopify_api/version.rb +1 -1
- data/test/assigned_fulfillment_order_test.rb +77 -0
- data/test/base_test.rb +14 -0
- data/test/fixtures/assigned_fulfillment_orders.json +78 -0
- data/test/fixtures/fulfillment_order.json +38 -0
- data/test/fixtures/fulfillment_order_locations_for_move.json +18 -0
- data/test/fixtures/fulfillment_orders.json +78 -0
- data/test/fixtures/fulfillments.json +53 -0
- data/test/fixtures/graphql/2019-10.json +1083 -0
- data/test/fixtures/graphql/dummy_schema.rb +16 -0
- data/test/fixtures/graphql/unstable.json +1083 -0
- data/test/fulfillment_order_test.rb +462 -0
- data/test/fulfillment_order_test_helper.rb +7 -0
- data/test/fulfillment_test.rb +164 -1
- data/test/fulfillment_v2_test.rb +62 -0
- data/test/graphql/http_client_test.rb +26 -0
- data/test/graphql_test.rb +147 -0
- data/test/order_test.rb +50 -0
- data/test/session_test.rb +26 -13
- data/test/test_helper.rb +4 -1
- metadata +25 -3
- data/lib/shopify_api/resources/graphql.rb +0 -22
data/test/session_test.rb
CHANGED
@@ -150,20 +150,21 @@ class SessionTest < Test::Unit::TestCase
|
|
150
150
|
assert_equal(ShopifyAPI::ApiVersion.new(handle: '2019-01'), ShopifyAPI::Base.api_version)
|
151
151
|
end
|
152
152
|
|
153
|
-
test "create_permission_url
|
154
|
-
ShopifyAPI::Session.setup(:
|
153
|
+
test "create_permission_url requires redirect_uri" do
|
154
|
+
ShopifyAPI::Session.setup(api_key: "My_test_key", secret: "My test secret")
|
155
155
|
session = ShopifyAPI::Session.new(
|
156
156
|
domain: 'http://localhost.myshopify.com',
|
157
157
|
token: 'any-token',
|
158
158
|
api_version: any_api_version
|
159
159
|
)
|
160
160
|
scope = ["write_products"]
|
161
|
-
|
162
|
-
|
161
|
+
assert_raises(ArgumentError) do
|
162
|
+
session.create_permission_url(scope)
|
163
|
+
end
|
163
164
|
end
|
164
165
|
|
165
166
|
test "create_permission_url returns correct url with single scope and redirect uri" do
|
166
|
-
ShopifyAPI::Session.setup(:
|
167
|
+
ShopifyAPI::Session.setup(api_key: "My_test_key", secret: "My test secret")
|
167
168
|
session = ShopifyAPI::Session.new(
|
168
169
|
domain: 'http://localhost.myshopify.com',
|
169
170
|
token: 'any-token',
|
@@ -174,28 +175,40 @@ class SessionTest < Test::Unit::TestCase
|
|
174
175
|
assert_equal "https://localhost.myshopify.com/admin/oauth/authorize?client_id=My_test_key&scope=write_products&redirect_uri=http://my_redirect_uri.com", permission_url
|
175
176
|
end
|
176
177
|
|
177
|
-
test "create_permission_url returns correct url with dual scope
|
178
|
-
ShopifyAPI::Session.setup(:
|
178
|
+
test "create_permission_url returns correct url with dual scope" do
|
179
|
+
ShopifyAPI::Session.setup(api_key: "My_test_key", secret: "My test secret")
|
179
180
|
session = ShopifyAPI::Session.new(
|
180
181
|
domain: 'http://localhost.myshopify.com',
|
181
182
|
token: 'any-token',
|
182
183
|
api_version: any_api_version
|
183
184
|
)
|
184
185
|
scope = ["write_products","write_customers"]
|
185
|
-
permission_url = session.create_permission_url(scope)
|
186
|
-
assert_equal "https://localhost.myshopify.com/admin/oauth/authorize?client_id=My_test_key&scope=write_products,write_customers", permission_url
|
186
|
+
permission_url = session.create_permission_url(scope, "http://my_redirect_uri.com")
|
187
|
+
assert_equal "https://localhost.myshopify.com/admin/oauth/authorize?client_id=My_test_key&scope=write_products,write_customers&redirect_uri=http://my_redirect_uri.com", permission_url
|
188
|
+
end
|
189
|
+
|
190
|
+
test "create_permission_url returns correct url with no scope" do
|
191
|
+
ShopifyAPI::Session.setup(api_key: "My_test_key", secret: "My test secret")
|
192
|
+
session = ShopifyAPI::Session.new(
|
193
|
+
domain: 'http://localhost.myshopify.com',
|
194
|
+
token: 'any-token',
|
195
|
+
api_version: any_api_version
|
196
|
+
)
|
197
|
+
scope = []
|
198
|
+
permission_url = session.create_permission_url(scope, "http://my_redirect_uri.com")
|
199
|
+
assert_equal "https://localhost.myshopify.com/admin/oauth/authorize?client_id=My_test_key&scope=&redirect_uri=http://my_redirect_uri.com", permission_url
|
187
200
|
end
|
188
201
|
|
189
|
-
test "create_permission_url returns correct url with
|
190
|
-
ShopifyAPI::Session.setup(:
|
202
|
+
test "create_permission_url returns correct url with state" do
|
203
|
+
ShopifyAPI::Session.setup(api_key: "My_test_key", secret: "My test secret")
|
191
204
|
session = ShopifyAPI::Session.new(
|
192
205
|
domain: 'http://localhost.myshopify.com',
|
193
206
|
token: 'any-token',
|
194
207
|
api_version: any_api_version
|
195
208
|
)
|
196
209
|
scope = []
|
197
|
-
permission_url = session.create_permission_url(scope)
|
198
|
-
assert_equal "https://localhost.myshopify.com/admin/oauth/authorize?client_id=My_test_key&scope=", permission_url
|
210
|
+
permission_url = session.create_permission_url(scope, "http://my_redirect_uri.com", state: "My nonce")
|
211
|
+
assert_equal "https://localhost.myshopify.com/admin/oauth/authorize?client_id=My_test_key&scope=&redirect_uri=http://my_redirect_uri.com&state=My%20nonce", permission_url
|
199
212
|
end
|
200
213
|
|
201
214
|
test "raise exception if code invalid in request token" do
|
data/test/test_helper.rb
CHANGED
@@ -92,6 +92,7 @@ module Test
|
|
92
92
|
end
|
93
93
|
|
94
94
|
def fake(endpoint, options={})
|
95
|
+
request_body = options.has_key?(:request_body) ? options.delete(:request_body) : nil
|
95
96
|
body = options.has_key?(:body) ? options.delete(:body) : load_fixture(endpoint)
|
96
97
|
format = options.delete(:format) || :json
|
97
98
|
method = options.delete(:method) || :get
|
@@ -104,7 +105,9 @@ module Test
|
|
104
105
|
"https://this-is-my-test-shop.myshopify.com#{api_version.construct_api_path("#{endpoint}#{extension}")}"
|
105
106
|
end
|
106
107
|
|
107
|
-
WebMock.stub_request(method, url)
|
108
|
+
stubbing = WebMock.stub_request(method, url)
|
109
|
+
stubbing = stubbing.with(body: request_body) if request_body
|
110
|
+
stubbing.to_return(
|
108
111
|
body: body, status: status, headers: { content_type: "text/#{format}", content_length: 1 }.merge(options)
|
109
112
|
)
|
110
113
|
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:
|
4
|
+
version: 9.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeresource
|
@@ -203,6 +203,7 @@ files:
|
|
203
203
|
- Rakefile
|
204
204
|
- bin/shopify
|
205
205
|
- docker-compose.yml
|
206
|
+
- docs/graphql.md
|
206
207
|
- lib/active_resource/connection_ext.rb
|
207
208
|
- lib/active_resource/detailed_log_subscriber.rb
|
208
209
|
- lib/active_resource/json_errors.rb
|
@@ -212,6 +213,10 @@ files:
|
|
212
213
|
- lib/shopify_api/countable.rb
|
213
214
|
- lib/shopify_api/disable_prefix_check.rb
|
214
215
|
- lib/shopify_api/events.rb
|
216
|
+
- lib/shopify_api/graphql.rb
|
217
|
+
- lib/shopify_api/graphql/http_client.rb
|
218
|
+
- lib/shopify_api/graphql/railtie.rb
|
219
|
+
- lib/shopify_api/graphql/task.rake
|
215
220
|
- lib/shopify_api/limits.rb
|
216
221
|
- lib/shopify_api/message_enricher.rb
|
217
222
|
- lib/shopify_api/meta.rb
|
@@ -230,6 +235,7 @@ files:
|
|
230
235
|
- lib/shopify_api/resources/array_base.rb
|
231
236
|
- lib/shopify_api/resources/article.rb
|
232
237
|
- lib/shopify_api/resources/asset.rb
|
238
|
+
- lib/shopify_api/resources/assigned_fulfillment_order.rb
|
233
239
|
- lib/shopify_api/resources/base.rb
|
234
240
|
- lib/shopify_api/resources/billing_address.rb
|
235
241
|
- lib/shopify_api/resources/blog.rb
|
@@ -254,10 +260,12 @@ files:
|
|
254
260
|
- lib/shopify_api/resources/event.rb
|
255
261
|
- lib/shopify_api/resources/fulfillment.rb
|
256
262
|
- lib/shopify_api/resources/fulfillment_event.rb
|
263
|
+
- lib/shopify_api/resources/fulfillment_order.rb
|
264
|
+
- lib/shopify_api/resources/fulfillment_order_locations_for_move.rb
|
257
265
|
- lib/shopify_api/resources/fulfillment_request.rb
|
258
266
|
- lib/shopify_api/resources/fulfillment_service.rb
|
267
|
+
- lib/shopify_api/resources/fulfillment_v2.rb
|
259
268
|
- lib/shopify_api/resources/gift_card.rb
|
260
|
-
- lib/shopify_api/resources/graphql.rb
|
261
269
|
- lib/shopify_api/resources/image.rb
|
262
270
|
- lib/shopify_api/resources/inventory_item.rb
|
263
271
|
- lib/shopify_api/resources/inventory_level.rb
|
@@ -319,6 +327,7 @@ files:
|
|
319
327
|
- test/application_credit_test.rb
|
320
328
|
- test/article_test.rb
|
321
329
|
- test/asset_test.rb
|
330
|
+
- test/assigned_fulfillment_order_test.rb
|
322
331
|
- test/base_test.rb
|
323
332
|
- test/blog_test.rb
|
324
333
|
- test/carrier_service_test.rb
|
@@ -350,6 +359,7 @@ files:
|
|
350
359
|
- test/fixtures/articles.json
|
351
360
|
- test/fixtures/asset.json
|
352
361
|
- test/fixtures/assets.json
|
362
|
+
- test/fixtures/assigned_fulfillment_orders.json
|
353
363
|
- test/fixtures/authors.json
|
354
364
|
- test/fixtures/blog.json
|
355
365
|
- test/fixtures/blogs.json
|
@@ -384,10 +394,17 @@ files:
|
|
384
394
|
- test/fixtures/events.json
|
385
395
|
- test/fixtures/fulfillment.json
|
386
396
|
- test/fixtures/fulfillment_event.json
|
397
|
+
- test/fixtures/fulfillment_order.json
|
398
|
+
- test/fixtures/fulfillment_order_locations_for_move.json
|
399
|
+
- test/fixtures/fulfillment_orders.json
|
387
400
|
- test/fixtures/fulfillment_request.json
|
388
401
|
- test/fixtures/fulfillment_service.json
|
402
|
+
- test/fixtures/fulfillments.json
|
389
403
|
- test/fixtures/gift_card.json
|
390
404
|
- test/fixtures/gift_card_disabled.json
|
405
|
+
- test/fixtures/graphql/2019-10.json
|
406
|
+
- test/fixtures/graphql/dummy_schema.rb
|
407
|
+
- test/fixtures/graphql/unstable.json
|
391
408
|
- test/fixtures/image.json
|
392
409
|
- test/fixtures/images.json
|
393
410
|
- test/fixtures/inventory_level.json
|
@@ -447,10 +464,15 @@ files:
|
|
447
464
|
- test/fixtures/webhook.json
|
448
465
|
- test/fixtures/webhooks.json
|
449
466
|
- test/fulfillment_event_test.rb
|
467
|
+
- test/fulfillment_order_test.rb
|
468
|
+
- test/fulfillment_order_test_helper.rb
|
450
469
|
- test/fulfillment_request_test.rb
|
451
470
|
- test/fulfillment_service_test.rb
|
452
471
|
- test/fulfillment_test.rb
|
472
|
+
- test/fulfillment_v2_test.rb
|
453
473
|
- test/gift_card_test.rb
|
474
|
+
- test/graphql/http_client_test.rb
|
475
|
+
- test/graphql_test.rb
|
454
476
|
- test/image_test.rb
|
455
477
|
- test/inventory_level_test.rb
|
456
478
|
- test/lib/webmock_extensions/last_request.rb
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require 'graphql/client'
|
3
|
-
require 'graphql/client/http'
|
4
|
-
|
5
|
-
module ShopifyAPI
|
6
|
-
# GraphQL API.
|
7
|
-
class GraphQL
|
8
|
-
def initialize
|
9
|
-
uri = Base.site.dup
|
10
|
-
uri.path = Base.api_version.construct_graphql_path
|
11
|
-
@http = ::GraphQL::Client::HTTP.new(uri.to_s) do
|
12
|
-
define_method(:headers) do |_context|
|
13
|
-
Base.headers
|
14
|
-
end
|
15
|
-
end
|
16
|
-
@schema = ::GraphQL::Client.load_schema(@http)
|
17
|
-
@client = ::GraphQL::Client.new(schema: @schema, execute: @http)
|
18
|
-
end
|
19
|
-
|
20
|
-
delegate :parse, :query, to: :@client
|
21
|
-
end
|
22
|
-
end
|