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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 300adbcc594f4ad258ccf2bf74e81c0c6763c41f722a2f35b2bb7641c394d27b
4
- data.tar.gz: 776d8e1439d218c2c09e2dbf1b01a174569b203fd4df6f48c8ba22d042785d04
3
+ metadata.gz: f5f47627632cde83fad96703fba4335e00b5f04a303c40d7c276558ed0d59c04
4
+ data.tar.gz: 9b0fffc153c69cd1caf0cc67aae87070af2a780dbec6d13c71b63513c0165bf3
5
5
  SHA512:
6
- metadata.gz: b2b388ed76c1b812f3530e929b9eb33ef070001cdd056a7eb5dbc28b12d5678d02ef2c332f4bfece665eb1f838e383cf6c98189e3a30f6df0875b39c80012f63
7
- data.tar.gz: 55e85ebabd3e2a0186d532a216f9ab6653a88cf605cb46010e614dff729ed0ed65f0e57ec5f82d225c3d1e58bcada46ebfd5f16162264f3b9131b4b11a45c92d
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(STDOUT) # defaults to a null logger
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(STDOUT)
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.grahql_bulk(%(
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 and private app password:
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
- create_webhook.(client, {
16
- topic: topic,
17
- fields: topic[: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.post_json(credentials, 'webhooks', webhook: webhook.merge(
12
+ client.post('webhooks', webhook: webhook.merge(
13
13
  address: ShopifyClient.config.webhook_uri,
14
14
  ))
15
15
  rescue Response::Error => e
@@ -8,7 +8,7 @@ module ShopifyClient
8
8
  #
9
9
  # @return [Array<Hash>] response data
10
10
  def call(client)
11
- webhooks = client.get(credentials, 'webhooks')['webhooks']
11
+ webhooks = client.get('webhooks').data['webhooks']
12
12
 
13
13
  delete_webhook = DeleteWebhook.new
14
14
 
@@ -7,7 +7,7 @@ module ShopifyClient
7
7
  #
8
8
  # @return [Hash] response data
9
9
  def call(client, id)
10
- client.delete(credentials, "webhooks/#{id}")
10
+ client.delete("webhooks/#{id}")
11
11
  end
12
12
  end
13
13
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ShopifyClient
4
- VERSION = '0.0.2'
4
+ VERSION = '0.0.3'
5
5
  end
@@ -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: nil, &block)
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.2
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-05 00:00:00.000000000 Z
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.15
202
+ rubygems_version: 3.2.22
203
203
  signing_key:
204
204
  specification_version: 4
205
205
  summary: Shopify client library