muffin_man 1.4.1 → 1.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/lib/muffin_man/orders/v0.rb +55 -0
- 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 +2 -0
- metadata +4 -2
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
@@ -1,3 +1,15 @@
|
|
1
|
+
# 1.4.4
|
2
|
+
|
3
|
+
- Support for Tokens API [#17](https://github.com/patterninc/muffin_man/pull/17)
|
4
|
+
|
5
|
+
# 1.4.3
|
6
|
+
|
7
|
+
- Support for getOrderAddress [#16](https://github.com/patterninc/muffin_man/pull/16)
|
8
|
+
|
9
|
+
# 1.4.2
|
10
|
+
|
11
|
+
- Support for getOrders and getOrderItems [#15](https://github.com/patterninc/muffin_man/pull/15)
|
12
|
+
|
1
13
|
# 1.4.0
|
2
14
|
|
3
15
|
- Pass cache key to client for caching access tokens [#11](https://github.com/patterninc/muffin_man/pull/11)
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module MuffinMan
|
2
|
+
module Orders
|
3
|
+
class V0 < SpApiClient
|
4
|
+
|
5
|
+
GET_ORDERS_PARAMS = %w[
|
6
|
+
CreatedAfter
|
7
|
+
CreatedBefore
|
8
|
+
LastUpdatedAfter
|
9
|
+
LastUpdatedBefore
|
10
|
+
OrderStatuses
|
11
|
+
FulfillmentChannels
|
12
|
+
PaymentMethods
|
13
|
+
BuyerEmail
|
14
|
+
SellerOrderId
|
15
|
+
MaxResultsPerPage
|
16
|
+
EasyShipShipmentStatuses
|
17
|
+
NextToken
|
18
|
+
AmazonOrderIds
|
19
|
+
ActualFulfillmentSupplySourceId
|
20
|
+
IsISPU
|
21
|
+
StoreChainStoreId
|
22
|
+
].freeze
|
23
|
+
|
24
|
+
GET_ORDER_ITEMS_PARAMS = %w[
|
25
|
+
NextToken
|
26
|
+
].freeze
|
27
|
+
|
28
|
+
PII_DATA_ELEMENTS = %w[
|
29
|
+
buyerInfo shippingAddress buyerTaxInformation
|
30
|
+
]
|
31
|
+
|
32
|
+
def get_orders(marketplace_ids, params = {}, pii_data_elements: [])
|
33
|
+
@local_var_path = "/orders/v0/orders"
|
34
|
+
@pii_data_elements = pii_data_elements & PII_DATA_ELEMENTS
|
35
|
+
@query_params = params.slice(*GET_ORDERS_PARAMS)
|
36
|
+
@query_params["MarketplaceIds"] = marketplace_ids
|
37
|
+
@request_type = "GET"
|
38
|
+
call_api
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_order_items(order_id, params = {})
|
42
|
+
@query_params = params.slice(*GET_ORDER_ITEMS_PARAMS)
|
43
|
+
@local_var_path = "/orders/v0/orders/#{order_id}/orderItems"
|
44
|
+
@request_type = "GET"
|
45
|
+
call_api
|
46
|
+
end
|
47
|
+
|
48
|
+
def get_order_address(order_id)
|
49
|
+
@local_var_path = "/orders/v0/orders/#{order_id}/address"
|
50
|
+
@request_type = "GET"
|
51
|
+
call_api
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -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
@@ -2,10 +2,12 @@ require "muffin_man/version"
|
|
2
2
|
require "muffin_man/sp_api_client"
|
3
3
|
require "muffin_man/lwa/auth_helper"
|
4
4
|
require "muffin_man/solicitations/v1"
|
5
|
+
require "muffin_man/orders/v0"
|
5
6
|
require "muffin_man/reports/v20210630"
|
6
7
|
require "muffin_man/catalog_items/v20201201"
|
7
8
|
require "muffin_man/finances/v0"
|
8
9
|
require "muffin_man/authorization/v1"
|
10
|
+
require "muffin_man/tokens/v20210301"
|
9
11
|
|
10
12
|
module MuffinMan
|
11
13
|
class Error < StandardError; end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: exe
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-
|
13
|
+
date: 2022-07-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
@@ -142,9 +142,11 @@ files:
|
|
142
142
|
- lib/muffin_man/catalog_items/v20201201.rb
|
143
143
|
- lib/muffin_man/finances/v0.rb
|
144
144
|
- lib/muffin_man/lwa/auth_helper.rb
|
145
|
+
- lib/muffin_man/orders/v0.rb
|
145
146
|
- lib/muffin_man/reports/v20210630.rb
|
146
147
|
- lib/muffin_man/solicitations/v1.rb
|
147
148
|
- lib/muffin_man/sp_api_client.rb
|
149
|
+
- lib/muffin_man/tokens/v20210301.rb
|
148
150
|
- lib/muffin_man/version.rb
|
149
151
|
- muffin_man.gemspec
|
150
152
|
homepage: https://github.com/patterninc/muffin_man
|