shopify-client 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -5
- data/lib/shopify-client/create_all_webhooks.rb +7 -5
- data/lib/shopify-client/create_webhook.rb +1 -1
- data/lib/shopify-client/delete_all_webhooks.rb +1 -1
- data/lib/shopify-client/delete_webhook.rb +1 -1
- data/lib/shopify-client/version.rb +1 -1
- data/lib/shopify-client/webhook_list.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f5f47627632cde83fad96703fba4335e00b5f04a303c40d7c276558ed0d59c04
|
4
|
+
data.tar.gz: 9b0fffc153c69cd1caf0cc67aae87070af2a780dbec6d13c71b63513c0165bf3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 400820d737e8aa67dea8d4e08e3c3f3d77f5185c91c69ee1e3605707d56d22508cfb64a7cbe9789e1d5f5b9274cbee8ce9f654e7da580800a3c5aa4edd74a294
|
7
|
+
data.tar.gz: 21ecdc9776deb76f0a36b7be42b4a0ab8ad90659f2a47c756f2f9aebfb69377722b6af7710c5915272cec99b1067ecaf9e5cff635de995804fb379a9a3b1ba3a
|
data/README.md
CHANGED
@@ -46,7 +46,7 @@ Setup
|
|
46
46
|
config.api_version = '...' # e.g. '2021-04'
|
47
47
|
config.cache_ttl = 3600
|
48
48
|
config.redirect_uri = '...' # for OAuth
|
49
|
-
config.logger = Logger.new(
|
49
|
+
config.logger = Logger.new($stdout) # defaults to a null logger
|
50
50
|
config.scope = '...'
|
51
51
|
config.shared_secret = '...'
|
52
52
|
config.webhook_uri = '...'
|
@@ -80,7 +80,7 @@ Calling the API
|
|
80
80
|
|
81
81
|
Request logging is disabled by default. To enable it:
|
82
82
|
|
83
|
-
ShopifyClient.config.logger = Logger.new(
|
83
|
+
ShopifyClient.config.logger = Logger.new($stdout)
|
84
84
|
|
85
85
|
Request throttling is enabled by default. If you're using Redis, throttling will
|
86
86
|
automatically make use of it; otherwise, throttling will only be maintained
|
@@ -93,7 +93,7 @@ The gem wraps Shopify's bulk query API by writing the result to a temporary file
|
|
93
93
|
and yielding an enumerator which itself streams each line of the result to limit
|
94
94
|
memory usage.
|
95
95
|
|
96
|
-
client.
|
96
|
+
client.graphql_bulk(%(
|
97
97
|
{
|
98
98
|
products {
|
99
99
|
edges {
|
@@ -300,7 +300,7 @@ Find a single result:
|
|
300
300
|
|
301
301
|
Iterate over results (automatic pagination):
|
302
302
|
|
303
|
-
order_repo.all.each do |order|
|
303
|
+
order_repo.all(client).each do |order|
|
304
304
|
# ...
|
305
305
|
end
|
306
306
|
|
@@ -350,10 +350,12 @@ Testing
|
|
350
350
|
### Integration tests
|
351
351
|
|
352
352
|
The integration tests require a private app with the scope `write_products`.
|
353
|
-
Create a .env file specifying the test shop
|
353
|
+
Create a .env file specifying the test shop, private app password, and a valid
|
354
|
+
webhook URI:
|
354
355
|
|
355
356
|
TEST_SHOP='test-shop.myshopify.com'
|
356
357
|
TEST_PASSWORD='shppa_...'
|
358
|
+
TEST_WEBHOOK_URI='https://.../webhooks'
|
357
359
|
|
358
360
|
Run the suite:
|
359
361
|
|
@@ -10,12 +10,14 @@ module ShopifyClient
|
|
10
10
|
def call(client)
|
11
11
|
create_webhook = CreateWebhook.new
|
12
12
|
|
13
|
-
ShopifyClient.webhooks.map do |topic|
|
13
|
+
ShopifyClient.webhooks.map do |topic, options|
|
14
14
|
Thread.new do
|
15
|
-
|
16
|
-
topic
|
17
|
-
fields:
|
18
|
-
|
15
|
+
webhook = {}.tap do |webhook|
|
16
|
+
webhook[:topic] = topic
|
17
|
+
webhook[:fields] = options[:fields] unless options[:fields].empty?
|
18
|
+
end
|
19
|
+
|
20
|
+
create_webhook.(client, webhook)
|
19
21
|
end
|
20
22
|
end.map(&:value)
|
21
23
|
end
|
@@ -9,7 +9,7 @@ module ShopifyClient
|
|
9
9
|
#
|
10
10
|
# @return [Hash] response data
|
11
11
|
def call(client, webhook)
|
12
|
-
client.
|
12
|
+
client.post('webhooks', webhook: webhook.merge(
|
13
13
|
address: ShopifyClient.config.webhook_uri,
|
14
14
|
))
|
15
15
|
rescue Response::Error => e
|
@@ -12,7 +12,7 @@ module ShopifyClient
|
|
12
12
|
# @param topic [String]
|
13
13
|
# @param handler [#call]
|
14
14
|
# @param fields [Array<String>] e.g. %w[id tags]
|
15
|
-
def register(topic, handler = nil, fields:
|
15
|
+
def register(topic, handler = nil, fields: [], &block)
|
16
16
|
raise ArgumentError unless nil ^ handler ^ block
|
17
17
|
|
18
18
|
handler = block if block
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shopify-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kelsey Judson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -199,7 +199,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
199
199
|
- !ruby/object:Gem::Version
|
200
200
|
version: '0'
|
201
201
|
requirements: []
|
202
|
-
rubygems_version: 3.2.
|
202
|
+
rubygems_version: 3.2.22
|
203
203
|
signing_key:
|
204
204
|
specification_version: 4
|
205
205
|
summary: Shopify client library
|