muffin_man 1.4.5 → 1.4.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b464f989ff6561fcd595fa4e635537b955d4b4335ebe5932df370d6c837587a8
4
- data.tar.gz: 4dd6ce7d1228112f15e39017d83f87a8e6606eef8504766da7719d3ec764a414
3
+ metadata.gz: 062bcf57cb27afd95911a7bac99717cd9f4b070c429013584cddfe3cbf661886
4
+ data.tar.gz: 5dc42d8a414afd0d973dca6b8266b53f84a4492daf8b4b7bd3067b59f874a634
5
5
  SHA512:
6
- metadata.gz: 1d3ac2b501430a907d228b9c8d8bde739b668a2b3a18989b11893f3951c1fda2d72d427e54744aadc59f13bdec49923af9b12514c937f42e3ca0dd057f95b956
7
- data.tar.gz: c7826e357ef7a75a5aa67825139faf7dd5374af2edd15c283520f5292fbddc82c33c909f9c5df52acc374062ac351ea4d79b8ec100f001c38cb36413191d9eac
6
+ metadata.gz: d725f54db9a3286ee469912f636187dc5de0b2dde1e2cd7af0430b981984d6c08a1ef2ea6afe1c747b960b3a5a067b29714a6a023a00e4b31fed300700702885
7
+ data.tar.gz: 2a317b00e4afc4107085a2ab4c6447f8e79074a824f1b8df2e969ffffaef59ee0237deb4c1b0b3b7ee9d68df0d48dfa3d3dd85826ce63c06c5d8182f9fdfb60f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ # 1.4.6
2
+
3
+ - Support for Catalog API's of version 20220401 [#22](https://github.com/patterninc/muffin_man/pull/22)
4
+
5
+ # 1.4.5
6
+
7
+ - Support for GetCompetitivePricing endpoint [#19] (https://github.com/patterninc/muffin_man/pull/19)
8
+
1
9
  # 1.4.4
2
10
 
3
11
  - 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,16 @@
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
+ end
15
+ end
16
+ 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
@@ -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.6"
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,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.5
4
+ version: 1.4.6
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-08-22 00:00:00.000000000 Z
13
+ date: 2022-09-21 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -139,15 +139,22 @@ 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
147
153
  - lib/muffin_man/solicitations/v1.rb
148
154
  - lib/muffin_man/sp_api_client.rb
149
155
  - lib/muffin_man/tokens/v20210301.rb
150
156
  - lib/muffin_man/version.rb
157
+ - lib/sp_api_helpers.rb
151
158
  - muffin_man.gemspec
152
159
  homepage: https://github.com/patterninc/muffin_man
153
160
  licenses: