shopify_api 12.1.0 → 12.2.1
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/.github/workflows/stale.yml +2 -2
- data/CHANGELOG.md +7 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +15 -1
- data/README.md +2 -2
- data/docs/usage/session_storage.md +1 -1
- data/lib/shopify_api/auth/oauth.rb +11 -2
- data/lib/shopify_api/context.rb +9 -6
- data/lib/shopify_api/version.rb +1 -1
- data/shopify_api.gemspec +2 -0
- metadata +30 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9061778f35348ae6c1013eed58d1d1d274e84ec63796d33296ac7205319aee40
|
4
|
+
data.tar.gz: 9e0ea6bd2543ad11963eab31617b2700383825471483ecef46793fc9e454fd34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05a97d69417a4192bd8e83e5eded057931640d700041f6b6d15459d85b3a463de049e5789153dfee75a9df6af8f287956dca4e51c8a230a816596a3e85a2a3b2
|
7
|
+
data.tar.gz: a7a1d5e77c69b85566c2484ca64aebb05cd6bfd3701f90aa17b9d8ab5b1f1db6e28ecdbb34dc0dc76cefd8813ab14e98e1fcf2bb8d41797d8f235b757e90f274
|
data/.github/workflows/stale.yml
CHANGED
@@ -12,12 +12,12 @@ jobs:
|
|
12
12
|
steps:
|
13
13
|
- uses: actions/stale@v5
|
14
14
|
with:
|
15
|
-
days-before-issue-stale:
|
15
|
+
days-before-issue-stale: 60
|
16
16
|
days-before-issue-close: 14
|
17
17
|
operations-per-run: 1000
|
18
18
|
stale-issue-label: "Stale"
|
19
19
|
stale-issue-message: >
|
20
|
-
This issue is stale because it has been open for
|
20
|
+
This issue is stale because it has been open for 60 days with no activity. It will be closed if no further action occurs in 14 days.
|
21
21
|
close-issue-message: |
|
22
22
|
We are closing this issue because it has been inactive for a few months.
|
23
23
|
This probably means that it is not reproducible or it has been fixed in a newer version.
|
data/CHANGELOG.md
CHANGED
@@ -4,6 +4,13 @@ Note: For changes to the API, see https://shopify.dev/changelog?filter=api
|
|
4
4
|
|
5
5
|
## Unreleased
|
6
6
|
|
7
|
+
## Version 12.2.1
|
8
|
+
- [#1045](https://github.com/Shopify/shopify-api-ruby/pull/1045) Fixes bug with host/host_name requirement.
|
9
|
+
|
10
|
+
## Version 12.2.0
|
11
|
+
|
12
|
+
- [#1023](https://github.com/Shopify/shopify-api-ruby/pull/1023) Allow custom scopes during the OAuth process
|
13
|
+
|
7
14
|
## Version 12.1.0
|
8
15
|
|
9
16
|
- [#1017](https://github.com/Shopify/shopify-api-ruby/pull/1017) Add support for `http` with localhost development without using a TLS tunnel
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
shopify_api (12.1
|
4
|
+
shopify_api (12.2.1)
|
5
5
|
concurrent-ruby
|
6
6
|
hash_diff
|
7
7
|
httparty
|
@@ -23,6 +23,7 @@ GEM
|
|
23
23
|
addressable (2.8.0)
|
24
24
|
public_suffix (>= 2.0.2, < 5.0)
|
25
25
|
ast (2.4.2)
|
26
|
+
byebug (11.1.3)
|
26
27
|
coderay (1.1.3)
|
27
28
|
concurrent-ruby (1.1.9)
|
28
29
|
crack (0.4.5)
|
@@ -38,6 +39,7 @@ GEM
|
|
38
39
|
concurrent-ruby (~> 1.0)
|
39
40
|
json (2.6.2)
|
40
41
|
jwt (2.5.0)
|
42
|
+
language_server-protocol (3.17.0.1)
|
41
43
|
method_source (1.0.0)
|
42
44
|
mime-types (3.4.1)
|
43
45
|
mime-types-data (~> 3.2015)
|
@@ -51,9 +53,13 @@ GEM
|
|
51
53
|
parallel (1.22.1)
|
52
54
|
parser (3.1.2.1)
|
53
55
|
ast (~> 2.4.1)
|
56
|
+
prettier_print (0.1.0)
|
54
57
|
pry (0.14.1)
|
55
58
|
coderay (~> 1.1)
|
56
59
|
method_source (~> 1.0)
|
60
|
+
pry-byebug (3.10.1)
|
61
|
+
byebug (~> 11.0)
|
62
|
+
pry (>= 0.13, < 0.15)
|
57
63
|
public_suffix (4.0.6)
|
58
64
|
rainbow (3.1.1)
|
59
65
|
rake (13.0.6)
|
@@ -80,6 +86,10 @@ GEM
|
|
80
86
|
rubocop (~> 1.35)
|
81
87
|
rubocop-sorbet (0.6.11)
|
82
88
|
rubocop (>= 0.90.0)
|
89
|
+
ruby-lsp (0.3.2)
|
90
|
+
language_server-protocol (~> 3.17.0)
|
91
|
+
sorbet-runtime
|
92
|
+
syntax_tree (>= 3.4)
|
83
93
|
ruby-progressbar (1.11.0)
|
84
94
|
securerandom (0.2.0)
|
85
95
|
sorbet (0.5.10438)
|
@@ -94,6 +104,8 @@ GEM
|
|
94
104
|
sorbet (>= 0.5.9204)
|
95
105
|
sorbet-runtime (>= 0.5.9204)
|
96
106
|
thor (>= 0.19.2)
|
107
|
+
syntax_tree (3.6.1)
|
108
|
+
prettier_print
|
97
109
|
tapioca (0.10.2)
|
98
110
|
bundler (>= 1.17.3)
|
99
111
|
netrc (>= 0.11.0)
|
@@ -132,10 +144,12 @@ DEPENDENCIES
|
|
132
144
|
fakefs
|
133
145
|
minitest
|
134
146
|
mocha
|
147
|
+
pry-byebug
|
135
148
|
rake
|
136
149
|
rubocop
|
137
150
|
rubocop-shopify
|
138
151
|
rubocop-sorbet
|
152
|
+
ruby-lsp
|
139
153
|
shopify_api!
|
140
154
|
sorbet
|
141
155
|
tapioca
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
|
7
7
|
This library provides support for Ruby [Shopify apps](https://apps.shopify.com/) to access the [Shopify Admin API](https://shopify.dev/api/admin), by making it easier to perform the following actions:
|
8
8
|
|
9
|
-
- Creating [online](https://shopify.dev/
|
9
|
+
- Creating [online](https://shopify.dev/apps/auth/oauth/access-modes#online-access) or [offline](https://shopify.dev/apps/auth/oauth/access-modes#offline-access) access tokens for the Admin API via OAuth
|
10
10
|
- Making requests to the [REST API](https://shopify.dev/api/admin-rest)
|
11
11
|
- Making requests to the [GraphQL API](https://shopify.dev/api/admin-graphql)
|
12
12
|
- Registering/processing webhooks
|
@@ -51,7 +51,7 @@ Start by initializing the `ShopifyAPI::Context` with the parameters of your app
|
|
51
51
|
ShopifyAPI::Context.setup(
|
52
52
|
api_key: "<api-key>",
|
53
53
|
api_secret_key: "<api-secret-key>",
|
54
|
-
|
54
|
+
host: "<https://application-host-name.com>",
|
55
55
|
scope: "read_orders,read_products,etc",
|
56
56
|
session_storage: ShopifyAPI::Auth::FileSessionStorage.new, # See more details below
|
57
57
|
is_embedded: true, # Set to true if you are building an embedded app
|
@@ -5,7 +5,7 @@ The implementation of session storage that you pass in `ShopifyAPI::Context.setu
|
|
5
5
|
|
6
6
|
## Create a New Session Storage Class
|
7
7
|
|
8
|
-
You can create a session storage class that includes `ShopifyAPI::Auth::
|
8
|
+
You can create a session storage class that includes `ShopifyAPI::Auth::SessionStorage` and override the methods as shown in the table and example below:
|
9
9
|
|
10
10
|
| Method Name | Input Type | Return Type |
|
11
11
|
| ---------------------- | --------------------------------- | ------------------------------ |
|
@@ -16,9 +16,18 @@ module ShopifyAPI
|
|
16
16
|
shop: String,
|
17
17
|
redirect_path: String,
|
18
18
|
is_online: T.nilable(T::Boolean),
|
19
|
+
scope_override: T.nilable(T.any(ShopifyAPI::Auth::AuthScopes, T::Array[String], String)),
|
19
20
|
).returns(T::Hash[Symbol, T.any(String, SessionCookie)])
|
20
21
|
end
|
21
|
-
def begin_auth(shop:, redirect_path:, is_online: true)
|
22
|
+
def begin_auth(shop:, redirect_path:, is_online: true, scope_override: nil)
|
23
|
+
scope = if scope_override.nil?
|
24
|
+
ShopifyAPI::Context.scope
|
25
|
+
elsif scope_override.is_a?(ShopifyAPI::Auth::AuthScopes)
|
26
|
+
scope_override
|
27
|
+
else
|
28
|
+
ShopifyAPI::Auth::AuthScopes.new(scope_override)
|
29
|
+
end
|
30
|
+
|
22
31
|
unless Context.setup?
|
23
32
|
raise Errors::ContextNotSetupError, "ShopifyAPI::Context not setup, please call ShopifyAPI::Context.setup"
|
24
33
|
end
|
@@ -30,7 +39,7 @@ module ShopifyAPI
|
|
30
39
|
|
31
40
|
query = {
|
32
41
|
client_id: ShopifyAPI::Context.api_key,
|
33
|
-
scope:
|
42
|
+
scope: scope.to_s,
|
34
43
|
redirect_uri: "#{ShopifyAPI::Context.host}#{redirect_path}",
|
35
44
|
state: state,
|
36
45
|
"grant_options[]": is_online ? "per-user" : "",
|
data/lib/shopify_api/context.rb
CHANGED
@@ -8,7 +8,6 @@ module ShopifyAPI
|
|
8
8
|
@api_key = T.let("", String)
|
9
9
|
@api_secret_key = T.let("", String)
|
10
10
|
@api_version = T.let(LATEST_SUPPORTED_ADMIN_VERSION, String)
|
11
|
-
@host_name = T.let("", String)
|
12
11
|
@scope = T.let(Auth::AuthScopes.new, Auth::AuthScopes)
|
13
12
|
@session_storage = T.let(ShopifyAPI::Auth::FileSessionStorage.new, ShopifyAPI::Auth::SessionStorage)
|
14
13
|
@is_private = T.let(false, T::Boolean)
|
@@ -30,12 +29,12 @@ module ShopifyAPI
|
|
30
29
|
api_key: String,
|
31
30
|
api_secret_key: String,
|
32
31
|
api_version: String,
|
33
|
-
host_name: String,
|
34
32
|
scope: T.any(T::Array[String], String),
|
35
33
|
is_private: T::Boolean,
|
36
34
|
is_embedded: T::Boolean,
|
37
35
|
session_storage: ShopifyAPI::Auth::SessionStorage,
|
38
36
|
logger: Logger,
|
37
|
+
host_name: T.nilable(String),
|
39
38
|
host: T.nilable(String),
|
40
39
|
private_shop: T.nilable(String),
|
41
40
|
user_agent_prefix: T.nilable(String),
|
@@ -46,12 +45,12 @@ module ShopifyAPI
|
|
46
45
|
api_key:,
|
47
46
|
api_secret_key:,
|
48
47
|
api_version:,
|
49
|
-
host_name:,
|
50
48
|
scope:,
|
51
49
|
is_private:,
|
52
50
|
is_embedded:,
|
53
51
|
session_storage:,
|
54
52
|
logger: Logger.new($stdout),
|
53
|
+
host_name: nil,
|
55
54
|
host: ENV["HOST"] || "https://#{host_name}",
|
56
55
|
private_shop: nil,
|
57
56
|
user_agent_prefix: nil,
|
@@ -65,7 +64,6 @@ module ShopifyAPI
|
|
65
64
|
@api_key = api_key
|
66
65
|
@api_secret_key = api_secret_key
|
67
66
|
@api_version = api_version
|
68
|
-
@host_name = host_name
|
69
67
|
@host = T.let(host, T.nilable(String))
|
70
68
|
@is_private = is_private
|
71
69
|
@scope = Auth::AuthScopes.new(scope)
|
@@ -108,7 +106,7 @@ module ShopifyAPI
|
|
108
106
|
end
|
109
107
|
|
110
108
|
sig { returns(String) }
|
111
|
-
attr_reader :api_key, :api_secret_key, :api_version
|
109
|
+
attr_reader :api_key, :api_secret_key, :api_version
|
112
110
|
|
113
111
|
sig { returns(Auth::AuthScopes) }
|
114
112
|
attr_reader :scope
|
@@ -134,7 +132,7 @@ module ShopifyAPI
|
|
134
132
|
|
135
133
|
sig { returns(T::Boolean) }
|
136
134
|
def setup?
|
137
|
-
[api_key, api_secret_key,
|
135
|
+
[api_key, api_secret_key, T.must(host)].none?(&:empty?)
|
138
136
|
end
|
139
137
|
|
140
138
|
sig { returns(T.nilable(Auth::Session)) }
|
@@ -158,6 +156,11 @@ module ShopifyAPI
|
|
158
156
|
def host_scheme
|
159
157
|
T.must(URI.parse(T.must(host)).scheme)
|
160
158
|
end
|
159
|
+
|
160
|
+
sig { returns(String) }
|
161
|
+
def host_name
|
162
|
+
T.must(URI(T.must(host)).host)
|
163
|
+
end
|
161
164
|
end
|
162
165
|
end
|
163
166
|
end
|
data/lib/shopify_api/version.rb
CHANGED
data/shopify_api.gemspec
CHANGED
@@ -43,10 +43,12 @@ Gem::Specification.new do |s|
|
|
43
43
|
s.add_runtime_dependency("zeitwerk", "~> 2.5")
|
44
44
|
|
45
45
|
s.add_development_dependency("activesupport")
|
46
|
+
s.add_development_dependency("pry-byebug")
|
46
47
|
s.add_development_dependency("rake")
|
47
48
|
s.add_development_dependency("rubocop")
|
48
49
|
s.add_development_dependency("rubocop-shopify")
|
49
50
|
s.add_development_dependency("rubocop-sorbet")
|
51
|
+
s.add_development_dependency("ruby-lsp")
|
50
52
|
s.add_development_dependency("sorbet")
|
51
53
|
s.add_development_dependency("tapioca")
|
52
54
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shopify_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 12.1
|
4
|
+
version: 12.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -150,6 +150,20 @@ dependencies:
|
|
150
150
|
- - ">="
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: pry-byebug
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
168
|
name: rake
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -206,6 +220,20 @@ dependencies:
|
|
206
220
|
- - ">="
|
207
221
|
- !ruby/object:Gem::Version
|
208
222
|
version: '0'
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: ruby-lsp
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - ">="
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: '0'
|
230
|
+
type: :development
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - ">="
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: '0'
|
209
237
|
- !ruby/object:Gem::Dependency
|
210
238
|
name: sorbet
|
211
239
|
requirement: !ruby/object:Gem::Requirement
|