class AmzSpApi::SalesApiModel::SalesApi
Attributes
Public Class Methods
# File lib/sales-api-model/api/sales_api.rb, line 16 def initialize(api_client = ApiClient.default) @api_client = api_client end
Public Instance Methods
Returns aggregated order metrics for given interval, broken down by granularity, for given buyer type. **Usage Plan:** | Rate (requests per second) | Burst | | —- | —- | | .5 | 15 | For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation. @param marketplace_ids A list of marketplace identifiers. Example: ATVPDKIKX0DER indicates the US marketplace. @param interval A time interval used for selecting order metrics. This takes the form of two dates separated by two hyphens (first date is inclusive; second date is exclusive). Dates are in ISO8601 format and must represent absolute time (either Z notation or offset notation). Example: 2018-09-01T00:00:00-07:00–2018-09-04T00:00:00-07:00 requests order metrics for Sept 1st, 2nd and 3rd in the -07:00 zone. @param granularity The granularity of the grouping of order metrics, based on a unit of time. Specifying granularity=Hour results in a successful request only if the interval specified is less than or equal to 30 days from now. For all other granularities, the interval specified must be less or equal to 2 years from now. Specifying granularity=Total results in order metrics that are aggregated over the entire interval that you specify. If the interval start and end date don’t align with the specified granularity, the head and tail end of the response interval will contain partial data. Example: Day to get a daily breakdown of the request interval, where the day boundary is defined by the granularityTimeZone. @param [Hash] opts the optional parameters @option opts [String] :granularity_time_zone 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. @option opts [String] :buyer_type 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) @option opts [String] :fulfillment_network 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. @option opts [String] :first_day_of_week 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) @option opts [String] :asin 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. @option opts [String] :sku 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. @return [GetOrderMetricsResponse]
# File lib/sales-api-model/api/sales_api.rb, line 31 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
Returns aggregated order metrics for given interval, broken down by granularity, for given buyer type. **Usage Plan:** | Rate (requests per second) | Burst | | —- | —- | | .5 | 15 | For more information, see "Usage Plans and Rate Limits" in the Selling Partner API documentation. @param marketplace_ids A list of marketplace identifiers. Example: ATVPDKIKX0DER indicates the US marketplace. @param interval A time interval used for selecting order metrics. This takes the form of two dates separated by two hyphens (first date is inclusive; second date is exclusive). Dates are in ISO8601 format and must represent absolute time (either Z notation or offset notation). Example: 2018-09-01T00:00:00-07:00–2018-09-04T00:00:00-07:00 requests order metrics for Sept 1st, 2nd and 3rd in the -07:00 zone. @param granularity The granularity of the grouping of order metrics, based on a unit of time. Specifying granularity=Hour results in a successful request only if the interval specified is less than or equal to 30 days from now. For all other granularities, the interval specified must be less or equal to 2 years from now. Specifying granularity=Total results in order metrics that are aggregated over the entire interval that you specify. If the interval start and end date don’t align with the specified granularity, the head and tail end of the response interval will contain partial data. Example: Day to get a daily breakdown of the request interval, where the day boundary is defined by the granularityTimeZone. @param [Hash] opts the optional parameters @option opts [String] :granularity_time_zone 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. @option opts [String] :buyer_type 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. @option opts [String] :fulfillment_network 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. @option opts [String] :first_day_of_week 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. @option opts [String] :asin 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. @option opts [String] :sku 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. @return [Array<(GetOrderMetricsResponse
, Integer, Hash)>] GetOrderMetricsResponse
data, response status code and response headers
# File lib/sales-api-model/api/sales_api.rb, line 48 def get_order_metrics_with_http_info(marketplace_ids, interval, granularity, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: SalesApi.get_order_metrics ...' end # verify the required parameter 'marketplace_ids' is set if @api_client.config.client_side_validation && marketplace_ids.nil? fail ArgumentError, "Missing the required parameter 'marketplace_ids' when calling SalesApi.get_order_metrics" end # verify the required parameter 'interval' is set if @api_client.config.client_side_validation && interval.nil? fail ArgumentError, "Missing the required parameter 'interval' when calling SalesApi.get_order_metrics" end # verify the required parameter 'granularity' is set if @api_client.config.client_side_validation && granularity.nil? fail ArgumentError, "Missing the required parameter 'granularity' when calling SalesApi.get_order_metrics" end # verify enum value if @api_client.config.client_side_validation && !['Hour', 'Day', 'Week', 'Month', 'Year', 'Total'].include?(granularity) fail ArgumentError, "invalid value for 'granularity', must be one of Hour, Day, Week, Month, Year, Total" end if @api_client.config.client_side_validation && opts[:'buyer_type'] && !['B2B', 'B2C', 'All'].include?(opts[:'buyer_type']) fail ArgumentError, 'invalid value for "buyer_type", must be one of B2B, B2C, All' end if @api_client.config.client_side_validation && opts[:'first_day_of_week'] && !['Monday', 'Sunday'].include?(opts[:'first_day_of_week']) fail ArgumentError, 'invalid value for "first_day_of_week", must be one of Monday, Sunday' end # 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'] if !opts[:'granularity_time_zone'].nil? query_params[:'buyerType'] = opts[:'buyer_type'] if !opts[:'buyer_type'].nil? query_params[:'fulfillmentNetwork'] = opts[:'fulfillment_network'] if !opts[:'fulfillment_network'].nil? query_params[:'firstDayOfWeek'] = opts[:'first_day_of_week'] if !opts[:'first_day_of_week'].nil? query_params[:'asin'] = opts[:'asin'] if !opts[:'asin'].nil? query_params[:'sku'] = opts[:'sku'] if !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) if @api_client.config.debugging @api_client.config.logger.debug "API called: SalesApi#get_order_metrics\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end