Class: Peddler::APIs::Reports20210630

Inherits:
Peddler::API show all
Includes:
Helpers::Reports20210630
Defined in:
lib/peddler/apis/reports_2021_06_30.rb,
lib/peddler/apis/reports_2021_06_30/error.rb,
lib/peddler/apis/reports_2021_06_30/report.rb,
lib/peddler/apis/reports_2021_06_30/error_list.rb,
lib/peddler/apis/reports_2021_06_30/report_list.rb,
lib/peddler/apis/reports_2021_06_30/report_document.rb,
lib/peddler/apis/reports_2021_06_30/report_schedule.rb,
lib/peddler/apis/reports_2021_06_30/get_reports_response.rb,
lib/peddler/apis/reports_2021_06_30/report_schedule_list.rb,
lib/peddler/apis/reports_2021_06_30/create_report_response.rb,
lib/peddler/apis/reports_2021_06_30/create_report_specification.rb,
lib/peddler/apis/reports_2021_06_30/create_report_schedule_response.rb,
lib/peddler/apis/reports_2021_06_30/create_report_schedule_specification.rb

Overview

Selling Partner API for Reports

The Selling Partner API for Reports lets you retrieve and manage a variety of reports that can help selling partners manage their businesses.

Defined Under Namespace

Classes: ReportList

Constant Summary collapse

Error =

Error response returned when the request is unsuccessful.

Structure.new do
  # @return [String] An error code that identifies the type of error that occurred.
  attribute(:code, String)

  # @return [String] A message that describes the error condition.
  attribute(:message, String)

  # @return [String] Additional details that can help the caller understand or fix the issue.
  attribute?(:details, String)
end
Report =

Detailed information about the report.

Structure.new do
  # @return [Time] The date and time when the report was created.
  attribute(:created_time, Time, from: "createdTime")

  # @return [String] The processing status of the report.
  attribute(:processing_status, String, from: "processingStatus")

  # @return [String] The identifier for the report. This identifier is unique only in combination with a seller
  # ID.
  attribute(:report_id, String, from: "reportId")

  # @return [String] The report type. Refer to [Report Type
  # Values](https://developer-docs.amazon.com/sp-api/docs/report-type-values) for more information.
  attribute(:report_type, String, from: "reportType")

  # @return [Time] The end of a date and time range used for selecting the data to report.
  attribute?(:data_end_time, Time, from: "dataEndTime")

  # @return [Time] The start of a date and time range used for selecting the data to report.
  attribute?(:data_start_time, Time, from: "dataStartTime")

  # @return [Array<String>] A list of marketplace identifiers for the report.
  attribute?(:marketplace_ids, [String], from: "marketplaceIds")

  # @return [Time] The date and time when the report processing completed, in
  # {https://developer-docs.amazon.com/sp-api/docs/iso-8601 ISO 8601} date time format.
  attribute?(:processing_end_time, Time, from: "processingEndTime")

  # @return [Time] The date and time when the report processing started, in
  # {https://developer-docs.amazon.com/sp-api/docs/iso-8601 ISO 8601} date time format.
  attribute?(:processing_start_time, Time, from: "processingStartTime")

  # @return [String] The identifier for the report document. Pass this into the `getReportDocument` operation to
  # get the information you will need to retrieve the report document's contents.
  attribute?(:report_document_id, String, from: "reportDocumentId")

  # @return [String] The identifier of the report schedule that created this report (if any). This identifier is
  # unique only in combination with a seller ID.
  attribute?(:report_schedule_id, String, from: "reportScheduleId")
end
ErrorList =

A list of error responses returned when a request is unsuccessful.

Structure.new do
  # @return [Array<Error>] Error response returned when the request is unsuccessful.
  attribute(:errors, [Error])
end
ReportDocument =

Information required for the report document.

Structure.new do
  # @return [String] The identifier for the report document. This identifier is unique only in combination with a
  # seller ID.
  attribute(:report_document_id, String, from: "reportDocumentId")

  # @return [String] A presigned URL for the report document. If `compressionAlgorithm` is not returned, you can
  # download the report directly from this URL. This URL expires after 5 minutes.
  attribute(:url, String)

  # @return [String] If the report document contents have been compressed, the compression algorithm used is
  # returned in this property and you must decompress the report when you download. Otherwise, you can download
  # the report directly. Refer to [Step 2. Download the
  # report](https://developer-docs.amazon.com/sp-api/docs/reports-api-v2021-06-30-retrieve-a-report#step-2-download-the-report)
  # in the use case guide, where sample code is provided.
  attribute?(:compression_algorithm, String, from: "compressionAlgorithm")
end
ReportSchedule =

Detailed information about a report schedule.

Structure.new do
  # @return [String] An {https://developer-docs.amazon.com/sp-api/docs/iso-8601 ISO 8601} period value that
  # indicates how often a report should be created.
  attribute(:period, String)

  # @return [String] The identifier for the report schedule. This identifier is unique only in combination with a
  # seller ID.
  attribute(:report_schedule_id, String, from: "reportScheduleId")

  # @return [String] The report type. Refer to [Report Type
  # Values](https://developer-docs.amazon.com/sp-api/docs/report-type-values) for more information.
  attribute(:report_type, String, from: "reportType")

  # @return [Array<String>] A list of marketplace identifiers. The report document's contents will contain data
  # for all of the specified marketplaces, unless the report type indicates otherwise.
  attribute?(:marketplace_ids, [String], from: "marketplaceIds")

  # @return [Time] The date and time when the schedule will create its next report, in
  # {https://developer-docs.amazon.com/sp-api/docs/iso-8601 ISO 8601} date time format.
  attribute?(:next_report_creation_time, Time, from: "nextReportCreationTime")

  # @return [Hash]
  attribute?(:report_options, Hash, from: "reportOptions")
end
GetReportsResponse =

The response for the getReports operation.

Structure.new do
  # @return [Array<Report>] The reports.
  attribute(:reports, [Report])

  # @return [String] Returned when the number of results exceeds `pageSize`. To get the next page of results, call
  # `getReports` with this token as the only parameter.
  attribute?(:next_token, String, from: "nextToken")
end
ReportScheduleList =

A list of report schedules.

Structure.new do
  # @return [Array<ReportSchedule>] Detailed information about a report schedule.
  attribute(:report_schedules, [ReportSchedule], from: "reportSchedules")
end
CreateReportResponse =

The response schema.

Structure.new do
  # @return [String] The identifier for the report. This identifier is unique only in combination with a seller
  # ID.
  attribute(:report_id, String, from: "reportId")
end
CreateReportSpecification =

Information required to create the report.

Structure.new do
  # @return [Array<String>] A list of marketplace identifiers. The report document's contents will contain data
  # for all of the specified marketplaces, unless the report type indicates otherwise.
  attribute(:marketplace_ids, [String], from: "marketplaceIds")

  # @return [String] The report type. Refer to [Report Type
  # Values](https://developer-docs.amazon.com/sp-api/docs/report-type-values) for more information.
  attribute(:report_type, String, from: "reportType")

  # @return [Time] The end of a date and time range, in {https://developer-docs.amazon.com/sp-api/docs/iso-8601
  # ISO 8601} date time format, used for selecting the data to report. The default is now. The value must be prior
  # to or equal to the current date and time. Not all report types make use of this.
  attribute?(:data_end_time, Time, from: "dataEndTime")

  # @return [Time] The start of a date and time range, in {https://developer-docs.amazon.com/sp-api/docs/iso-8601
  # ISO 8601} date time format, used for selecting the data to report. The default is now. The value must be prior
  # to or equal to the current date and time. Not all report types make use of this.
  attribute?(:data_start_time, Time, from: "dataStartTime")

  # @return [Hash]
  attribute?(:report_options, Hash, from: "reportOptions")
end
CreateReportScheduleResponse =

Response schema.

Structure.new do
  # @return [String] The identifier for the report schedule. This identifier is unique only in combination with a
  # seller ID.
  attribute(:report_schedule_id, String, from: "reportScheduleId")
end
CreateReportScheduleSpecification =

Information required to create the report schedule.

Structure.new do
  # @return [Array<String>] A list of marketplace identifiers for the report schedule.
  attribute(:marketplace_ids, [String], from: "marketplaceIds")

  # @return [String] One of a set of predefined {https://developer-docs.amazon.com/sp-api/docs/iso-8601 ISO 8601}
  # periods that specifies how often a report should be created.
  attribute(:period, String)

  # @return [String] The report type. Refer to [Report Type
  # Values](https://developer-docs.amazon.com/sp-api/docs/report-type-values) for more information.
  attribute(:report_type, String, from: "reportType")

  # @return [Time] The date and time when the schedule will create its next report, in
  # {https://developer-docs.amazon.com/sp-api/docs/iso-8601 ISO 8601} date time format.
  attribute?(:next_report_creation_time, Time, from: "nextReportCreationTime")

  # @return [Hash]
  attribute?(:report_options, Hash, from: "reportOptions")
end

Instance Attribute Summary

Attributes inherited from Peddler::API

#access_token, #endpoint, #retries

Instance Method Summary collapse

Methods included from Helpers::Reports20210630

#download_report_document

Methods inherited from Peddler::API

#endpoint_uri, #http, #initialize, #meter, #retriable, #sandbox, #sandbox?, #use, #via

Constructor Details

This class inherits a constructor from Peddler::API

Instance Method Details

#cancel_report(report_id, rate_limit: 0.0222) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Cancels the report that you specify. Only reports with processingStatus=IN_QUEUE can be cancelled. Cancelled reports are returned in subsequent calls to the getReport and getReports operations.

seller ID.

Parameters:

  • report_id (String)

    The identifier for the report. This identifier is unique only in combination with a

  • rate_limit (Float) (defaults to: 0.0222)

    Requests per second

Returns:



74
75
76
77
# File 'lib/peddler/apis/reports_2021_06_30.rb', line 74

def cancel_report(report_id, rate_limit: 0.0222)
  path = "/reports/2021-06-30/reports/#{percent_encode(report_id)}"
  meter(rate_limit).delete(path)
end

#cancel_report_schedule(report_schedule_id, rate_limit: 0.0222) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Cancels the report schedule that you specify.

combination with a seller ID.

Parameters:

  • report_schedule_id (String)

    The identifier for the report schedule. This identifier is unique only in

  • rate_limit (Float) (defaults to: 0.0222)

    Requests per second

Returns:



128
129
130
131
# File 'lib/peddler/apis/reports_2021_06_30.rb', line 128

def cancel_report_schedule(report_schedule_id, rate_limit: 0.0222)
  path = "/reports/2021-06-30/schedules/#{percent_encode(report_schedule_id)}"
  meter(rate_limit).delete(path)
end

#create_report(body, rate_limit: 0.0167) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Creates a report.

Parameters:

  • body (Hash)

    Information required to create the report.

  • rate_limit (Float) (defaults to: 0.0167)

    Requests per second

Returns:



60
61
62
63
64
# File 'lib/peddler/apis/reports_2021_06_30.rb', line 60

def create_report(body, rate_limit: 0.0167)
  path = "/reports/2021-06-30/reports"
  parser = -> { CreateReportResponse }
  meter(rate_limit).post(path, body:, parser:)
end

#create_report_schedule(body, rate_limit: 0.0222) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Creates a report schedule. If a report schedule with the same report type and marketplace IDs already exists, it will be cancelled and replaced with this one.

Parameters:

  • body (Hash)

    Information required to create the report schedule.

  • rate_limit (Float) (defaults to: 0.0222)

    Requests per second

Returns:



115
116
117
118
119
# File 'lib/peddler/apis/reports_2021_06_30.rb', line 115

def create_report_schedule(body, rate_limit: 0.0222)
  path = "/reports/2021-06-30/schedules"
  parser = -> { CreateReportScheduleResponse }
  meter(rate_limit).post(path, body:, parser:)
end

#get_report(report_id, rate_limit: 2.0) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Returns report details (including the reportDocumentId, if available) for the report that you specify.

seller ID.

Parameters:

  • report_id (String)

    The identifier for the report. This identifier is unique only in combination with a

  • rate_limit (Float) (defaults to: 2.0)

    Requests per second

Returns:



86
87
88
89
90
# File 'lib/peddler/apis/reports_2021_06_30.rb', line 86

def get_report(report_id, rate_limit: 2.0)
  path = "/reports/2021-06-30/reports/#{percent_encode(report_id)}"
  parser = -> { Report }
  meter(rate_limit).get(path, parser:)
end

#get_report_document(report_document_id, rate_limit: 0.0167) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Returns the information required for retrieving a report document's contents.

Parameters:

  • report_document_id (String)

    The identifier for the report document.

  • rate_limit (Float) (defaults to: 0.0167)

    Requests per second

Returns:



152
153
154
155
156
# File 'lib/peddler/apis/reports_2021_06_30.rb', line 152

def get_report_document(report_document_id, rate_limit: 0.0167)
  path = "/reports/2021-06-30/documents/#{percent_encode(report_document_id)}"
  parser = -> { ReportDocument }
  meter(rate_limit).get(path, parser:)
end

#get_report_schedule(report_schedule_id, rate_limit: 0.0222) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Returns report schedule details for the report schedule that you specify.

combination with a seller ID.

Parameters:

  • report_schedule_id (String)

    The identifier for the report schedule. This identifier is unique only in

  • rate_limit (Float) (defaults to: 0.0222)

    Requests per second

Returns:



140
141
142
143
144
# File 'lib/peddler/apis/reports_2021_06_30.rb', line 140

def get_report_schedule(report_schedule_id, rate_limit: 0.0222)
  path = "/reports/2021-06-30/schedules/#{percent_encode(report_schedule_id)}"
  parser = -> { ReportSchedule }
  meter(rate_limit).get(path, parser:)
end

#get_report_schedules(report_types, rate_limit: 0.0222) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Returns report schedule details that match the filters that you specify.

Type Values](https://developer-docs.amazon.com/sp-api/docs/report-type-values) for more information.

Parameters:

  • report_types (Array<String>)

    A list of report types used to filter report schedules. Refer to [Report

  • rate_limit (Float) (defaults to: 0.0222)

    Requests per second

Returns:



99
100
101
102
103
104
105
106
# File 'lib/peddler/apis/reports_2021_06_30.rb', line 99

def get_report_schedules(report_types, rate_limit: 0.0222)
  path = "/reports/2021-06-30/schedules"
  params = {
    "reportTypes" => stringify_array(report_types),
  }.compact
  parser = -> { ReportScheduleList }
  meter(rate_limit).get(path, params:, parser:)
end

#get_reports(report_types: nil, processing_statuses: nil, marketplace_ids: nil, page_size: 10, created_since: nil, created_until: nil, next_token: nil, rate_limit: 0.0222) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Returns report details for the reports that match the filters that you specify.

Values](https://developer-docs.amazon.com/sp-api/docs/report-type-values) for more information. When reportTypes is provided, the other filter parameters (processingStatuses, marketplaceIds, createdSince, createdUntil) and pageSize may also be provided. Either reportTypes or nextToken is required. returned will match at least one of the marketplaces that you specify. in ISO 8601 date time format. The default is 90 days ago. Reports are retained for a maximum of 90 days. in ISO 8601 date time format. The default is now. returned when the number of results exceeds the specified pageSize value. To get the next page of results, call the getReports operation and include this token as the only parameter. Specifying nextToken with any other parameters will cause the request to fail.

Parameters:

  • report_types (Array<String>) (defaults to: nil)

    A list of report types used to filter reports. Refer to [Report Type

  • processing_statuses (Array<String>) (defaults to: nil)

    A list of processing statuses used to filter reports.

  • marketplace_ids (Array<String>) (defaults to: nil)

    A list of marketplace identifiers used to filter reports. The reports

  • page_size (Integer) (defaults to: 10)

    The maximum number of reports to return in a single call.

  • created_since (String) (defaults to: nil)

    The earliest report creation date and time for reports to include in the response,

  • created_until (String) (defaults to: nil)

    The latest report creation date and time for reports to include in the response,

  • next_token (String) (defaults to: nil)

    A string token returned in the response to your previous request. nextToken is

  • rate_limit (Float) (defaults to: 0.0222)

    Requests per second

Returns:



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/peddler/apis/reports_2021_06_30.rb', line 38

def get_reports(report_types: nil, processing_statuses: nil, marketplace_ids: nil, page_size: 10,
  created_since: nil, created_until: nil, next_token: nil, rate_limit: 0.0222)
  path = "/reports/2021-06-30/reports"
  params = {
    "reportTypes" => stringify_array(report_types),
    "processingStatuses" => stringify_array(processing_statuses),
    "marketplaceIds" => stringify_array(marketplace_ids),
    "pageSize" => page_size,
    "createdSince" => created_since,
    "createdUntil" => created_until,
    "nextToken" => next_token,
  }.compact
  parser = -> { GetReportsResponse }
  meter(rate_limit).get(path, params:, parser:)
end