amzn_sp_api 1.0.0 → 1.0.2

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: a479c21b1f86bf4691e808b07cd8d6f8c1e07279f386af90ed47b7cd1e879981
4
+ data.tar.gz: 03005c132e4945257e0e56552814c7a7021b6cecd18976d61056e85f7e4bf2d6
5
5
  SHA512:
6
- metadata.gz: 043f54965076a2a497d12dfe2790a2656a6f0565c4300f52205633c2b84296d3da996a8d00a3cd61b35bd3bddf12a38ad15702ae591a00d9e50987102d8cea2d
7
- data.tar.gz: 237af6f4c5ec9d64fd2a4e7413829b3fe9c980012bb498fa257f46cc7bd8157d45884071ce543b41761bde2a87eb0e4da39145d604ff41757cae3add268960aa
6
+ metadata.gz: 5fa6d95db9b0fa85a43855f28178b28984e5447de1355dfe7dde907426137366eaff59ffb79baaf8087039d65e31c8ada1d70275118dbe0570be5b7ad8b958fd
7
+ data.tar.gz: 730ebd84560cf052abcdd72db224065c22bc3a349f2c2ab339587ae2453a3885be09f429ae5ec09351c41473faefdca37ef91f2add89c0db5d32bb2d1c5a1b99
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.2)
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.2'
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
+ 'client_credentials' => 'sellingpartnerapi::notifications',
48
+ 'refresh_token' => '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.2
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