lucid-shopify 0.50.1 → 0.50.2
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/lib/lucid/shopify/response.rb +22 -4
- data/lib/lucid/shopify/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f831f0a86deaa7d4ba5b5150e287c4db5380de44e91278a2f37257a45e188c9
|
4
|
+
data.tar.gz: 027071d699cec5c4cb1948d7a39be74afc7125f360cca3ffd0588af73a51c2b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 357be516c2a2a231db80409cac04e341ad7758fd2731e5fbd6e98a52fcdab9cbe6c42c827a714d1f5c9dfea66f45b2005f4eb918cbb3416673bc25ae49fb4cbe
|
7
|
+
data.tar.gz: ceb7df92ae20091390402ecae5c55ff55b427412a3ae6fc8df3de0a582c456d5c55222ce02d778739ca501fc5aaeb126bdc2ba451acc2ef195278a60364e1e51
|
@@ -131,7 +131,7 @@ module Lucid
|
|
131
131
|
|
132
132
|
# @return [Boolean]
|
133
133
|
def errors?
|
134
|
-
return
|
134
|
+
return true if user_errors?
|
135
135
|
|
136
136
|
data_hash.has_key?('errors') # should be only on 422
|
137
137
|
end
|
@@ -140,11 +140,29 @@ module Lucid
|
|
140
140
|
#
|
141
141
|
# @return [Boolean]
|
142
142
|
private def user_errors?
|
143
|
-
errors =
|
143
|
+
errors = find_user_errors
|
144
144
|
|
145
145
|
!errors.nil? && !errors.empty?
|
146
146
|
end
|
147
147
|
|
148
|
+
# GraphQL user errors (find recursively).
|
149
|
+
#
|
150
|
+
# @param hash [Hash]
|
151
|
+
#
|
152
|
+
# @return [Array, nil]
|
153
|
+
private def find_user_errors(hash = data_hash)
|
154
|
+
return nil unless request.is_a?(PostGraphQLRequest)
|
155
|
+
|
156
|
+
hash.each do |k, v|
|
157
|
+
return v if k == 'userErrors'
|
158
|
+
if v.is_a?(Hash)
|
159
|
+
errors = find_user_errors(v)
|
160
|
+
return errors if errors
|
161
|
+
end
|
162
|
+
end
|
163
|
+
nil
|
164
|
+
end
|
165
|
+
|
148
166
|
# A string rather than an object is returned by Shopify in the case of,
|
149
167
|
# e.g., 'Not found'. In this case, we return it under the 'resource' key.
|
150
168
|
#
|
@@ -167,11 +185,11 @@ module Lucid
|
|
167
185
|
#
|
168
186
|
# @return [Hash]
|
169
187
|
private def user_errors
|
170
|
-
errors =
|
188
|
+
errors = find_user_errors
|
171
189
|
return {} if errors.nil? || errors.empty?
|
172
190
|
errors.map do |error|
|
173
191
|
[
|
174
|
-
error['field'],
|
192
|
+
error['field'].join('.'),
|
175
193
|
error['message'],
|
176
194
|
]
|
177
195
|
end.to_h
|