muffin_man 1.1.0 → 1.2.0
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/lib/muffin_man/authorization/v1.rb +17 -0
- data/lib/muffin_man/sp_api_client.rb +26 -2
- data/lib/muffin_man/version.rb +1 -1
- data/lib/muffin_man.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bed4f016d8045bd0f40bfe4e4ca1be2467fac83ff0549674610c20ad3cba9795
|
4
|
+
data.tar.gz: f955bc7597541ed72eeaeb343d42d83a26892acf31fd3041a287697ae05c6828
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: faed598abf08c41f6e68b627fddaf35e2ccf1a64b95585167827aff7dd996093e6051c2f8caa7e939fe9545b8c91876c8df50bf74f97620b9cb9137934ff5b36
|
7
|
+
data.tar.gz: 0b9a3a286fcd8dc499fc209a276a11f933270f8e430910281f729b817d2f1eebe684d835e0b73250127888550f0f190353c2f84fe51513d65711136e7b7c90a0
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module MuffinMan
|
2
|
+
module Authorization
|
3
|
+
class V1 < SpApiClient
|
4
|
+
def get_authorization_code(selling_partner_id, developer_id, mws_auth_token)
|
5
|
+
@query_params = {
|
6
|
+
"sellingPartnerId" => selling_partner_id,
|
7
|
+
"developerId" => developer_id,
|
8
|
+
"mwsAuthToken" => mws_auth_token
|
9
|
+
}
|
10
|
+
@query_params = {} if sandbox
|
11
|
+
@request_type = "GET"
|
12
|
+
@local_var_path = "/authorization/v1/authorizationCode"
|
13
|
+
call_api
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -8,7 +8,7 @@ module MuffinMan
|
|
8
8
|
class SpApiClient
|
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, :region, :request_type,
|
11
|
-
:local_var_path, :query_params, :request_body
|
11
|
+
:local_var_path, :query_params, :request_body, :scope
|
12
12
|
ACCESS_TOKEN_URL = 'https://api.amazon.com/auth/o2/token'.freeze
|
13
13
|
SERVICE_NAME = 'execute-api'.freeze
|
14
14
|
AWS_REGION_MAP = {
|
@@ -25,6 +25,7 @@ module MuffinMan
|
|
25
25
|
@aws_secret_access_key = credentials[:aws_secret_access_key]
|
26
26
|
@sts_iam_role_arn = credentials[:sts_iam_role_arn]
|
27
27
|
@region = credentials[:region] || 'na'
|
28
|
+
@scope = credentials[:scope]
|
28
29
|
@sandbox = sandbox
|
29
30
|
Typhoeus::Config.user_agent = ''
|
30
31
|
@config = MuffinMan.configuration
|
@@ -91,6 +92,28 @@ module MuffinMan
|
|
91
92
|
JSON.parse(response.body)
|
92
93
|
end
|
93
94
|
|
95
|
+
def retrieve_grantless_access_token
|
96
|
+
# No storage of this type for now
|
97
|
+
request_grantless_access_token["access_token"]
|
98
|
+
end
|
99
|
+
|
100
|
+
def request_grantless_access_token
|
101
|
+
body = {
|
102
|
+
grant_type: "client_credentials",
|
103
|
+
scope: scope,
|
104
|
+
client_id: client_id,
|
105
|
+
client_secret: client_secret
|
106
|
+
}
|
107
|
+
response = Typhoeus.post(
|
108
|
+
ACCESS_TOKEN_URL,
|
109
|
+
body: URI.encode_www_form(body),
|
110
|
+
headers: {
|
111
|
+
"Content-Type" => "application/x-www-form-urlencoded;charset=UTF-8"
|
112
|
+
}
|
113
|
+
)
|
114
|
+
JSON.parse(response.body)
|
115
|
+
end
|
116
|
+
|
94
117
|
def request_sts_token
|
95
118
|
client = Aws::STS::Client.new(
|
96
119
|
region: derive_aws_region,
|
@@ -117,8 +140,9 @@ module MuffinMan
|
|
117
140
|
end
|
118
141
|
|
119
142
|
def headers
|
143
|
+
access_token = scope ? retrieve_grantless_access_token : retrieve_lwa_access_token
|
120
144
|
headers = {
|
121
|
-
'x-amz-access-token' =>
|
145
|
+
'x-amz-access-token' => access_token,
|
122
146
|
'user-agent' => "MuffinMan/#{VERSION} (Language=Ruby)",
|
123
147
|
'content-type' => "application/json"
|
124
148
|
}
|
data/lib/muffin_man/version.rb
CHANGED
data/lib/muffin_man.rb
CHANGED
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
|
+
version: 1.2.0
|
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-04-
|
13
|
+
date: 2022-04-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- bin/console
|
124
124
|
- bin/setup
|
125
125
|
- lib/muffin_man.rb
|
126
|
+
- lib/muffin_man/authorization/v1.rb
|
126
127
|
- lib/muffin_man/catalog_items/v20201201.rb
|
127
128
|
- lib/muffin_man/finances/v0.rb
|
128
129
|
- lib/muffin_man/reports/v20210630.rb
|