Class: AmznSpApi::CatalogItemsApiModel::CatalogApi

Inherits:
Object
  • Object
show all
Defined in:
lib/catalog_items_api_model/api/catalog_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ CatalogApi

Returns a new instance of CatalogApi.



14
15
16
# File 'lib/catalog_items_api_model/api/catalog_api.rb', line 14

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



12
13
14
# File 'lib/catalog_items_api_model/api/catalog_api.rb', line 12

def api_client
  @api_client
end

Instance Method Details

#get_catalog_item(asin, marketplace_ids, opts = {}) ⇒ Item

Retrieves details for an item in the Amazon catalog. **Usage Plan:** | Rate (requests per second) | Burst | | —- | —- | | 2 | 2 | The ‘x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may observe higher rate and burst values than those shown here. For more information, refer to the [Usage Plans and Rate Limits in the Selling Partner API](doc:usage-plans-and-rate-limits-in-the-sp-api).

Parameters:

  • asin

    The Amazon Standard Identification Number (ASIN) of the item.

  • marketplace_ids

    A comma-delimited list of Amazon marketplace identifiers. Data sets in the response contain data only for the specified marketplaces.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :included_data (Array<String>)

    A comma-delimited list of data sets to include in the response. Default: &#x60;summaries&#x60;.

  • :locale (String)

    Locale for retrieving localized summaries. Defaults to the primary locale of the marketplace.

Returns:



25
26
27
28
# File 'lib/catalog_items_api_model/api/catalog_api.rb', line 25

def get_catalog_item(asin, marketplace_ids, opts = {})
  data, _status_code, _headers = get_catalog_item_with_http_info(asin, marketplace_ids, opts)
  data
end

#get_catalog_item_with_http_info(asin, marketplace_ids, opts = {}) ⇒ Array<(Item, Integer, Hash)>

Retrieves details for an item in the Amazon catalog. **Usage Plan:** | Rate (requests per second) | Burst | | —- | —- | | 2 | 2 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may observe higher rate and burst values than those shown here. For more information, refer to the [Usage Plans and Rate Limits in the Selling Partner API](doc:usage-plans-and-rate-limits-in-the-sp-api).

Parameters:

  • asin

    The Amazon Standard Identification Number (ASIN) of the item.

  • marketplace_ids

    A comma-delimited list of Amazon marketplace identifiers. Data sets in the response contain data only for the specified marketplaces.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :included_data (Array<String>)

    A comma-delimited list of data sets to include in the response. Default: &#x60;summaries&#x60;.

  • :locale (String)

    Locale for retrieving localized summaries. Defaults to the primary locale of the marketplace.

Returns:

  • (Array<(Item, Integer, Hash)>)

    Item data, response status code and response headers

Raises:

  • (ArgumentError)


37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/catalog_items_api_model/api/catalog_api.rb', line 37

def get_catalog_item_with_http_info(asin, marketplace_ids, opts = {})
  @api_client.config.logger.debug 'Calling API: CatalogApi.get_catalog_item ...' if @api_client.config.debugging
  # verify the required parameter 'asin' is set
  raise ArgumentError, "Missing the required parameter 'asin' when calling CatalogApi.get_catalog_item" if @api_client.config.client_side_validation && asin.nil?
  # verify the required parameter 'marketplace_ids' is set
  raise ArgumentError, "Missing the required parameter 'marketplace_ids' when calling CatalogApi.get_catalog_item" if @api_client.config.client_side_validation && marketplace_ids.nil?
  raise ArgumentError, 'invalid value for "included_data", must include one of attributes, dimensions, identifiers, images, productTypes, relationships, salesRanks, summaries, vendorDetails' if @api_client.config.client_side_validation && opts[:included_data] && !opts[:included_data].all? { |item| %w[attributes dimensions identifiers images productTypes relationships salesRanks summaries vendorDetails].include?(item) }

  # resource path
  local_var_path = '/catalog/2022-04-01/items/{asin}'.sub('{' + 'asin' + '}', asin.to_s)

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:marketplaceIds] = @api_client.build_collection_param(marketplace_ids, :csv)
  query_params[:includedData] = @api_client.build_collection_param(opts[:included_data], :csv) unless opts[:included_data].nil?
  query_params[:locale] = opts[:locale] unless opts[:locale].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body]

  return_type = opts[:return_type] || 'Item'

  auth_names = opts[:auth_names] || []
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
                                                    header_params: header_params,
                                                    query_params: query_params,
                                                    form_params: form_params,
                                                    body: post_body,
                                                    auth_names: auth_names,
                                                    return_type: return_type)

  @api_client.config.logger.debug "API called: CatalogApi#get_catalog_item\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" if @api_client.config.debugging
  [data, status_code, headers]
end

#search_catalog_items(marketplace_ids, opts = {}) ⇒ ItemSearchResults

Search for and return a list of Amazon catalog items and associated information either by identifier or by keywords. **Usage Plans:** | Rate (requests per second) | Burst | | —- | —- | | 2 | 2 | The ‘x-amzn-RateLimit-Limit` response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may observe higher rate and burst values than those shown here. For more information, refer to the [Usage Plans and Rate Limits in the Selling Partner API](doc:usage-plans-and-rate-limits-in-the-sp-api).

Parameters:

  • marketplace_ids

    A comma-delimited list of Amazon marketplace identifiers for the request.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :identifiers (Array<String>)

    A comma-delimited list of product identifiers to search the Amazon catalog for. Note: Cannot be used with &#x60;keywords&#x60;.

  • :identifiers_type (String)

    Type of product identifiers to search the Amazon catalog for. Note: Required when &#x60;identifiers&#x60; are provided.

  • :included_data (Array<String>)

    A comma-delimited list of data sets to include in the response. Default: &#x60;summaries&#x60;.

  • :locale (String)

    Locale for retrieving localized summaries. Defaults to the primary locale of the marketplace.

  • :seller_id (String)

    A selling partner identifier, such as a seller account or vendor code. Note: Required when &#x60;identifiersType&#x60; is &#x60;SKU&#x60;.

  • :keywords (Array<String>)

    A comma-delimited list of words to search the Amazon catalog for. Note: Cannot be used with &#x60;identifiers&#x60;.

  • :brand_names (Array<String>)

    A comma-delimited list of brand names to limit the search for &#x60;keywords&#x60;-based queries. Note: Cannot be used with &#x60;identifiers&#x60;.

  • :classification_ids (Array<String>)

    A comma-delimited list of classification identifiers to limit the search for &#x60;keywords&#x60;-based queries. Note: Cannot be used with &#x60;identifiers&#x60;.

  • :page_size (Integer)

    Number of results to be returned per page. (default to 10)

  • :page_token (String)

    A token to fetch a certain page when there are multiple pages worth of results.

  • :keywords_locale (String)

    The language of the keywords provided for &#x60;keywords&#x60;-based queries. Defaults to the primary locale of the marketplace. Note: Cannot be used with &#x60;identifiers&#x60;.

Returns:



95
96
97
98
# File 'lib/catalog_items_api_model/api/catalog_api.rb', line 95

def search_catalog_items(marketplace_ids, opts = {})
  data, _status_code, _headers = search_catalog_items_with_http_info(marketplace_ids, opts)
  data
end

#search_catalog_items_with_http_info(marketplace_ids, opts = {}) ⇒ Array<(ItemSearchResults, Integer, Hash)>

Search for and return a list of Amazon catalog items and associated information either by identifier or by keywords. **Usage Plans:** | Rate (requests per second) | Burst | | —- | —- | | 2 | 2 | The &#x60;x-amzn-RateLimit-Limit&#x60; response header returns the usage plan rate limits that were applied to the requested operation, when available. The table above indicates the default rate and burst values for this operation. Selling partners whose business demands require higher throughput may observe higher rate and burst values than those shown here. For more information, refer to the [Usage Plans and Rate Limits in the Selling Partner API](doc:usage-plans-and-rate-limits-in-the-sp-api).

Parameters:

  • marketplace_ids

    A comma-delimited list of Amazon marketplace identifiers for the request.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :identifiers (Array<String>)

    A comma-delimited list of product identifiers to search the Amazon catalog for. Note: Cannot be used with &#x60;keywords&#x60;.

  • :identifiers_type (String)

    Type of product identifiers to search the Amazon catalog for. Note: Required when &#x60;identifiers&#x60; are provided.

  • :included_data (Array<String>)

    A comma-delimited list of data sets to include in the response. Default: &#x60;summaries&#x60;.

  • :locale (String)

    Locale for retrieving localized summaries. Defaults to the primary locale of the marketplace.

  • :seller_id (String)

    A selling partner identifier, such as a seller account or vendor code. Note: Required when &#x60;identifiersType&#x60; is &#x60;SKU&#x60;.

  • :keywords (Array<String>)

    A comma-delimited list of words to search the Amazon catalog for. Note: Cannot be used with &#x60;identifiers&#x60;.

  • :brand_names (Array<String>)

    A comma-delimited list of brand names to limit the search for &#x60;keywords&#x60;-based queries. Note: Cannot be used with &#x60;identifiers&#x60;.

  • :classification_ids (Array<String>)

    A comma-delimited list of classification identifiers to limit the search for &#x60;keywords&#x60;-based queries. Note: Cannot be used with &#x60;identifiers&#x60;.

  • :page_size (Integer)

    Number of results to be returned per page.

  • :page_token (String)

    A token to fetch a certain page when there are multiple pages worth of results.

  • :keywords_locale (String)

    The language of the keywords provided for &#x60;keywords&#x60;-based queries. Defaults to the primary locale of the marketplace. Note: Cannot be used with &#x60;identifiers&#x60;.

Returns:

  • (Array<(ItemSearchResults, Integer, Hash)>)

    ItemSearchResults data, response status code and response headers

Raises:

  • (ArgumentError)


115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/catalog_items_api_model/api/catalog_api.rb', line 115

def search_catalog_items_with_http_info(marketplace_ids, opts = {})
  @api_client.config.logger.debug 'Calling API: CatalogApi.search_catalog_items ...' if @api_client.config.debugging
  # verify the required parameter 'marketplace_ids' is set
  raise ArgumentError, "Missing the required parameter 'marketplace_ids' when calling CatalogApi.search_catalog_items" if @api_client.config.client_side_validation && marketplace_ids.nil?
  raise ArgumentError, 'invalid value for "identifiers_type", must be one of ASIN, EAN, GTIN, ISBN, JAN, MINSAN, SKU, UPC' if @api_client.config.client_side_validation && opts[:identifiers_type] && !%w[ASIN EAN GTIN ISBN JAN MINSAN SKU UPC].include?(opts[:identifiers_type])
  raise ArgumentError, 'invalid value for "included_data", must include one of attributes, dimensions, identifiers, images, productTypes, relationships, salesRanks, summaries, vendorDetails' if @api_client.config.client_side_validation && opts[:included_data] && !opts[:included_data].all? { |item| %w[attributes dimensions identifiers images productTypes relationships salesRanks summaries vendorDetails].include?(item) }

  # resource path
  local_var_path = '/catalog/2022-04-01/items'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:marketplaceIds] = @api_client.build_collection_param(marketplace_ids, :csv)
  query_params[:identifiers] = @api_client.build_collection_param(opts[:identifiers], :csv) unless opts[:identifiers].nil?
  query_params[:identifiersType] = opts[:identifiers_type] unless opts[:identifiers_type].nil?
  query_params[:includedData] = @api_client.build_collection_param(opts[:included_data], :csv) unless opts[:included_data].nil?
  query_params[:locale] = opts[:locale] unless opts[:locale].nil?
  query_params[:sellerId] = opts[:seller_id] unless opts[:seller_id].nil?
  query_params[:keywords] = @api_client.build_collection_param(opts[:keywords], :csv) unless opts[:keywords].nil?
  query_params[:brandNames] = @api_client.build_collection_param(opts[:brand_names], :csv) unless opts[:brand_names].nil?
  query_params[:classificationIds] = @api_client.build_collection_param(opts[:classification_ids], :csv) unless opts[:classification_ids].nil?
  query_params[:pageSize] = opts[:page_size] unless opts[:page_size].nil?
  query_params[:pageToken] = opts[:page_token] unless opts[:page_token].nil?
  query_params[:keywordsLocale] = opts[:keywords_locale] unless opts[:keywords_locale].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body]

  return_type = opts[:return_type] || 'ItemSearchResults'

  auth_names = opts[:auth_names] || []
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
                                                    header_params: header_params,
                                                    query_params: query_params,
                                                    form_params: form_params,
                                                    body: post_body,
                                                    auth_names: auth_names,
                                                    return_type: return_type)

  @api_client.config.logger.debug "API called: CatalogApi#search_catalog_items\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" if @api_client.config.debugging
  [data, status_code, headers]
end