muffin_man 1.4.3 → 1.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/muffin_man/orders/v0.rb +6 -1
- data/lib/muffin_man/sp_api_client.rb +20 -2
- data/lib/muffin_man/tokens/v20210301.rb +19 -0
- data/lib/muffin_man/version.rb +1 -1
- data/lib/muffin_man.rb +1 -0
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 33ab3775741e9ae115fdd18683e7632ad1d9f0da5b5c54ee98fbfdc951cacb45
|
4
|
+
data.tar.gz: 57629b160dce923145c0d6784cca34b174fdb757f82e95b9d2c18359c6ee137c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b27ea646bb4beca9038140758b1b0e8082b5beab76ec8c6af8723a5a5459e4466ef1f90bce09799f5adf5794cf71c4ee030734c8a978470ddb0e0d8bc38ff4c4
|
7
|
+
data.tar.gz: 15b93790c3f8d6193e0c2fdf13c2f7f90398fbe0771eb57edf6df651573cd973af630a6a4f78fd56297cf98f6119e9730fe3741883ad81ae36519c5dbdad2024
|
data/CHANGELOG.md
CHANGED
data/lib/muffin_man/orders/v0.rb
CHANGED
@@ -25,8 +25,13 @@ module MuffinMan
|
|
25
25
|
NextToken
|
26
26
|
].freeze
|
27
27
|
|
28
|
-
|
28
|
+
PII_DATA_ELEMENTS = %w[
|
29
|
+
buyerInfo shippingAddress buyerTaxInformation
|
30
|
+
]
|
31
|
+
|
32
|
+
def get_orders(marketplace_ids, params = {}, pii_data_elements: [])
|
29
33
|
@local_var_path = "/orders/v0/orders"
|
34
|
+
@pii_data_elements = pii_data_elements & PII_DATA_ELEMENTS
|
30
35
|
@query_params = params.slice(*GET_ORDERS_PARAMS)
|
31
36
|
@query_params["MarketplaceIds"] = marketplace_ids
|
32
37
|
@request_type = "GET"
|
@@ -9,7 +9,8 @@ module MuffinMan
|
|
9
9
|
attr_reader :refresh_token, :client_id, :client_secret, :aws_access_key_id,
|
10
10
|
:aws_secret_access_key, :sts_iam_role_arn, :sandbox, :config,
|
11
11
|
:region, :request_type, :local_var_path, :query_params,
|
12
|
-
:request_body, :scope, :access_token_cache_key
|
12
|
+
:request_body, :scope, :access_token_cache_key, :credentials,
|
13
|
+
:pii_data_elements
|
13
14
|
|
14
15
|
ACCESS_TOKEN_URL = "https://api.amazon.com/auth/o2/token".freeze
|
15
16
|
SERVICE_NAME = "execute-api".freeze
|
@@ -30,6 +31,8 @@ module MuffinMan
|
|
30
31
|
@scope = credentials[:scope]
|
31
32
|
@access_token_cache_key = credentials[:access_token_cache_key]
|
32
33
|
@sandbox = sandbox
|
34
|
+
@credentials = credentials
|
35
|
+
@pii_data_elements = []
|
33
36
|
Typhoeus::Config.user_agent = ""
|
34
37
|
@config = MuffinMan.configuration
|
35
38
|
end
|
@@ -146,7 +149,11 @@ module MuffinMan
|
|
146
149
|
end
|
147
150
|
|
148
151
|
def headers
|
149
|
-
|
152
|
+
if requires_rdt_token_for_pii?
|
153
|
+
access_token = retrieve_rdt_access_token || retrieve_lwa_access_token
|
154
|
+
else
|
155
|
+
access_token = scope ? retrieve_grantless_access_token : retrieve_lwa_access_token
|
156
|
+
end
|
150
157
|
headers = {
|
151
158
|
"x-amz-access-token" => access_token,
|
152
159
|
"user-agent" => "MuffinMan/#{VERSION} (Language=Ruby)",
|
@@ -155,6 +162,17 @@ module MuffinMan
|
|
155
162
|
signed_request.headers.merge(headers)
|
156
163
|
end
|
157
164
|
|
165
|
+
def requires_rdt_token_for_pii?
|
166
|
+
pii_data_elements.any?
|
167
|
+
end
|
168
|
+
|
169
|
+
def retrieve_rdt_access_token
|
170
|
+
rdt_token_response = Tokens::V20210301.new(credentials, sandbox).create_restricted_data_token(
|
171
|
+
@local_var_path, @request_type, pii_data_elements
|
172
|
+
)
|
173
|
+
JSON.parse(rdt_token_response.body)["restrictedDataToken"]
|
174
|
+
end
|
175
|
+
|
158
176
|
def derive_aws_region
|
159
177
|
@aws_region ||= AWS_REGION_MAP[region]
|
160
178
|
unless @aws_region
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module MuffinMan
|
2
|
+
module Tokens
|
3
|
+
class V20210301 < SpApiClient
|
4
|
+
def create_restricted_data_token(path, method, data_elements, target_application: nil)
|
5
|
+
@local_var_path = "/tokens/2021-03-01/restrictedDataToken"
|
6
|
+
@request_body = {}
|
7
|
+
@request_body["targetApplication"] = target_application unless target_application.nil?
|
8
|
+
restricted_resources = {
|
9
|
+
"method" => method,
|
10
|
+
"path" => path,
|
11
|
+
"dataElements" => data_elements
|
12
|
+
}
|
13
|
+
@request_body["restrictedResources"] = [restricted_resources]
|
14
|
+
@request_type = "POST"
|
15
|
+
call_api
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/muffin_man/version.rb
CHANGED
data/lib/muffin_man.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: muffin_man
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gavin
|
8
8
|
- Jason
|
9
9
|
- Nate
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
13
|
date: 2022-07-28 00:00:00.000000000 Z
|
@@ -116,7 +116,7 @@ dependencies:
|
|
116
116
|
- - ">="
|
117
117
|
- !ruby/object:Gem::Version
|
118
118
|
version: 2.4.4
|
119
|
-
description:
|
119
|
+
description:
|
120
120
|
email:
|
121
121
|
- gavin@pattern.com
|
122
122
|
- jason@pattern.com
|
@@ -146,13 +146,14 @@ files:
|
|
146
146
|
- lib/muffin_man/reports/v20210630.rb
|
147
147
|
- lib/muffin_man/solicitations/v1.rb
|
148
148
|
- lib/muffin_man/sp_api_client.rb
|
149
|
+
- lib/muffin_man/tokens/v20210301.rb
|
149
150
|
- lib/muffin_man/version.rb
|
150
151
|
- muffin_man.gemspec
|
151
152
|
homepage: https://github.com/patterninc/muffin_man
|
152
153
|
licenses:
|
153
154
|
- MIT
|
154
155
|
metadata: {}
|
155
|
-
post_install_message:
|
156
|
+
post_install_message:
|
156
157
|
rdoc_options: []
|
157
158
|
require_paths:
|
158
159
|
- lib
|
@@ -167,8 +168,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
168
|
- !ruby/object:Gem::Version
|
168
169
|
version: '0'
|
169
170
|
requirements: []
|
170
|
-
rubygems_version: 3.
|
171
|
-
signing_key:
|
171
|
+
rubygems_version: 3.0.3
|
172
|
+
signing_key:
|
172
173
|
specification_version: 4
|
173
174
|
summary: Amazon Selling Partner API client
|
174
175
|
test_files: []
|