amzn_sp_api 1.0.0 → 1.0.1

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: b83a2c0c87017907312b85740ba5228b0e8f685e5cfe2e17987eaff40b54768a
4
- data.tar.gz: 8905c81368f24260ead217927352ae7bf74858c35e9f25ba9943e5ed66a99b63
3
+ metadata.gz: f1b9dfde3c75d07c2a76693888913160222066f2c31fede720af510bcf7346ee
4
+ data.tar.gz: a613ae63a0917235adc069b61b5d0f7dcadfcb43a3b5ac5ce2dc7c42354c7fa1
5
5
  SHA512:
6
- metadata.gz: 043f54965076a2a497d12dfe2790a2656a6f0565c4300f52205633c2b84296d3da996a8d00a3cd61b35bd3bddf12a38ad15702ae591a00d9e50987102d8cea2d
7
- data.tar.gz: 237af6f4c5ec9d64fd2a4e7413829b3fe9c980012bb498fa257f46cc7bd8157d45884071ce543b41761bde2a87eb0e4da39145d604ff41757cae3add268960aa
6
+ metadata.gz: 2e59e68086459de5aa0914c253caacd15587ad0d87f2e00eb549f7516f06ad9e9664d1f5cf9be29a9b1a7d0367ffb1974fd0a54c1dadf0e6113e43b384161153
7
+ data.tar.gz: a655720eb4b4e7674966bb546f7eb247fa4e8f58649c2b43b4c0fafa11480fe73e065b48e05b069713d98fbfc3839f640ed661a5715ba0998cee496ede949383
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- amzn_sp_api (1.0.0)
4
+ amzn_sp_api (1.0.1)
5
5
  aws-sigv4 (~> 1.5)
6
6
  json (~> 2.6)
7
7
  typhoeus (~> 1.4)
@@ -1,3 +1,3 @@
1
1
  module AmznSpApi
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.1'
3
3
  end
@@ -326,7 +326,6 @@ module AmznSpApi
326
326
  def object_to_http_body(model)
327
327
  return model if model.nil? || model.is_a?(String)
328
328
 
329
- local_body = nil
330
329
  local_body = if model.is_a?(Array)
331
330
  model.map { |m| object_to_hash(m) }
332
331
  else
@@ -39,11 +39,13 @@ module AmznSpApi
39
39
  new_access_token.config.host = 'api.amazon.com'
40
40
 
41
41
  header_params = { 'Content-Type' => 'application/x-www-form-urlencoded' }
42
+ grant_type = config.scope.present? ? 'client_credentials' : 'refresh_token'
42
43
  form_params = {
43
- grant_type: 'refresh_token',
44
+ grant_type: grant_type,
44
45
  refresh_token: config.refresh_token,
45
46
  client_id: config.client_id,
46
- client_secret: config.client_secret
47
+ client_secret: config.client_secret,
48
+ scope: config.scope
47
49
  }
48
50
  data, status_code, headers = new_access_token.super_call_api(:POST, '/auth/o2/token', header_params: header_params,
49
51
  form_params: form_params, return_type: 'Object')
@@ -1,10 +1,21 @@
1
1
  require 'amzn_sp_api/configuration'
2
2
 
3
+ # from https://developer-docs.amazon.com/sp-api/docs/connecting-to-the-selling-partner-api
3
4
  module AmznSpApi
4
5
  class SpApiConfiguration < Configuration
6
+ # The type of access grant requested.
7
+ # @values: refresh_token Use this for calling operations that require authorization from a selling partner. All operations that are not grantless operations require authorization from a selling partner. When specifying this value, include the refresh_token parameter.
8
+ # @values: client_credentials Use this for calling grantless operations. When specifying this value, include the parameter.scope
9
+ attr_accessor :grant_type
10
+
5
11
  # The LWA refresh token.
6
12
  attr_accessor :refresh_token
7
13
 
14
+ # The scope of the LWA authorization grant.
15
+ # @values: sellingpartnerapi::notifications. For the Notifications API.
16
+ # @values: sellingpartnerapi::migration. For the Authorization API.
17
+ attr_accessor :scope
18
+
8
19
  # The LWA client identifier.
9
20
  attr_accessor :client_id
10
21
 
@@ -31,6 +42,12 @@ module AmznSpApi
31
42
 
32
43
  attr_accessor :get_access_token
33
44
 
45
+ # from https://developer-docs.amazon.com/sp-api/docs/connecting-to-the-selling-partner-api#step-1-request-a-login-with-amazon-access-token
46
+ SCOPE = {
47
+ 'refresh_token' => 'sellingpartnerapi::notifications',
48
+ 'client_credentials' => 'sellingpartnerapi::migration'
49
+ }.freeze
50
+
34
51
  # from https://developer-docs.amazon.com/sp-api/docs/sp-api-endpoints
35
52
  AWS_REGION_MAP = {
36
53
  'na' => 'us-east-1',
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: amzn_sp_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - zevinto
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-08 00:00:00.000000000 Z
11
+ date: 2023-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sigv4