Class: MuffinMan::Listings::V20200901

Inherits:
SpApiClient show all
Defined in:
lib/muffin_man/listings/v20200901.rb

Constant Summary collapse

REQUIREMENTS =
%w[LISTING LISTING_PRODUCT_ONLY LISTING_OFFER_ONLY].freeze
REQUIREMENTS_ENFORCED =
%w[ENFORCED NOT_ENFORCED].freeze
LOCALE =
%w[DEFAULT ar ar_AE de de_DE en en_AE en_AU en_CA en_GB en_IN en_SG en_US es es_ES es_MX es_US fr
   fr_CA fr_FR it it_IT ja ja_JP nl nl_NL pl pl_PL pt pt_BR pt_PT sv sv_SE tr tr_TR zh zh_CN zh_TW]
.freeze
PRODUCT_TYPES_PATH =
"/definitions/2020-09-01/productTypes"

Constants inherited from SpApiClient

SpApiClient::ACCESS_TOKEN_URL, SpApiClient::AWS_REGION_MAP, SpApiClient::SERVICE_NAME, SpApiClient::UNPROCESSABLE_ENTITY_STATUS_CODE

Instance Attribute Summary

Attributes inherited from SpApiClient

#access_token_cache_key, #aws_access_key_id, #aws_secret_access_key, #client_id, #client_secret, #config, #credentials, #local_var_path, #pii_data_elements, #query_params, #refresh_token, #region, #request_body, #request_type, #sandbox, #scope, #sts_iam_role_arn

Instance Method Summary collapse

Methods inherited from SpApiClient

#initialize

Constructor Details

This class inherits a constructor from MuffinMan::SpApiClient

Instance Method Details

#get_definitions_product_type(product_type, marketplace_ids, options = {}) ⇒ Object

rubocop:disable Metrics/CyclomaticComplexity rubocop:disable Metrics/PerceivedComplexity



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/muffin_man/listings/v20200901.rb', line 24

def get_definitions_product_type(product_type, marketplace_ids, options = {})
  options = options.with_indifferent_access
  @local_var_path = "#{PRODUCT_TYPES_PATH}/#{product_type}"
  @marketplace_ids = marketplace_ids.is_a?(Array) ? marketplace_ids : [marketplace_ids]
  @query_params = { "marketplaceIds" => @marketplace_ids.join(",") }
  @query_params["sellerId"] = options["sellerId"] if options["sellerId"]
  @query_params["productTypeVersion"] = options["productTypeVersion"].upcase if options["productTypeVersion"]
  if REQUIREMENTS.include?(options["requirements"]&.upcase)
    @query_params["requirements"] = options["requirements"].upcase
  end

  if REQUIREMENTS_ENFORCED.include?(options["requirementsEnforced"]&.upcase)
    @query_params["requirementsEnforced"] = options["requirementsEnforced"].upcase
  end

  @query_params["locale"] = options["locale"] if LOCALE.include?(options["locale"])

  @request_type = "GET"
  call_api
end

#search_definitions_product_types(marketplace_ids, keywords = nil) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/muffin_man/listings/v20200901.rb', line 13

def search_definitions_product_types(marketplace_ids, keywords = nil)
  @local_var_path = PRODUCT_TYPES_PATH
  @marketplace_ids = marketplace_ids.is_a?(Array) ? marketplace_ids : [marketplace_ids]
  @query_params = { "marketplaceIds" => @marketplace_ids.join(",") }
  @query_params["keywords"] = keywords if keywords.present?
  @request_type = "GET"
  call_api
end