shopify_api 9.3.0 → 9.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +2 -2
- data/lib/shopify_api/session.rb +8 -2
- data/lib/shopify_api/version.rb +1 -1
- data/test/session_test.rb +63 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb95bdd7eace9c3fd781e8e05b8888b657ed84e85707f00d9220f049e13fdaa9
|
4
|
+
data.tar.gz: 856d86bf1f36fc436ad7d1a713b1956b5b69ef6c708b83edd4a5d6001eae5f91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 978438061f1192357b7fe6b238f1fb88efb9d3129b4ed63efe0cab98330dd9420462cfb4548ee4024aeb4a5c9b07ea7d7ec865799798167b7dae09b2b26558f2
|
7
|
+
data.tar.gz: e07296eda7512ab2ba356bdf9f157e4dad758e4a2273d171c56423f0761815e8fd74a747f27b7c54ee33148f131e757e54b5ef1578c4c8506bf462905f2ea51a
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
## Version 9.4.0
|
2
|
+
|
3
|
+
* [#843](https://github.com/Shopify/shopify_api/pull/843) Introduce a new `access_scopes` attribute on the Session class.
|
4
|
+
* Specifying this in the Session constructor is optional. By default, this attribute returns `nil`.
|
5
|
+
|
1
6
|
## Version 9.3.0
|
2
7
|
|
3
8
|
* [#797](https://github.com/Shopify/shopify_api/pull/797) Release new Endpoint `fulfillment_order.open` and `fulfillment_order.reschedule`.
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
shopify_api (9.
|
4
|
+
shopify_api (9.4.0)
|
5
5
|
activeresource (>= 4.1.0, < 6.0.0)
|
6
6
|
graphql-client
|
7
7
|
rack
|
@@ -41,7 +41,7 @@ GEM
|
|
41
41
|
eventmachine (1.2.7)
|
42
42
|
ffi (1.12.2)
|
43
43
|
forwardable-extended (2.6.0)
|
44
|
-
graphql (1.12.
|
44
|
+
graphql (1.12.5)
|
45
45
|
graphql-client (0.16.0)
|
46
46
|
activesupport (>= 3.0)
|
47
47
|
graphql (~> 1.8)
|
data/lib/shopify_api/session.rb
CHANGED
@@ -13,7 +13,7 @@ module ShopifyAPI
|
|
13
13
|
self.myshopify_domain = 'myshopify.com'
|
14
14
|
|
15
15
|
attr_accessor :domain, :token, :name, :extra
|
16
|
-
attr_reader :api_version
|
16
|
+
attr_reader :api_version, :access_scopes
|
17
17
|
alias_method :url, :domain
|
18
18
|
|
19
19
|
class << self
|
@@ -92,10 +92,11 @@ module ShopifyAPI
|
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
95
|
-
def initialize(domain:, token:, api_version: ShopifyAPI::Base.api_version, extra: {})
|
95
|
+
def initialize(domain:, token:, access_scopes: nil, api_version: ShopifyAPI::Base.api_version, extra: {})
|
96
96
|
self.domain = self.class.prepare_domain(domain)
|
97
97
|
self.api_version = api_version
|
98
98
|
self.token = token
|
99
|
+
self.access_scopes = access_scopes
|
99
100
|
self.extra = extra
|
100
101
|
end
|
101
102
|
|
@@ -180,6 +181,11 @@ module ShopifyAPI
|
|
180
181
|
|
181
182
|
private
|
182
183
|
|
184
|
+
def access_scopes=(access_scopes)
|
185
|
+
return unless access_scopes
|
186
|
+
@access_scopes = ShopifyAPI::ApiAccess.new(access_scopes)
|
187
|
+
end
|
188
|
+
|
183
189
|
def parameterize(params)
|
184
190
|
URI.escape(params.collect { |k, v| "#{k}=#{v}" }.join('&'))
|
185
191
|
end
|
data/lib/shopify_api/version.rb
CHANGED
data/test/session_test.rb
CHANGED
@@ -54,6 +54,39 @@ class SessionTest < Test::Unit::TestCase
|
|
54
54
|
assert(session.valid?)
|
55
55
|
end
|
56
56
|
|
57
|
+
test "be valid with nil access_scopes" do
|
58
|
+
session = ShopifyAPI::Session.new(
|
59
|
+
domain: "testshop.myshopify.com",
|
60
|
+
token: "any-token",
|
61
|
+
api_version: any_api_version,
|
62
|
+
access_scopes: nil
|
63
|
+
)
|
64
|
+
|
65
|
+
assert(session.valid?)
|
66
|
+
end
|
67
|
+
|
68
|
+
test "be valid with string of access_scopes" do
|
69
|
+
session = ShopifyAPI::Session.new(
|
70
|
+
domain: "testshop.myshopify.com",
|
71
|
+
token: "any-token",
|
72
|
+
api_version: any_api_version,
|
73
|
+
access_scopes: "read_products, write_orders"
|
74
|
+
)
|
75
|
+
|
76
|
+
assert(session.valid?)
|
77
|
+
end
|
78
|
+
|
79
|
+
test "be valid with a collection of access_scopes" do
|
80
|
+
session = ShopifyAPI::Session.new(
|
81
|
+
domain: "testshop.myshopify.com",
|
82
|
+
token: "any-token",
|
83
|
+
api_version: any_api_version,
|
84
|
+
access_scopes: %w(read_products write_orders)
|
85
|
+
)
|
86
|
+
|
87
|
+
assert(session.valid?)
|
88
|
+
end
|
89
|
+
|
57
90
|
test "not raise error without params" do
|
58
91
|
assert_nothing_raised do
|
59
92
|
ShopifyAPI::Session.new(domain: "testshop.myshopify.com", token: "any-token", api_version: any_api_version)
|
@@ -84,6 +117,36 @@ class SessionTest < Test::Unit::TestCase
|
|
84
117
|
end
|
85
118
|
end
|
86
119
|
|
120
|
+
test "provides default nil access_scopes attribute" do
|
121
|
+
session = ShopifyAPI::Session.new(
|
122
|
+
domain: "testshop.myshopify.com",
|
123
|
+
token: "any-token",
|
124
|
+
api_version: any_api_version
|
125
|
+
)
|
126
|
+
assert_nil session.access_scopes
|
127
|
+
end
|
128
|
+
|
129
|
+
test "provides specified nil access_scopes attribute" do
|
130
|
+
session = ShopifyAPI::Session.new(
|
131
|
+
domain: "testshop.myshopify.com",
|
132
|
+
token: "any-token",
|
133
|
+
access_scopes: "read_products",
|
134
|
+
api_version: any_api_version
|
135
|
+
)
|
136
|
+
assert_equal "read_products", session.access_scopes.to_s
|
137
|
+
end
|
138
|
+
|
139
|
+
test "session instantiation raises error if bad access scopes are provided" do
|
140
|
+
assert_raises NoMethodError do
|
141
|
+
ShopifyAPI::Session.new(
|
142
|
+
domain: "testshop.myshopify.com",
|
143
|
+
token: "any-token",
|
144
|
+
access_scopes: { bad_input: "bad_input" },
|
145
|
+
api_version: any_api_version
|
146
|
+
)
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
87
150
|
test "raise error if params passed but signature omitted" do
|
88
151
|
assert_raises(ShopifyAPI::ValidationException) do
|
89
152
|
session = ShopifyAPI::Session.new(domain: "testshop.myshopify.com", token: nil, api_version: any_api_version)
|
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: 9.
|
4
|
+
version: 9.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shopify
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activeresource
|