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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 73854704f72bca959d915cec44e6c54f794d3d5d60dc97f343f4993a88e08a55
4
- data.tar.gz: a85ee03d769fddbbb6f5df673cffedbd5b6f2706c3f3a27ba2096fbde622585e
3
+ metadata.gz: cb95bdd7eace9c3fd781e8e05b8888b657ed84e85707f00d9220f049e13fdaa9
4
+ data.tar.gz: 856d86bf1f36fc436ad7d1a713b1956b5b69ef6c708b83edd4a5d6001eae5f91
5
5
  SHA512:
6
- metadata.gz: d98a3b0c0c57787436e557aa66f3f5d7de4f2373ae7e97eb0dd3283da7935f0c30d561ed690b132c54a7336ad040d25e2be66888892b05e1ca8844ad0eb6266f
7
- data.tar.gz: 6d11786b5b42c116370c5696ae8cf43b3ee111a6ab344b3d0d0e7c738510323b74f7d7df6441c9c83dba6286d53218185c41ef211eb5f61b64a95c807ea1c9c9
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.3.0)
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.3)
44
+ graphql (1.12.5)
45
45
  graphql-client (0.16.0)
46
46
  activesupport (>= 3.0)
47
47
  graphql (~> 1.8)
@@ -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
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module ShopifyAPI
3
- VERSION = "9.3.0"
3
+ VERSION = "9.4.0"
4
4
  end
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.3.0
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-01-27 00:00:00.000000000 Z
11
+ date: 2021-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeresource