Class: AmznSpApi::SalesApiModel::SalesApi

Inherits:
Object
  • Object
show all
Defined in:
lib/sales_api_model/api/sales_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ SalesApi



14
15
16
# File 'lib/sales_api_model/api/sales_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/sales_api_model/api/sales_api.rb', line 12

def api_client
  @api_client
end

Instance Method Details

#get_order_metrics(marketplace_ids, interval, granularity, opts = {}) ⇒ GetOrderMetricsResponse

Returns aggregated order metrics for given interval, broken down by granularity, for given buyer type. **Usage Plan:** | Rate (requests per second) | Burst | | —- | —- | | .5 | 15 | 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 see higher rate and burst values than those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](doc:usage-plans-and-rate-limits-in-the-sp-api).

Options Hash (opts):

  • :granularity_time_zone (String)

    An IANA-compatible time zone for determining the day boundary. Required when specifying a granularity value greater than Hour. The granularityTimeZone value must align with the offset of the specified interval value. For example, if the interval value uses Z notation, then granularityTimeZone must be UTC. If the interval value uses an offset, then granularityTimeZone must be an IANA-compatible time zone that matches the offset. Example: US/Pacific to compute day boundaries, accounting for daylight time savings, for US/Pacific zone.

  • :buyer_type (String)

    Filters the results by the buyer type that you specify, B2B (business to business) or B2C (business to customer). Example: B2B, if you want the response to include order metrics for only B2B buyers. (default to All)

  • :fulfillment_network (String)

    Filters the results by the fulfillment network that you specify, MFN (merchant fulfillment network) or AFN (Amazon fulfillment network). Do not include this filter if you want the response to include order metrics for all fulfillment networks. Example: AFN, if you want the response to include order metrics for only Amazon fulfillment network.

  • :first_day_of_week (String)

    Specifies the day that the week starts on when granularity=Week, either Monday or Sunday. Default: Monday. Example: Sunday, if you want the week to start on a Sunday. (default to Monday)

  • :asin (String)

    Filters the results by the ASIN that you specify. Specifying both ASIN and SKU returns an error. Do not include this filter if you want the response to include order metrics for all ASINs. Example: B0792R1RSN, if you want the response to include order metrics for only ASIN B0792R1RSN.

  • :sku (String)

    Filters the results by the SKU that you specify. Specifying both ASIN and SKU returns an error. Do not include this filter if you want the response to include order metrics for all SKUs. Example: TestSKU, if you want the response to include order metrics for only SKU TestSKU.



30
31
32
33
# File 'lib/sales_api_model/api/sales_api.rb', line 30

def get_order_metrics(marketplace_ids, interval, granularity, opts = {})
  data, _status_code, _headers = get_order_metrics_with_http_info(marketplace_ids, interval, granularity, opts)
  data
end

#get_order_metrics_with_http_info(marketplace_ids, interval, granularity, opts = {}) ⇒ Array<(GetOrderMetricsResponse, Integer, Hash)>

Returns aggregated order metrics for given interval, broken down by granularity, for given buyer type. **Usage Plan:** | Rate (requests per second) | Burst | | —- | —- | | .5 | 15 | 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 see higher rate and burst values than those shown here. For more information, see [Usage Plans and Rate Limits in the Selling Partner API](doc:usage-plans-and-rate-limits-in-the-sp-api).

Options Hash (opts):

  • :granularity_time_zone (String)

    An IANA-compatible time zone for determining the day boundary. Required when specifying a granularity value greater than Hour. The granularityTimeZone value must align with the offset of the specified interval value. For example, if the interval value uses Z notation, then granularityTimeZone must be UTC. If the interval value uses an offset, then granularityTimeZone must be an IANA-compatible time zone that matches the offset. Example: US/Pacific to compute day boundaries, accounting for daylight time savings, for US/Pacific zone.

  • :buyer_type (String)

    Filters the results by the buyer type that you specify, B2B (business to business) or B2C (business to customer). Example: B2B, if you want the response to include order metrics for only B2B buyers.

  • :fulfillment_network (String)

    Filters the results by the fulfillment network that you specify, MFN (merchant fulfillment network) or AFN (Amazon fulfillment network). Do not include this filter if you want the response to include order metrics for all fulfillment networks. Example: AFN, if you want the response to include order metrics for only Amazon fulfillment network.

  • :first_day_of_week (String)

    Specifies the day that the week starts on when granularity&#x3D;Week, either Monday or Sunday. Default: Monday. Example: Sunday, if you want the week to start on a Sunday.

  • :asin (String)

    Filters the results by the ASIN that you specify. Specifying both ASIN and SKU returns an error. Do not include this filter if you want the response to include order metrics for all ASINs. Example: B0792R1RSN, if you want the response to include order metrics for only ASIN B0792R1RSN.

  • :sku (String)

    Filters the results by the SKU that you specify. Specifying both ASIN and SKU returns an error. Do not include this filter if you want the response to include order metrics for all SKUs. Example: TestSKU, if you want the response to include order metrics for only SKU TestSKU.

Raises:

  • (ArgumentError)


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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/sales_api_model/api/sales_api.rb', line 47

def get_order_metrics_with_http_info(marketplace_ids, interval, granularity, opts = {})
  @api_client.config.logger.debug 'Calling API: SalesApi.get_order_metrics ...' if @api_client.config.debugging
  # verify the required parameter 'marketplace_ids' is set
  raise ArgumentError, "Missing the required parameter 'marketplace_ids' when calling SalesApi.get_order_metrics" if @api_client.config.client_side_validation && marketplace_ids.nil?
  # verify the required parameter 'interval' is set
  raise ArgumentError, "Missing the required parameter 'interval' when calling SalesApi.get_order_metrics" if @api_client.config.client_side_validation && interval.nil?
  # verify the required parameter 'granularity' is set
  raise ArgumentError, "Missing the required parameter 'granularity' when calling SalesApi.get_order_metrics" if @api_client.config.client_side_validation && granularity.nil?
  # verify enum value
  raise ArgumentError, "invalid value for 'granularity', must be one of Hour, Day, Week, Month, Year, Total" if @api_client.config.client_side_validation && !%w[Hour Day Week Month Year Total].include?(granularity)
  raise ArgumentError, 'invalid value for "buyer_type", must be one of B2B, B2C, All' if @api_client.config.client_side_validation && opts[:buyer_type] && !%w[B2B B2C All].include?(opts[:buyer_type])
  raise ArgumentError, 'invalid value for "first_day_of_week", must be one of Monday, Sunday' if @api_client.config.client_side_validation && opts[:first_day_of_week] && !%w[Monday Sunday].include?(opts[:first_day_of_week])

  # resource path
  local_var_path = '/sales/v1/orderMetrics'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:marketplaceIds] = @api_client.build_collection_param(marketplace_ids, :csv)
  query_params[:interval] = interval
  query_params[:granularity] = granularity
  query_params[:granularityTimeZone] = opts[:granularity_time_zone] unless opts[:granularity_time_zone].nil?
  query_params[:buyerType] = opts[:buyer_type] unless opts[:buyer_type].nil?
  query_params[:fulfillmentNetwork] = opts[:fulfillment_network] unless opts[:fulfillment_network].nil?
  query_params[:firstDayOfWeek] = opts[:first_day_of_week] unless opts[:first_day_of_week].nil?
  query_params[:asin] = opts[:asin] unless opts[:asin].nil?
  query_params[:sku] = opts[:sku] unless opts[:sku].nil?

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

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

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

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

  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: SalesApi#get_order_metrics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" if @api_client.config.debugging
  [data, status_code, headers]
end