muffin_man 0.1.1 → 1.0.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/.github/workflows/ci.yml +32 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +1 -1
- data/LICENSE.txt +1 -1
- data/README.md +9 -3
- data/lib/muffin_man/catalog_items/v20201201.rb +56 -0
- data/lib/muffin_man/reports/v20210630.rb +29 -0
- data/lib/muffin_man/solicitations/v1.rb +21 -0
- data/lib/muffin_man/sp_api_client.rb +12 -3
- data/lib/muffin_man/version.rb +1 -1
- data/lib/muffin_man.rb +4 -2
- data/muffin_man.gemspec +2 -2
- metadata +13 -16
- data/lib/muffin_man/solicitations.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 452a879ba32d96175ec80f2ec96c23d8b52fdb02825e9a27d1b90048f34bfc07
|
4
|
+
data.tar.gz: dba288535b7f032c084cdcfeb9f8d40ca5ad5d60152f0efde44cc2659a760252
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f19c0be669410e54f1578ca18a5b9c23a9ae178b9b15c9314224e8c79b1b8ed0344a3cccde5c196e4f12d7678aa455c9ebdadcd306680c779fb05e2ad822587
|
7
|
+
data.tar.gz: 7a6123fd6c3e90d505bc9408a3c9b5b8b3606074d0117e5bfb2de2b2b26741df970819631c77c3822903a8dba7131fdbf57d9adfaebb8eda5403e535e44057cb
|
@@ -0,0 +1,32 @@
|
|
1
|
+
name: Ruby CI
|
2
|
+
|
3
|
+
# Controls when the workflow will run
|
4
|
+
on:
|
5
|
+
# Triggers the workflow on push or pull request events but only for the master branch
|
6
|
+
push:
|
7
|
+
branches:
|
8
|
+
- 'master'
|
9
|
+
pull_request:
|
10
|
+
branches:
|
11
|
+
- 'master'
|
12
|
+
|
13
|
+
jobs:
|
14
|
+
ci-build:
|
15
|
+
runs-on: ubuntu-latest
|
16
|
+
|
17
|
+
strategy:
|
18
|
+
matrix:
|
19
|
+
ruby-version: [2.7, 2.6, 2.5]
|
20
|
+
|
21
|
+
# Check-out repo
|
22
|
+
steps:
|
23
|
+
- name: Checkout
|
24
|
+
uses: actions/checkout@v2
|
25
|
+
- name: Set up Ruby ${{ matrix.ruby-version }}
|
26
|
+
uses: ruby/setup-ruby@v1
|
27
|
+
with:
|
28
|
+
ruby-version: ${{ matrix.ruby-version }}
|
29
|
+
- name: Install dependencies
|
30
|
+
run: bundle install
|
31
|
+
- name: Run RSpec
|
32
|
+
run: bundle exec rspec
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
# MuffinMan
|
2
2
|
|
3
|
+

|
4
|
+
|
3
5
|
MuffinMan is a ruby interface to the Amazon Selling Partner API. For more information on registering to use the Selling Partner API, see [Amazon's documentation](https://github.com/amzn/selling-partner-api-docs/blob/main/guides/developer-guide/SellingPartnerApiDeveloperGuide.md)
|
4
6
|
|
5
|
-
As of now, this gem only supports the
|
7
|
+
As of now, this gem only supports portions of the following APIs with more to come:
|
8
|
+
|
9
|
+
- `create_product_review_and_seller_feedback_solicitation`
|
10
|
+
- `catalog_items`
|
11
|
+
- `reports`
|
6
12
|
|
7
13
|
## Installation
|
8
14
|
|
@@ -35,8 +41,8 @@ credentials = {
|
|
35
41
|
region: REGION, # This can be one of ['na', 'eu', 'fe'] and defaults to 'na'
|
36
42
|
sts_iam_role_arn: STS_IAM_ROLE_ARN, # Optional
|
37
43
|
}
|
38
|
-
client = MuffinMan::Solicitations.new(credentials)
|
39
|
-
response = client.create_product_review_and_seller_feedback_solicitation(amazon_order_id, marketplace_ids
|
44
|
+
client = MuffinMan::Solicitations::V1.new(credentials)
|
45
|
+
response = client.create_product_review_and_seller_feedback_solicitation(amazon_order_id, marketplace_ids)
|
40
46
|
JSON.parse(response.body)
|
41
47
|
```
|
42
48
|
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module MuffinMan
|
2
|
+
module CatalogItems
|
3
|
+
class V20201201 < SpApiClient
|
4
|
+
SANDBOX_KEYWORDS = "shoes".freeze
|
5
|
+
SANDBOX_ASIN = "B07N4M94X4".freeze
|
6
|
+
SANDBOX_MARKETPLACE_IDS = "ATVPDKIKX0DER".freeze
|
7
|
+
attr_reader :keywords, :asin, :marketplace_ids, :params
|
8
|
+
|
9
|
+
SEARCH_CATALOG_ITEMS_PARAMS = %w[
|
10
|
+
includedData
|
11
|
+
brandNames
|
12
|
+
classificationIds
|
13
|
+
pageSize
|
14
|
+
pageToken
|
15
|
+
keywordsLocale
|
16
|
+
locale
|
17
|
+
].freeze
|
18
|
+
GET_CATALOG_ITEM_PARAMS = %w[includeData locale].freeze
|
19
|
+
|
20
|
+
def search_catalog_items(keywords, marketplace_ids, params = {})
|
21
|
+
if sandbox
|
22
|
+
keywords = SANDBOX_KEYWORDS
|
23
|
+
marketplace_ids = SANDBOX_MARKETPLACE_IDS
|
24
|
+
params = {}
|
25
|
+
end
|
26
|
+
@keywords = keywords.is_a?(Array) ? keywords : [keywords]
|
27
|
+
@marketplace_ids = marketplace_ids.is_a?(Array) ? marketplace_ids : [marketplace_ids]
|
28
|
+
@params = params
|
29
|
+
@local_var_path = "/catalog/2020-12-01/items"
|
30
|
+
@query_params = {
|
31
|
+
"keywords" => @keywords.join(","),
|
32
|
+
"marketplaceIds" => @marketplace_ids.join(",")
|
33
|
+
}
|
34
|
+
@query_params.merge!(@params.slice(*SEARCH_CATALOG_ITEMS_PARAMS))
|
35
|
+
@request_type = "GET"
|
36
|
+
call_api
|
37
|
+
end
|
38
|
+
|
39
|
+
def get_catalog_item(asin, marketplace_ids, params = {})
|
40
|
+
if sandbox
|
41
|
+
asin = SANDBOX_ASIN
|
42
|
+
marketplace_ids = SANDBOX_MARKETPLACE_IDS
|
43
|
+
params = {}
|
44
|
+
end
|
45
|
+
@asin = asin
|
46
|
+
@marketplace_ids = marketplace_ids.is_a?(Array) ? marketplace_ids : [marketplace_ids]
|
47
|
+
@params = params
|
48
|
+
@local_var_path = "/catalog/2020-12-01/items/#{@asin}"
|
49
|
+
@query_params = { "marketplaceIds" => @marketplace_ids.join(",") }
|
50
|
+
@query_params.merge!(@params.slice(*GET_CATALOG_ITEM_PARAMS))
|
51
|
+
@request_type = "GET"
|
52
|
+
call_api
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module MuffinMan
|
2
|
+
module Reports
|
3
|
+
class V20210630 < SpApiClient
|
4
|
+
SANDBOX_REPORT_TYPE = "GET_MERCHANT_LISTINGS_ALL_DATA"
|
5
|
+
SANDBOX_START_TIME = "2019-12-10T20:11:24.000Z"
|
6
|
+
SANDBOX_MARKETPLACE_IDS = [
|
7
|
+
"A1PA6795UKMFR9",
|
8
|
+
"ATVPDKIKX0DER"
|
9
|
+
]
|
10
|
+
|
11
|
+
def create_report(report_type, marketplace_ids, start_time = nil, end_time = nil, report_options = {})
|
12
|
+
report_type = sandbox ? SANDBOX_REPORT_TYPE : report_type
|
13
|
+
marketplace_ids = sandbox ? SANDBOX_MARKETPLACE_IDS : marketplace_ids
|
14
|
+
start_time = sandbox ? SANDBOX_START_TIME : start_time
|
15
|
+
|
16
|
+
@local_var_path = "/reports/2021-06-30/reports"
|
17
|
+
@request_body = {
|
18
|
+
"reportType" => report_type,
|
19
|
+
"marketplaceIds" => marketplace_ids,
|
20
|
+
}
|
21
|
+
@request_body["dataStartTime"] = start_time unless start_time.nil?
|
22
|
+
@request_body["dataEndTime"] = end_time unless end_time.nil?
|
23
|
+
@request_body["reportOptions"] = report_options unless report_options.empty?
|
24
|
+
@request_type = 'POST'
|
25
|
+
call_api
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module MuffinMan
|
2
|
+
module Solicitations
|
3
|
+
class V1 < SpApiClient
|
4
|
+
SANDBOX_AMAZON_ORDER_ID = "123-1234567-1234567"
|
5
|
+
SANDBOX_MARKETPLACE_IDS = "ATVPDKIKX0DER"
|
6
|
+
attr_reader :amazon_order_id, :marketplace_ids
|
7
|
+
|
8
|
+
# Sends a solicitation to a buyer asking for seller feedback and a product review for the specified order. Send only one productReviewAndSellerFeedback or free form proactive message per order. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | For more information, see \"Usage Plans and Rate Limits\" in the Selling Partner API documentation.
|
9
|
+
# @param amazon_order_id An Amazon order identifier. This specifies the order for which a solicitation is sent.
|
10
|
+
# @param marketplace_ids A marketplace identifier. This specifies the marketplace in which the order was placed. Only one marketplace can be specified.
|
11
|
+
def create_product_review_and_seller_feedback_solicitation(amazon_order_id, marketplace_ids)
|
12
|
+
@amazon_order_id = sandbox ? SANDBOX_AMAZON_ORDER_ID : amazon_order_id
|
13
|
+
@marketplace_ids = sandbox ? SANDBOX_MARKETPLACE_IDS : marketplace_ids
|
14
|
+
@local_var_path = '/solicitations/v1/orders/{amazonOrderId}/solicitations/productReviewAndSellerFeedback'.sub('{' + 'amazonOrderId' + '}', @amazon_order_id)
|
15
|
+
@query_params = { "marketplaceIds" => @marketplace_ids }
|
16
|
+
@request_type = 'POST'
|
17
|
+
call_api
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -7,7 +7,8 @@ require 'securerandom'
|
|
7
7
|
module MuffinMan
|
8
8
|
class SpApiClient
|
9
9
|
attr_reader :refresh_token, :client_id, :client_secret, :aws_access_key_id,
|
10
|
-
:aws_secret_access_key, :sts_iam_role_arn, :sandbox, :config, :region
|
10
|
+
:aws_secret_access_key, :sts_iam_role_arn, :sandbox, :config, :region, :request_type,
|
11
|
+
:local_var_path, :query_params, :request_body
|
11
12
|
ACCESS_TOKEN_URL = 'https://api.amazon.com/auth/o2/token'.freeze
|
12
13
|
SERVICE_NAME = 'execute-api'.freeze
|
13
14
|
AWS_REGION_MAP = {
|
@@ -32,7 +33,15 @@ module MuffinMan
|
|
32
33
|
private
|
33
34
|
|
34
35
|
def call_api
|
35
|
-
Typhoeus.send(request_type.downcase.to_sym, request.url,
|
36
|
+
Typhoeus.send(request_type.downcase.to_sym, request.url, request_opts)
|
37
|
+
end
|
38
|
+
|
39
|
+
def request_opts
|
40
|
+
opts = { headers: headers }
|
41
|
+
if request_body
|
42
|
+
opts[:body] = request_body.to_json
|
43
|
+
end
|
44
|
+
opts
|
36
45
|
end
|
37
46
|
|
38
47
|
def sp_api_host
|
@@ -107,7 +116,7 @@ module MuffinMan
|
|
107
116
|
request_config[:credentials_provider] = request_sts_token
|
108
117
|
end
|
109
118
|
signer = Aws::Sigv4::Signer.new(request_config)
|
110
|
-
signer.sign_request(http_method: request_type, url: request.url)
|
119
|
+
signer.sign_request(http_method: request_type, url: request.url, body: request_body&.to_json)
|
111
120
|
end
|
112
121
|
|
113
122
|
def headers
|
data/lib/muffin_man/version.rb
CHANGED
data/lib/muffin_man.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
|
1
|
+
require "muffin_man/version"
|
2
2
|
require "muffin_man/sp_api_client"
|
3
|
-
require "muffin_man/solicitations"
|
3
|
+
require "muffin_man/solicitations/v1"
|
4
|
+
require "muffin_man/reports/v20210630"
|
5
|
+
require "muffin_man/catalog_items/v20201201"
|
4
6
|
|
5
7
|
module MuffinMan
|
6
8
|
class Error < StandardError; end
|
data/muffin_man.gemspec
CHANGED
@@ -22,6 +22,6 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency 'webmock', '~> 2.1'
|
23
23
|
spec.add_development_dependency 'mock_redis', '>=0.14'
|
24
24
|
spec.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
|
25
|
-
spec.add_runtime_dependency 'aws-sigv4', '
|
26
|
-
spec.add_runtime_dependency 'aws-sdk-core', '
|
25
|
+
spec.add_runtime_dependency 'aws-sigv4', '>= 1.1'
|
26
|
+
spec.add_runtime_dependency 'aws-sdk-core', '>= 2.4.4'
|
27
27
|
end
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: muffin_man
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
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
|
-
date:
|
13
|
+
date: 2022-01-28 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|
@@ -78,23 +78,20 @@ dependencies:
|
|
78
78
|
name: aws-sigv4
|
79
79
|
requirement: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
|
-
- - "
|
81
|
+
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '1.1'
|
84
84
|
type: :runtime
|
85
85
|
prerelease: false
|
86
86
|
version_requirements: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- - "
|
88
|
+
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '1.1'
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: aws-sdk-core
|
93
93
|
requirement: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- - "~>"
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
version: '2.4'
|
98
95
|
- - ">="
|
99
96
|
- !ruby/object:Gem::Version
|
100
97
|
version: 2.4.4
|
@@ -102,13 +99,10 @@ dependencies:
|
|
102
99
|
prerelease: false
|
103
100
|
version_requirements: !ruby/object:Gem::Requirement
|
104
101
|
requirements:
|
105
|
-
- - "~>"
|
106
|
-
- !ruby/object:Gem::Version
|
107
|
-
version: '2.4'
|
108
102
|
- - ">="
|
109
103
|
- !ruby/object:Gem::Version
|
110
104
|
version: 2.4.4
|
111
|
-
description:
|
105
|
+
description:
|
112
106
|
email:
|
113
107
|
- gavin@pattern.com
|
114
108
|
- jason@pattern.com
|
@@ -118,6 +112,7 @@ extensions: []
|
|
118
112
|
extra_rdoc_files: []
|
119
113
|
files:
|
120
114
|
- ".circleci/config.yml"
|
115
|
+
- ".github/workflows/ci.yml"
|
121
116
|
- ".gitignore"
|
122
117
|
- ".rspec"
|
123
118
|
- ".rubocop.yml"
|
@@ -129,7 +124,9 @@ files:
|
|
129
124
|
- bin/console
|
130
125
|
- bin/setup
|
131
126
|
- lib/muffin_man.rb
|
132
|
-
- lib/muffin_man/
|
127
|
+
- lib/muffin_man/catalog_items/v20201201.rb
|
128
|
+
- lib/muffin_man/reports/v20210630.rb
|
129
|
+
- lib/muffin_man/solicitations/v1.rb
|
133
130
|
- lib/muffin_man/sp_api_client.rb
|
134
131
|
- lib/muffin_man/version.rb
|
135
132
|
- muffin_man.gemspec
|
@@ -137,7 +134,7 @@ homepage: https://github.com/patterninc/muffin_man
|
|
137
134
|
licenses:
|
138
135
|
- MIT
|
139
136
|
metadata: {}
|
140
|
-
post_install_message:
|
137
|
+
post_install_message:
|
141
138
|
rdoc_options: []
|
142
139
|
require_paths:
|
143
140
|
- lib
|
@@ -152,8 +149,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
149
|
- !ruby/object:Gem::Version
|
153
150
|
version: '0'
|
154
151
|
requirements: []
|
155
|
-
rubygems_version: 3.
|
156
|
-
signing_key:
|
152
|
+
rubygems_version: 3.2.3
|
153
|
+
signing_key:
|
157
154
|
specification_version: 4
|
158
155
|
summary: Amazon Selling Partner API client
|
159
156
|
test_files: []
|
@@ -1,19 +0,0 @@
|
|
1
|
-
module MuffinMan
|
2
|
-
class Solicitations < SpApiClient
|
3
|
-
SANDBOX_AMAZON_ORDER_ID = "123-1234567-1234567"
|
4
|
-
SANDBOX_MARKETPLACE_IDS = "ATVPDKIKX0DER"
|
5
|
-
attr_reader :amazon_order_id, :marketplace_ids, :request_type, :local_var_path, :query_params
|
6
|
-
|
7
|
-
# Sends a solicitation to a buyer asking for seller feedback and a product review for the specified order. Send only one productReviewAndSellerFeedback or free form proactive message per order. **Usage Plan:** | Rate (requests per second) | Burst | | ---- | ---- | | 1 | 5 | For more information, see \"Usage Plans and Rate Limits\" in the Selling Partner API documentation.
|
8
|
-
# @param amazon_order_id An Amazon order identifier. This specifies the order for which a solicitation is sent.
|
9
|
-
# @param marketplace_ids A marketplace identifier. This specifies the marketplace in which the order was placed. Only one marketplace can be specified.
|
10
|
-
def create_product_review_and_seller_feedback_solicitation(amazon_order_id, marketplace_ids)
|
11
|
-
@amazon_order_id = sandbox ? SANDBOX_AMAZON_ORDER_ID : amazon_order_id
|
12
|
-
@marketplace_ids = sandbox ? SANDBOX_MARKETPLACE_IDS : marketplace_ids
|
13
|
-
@local_var_path = '/solicitations/v1/orders/{amazonOrderId}/solicitations/productReviewAndSellerFeedback'.sub('{' + 'amazonOrderId' + '}', @amazon_order_id)
|
14
|
-
@query_params = { "marketplaceIds" => @marketplace_ids }
|
15
|
-
@request_type = 'POST'
|
16
|
-
call_api
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|