Module: Amazon::MWS::Report

Includes:
Enumerations
Defined in:
lib/amazon/mws/report.rb,
lib/amazon/mws/report_enumerations.rb

Defined Under Namespace

Modules: Enumerations

Constant Summary

Constants included from Enumerations

Enumerations::REPORT_TYPES, Enumerations::SCHEDULE

Instance Method Summary collapse

Instance Method Details

#cancel_report_requests(params = {}) ⇒ Object

ReportRequestIdList A structured list of report request IDs. If you pass in explicit IDs in this call, the other conditions, if specified, will be ignored.

ReportTypeList A structured ReportType list by which to filter reports.

ReportProcessingStatusList A structured list of report processing statuses by which to filter report requests.

ReportProcessingStatus SUBMITTED IN_PROGRESS CANCELLED DONE DONE_NO_DATA

RequestedFromDate The earliest date you are looking for, in ISO8601 date format (for example, “2008-07-03T18:12:22Z” or “2008-07-03T18:12:22.093-07:00”).

RequestedToDate The most recent date you are looking for.



154
155
156
157
# File 'lib/amazon/mws/report.rb', line 154

def cancel_report_requests(params = {})
  response = get("/", {"Action" => "CancelReportRequests"}.merge(params))
  CancelReportRequestsResponse.format(response)
end

#get_report(report_id, params = {}) ⇒ Object Also known as: report

GetReport Description

The GetReport operation returns the contents of a report and the Content-MD5 header for the returned body. Reports are retained for 90 days from the time they have been generated.

Amazon MWS limits calls to 1,000 total calls per hour per seller account, including a limit of 60 calls per hour to GetReport.

You should compute the MD5 hash of the HTTP body and compare that with the returned Content-MD5 header value. If they do not match, which means the body was corrupted during transmission, you should discard the result and automatically retry the call for up to three more times. Please notify us if you ever see such a corrupted body. You can contact us by using the contact form at mws.amazon.com (mws.amazon.com). For more information, see Using the Content-MD5 Header with SubmitFeed.



223
224
225
226
# File 'lib/amazon/mws/report.rb', line 223

def get_report(report_id, params = {})
  response = get("/", {"Action" => "GetReport", "ReportId" => report_id})
  # TODO format response
end

#get_report_count(params = {}) ⇒ Object Also known as: report_count

ReportTypeList A structured ReportType list by which to filter reports.

Acknowledged Set to true to list reports that have been acknowledged with a prior call to UpdateReportAcknowledgements. Set to false to list reports that have not been acknowledged.

AvailableFromDate The earliest date you are looking for, in ISO8601 date format (for example, “2008-07-03T18:12:22Z” or “2008-07-03T18:12:22.093-07:00”).

AvailableToDate The most recent date you are looking for.



196
197
198
199
# File 'lib/amazon/mws/report.rb', line 196

def get_report_count(params = {})
  response = get("/", {"Action" => "GetReportCount"})
  GetReportCountResponse.format(response)
end

#get_report_list(params = {}) ⇒ Object Also known as: report_list

GetReportList The GetReportList operation returns a list of reports within the previous 90 days that match the query parameters. The maximum number of results that will be returned in one call is one hundred. If there are additional results to return, HasNext will be returned in the response with a true value. To retrieve all the results, you can use the value of the NextToken parameter to call GetReportListByNextToken until HasNext is false.

Request Parameters



170
171
172
173
# File 'lib/amazon/mws/report.rb', line 170

def get_report_list(params = {})
  response = get("/", {"Action" => "GetReportList"}.merge(params))
  GetReportListResponse.format(response)
end

#get_report_request_count(params = {}) ⇒ Object Also known as: report_request_count

GetReportRequestCount The GetReportRequestCount returns a count of report requests.



114
115
116
117
# File 'lib/amazon/mws/report.rb', line 114

def get_report_request_count(params = {})
  response = get("/", {"Action" => "GetReportRequestCount"})
  GetReportRequestCountResponse.format(response)
end

#get_report_request_list(params = {}) ⇒ Object Also known as: report_request_list

Optional Request Parameters

ReportRequestIdList - A structured list of report request IDs. If you pass in explicit IDs in this call, the other conditions, if specified, will be ignored.

ReportTypeList - A structured ReportType list by which to filter reports.

ReportProcessingStatusList -A structured list of report processing statuses by which to filter report requests.

ReportProcessingStatus values:

SUBMITTED IN_PROGRESS CANCELLED DONE DONE_NO_DATA

MaxCount - Maximum number of reports to return in the list. If you specify a number greater than 100, the call will be rejected.

RequestedFromDate - The earliest date you are looking for, in ISO8601 date format (for example, “2008-07-03T18:12:22Z” or “2008-07-03T18:12:22.093-07:00”).

RequestedToDate - The most recent date you are looking for.



79
80
81
82
# File 'lib/amazon/mws/report.rb', line 79

def get_report_request_list(params = {})
  response = get("/", {"Action" => "GetReportRequestList"}.merge(params))
  GetReportRequestListResponse.format(response)
end

#get_report_request_list_by_next_token(next_token) ⇒ Object Also known as: report_request_list_by_next_token

NextToken Token returned in a previous call to either GetReportRequestList or GetReportRequestListByNextToken when the value of HasNext was true.



99
100
101
102
103
104
105
106
107
# File 'lib/amazon/mws/report.rb', line 99

def get_report_request_list_by_next_token(next_token)
  response = 
   post("/", {
     "Action"   => "GetReportRequestListByNextToken", 
     "NextToken" => next_token
   })

   GetReportRequestListByNextTokenResponse.format(response)
end

#get_report_schedule_count(params = {}) ⇒ Object Also known as: report_schedule_count



299
300
301
302
# File 'lib/amazon/mws/report.rb', line 299

def get_report_schedule_count(params = {})
  response = get("/", {"Action" => "GetReportScheduleCount"})
  GetReportScheduleCountResponse.format(response)
end

#get_report_schedule_list(params = {}) ⇒ Object Also known as: report_schedule_list



279
280
281
282
# File 'lib/amazon/mws/report.rb', line 279

def get_report_schedule_list(params = {})
  response = get("/", {"Action" => "GetReportScheduleList"}.merge(params))
  GetReportScheduleListResponse.format(response)
end

#get_report_schedule_list_by_next_token(next_token) ⇒ Object Also known as: report_schedule_list_by_next_token



287
288
289
290
291
292
293
294
295
# File 'lib/amazon/mws/report.rb', line 287

def get_report_schedule_list_by_next_token(next_token)
  response = 
   get("/", {
     "Action"   => "GetReportScheduleListByNextToken", 
     "NextToken" => next_token
   })

   GetReportScheduleListByNextTokenResponse.format(response)
end

#manage_report_schedule(report_type, schedule, params = {}) ⇒ Object

ManageReportSchedule The ManageReportSchedule operation creates, updates, or deletes a report schedule for a particular report type. Currently, only order reports can be scheduled.

Request Parameters

ReportType The type of reports that you want to schedule generation of. Currently, only order reports can be scheduled.

Schedule A string that describes how often a ReportRequest should be created. The list of enumerated values is found in the enumeration topic, Schedule.

ScheduledDate The date when the next report is scheduled to run. Limited to no more than 366 days in the future.

Raises:



249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'lib/amazon/mws/report.rb', line 249

def manage_report_schedule(report_type, schedule, params={})
  raise InvalidReportType if !REPORT_TYPES.include?(report_type)
  raise InvalidSchedule if !SCHEDULE.include?(schedule)
  
  response = 
  get("/", {
    "Action" => "ManageReportSchedule", 
    "Schedule" => schedule,
    "ReportType" => report_type
  })
  
  ManageReportScheduleResponse.format(reponse)
end

#request_report(report_type, params = {}) ⇒ Object

The RequestReport operation requests the generation of a report, which creates a report request. Reports are retained for 90 days. Required Request Parameters ReportType - The type of report to request.

Optional Request Parameters StartDate - Start of a date range used for selecting the data to report. EndDate - End of a date range used for selecting the data to report.

Raises:



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/amazon/mws/report.rb', line 17

def request_report(report_type, params ={})
  raise InvalidReportType if !REPORT_TYPES.include?(report_type)
  # These may need to be processed
  start_date = params[:start_date]
  end_date   = params[:end_date]

  query_params = {
    "Action"   => "RequestReport", 
    "ReportType" => REPORT_TYPES[report_type]
  }

  query_params.merge!({"StartDate" => start_date}) if start_date
  query_params.merge!({"EndDate" => end_date}) if end_date
      
  response = get("/", query_params)
  
  RequestReportResponse.format(response)
end