lucid-shopify 0.35.0 → 0.36.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e96b6b1a205fa3e97e3594aedce15b42fe63ea1815e0887a4a08cfb353f55fec
4
- data.tar.gz: eb0add1838afac04c4b94d1959c14f8b06968fa99ca7045162a99f36e8fa409f
3
+ metadata.gz: 6941ffc0f656f4a3f25df0ba4530aa8c793d3aedd3e87c0a4a333c5528ef6d16
4
+ data.tar.gz: 20b48f8e246754880b4f5506387774b5213605c2bf97bb7db2251c2ca24273c0
5
5
  SHA512:
6
- metadata.gz: 486193c71c99feef87a3327c7686a713968f06e98210085ea10d643ced26f093788d29c86f1b6d93e982b3ca88083c08d89e665e9d7ba90c7415d93b56b2971f
7
- data.tar.gz: 0b500a2554b66b324f8618e29d108a1f529f69023845d97c402374f5b7ced10357e1fea11ae72c4ce62cb2934cb757f09a4463723f8e2732822ad8336ead84a5
6
+ metadata.gz: 0460cdf66d11da1376772eba36cd03a94b60592e0385cf15b9026092107720c8d165791bd0459d791735b29c9683af76241128783cf6ad268c1c13b45f3726ad
7
+ data.tar.gz: d24830b5067246abd9918e87772a0f726a3a5b96594d81d17e5f6684977579ea0c73221c4f7bca8f884b9bc33cff80dabdf7fa9e201bd8a6dccb90fbe3012f41
@@ -10,8 +10,7 @@ module Lucid
10
10
  @create_webhook = create_webhook
11
11
  end
12
12
 
13
- # Create all webhooks for the shop. Shopify ignores any webhooks which
14
- # already exist remotely.
13
+ # Create all webhooks for the shop.
15
14
  #
16
15
  # @param credentials [Credentials]
17
16
  # @param webhooks [WebhookList]
@@ -18,6 +18,10 @@ module Lucid
18
18
  data = {**webhook, address: Shopify.config.webhook_uri}
19
19
 
20
20
  @client.post_json(credentials, 'webhooks', webhook: data)
21
+ rescue Response::Error => e
22
+ raise e unless e.response.error_message?([
23
+ 'address for this topic has already been taken'
24
+ ])
21
25
  end
22
26
  end
23
27
  end
@@ -18,7 +18,11 @@ module Lucid
18
18
 
19
19
  # @return [String]
20
20
  def message
21
- "bad response (#{response.status_code})"
21
+ if response.errors?
22
+ "bad response (#{response.status_code}) '#{response.error_messages.first}'"
23
+ else
24
+ "bad response (#{response.status_code})"
25
+ end
22
26
  end
23
27
  end
24
28
 
@@ -86,7 +90,7 @@ module Lucid
86
90
 
87
91
  # @return [Boolean]
88
92
  def errors?
89
- data_hash.has_key?('errors')
93
+ data_hash.has_key?('errors') # should be only on 422
90
94
  end
91
95
 
92
96
  # A string rather than an object is returned by Shopify in the case of,
@@ -105,6 +109,13 @@ module Lucid
105
109
  errors.map { |field, message| "#{field} #{message}" }
106
110
  end
107
111
 
112
+ # @param messages [Array<String>]
113
+ #
114
+ # @return [Boolean]
115
+ def error_message?(messages)
116
+ messages.any? { |message| error_messages.include?(message) }
117
+ end
118
+
108
119
  # @see Hash#each
109
120
  def each(&block)
110
121
  data_hash.each(&block)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Lucid
4
4
  module Shopify
5
- VERSION = '0.35.0'
5
+ VERSION = '0.36.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lucid-shopify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.35.0
4
+ version: 0.36.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kelsey Judson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-27 00:00:00.000000000 Z
11
+ date: 2019-12-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv