muffin_man 0.1.0 → 0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 42a69a2af21b2348c9ef63c2d514c5edc4d03ee1c970e6c0295f9ddbb4f57c01
4
- data.tar.gz: 9f0d990ad87181cdd0575b8d79f018aab3bd4fe3740290b3ab1247385539b43e
3
+ metadata.gz: d1b217205a970848a9dc08eea1daf04d52da4d5970bff2a00f0041867c320837
4
+ data.tar.gz: d7df1a7bd5738e336380d3ce6c17df85610d36498997374b2f5e34061a17cf69
5
5
  SHA512:
6
- metadata.gz: 15f2eaae1864b2a91286656457419c729b60c4feee643a1da34af06316b048ea5a6a9ed70d21d1caabd18bb572b31881a08a6e60bdde48365c9f2ad01d40e9e6
7
- data.tar.gz: 6cd9d7182c2e8ec16a053fba1890e8b00259e1b19f45652a14ad122399df04725691abae28ba64cd985347529a577953a71ce28ea6fc9d52f0c8047bc586e968
6
+ metadata.gz: 75d9be6ff3849a9a45ef506e90c4a13d407aeef6ea8f7e84cf1f3c30d4384e451e70ca704f1d7ffb5f621b5bfa0fed4c058a7dabdffdae35c2019c7a545b2914
7
+ data.tar.gz: 7d7696a4e3e9400471e0444b5864592dd0f5297ad1733b51a51bfbe5253564059d5397489acb0f53d7529611bd778cab1d6206eeab4606d39b8f0bc779703434
@@ -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
@@ -9,5 +9,8 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+
12
13
  .env
13
14
  Gemfile.lock
15
+ *.gem
16
+ .ruby-version
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.4
2
+ TargetRubyVersion: 2.5
3
3
 
4
4
  Style/StringLiterals:
5
5
  Enabled: true
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2021 Gavin
3
+ Copyright (c) 2022 Pattern Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -36,7 +36,7 @@ credentials = {
36
36
  sts_iam_role_arn: STS_IAM_ROLE_ARN, # Optional
37
37
  }
38
38
  client = MuffinMan::Solicitations.new(credentials)
39
- response = client.create_product_review_and_seller_feedback_solicitation(amazon_order_id, marketplace_ids, region)
39
+ response = client.create_product_review_and_seller_feedback_solicitation(amazon_order_id, marketplace_ids)
40
40
  JSON.parse(response.body)
41
41
  ```
42
42
 
@@ -0,0 +1,27 @@
1
+ module MuffinMan
2
+ class Reports < SpApiClient
3
+ SANDBOX_REPORT_TYPE = "GET_MERCHANT_LISTINGS_ALL_DATA"
4
+ SANDBOX_START_TIME = "2019-12-10T20:11:24.000Z"
5
+ SANDBOX_MARKETPLACE_IDS = [
6
+ "A1PA6795UKMFR9",
7
+ "ATVPDKIKX0DER"
8
+ ]
9
+
10
+ def create_report(report_type, marketplace_ids, start_time = nil, end_time = nil, report_options = {})
11
+ report_type = sandbox ? SANDBOX_REPORT_TYPE : report_type
12
+ marketplace_ids = sandbox ? SANDBOX_MARKETPLACE_IDS : marketplace_ids
13
+ start_time = sandbox ? SANDBOX_START_TIME : start_time
14
+
15
+ @local_var_path = "/reports/2021-06-30/reports"
16
+ @request_body = {
17
+ "reportType" => report_type,
18
+ "marketplaceIds" => marketplace_ids,
19
+ }
20
+ @request_body["dataStartTime"] = start_time unless start_time.nil?
21
+ @request_body["dataEndTime"] = end_time unless end_time.nil?
22
+ @request_body["reportOptions"] = report_options unless report_options.empty?
23
+ @request_type = 'POST'
24
+ call_api
25
+ end
26
+ end
27
+ end
@@ -2,7 +2,7 @@ module MuffinMan
2
2
  class Solicitations < SpApiClient
3
3
  SANDBOX_AMAZON_ORDER_ID = "123-1234567-1234567"
4
4
  SANDBOX_MARKETPLACE_IDS = "ATVPDKIKX0DER"
5
- attr_reader :amazon_order_id, :marketplace_ids, :request_type, :local_var_path, :query_params
5
+ attr_reader :amazon_order_id, :marketplace_ids
6
6
 
7
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
8
  # @param amazon_order_id An Amazon order identifier. This specifies the order for which a solicitation is sent.
@@ -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, headers: headers)
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
@@ -0,0 +1,56 @@
1
+ module MuffinMan
2
+ module V20201201
3
+ class CatalogItems < 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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MuffinMan
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/muffin_man.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require_relative "muffin_man/version"
2
2
  require "muffin_man/sp_api_client"
3
3
  require "muffin_man/solicitations"
4
+ require "muffin_man/reports"
5
+ require "muffin_man/v20201201/catalog_items"
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', '~> 1.2', '>= 1.2.2'
26
- spec.add_runtime_dependency 'aws-sdk-core', '~> 2.4', '>= 2.4.4'
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.1.0
4
+ version: 0.2.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: 2021-01-20 00:00:00.000000000 Z
13
+ date: 2022-01-28 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -78,29 +78,20 @@ dependencies:
78
78
  name: aws-sigv4
79
79
  requirement: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - "~>"
82
- - !ruby/object:Gem::Version
83
- version: '1.2'
84
81
  - - ">="
85
82
  - !ruby/object:Gem::Version
86
- version: 1.2.2
83
+ version: '1.1'
87
84
  type: :runtime
88
85
  prerelease: false
89
86
  version_requirements: !ruby/object:Gem::Requirement
90
87
  requirements:
91
- - - "~>"
92
- - !ruby/object:Gem::Version
93
- version: '1.2'
94
88
  - - ">="
95
89
  - !ruby/object:Gem::Version
96
- version: 1.2.2
90
+ version: '1.1'
97
91
  - !ruby/object:Gem::Dependency
98
92
  name: aws-sdk-core
99
93
  requirement: !ruby/object:Gem::Requirement
100
94
  requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '2.4'
104
95
  - - ">="
105
96
  - !ruby/object:Gem::Version
106
97
  version: 2.4.4
@@ -108,13 +99,10 @@ dependencies:
108
99
  prerelease: false
109
100
  version_requirements: !ruby/object:Gem::Requirement
110
101
  requirements:
111
- - - "~>"
112
- - !ruby/object:Gem::Version
113
- version: '2.4'
114
102
  - - ">="
115
103
  - !ruby/object:Gem::Version
116
104
  version: 2.4.4
117
- description:
105
+ description:
118
106
  email:
119
107
  - gavin@pattern.com
120
108
  - jason@pattern.com
@@ -124,6 +112,7 @@ extensions: []
124
112
  extra_rdoc_files: []
125
113
  files:
126
114
  - ".circleci/config.yml"
115
+ - ".github/workflows/ci.yml"
127
116
  - ".gitignore"
128
117
  - ".rspec"
129
118
  - ".rubocop.yml"
@@ -135,15 +124,17 @@ files:
135
124
  - bin/console
136
125
  - bin/setup
137
126
  - lib/muffin_man.rb
127
+ - lib/muffin_man/reports.rb
138
128
  - lib/muffin_man/solicitations.rb
139
129
  - lib/muffin_man/sp_api_client.rb
130
+ - lib/muffin_man/v20201201/catalog_items.rb
140
131
  - lib/muffin_man/version.rb
141
132
  - muffin_man.gemspec
142
133
  homepage: https://github.com/patterninc/muffin_man
143
134
  licenses:
144
135
  - MIT
145
136
  metadata: {}
146
- post_install_message:
137
+ post_install_message:
147
138
  rdoc_options: []
148
139
  require_paths:
149
140
  - lib
@@ -158,8 +149,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
149
  - !ruby/object:Gem::Version
159
150
  version: '0'
160
151
  requirements: []
161
- rubygems_version: 3.0.3
162
- signing_key:
152
+ rubygems_version: 3.1.6
153
+ signing_key:
163
154
  specification_version: 4
164
155
  summary: Amazon Selling Partner API client
165
156
  test_files: []