Class: AmznSpApi::SpApiConfiguration

Inherits:
Configuration show all
Defined in:
lib/amzn_sp_api/sp_api_configuration.rb

Constant Summary collapse

SCOPE =
%w[sellingpartnerapi::notifications sellingpartnerapi::migration]
AWS_REGION_MAP =
{
  'na' => 'us-east-1',
  'eu' => 'eu-west-1',
  'fe' => 'us-west-2'
}.freeze

Instance Attribute Summary collapse

Attributes inherited from Configuration

#access_token, #api_key, #api_key_prefix, #base_path, #cert_file, #client_side_validation, #debugging, #force_ending_format, #host, #inject_format, #key_file, #logger, #params_encoding, #password, #scheme, #ssl_ca_cert, #temp_folder_path, #timeout, #username, #verify_ssl, #verify_ssl_host

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Configuration

#api_key_with_prefix, #auth_settings, #base_url, #basic_auth_token, #configure, #initialize

Constructor Details

This class inherits a constructor from AmznSpApi::Configuration

Instance Attribute Details

#aws_access_key_idObject

The AWS access key Id



32
33
34
# File 'lib/amzn_sp_api/sp_api_configuration.rb', line 32

def aws_access_key_id
  @aws_access_key_id
end

#aws_secret_access_keyObject

The AWS secret access key,



35
36
37
# File 'lib/amzn_sp_api/sp_api_configuration.rb', line 35

def aws_secret_access_key
  @aws_secret_access_key
end

#client_idObject

The LWA client identifier.



20
21
22
# File 'lib/amzn_sp_api/sp_api_configuration.rb', line 20

def client_id
  @client_id
end

#client_secretObject

The LWA client secret.



23
24
25
# File 'lib/amzn_sp_api/sp_api_configuration.rb', line 23

def client_secret
  @client_secret
end

#credentials_providerObject

Either access key or credentials_provider for AWS Signer, e.g. Aws::STS::Client



38
39
40
# File 'lib/amzn_sp_api/sp_api_configuration.rb', line 38

def credentials_provider
  @credentials_provider
end

#get_access_tokenObject

Returns the value of attribute get_access_token.



43
44
45
# File 'lib/amzn_sp_api/sp_api_configuration.rb', line 43

def get_access_token
  @get_access_token
end

#grant_typeObject

The type of access grant requested. @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. @values: client_credentials Use this for calling grantless operations. When specifying this value, include the parameter.scope



9
10
11
# File 'lib/amzn_sp_api/sp_api_configuration.rb', line 9

def grant_type
  @grant_type
end

#refresh_tokenObject

The LWA refresh token.



12
13
14
# File 'lib/amzn_sp_api/sp_api_configuration.rb', line 12

def refresh_token
  @refresh_token
end

#regionObject

The AWS region to which you are directing your call.



29
30
31
# File 'lib/amzn_sp_api/sp_api_configuration.rb', line 29

def region
  @region
end

#sandboxObject

The Selling Partner API provides two sandbox environments: static and dynamic



26
27
28
# File 'lib/amzn_sp_api/sp_api_configuration.rb', line 26

def sandbox
  @sandbox
end

#save_access_tokenObject

Optional lambdas for storing and retrieving token



41
42
43
# File 'lib/amzn_sp_api/sp_api_configuration.rb', line 41

def save_access_token
  @save_access_token
end

#scopeObject

The scope of the LWA authorization grant. @values: sellingpartnerapi::notifications. For the Notifications API. @values: sellingpartnerapi::migration. For the Authorization API.



17
18
19
# File 'lib/amzn_sp_api/sp_api_configuration.rb', line 17

def scope
  @scope
end

Class Method Details

.defaultObject



76
77
78
# File 'lib/amzn_sp_api/sp_api_configuration.rb', line 76

def self.default
  @@default ||= SpApiConfiguration.new
end

Instance Method Details

#access_token_keyObject



72
73
74
# File 'lib/amzn_sp_api/sp_api_configuration.rb', line 72

def access_token_key
  Digest::MD5.hexdigest("#{client_id} #{refresh_token}")
end

#aws_regionObject



55
56
57
# File 'lib/amzn_sp_api/sp_api_configuration.rb', line 55

def aws_region
  AWS_REGION_MAP[region]
end