muffin_man 1.4.5 → 1.4.7

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: b464f989ff6561fcd595fa4e635537b955d4b4335ebe5932df370d6c837587a8
4
- data.tar.gz: 4dd6ce7d1228112f15e39017d83f87a8e6606eef8504766da7719d3ec764a414
3
+ metadata.gz: a917d17125d2557b73aec27117dd30327c866382198d202ba9a8d54bff5db82c
4
+ data.tar.gz: 46eafd766beab5cd7d300bbd2ad9a2aaf62d47ee48c67b51c0173f07eb657959
5
5
  SHA512:
6
- metadata.gz: 1d3ac2b501430a907d228b9c8d8bde739b668a2b3a18989b11893f3951c1fda2d72d427e54744aadc59f13bdec49923af9b12514c937f42e3ca0dd057f95b956
7
- data.tar.gz: c7826e357ef7a75a5aa67825139faf7dd5374af2edd15c283520f5292fbddc82c33c909f9c5df52acc374062ac351ea4d79b8ec100f001c38cb36413191d9eac
6
+ metadata.gz: 56e85f023181739f5946a912483eade11c1e14fe02963dd2ad845b3ddc7e95da36c0490c2cafd3a8d36ec83d6d0156374134a81e83c0e9cbbe8f2b9c8a76c515
7
+ data.tar.gz: 3034a2f736e1be8d4c4d0261ce90e76e5f2dba3b7c73572d30d72d90426c177faf483fc72cc9ed4192b2aee1f2364c091dee9a867fc641150f440ade552babef
data/CHANGELOG.md CHANGED
@@ -1,3 +1,15 @@
1
+ # 1.4.7
2
+
3
+ - Support for createInboundShipmentPlan [#24](https://github.com/patterninc/muffin_man/pull/24)
4
+
5
+ # 1.4.6
6
+
7
+ - Support for Catalog API's of version 20220401 [#22](https://github.com/patterninc/muffin_man/pull/22)
8
+
9
+ # 1.4.5
10
+
11
+ - Support for GetCompetitivePricing endpoint [#19] (https://github.com/patterninc/muffin_man/pull/19)
12
+
1
13
  # 1.4.4
2
14
 
3
15
  - Support for Tokens API [#17](https://github.com/patterninc/muffin_man/pull/17)
data/README.md CHANGED
@@ -9,6 +9,8 @@ As of now, this gem only supports portions of the following APIs with more to co
9
9
  - `create_product_review_and_seller_feedback_solicitation`
10
10
  - `catalog_items`
11
11
  - `reports`
12
+ - `product_fees`
13
+ - `product_pricing`
12
14
 
13
15
  ## Installation
14
16
 
@@ -0,0 +1,58 @@
1
+ module MuffinMan
2
+ module CatalogItems
3
+ class BaseApi < 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[includedData locale].freeze
19
+
20
+ API_VERSION = "2020-12-01".freeze
21
+
22
+ def search_catalog_items(keywords, marketplace_ids, params = {}, api_version=API_VERSION)
23
+ if sandbox
24
+ keywords = SANDBOX_KEYWORDS
25
+ marketplace_ids = SANDBOX_MARKETPLACE_IDS
26
+ params = {}
27
+ end
28
+ @keywords = keywords.is_a?(Array) ? keywords : [keywords]
29
+ @marketplace_ids = marketplace_ids.is_a?(Array) ? marketplace_ids : [marketplace_ids]
30
+ @params = params
31
+ @local_var_path = "/catalog/#{api_version}/items"
32
+ @query_params = {
33
+ "keywords" => @keywords.join(","),
34
+ "marketplaceIds" => @marketplace_ids.join(",")
35
+ }
36
+ @query_params.merge!(@params.slice(*SEARCH_CATALOG_ITEMS_PARAMS))
37
+ @request_type = "GET"
38
+ call_api
39
+ end
40
+
41
+ def get_catalog_item(asin, marketplace_ids, params = {}, api_version=API_VERSION)
42
+ if sandbox
43
+ asin = SANDBOX_ASIN
44
+ marketplace_ids = SANDBOX_MARKETPLACE_IDS
45
+ params = {}
46
+ end
47
+ @asin = asin
48
+ @marketplace_ids = marketplace_ids.is_a?(Array) ? marketplace_ids : [marketplace_ids]
49
+ @params = params
50
+ @local_var_path = "/catalog/#{api_version}/items/#{@asin}"
51
+ @query_params = { "marketplaceIds" => @marketplace_ids.join(",") }
52
+ @query_params.merge!(@params.slice(*GET_CATALOG_ITEM_PARAMS))
53
+ @request_type = "GET"
54
+ call_api
55
+ end
56
+ end
57
+ end
58
+ end
@@ -1,55 +1,17 @@
1
+ require "muffin_man/catalog_items/base_api"
2
+
1
3
  module MuffinMan
2
4
  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
5
+ class V20201201 < BaseApi
8
6
 
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[includedData locale].freeze
7
+ API_VERSION = "2020-12-01".freeze
19
8
 
20
9
  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
10
+ super(keywords, marketplace_ids, params, API_VERSION)
37
11
  end
38
12
 
39
13
  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
14
+ super(asin, marketplace_ids, params, API_VERSION)
53
15
  end
54
16
  end
55
17
  end
@@ -0,0 +1,18 @@
1
+ require "muffin_man/catalog_items/base_api"
2
+
3
+ module MuffinMan
4
+ module CatalogItems
5
+ class V20220401 < BaseApi
6
+
7
+ API_VERSION = "2022-04-01".freeze
8
+
9
+ def search_catalog_items(keywords, marketplace_ids, params = {})
10
+ super(keywords, marketplace_ids, params, API_VERSION)
11
+ end
12
+
13
+ def get_catalog_item(asin, marketplace_ids, params = {})
14
+ super(asin, marketplace_ids, params, API_VERSION)
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,29 @@
1
+ module MuffinMan
2
+ module FulfillmentInbound
3
+ class V0 < SpApiClient
4
+ def get_prep_instructions(ship_to_country_code, seller_sku_list: [], asin_list: [])
5
+ @local_var_path = "/fba/inbound/v0/prepInstructions"
6
+ @query_params = {
7
+ "ShipToCountryCode" => ship_to_country_code
8
+ }
9
+ @query_params["SellerSKUList"] = seller_sku_list.join(",") if seller_sku_list.any?
10
+ @query_params["ASINList"] = asin_list.join(",") if asin_list.any?
11
+ @request_type = "GET"
12
+ call_api
13
+ end
14
+
15
+ def create_inbound_shipment_plan(ship_from_address, label_prep_preference, inbound_shipment_plan_request_items, ship_to_country_code: nil, ship_to_country_subdivision_code: nil)
16
+ @local_var_path = "/fba/inbound/v0/plans"
17
+ @request_body = {
18
+ "ShipFromAddress" => ship_from_address,
19
+ "LabelPrepPreference" => label_prep_preference,
20
+ "InboundShipmentPlanRequestItems" => inbound_shipment_plan_request_items,
21
+ }
22
+ @request_body["ShipToCountryCode"] = ship_to_country_code unless ship_to_country_code.nil?
23
+ @request_body["ShipToCountrySubdivisionCode"] = ship_to_country_subdivision_code unless ship_to_country_subdivision_code.nil?
24
+ @request_type = "POST"
25
+ call_api
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,24 @@
1
+ module MuffinMan
2
+ module Listings
3
+ class V20210801 < SpApiClient
4
+ def get_listings_item(seller_id, sku, marketplace_ids, issue_locale: nil, included_data: [])
5
+ # Options for included_data:
6
+ # summaries
7
+ # attributes
8
+ # issues
9
+ # offers
10
+ # fulfillmentAvailability
11
+ # procurement
12
+ @local_var_path = "/listings/2021-08-01/items/#{seller_id}/#{sku}"
13
+ @marketplace_ids = marketplace_ids.is_a?(Array) ? marketplace_ids : [marketplace_ids]
14
+ @query_params = {
15
+ "marketplaceIds" => @marketplace_ids.join(",")
16
+ }
17
+ @query_params["issueLocale"] = issue_locale if issue_locale
18
+ @query_params["includedData"] = included_data.join(",") if included_data.any?
19
+ @request_type = "GET"
20
+ call_api
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MuffinMan
4
+ module ProductFees
5
+ require "json"
6
+ require "sp_api_helpers"
7
+ class V0 < SpApiClient
8
+ attr_reader :asin
9
+
10
+ def get_my_fees_estimate_for_asin(asin, marketplace_id, map_price, currency_code, shipping = nil, points = nil, identifier = SecureRandom.uuid,
11
+ is_amazon_fulfilled = true, optional_fulfillment_program = "FBA_CORE")
12
+ @local_var_path = "/products/fees/v0/items/#{asin}/feesEstimate"
13
+ @request_body = SpApiHelpers.fees_estimate_request_body(marketplace_id, map_price, currency_code, shipping, points, identifier,
14
+ is_amazon_fulfilled, optional_fulfillment_program).to_camelize
15
+ @request_type = "POST"
16
+ call_api
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MuffinMan
4
+ module ProductPricing
5
+ class V0 < SpApiClient
6
+ GET_COMPETITIVE_PRICE_PARAMS = %w[Asins Skus CustomerType].freeze
7
+
8
+ def get_competitive_pricing(marketplace_id, item_type='Asin', params = {})
9
+ @params = params
10
+ @local_var_path = "/products/pricing/v0/competitivePrice"
11
+ @query_params = { "MarketplaceId" => marketplace_id,
12
+ "ItemType" => item_type }
13
+ @query_params.merge!(@params.slice(*GET_COMPETITIVE_PRICE_PARAMS))
14
+ @request_type = "GET"
15
+ call_api
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,15 @@
1
+ module MuffinMan
2
+ module RequestHelpers
3
+ class Base
4
+ def self.json_body(*args)
5
+ new(*args).json_body
6
+ end
7
+
8
+ def initialize(*args); end
9
+
10
+ def json_body
11
+ {}
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,27 @@
1
+ module MuffinMan
2
+ module RequestHelpers
3
+ class InboundShipmentPlanRequestItem < Base
4
+ attr_reader :seller_sku, :asin, :condition, :quantity, :quantity_in_case, :prep_details_list
5
+
6
+ def initialize(seller_sku, asin, condition, quantity, quantity_in_case: nil, prep_details_list: [])
7
+ @seller_sku = seller_sku
8
+ @asin = asin
9
+ @quantity = quantity
10
+ @condition = condition
11
+ @quantity_in_case = quantity_in_case
12
+ @prep_details_list = prep_details_list
13
+ end
14
+
15
+ def json_body
16
+ {
17
+ "SellerSKU": seller_sku,
18
+ "ASIN": asin,
19
+ "Condition": condition,
20
+ "Quantity": quantity,
21
+ "QuantityInCase": quantity_in_case,
22
+ "PrepDetailsList": prep_details_list
23
+ }
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,2 @@
1
+ require 'muffin_man/request_helpers/base'
2
+ require 'muffin_man/request_helpers/inbound_shipment_plan_request_item'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MuffinMan
4
- VERSION = "1.4.5"
4
+ VERSION = "1.4.7"
5
5
  end
data/lib/muffin_man.rb CHANGED
@@ -5,9 +5,15 @@ require "muffin_man/solicitations/v1"
5
5
  require "muffin_man/orders/v0"
6
6
  require "muffin_man/reports/v20210630"
7
7
  require "muffin_man/catalog_items/v20201201"
8
+ require "muffin_man/catalog_items/v20220401"
8
9
  require "muffin_man/finances/v0"
10
+ require "muffin_man/product_fees/v0"
9
11
  require "muffin_man/authorization/v1"
10
12
  require "muffin_man/tokens/v20210301"
13
+ require "muffin_man/product_pricing/v0"
14
+ require "muffin_man/listings/v20210801"
15
+ require "muffin_man/fulfillment_inbound/v0"
16
+
11
17
 
12
18
  module MuffinMan
13
19
  class Error < StandardError; end
@@ -0,0 +1,93 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Module to help create request body for API endpoints
4
+ module SpApiHelpers
5
+ require "securerandom"
6
+
7
+ def self.fees_estimate_request_body(marketplace_id, price, fees_currency_code,
8
+ shipping = nil, points = nil, identifier = SecureRandom.uuid,
9
+ is_amazon_fulfilled = true, optional_fulfillment_program = "FBA_CORE")
10
+ GetMyFeesEstimateRequest.new(marketplace_id, price, fees_currency_code,
11
+ shipping, points, identifier,
12
+ is_amazon_fulfilled, optional_fulfillment_program)
13
+ end
14
+ class GetMyFeesEstimateRequest
15
+ attr_accessor :fees_estimate_request
16
+
17
+ def initialize(marketplace_id, price, fees_currency_code, shipping, points, identifier,
18
+ is_amazon_fulfilled, optional_fulfillment_program)
19
+ @fees_estimate_request = FeesEstimateRequest.new(marketplace_id, price, fees_currency_code, shipping, points,
20
+ identifier, is_amazon_fulfilled, optional_fulfillment_program)
21
+ end
22
+
23
+ def to_camelize
24
+ {
25
+ "FeesEstimateRequest" =>
26
+ fees_estimate_request.to_camelize
27
+ }
28
+ end
29
+ end
30
+
31
+ class FeesEstimateRequest
32
+ attr_accessor :marketplace_id, :price_to_estimate_fees, :identifier, :is_amazon_fulfilled,
33
+ :optional_fulfillment_program
34
+
35
+ def initialize(marketplace_id, price, currency_code, shipping, points, identifier, is_amazon_fulfilled,
36
+ optional_fulfillment_program)
37
+ @marketplace_id = marketplace_id
38
+ @price_to_estimate_fees = PriceToEstimateFees.new(price, currency_code, shipping, points)
39
+ @identifier = identifier
40
+ @is_amazon_fulfilled = is_amazon_fulfilled
41
+ @optional_fulfillment_program = optional_fulfillment_program if is_amazon_fulfilled
42
+ end
43
+
44
+ def to_camelize
45
+ {
46
+ "Identifier" => identifier,
47
+ "IsAmazonFulfilled" => is_amazon_fulfilled,
48
+ "MarketplaceId" => marketplace_id,
49
+ "OptionalFulfillmentProgram" => optional_fulfillment_program,
50
+ "PriceToEstimateFees" => price_to_estimate_fees.to_camelize
51
+ }
52
+ end
53
+ end
54
+
55
+ class PriceToEstimateFees
56
+ attr_accessor :listing_price, :shipping, :points
57
+
58
+ def initialize(listing_price, currency_code = MoneyType::USD, shipping = nil, points = nil)
59
+ @listing_price = MoneyType.new(listing_price, currency_code)
60
+ @shipping = MoneyType.new(shipping, currency_code) if shipping
61
+ @points = points if points
62
+ end
63
+
64
+ def to_camelize
65
+ { "ListingPrice" => listing_price.to_camelize }
66
+ end
67
+ end
68
+
69
+ class MoneyType
70
+ USD = "USD"
71
+ EUR = "EUR"
72
+ GBP = "GBP"
73
+ RMB = "RMB"
74
+ INR = "INR"
75
+ JPY = "JPY"
76
+ CAD = "CAD"
77
+ MXN = "MXN"
78
+
79
+ attr_accessor :amount, :currency_code
80
+
81
+ def initialize(amount, currency_code = USD)
82
+ @amount = amount.to_f
83
+ @currency_code = currency_code
84
+ end
85
+
86
+ def to_camelize
87
+ {
88
+ "Amount" => amount,
89
+ "CurrencyCode" => currency_code
90
+ }
91
+ end
92
+ end
93
+ 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: 1.4.5
4
+ version: 1.4.7
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: 2022-08-22 00:00:00.000000000 Z
13
+ date: 2022-09-23 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -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
@@ -139,21 +139,31 @@ files:
139
139
  - bin/setup
140
140
  - lib/muffin_man.rb
141
141
  - lib/muffin_man/authorization/v1.rb
142
+ - lib/muffin_man/catalog_items/base_api.rb
142
143
  - lib/muffin_man/catalog_items/v20201201.rb
144
+ - lib/muffin_man/catalog_items/v20220401.rb
143
145
  - lib/muffin_man/finances/v0.rb
146
+ - lib/muffin_man/fulfillment_inbound/v0.rb
147
+ - lib/muffin_man/listings/v20210801.rb
144
148
  - lib/muffin_man/lwa/auth_helper.rb
145
149
  - lib/muffin_man/orders/v0.rb
150
+ - lib/muffin_man/product_fees/v0.rb
151
+ - lib/muffin_man/product_pricing/v0.rb
146
152
  - lib/muffin_man/reports/v20210630.rb
153
+ - lib/muffin_man/request_helpers.rb
154
+ - lib/muffin_man/request_helpers/base.rb
155
+ - lib/muffin_man/request_helpers/inbound_shipment_plan_request_item.rb
147
156
  - lib/muffin_man/solicitations/v1.rb
148
157
  - lib/muffin_man/sp_api_client.rb
149
158
  - lib/muffin_man/tokens/v20210301.rb
150
159
  - lib/muffin_man/version.rb
160
+ - lib/sp_api_helpers.rb
151
161
  - muffin_man.gemspec
152
162
  homepage: https://github.com/patterninc/muffin_man
153
163
  licenses:
154
164
  - MIT
155
165
  metadata: {}
156
- post_install_message:
166
+ post_install_message:
157
167
  rdoc_options: []
158
168
  require_paths:
159
169
  - lib
@@ -168,8 +178,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
178
  - !ruby/object:Gem::Version
169
179
  version: '0'
170
180
  requirements: []
171
- rubygems_version: 3.1.6
172
- signing_key:
181
+ rubygems_version: 3.0.3
182
+ signing_key:
173
183
  specification_version: 4
174
184
  summary: Amazon Selling Partner API client
175
185
  test_files: []