lucid-shopify 0.62.0 → 0.65.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/README.md +1 -1
- data/lib/lucid/shopify/bulk_request.rb +19 -10
- data/lib/lucid/shopify/parse_link_header.rb +1 -1
- data/lib/lucid/shopify/response.rb +9 -3
- data/lib/lucid/shopify/version.rb +1 -1
- data/lib/lucid/shopify.rb +2 -2
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f9cc24c021a2e7349b023603f85f4b0aa39de82a71fb39a8069e0a969f6fd21
|
4
|
+
data.tar.gz: ee27cad81df8037ce13d0d05df89ae34b25d8e38ab85b4ede5706f13e9f03c51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90dbe471a2ded8cc5cce566faea28935d9642c11d4bfaa1fc273b0f076d779b25b731e5c045c63c704778fc6ac0be27e5ad3fd4b117cdf92aa29c04bc49cb099
|
7
|
+
data.tar.gz: 66a7b9d598e47898e3a7faf211ce8ee679b965b070b9bd65d6bdc2bb2266b40a80cef2f657f51b3773547228939dd2f7b09f049b95cc290acc8b0aa50fdbd3b7
|
data/README.md
CHANGED
@@ -35,7 +35,7 @@ Setup
|
|
35
35
|
|
36
36
|
Lucid::Shopify.configure do |config|
|
37
37
|
config.api_key = '...'
|
38
|
-
config.api_version = '...' # e.g. '2020-
|
38
|
+
config.api_version = '...' # e.g. '2020-04'
|
39
39
|
config.billing_callback_uri = '...'
|
40
40
|
config.callback_uri = '...' # (for OAuth; unused by this gem)
|
41
41
|
config.logger = Logger.new(STDOUT)
|
@@ -14,6 +14,8 @@ module Lucid
|
|
14
14
|
FailedOperationError = Class.new(OperationError)
|
15
15
|
ObsoleteOperationError = Class.new(OperationError)
|
16
16
|
|
17
|
+
TimeoutError = Class.new(Error)
|
18
|
+
|
17
19
|
class Operation
|
18
20
|
include Dry::Initializer.define -> do
|
19
21
|
# @return [Client]
|
@@ -32,6 +34,11 @@ module Lucid
|
|
32
34
|
# @param http [HTTP::Client]
|
33
35
|
#
|
34
36
|
# @yield [Enumerator<Hash>] yields each parsed line of JSONL
|
37
|
+
#
|
38
|
+
# @raise CanceledOperationError
|
39
|
+
# @raise ExpiredOperationError
|
40
|
+
# @raise FailedOperationError
|
41
|
+
# @raise ObsoleteOperationError
|
35
42
|
def call(delay: 1, http: Container[:http], &block)
|
36
43
|
url = loop do
|
37
44
|
status, url = poll
|
@@ -71,6 +78,9 @@ module Lucid
|
|
71
78
|
end
|
72
79
|
|
73
80
|
# Cancel the bulk operation.
|
81
|
+
#
|
82
|
+
# @raise ObsoleteOperationError
|
83
|
+
# @raise TimeoutError
|
74
84
|
def cancel
|
75
85
|
begin
|
76
86
|
client.post_graphql(credentials, <<~QUERY)
|
@@ -96,25 +106,24 @@ module Lucid
|
|
96
106
|
|
97
107
|
# Poll until operation status is met.
|
98
108
|
#
|
99
|
-
# @param statuses [Array<
|
109
|
+
# @param statuses [Array<String>] to terminate polling on
|
100
110
|
# @param timeout [Integer] in seconds
|
101
111
|
#
|
102
|
-
# @raise
|
112
|
+
# @raise ObsoleteOperationError
|
113
|
+
# @raise TimeoutError
|
103
114
|
def poll_until(statuses, timeout: 60)
|
104
115
|
Timeout.timeout(timeout) do
|
105
116
|
loop do
|
106
117
|
status, _ = poll
|
107
118
|
|
108
|
-
break if statuses.any?
|
109
|
-
case expected_status
|
110
|
-
when Regexp
|
111
|
-
status.match?(expected_status)
|
112
|
-
when String
|
113
|
-
status == expected_status
|
114
|
-
end
|
115
|
-
end
|
119
|
+
break if statuses.any? { |expected_status| status == expected_status }
|
116
120
|
end
|
117
121
|
end
|
122
|
+
rescue Timeout::Error
|
123
|
+
raise TimeoutError, 'exceeded %s seconds polling for status %s' % [
|
124
|
+
timeout,
|
125
|
+
statuses.join(', '),
|
126
|
+
]
|
118
127
|
end
|
119
128
|
|
120
129
|
# @return [Array(String, String | nil)] the operation status and the
|
@@ -15,7 +15,7 @@ module Lucid
|
|
15
15
|
case link_header
|
16
16
|
# NOTE: There is a strange behaviour where it seems that if the header
|
17
17
|
# value exceeds a certain length, it is split into chunks. It seems that
|
18
|
-
# if you use {HTTP::Headers#get}, you will always get {Array<String},
|
18
|
+
# if you use {HTTP::Headers#get}, you will always get {Array<String>},
|
19
19
|
# and it is the special behaviour of {HTTP::Headers#[]} causing this.
|
20
20
|
#
|
21
21
|
# However, why is it split in the first place? Does Shopify send
|
@@ -29,8 +29,8 @@ module Lucid
|
|
29
29
|
ClientError = Class.new(Error)
|
30
30
|
ServerError = Class.new(Error)
|
31
31
|
ShopError = Class.new(Error)
|
32
|
-
|
33
|
-
|
32
|
+
AccessTokenError = Class.new(ClientError)
|
33
|
+
GraphQLClientError = Class.new(ClientError) do
|
34
34
|
def message
|
35
35
|
case
|
36
36
|
when response.errors?
|
@@ -114,11 +114,17 @@ module Lucid
|
|
114
114
|
# @note https://shopify.dev/concepts/about-apis/response-codes
|
115
115
|
def assert!
|
116
116
|
case status_code
|
117
|
+
when 401
|
118
|
+
if error_message?([/access token/i])
|
119
|
+
raise AccessTokenError.new(request, self), 'Invalid access token'
|
120
|
+
else
|
121
|
+
raise ClientError.new(request, self)
|
122
|
+
end
|
117
123
|
when 402
|
118
124
|
raise ShopError.new(request, self), 'Shop is frozen, awaiting payment'
|
119
125
|
when 403
|
120
126
|
# NOTE: Not sure what this one means (undocumented).
|
121
|
-
if error_message?(/unavailable shop/i)
|
127
|
+
if error_message?([/unavailable shop/i])
|
122
128
|
raise ShopError.new(request, self), 'Shop is unavailable'
|
123
129
|
else
|
124
130
|
raise ClientError.new(request, self)
|
data/lib/lucid/shopify.rb
CHANGED
@@ -45,10 +45,10 @@ module Lucid
|
|
45
45
|
extend Dry::Configurable
|
46
46
|
|
47
47
|
setting :api_key
|
48
|
-
setting :api_version, '2020-
|
48
|
+
setting :api_version, default: '2020-04'
|
49
49
|
setting :billing_callback_uri
|
50
50
|
setting :callback_uri
|
51
|
-
setting :logger, Logger.new(File::NULL).freeze
|
51
|
+
setting :logger, default: Logger.new(File::NULL).freeze
|
52
52
|
setting :scope
|
53
53
|
setting :shared_secret
|
54
54
|
setting :webhook_uri
|
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.
|
4
|
+
version: 0.65.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kelsey Judson
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|
@@ -72,28 +72,28 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '0.
|
75
|
+
version: '0.13'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '0.
|
82
|
+
version: '0.13'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: dry-container
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '0.
|
89
|
+
version: '0.9'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '0.
|
96
|
+
version: '0.9'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: dry-initializer
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,7 +136,7 @@ dependencies:
|
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '4.1'
|
139
|
-
description:
|
139
|
+
description:
|
140
140
|
email: kelsey@lucid.nz
|
141
141
|
executables: []
|
142
142
|
extensions: []
|
@@ -179,7 +179,7 @@ homepage: https://github.com/lucidnz/gem-lucid-shopify
|
|
179
179
|
licenses:
|
180
180
|
- ISC
|
181
181
|
metadata: {}
|
182
|
-
post_install_message:
|
182
|
+
post_install_message:
|
183
183
|
rdoc_options: []
|
184
184
|
require_paths:
|
185
185
|
- lib
|
@@ -194,8 +194,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
194
194
|
- !ruby/object:Gem::Version
|
195
195
|
version: '0'
|
196
196
|
requirements: []
|
197
|
-
rubygems_version: 3.1.
|
198
|
-
signing_key:
|
197
|
+
rubygems_version: 3.1.6
|
198
|
+
signing_key:
|
199
199
|
specification_version: 4
|
200
200
|
summary: Shopify client library
|
201
201
|
test_files: []
|