Пример #1
0
	def update_report_acknowledgements(self, reports, marketplaces=None, debug=None):
		"""
		Updates the acknowledged status of the specified Reports.
		
		*reports* (**sequence**) is the list of Report IDs (``int``) to
		update. The maximum number of Reports that can be specified is 100.
		
		*marketplaces* (**sequence**) is the list of Amazon Marketplace IDs
		(``str``). Default is ``None`` for all marketplaces.
		"""
		if not is_sequence(reports):
			raise TypeError("reports:{!r} is not a sequence.".format(reports))
		elif len(reports) < 0 or 100 < len(reports):
			raise ValueError("reports len:{!r} must be between 1 and 100 inclusive.".format(len(reports)))
		
		# Build args.
		args = self.new_args()
		args['Action'] = 'UpdateReportAcknowledgements'
		args['Acknowledged'] = 'true'
			
		for i, report_id in enumerate(reports, 0):
			if not isinstance(report_id, basestring):
				raise TypeError("reports[{}]:{!r} is not a string.".format(i, report_id))
			elif not report_id:
				raise ValueError("reports[{}]:{!r} cannot be empty.".format(i, report_id))
			report_id = encode_string(report_id, 'ASCII', name="reports[{}]".format(i))
			
			args['ReportIdList.Id.{}'.format(report_id)] = report_id
			
		if marketplaces is not None:
			args.update(marketplace_args(marketplaces, name='marketplaces'))
		
		# Send Request.
		return self.send_request(args, debug=debug)
Пример #2
0
	def submit_feed(self, feed_type, data, content_type, marketplaces=None, debug=None):
		"""
		Submits the specified feed.

		*feed_type* (``str``) is the type of feed being submitted. This can
		be any of the keys or values from ``FEED_TYPES``.

		*data* (``str`` or ``file``) is the feed data. This can be either
		the raw bytes (``str``) or a ``file`` object supporting ``read()``.

		*content_type* (``str``) is the content type of *data*.

		*marketplaces* (**sequence**) optionally contains the ID (``str``)
		of each Amazon Marketplace to apply the feed to. Default is ``None``
		for all Amazon Marketplaces.

		Returns the response XML (``str``).
		"""
		if not isinstance(feed_type, str):
			raise TypeError("feed_type:{!r} is not a str.".format(feed_type))
		if data is None:
			raise TypeError("data:{!r} is not a str or file.".format(data))

		args = self.new_args()
		args['Action'] = 'SubmitFeed'
		args['FeedType'] = FEED_TYPES.get(feed_type, feed_type)

		if marketplaces is not None:
			args.update(marketplace_args(marketplaces, name='marketplaces'))

		return self.send_request(args, body=data, content_type=content_type, debug=debug)
Пример #3
0
    def get_report(self, report_id, marketplaces=None, debug=None):
        """
		Gets the contents of the Report.
		
		*report_id* (``int``) is the Report ID.
		
		*marketplaces* (**sequence**) is the list of marketplace IDs
		(``str``). Default is ``None`` for all marketplaces.
		
		Returns the contents of the Report.
		"""
        if not isinstance(report_id, (int, long)):
            raise TypeError(
                "report_id:{!r} is not an integer.".format(report_id))
        elif report_id < 0:
            raise ValueError(
                "report_id:{!r} cannot be less than 0.".format(report_id))

        # Build args.
        args = self.new_args()
        args['Action'] = 'GetReport'
        args['ReportId'] = report_id

        if marketplaces is not None:
            args.update(marketplace_args(marketplaces, name='marketplaces'))

        # Send request.
        return self.send_request(args, debug=debug)
Пример #4
0
	def get_report(self, report_id, marketplaces=None, debug=None):
		"""
		Gets the contents of the Report.
		
		*report_id* (``int``) is the Report ID.
		
		*marketplaces* (**sequence**) is the list of marketplace IDs
		(``str``). Default is ``None`` for all marketplaces.
		
		Returns the contents of the Report.
		"""
		if not isinstance(report_id, (int, long)):
			raise TypeError("report_id:{!r} is not an integer.".format(report_id))
		elif report_id < 0:
			raise ValueError("report_id:{!r} cannot be less than 0.".format(report_id))
			
		# Build args.
		args = self.new_args()
		args['Action'] = 'GetReport'
		args['ReportId'] = report_id
			
		if marketplaces is not None:
			args.update(marketplace_args(marketplaces, name='marketplaces'))
			
		# Send request.
		return self.send_request(args, debug=debug)
Пример #5
0
    def get_report_request_count(self,
                                 report_types=None,
                                 statuses=None,
                                 from_date=None,
                                 to_date=None,
                                 marketplaces=None,
                                 debug=None):
        """
		Gets the total number of Report Requests that match the query.
		
		*report_types* (**sequence**) is used to filter on Report Type
		(``str``). This can contain any keys or values from
		``REPORT_TYPES``. Default is ``None`` to not filter on Report Type.
		
		*statuses* (**sequence**) is used to filter on Report Processing
		Status (``str``). This can contain any keys or values from
		``REPORT_STATUSES``. Default is ``None`` to not filter on Report
		Processing Status.
		
		*from_date* (``datetime`` or ``float``) is the start of the date
		range to use for selecting Report Requests. Default is ``None`` for
		90 days ago.
		
		*to_date* (``datetime`` or ``float``) is the end of the date range
		to use for selecting Report Requests. Default is ``None`` for now.
		
		*marketplaces* (**sequence**) is the list of Amazon Marketplace IDs
		(``str``). Default is ``None`` for all marketplaces.
		
		Returns the raw XML response (``str``).
		"""
        if from_date is not None:
            from_date = datetime_to_iso8601(from_date, name='from_date')

        if to_date is not None:
            to_date = datetime_to_iso8601(to_date, name='to_date')

        # Build args.
        args = self.new_args()
        args['Action'] = 'GetReportRequestCount'

        if report_types is not None:
            args.update(report_type_args(report_types, name='report_types'))

        if statuses is not None:
            args.update(status_args(statuses, name='statuses'))

        if from_date:
            args['RequestedFromDate'] = from_date

        if to_date:
            args['RequestedToDate'] = to_date

        if marketplaces is not None:
            args.update(marketplace_args(marketplaces, name='marketplaces'))

        # Send request.
        return self.send_request(args, debug=debug)
Пример #6
0
	def request_report(self, report_type, start_date=None, end_date=None, show_sales_channel=None, marketplaces=None, debug=None):
		"""
		Requests that the specified Report be created.
		
		*report_type* (``str``) is the report type.
		
		*start_date* (``datetime`` or ``float``) is the start of the date
		range used for selecting the data to report. Default is ``None`` for
		now.
		
		*end_date* (``datetime`` or ``float``) is the end of the date range
		used for selecting the data to report. Default is ``None`` for now.
		
		*show_sales_channel* (``bool``) indicates that an additional column
		for several Order Reports should be shown (``True``), or not
		(``False``). Default is ``None`` to not show the additional column.
		
		*marketplaces* (**sequence**) is the list of Amazon Marketplace IDs
		(``str``). Default is ``None`` for all marketplaces.
		
		Returns the Report Request ID (``str``) if the response is to be
		parsed; otherwise, the raw XML response (``str``)
		"""
		report_type = REPORT_TYPES.get(report_type, report_type)
		if not isinstance(report_type, basestring):
			raise TypeError("report_type:{!r} is not a string.".format(report_type))
		elif not report_type:
			raise ValueError("report_type:{!r} cannot be empty.".format(report_type))
		report_type = report_type.encode('ASCII')
		
		if start_date is not None:
			start_date = datetime_to_iso8601(start_date, name='start_date')
			
		if end_date is not None:
			end_date = datetime_to_iso8601(end_date, name='end_date')
			
		if show_sales_channel is not None:
			show_sales_channel = bool(show_sales_channel)
		
		# Build request.
		args = self.new_args()
		args['Action'] = 'RequestReport'
		args['ReportType'] = report_type
		
		if start_date:
			args['StartDate'] = start_date
			
		if end_date:
			args['EndDate'] = end_date
			
		if show_sales_channel is not None:
			args['ReportOptions=ShowSalesChannel'] = 'true' if show_sales_channel else 'false'
	
		if marketplaces is not None:
			args.update(marketplace_args(marketplaces, name='marketplaces'))
			
		# Send request.
		return self.send_request(args, debug=debug)
Пример #7
0
	def get_report_count(self, report_types=None, acknowledged=None, from_date=None, to_date=None, marketplaces=None, debug=None):
		"""
		Gets the total number of Reports that match the query.
		
		*report_types* (**sequence**) is used to filter on Report Type
		(``str``). This can contain any keys or values from
		``REPORT_TYPES``. Default is ``None`` to not filter on Report Type.
		
		*acknowledged* (``bool``) is used to filter on whether Order Reports
		have been acknowledged (``True``), or not (``False``). Default is
		``None`` to not filter on Acknowledged state. 
		
		.. NOTE:: Setting *acknowledged* to ``True`` will result in only
		   Order Reports (not Listing Reports) being returned.
		
		*from_date* (``datetime`` or ``float``) is the start of the date
		range to use for selecting Report Requests. Default is ``None`` for
		90 days ago.
		
		*to_date* (``datetime`` or ``float``) is the end of the date range
		to use for selecting Report Requests. Default is ``None`` for now.
		
		*marketplaces* (**sequence**) is the list of Amazon Marketplace IDs
		(``str``). Default is ``None`` for all marketplaces.
		
		Returns the raw XML response (``str``).
		"""
		if acknowledged is not None:
			acknowledged = bool(acknowledged)
			
		if from_date is not None:
			from_date = datetime_to_iso8601(from_date, name='from_date')
			
		if to_date is not None:
			to_date = datetime_to_iso8601(to_date, name='to_date')
			
		# Build args.
		args = self.new_args()
		args['Action'] = 'GetReportCount'
		
		if report_types is not None:
			args.update(report_type_args(report_types, name='report_types'))
				
		if acknowledged is not None:
			args['Acknowledged'] = 'true' if acknowledged else 'false'
			
		if from_date:
			args['RequestedFromDate'] = from_date
			
		if to_date:
			args['RequestedToDate'] = to_date
			
		if marketplaces is not None:
			args.update(marketplace_args(marketplaces, name='marketplaces'))
			
		# Send request.
		return self.send_request(args, debug=debug)
Пример #8
0
    def update_report_acknowledgements(self,
                                       reports,
                                       acknowledged=None,
                                       marketplaces=None,
                                       debug=None):
        """
		Updates the acknowledged status of the specified Reports.

		*reports* (**sequence**) is the list of Report IDs (``int``) to
		update. The maximum number of Reports that can be specified is 100.

		*acknowledged* (**boolean**) is whether or not to mark the reports
		passed as acknowledged. Default is ``None``. Amazon MWS treats the
		absense of acknowledged by defaulting the value to True.

		*marketplaces* (**sequence**) is the list of Amazon Marketplace IDs
		(``str``). Default is ``None`` for all marketplaces.
		"""
        if not is_sequence(reports):
            raise TypeError("reports:{!r} is not a sequence.".format(reports))
        elif len(reports) < 0 or 100 < len(reports):
            raise ValueError(
                "reports len:{!r} must be between 1 and 100 inclusive.".format(
                    len(reports)))

        # Build args.
        args = self.new_args()
        args['Action'] = 'UpdateReportAcknowledgements'

        if acknowledged is True:
            args['Acknowledged'] = 'true'
        elif acknowledged is False:
            args['Acknowledged'] = 'false'
        elif acknowledged is not None:
            raise TypeError(
                "reports['acknowledged']:{!r} is not boolean.".format(
                    acknowledged))

        for i, report_id in enumerate(reports, 1):
            if not isinstance(report_id, basestring):
                raise TypeError("reports[{}]:{!r} is not a string.".format(
                    i, report_id))
            elif not report_id:
                raise ValueError("reports[{}]:{!r} cannot be empty.".format(
                    i, report_id))
            report_id = encode_string(report_id,
                                      'ASCII',
                                      name="reports[{}]".format(i))

            args['ReportIdList.Id.{}'.format(i)] = report_id

        if marketplaces is not None:
            args.update(marketplace_args(marketplaces, name='marketplaces'))

        # Send Request.
        return self.send_request(args, debug=debug)
Пример #9
0
	def get_report_request_count(self, report_types=None, statuses=None, from_date=None, to_date=None, marketplaces=None, debug=None):
		"""
		Gets the total number of Report Requests that match the query.
		
		*report_types* (**sequence**) is used to filter on Report Type
		(``str``). This can contain any keys or values from
		``REPORT_TYPES``. Default is ``None`` to not filter on Report Type.
		
		*statuses* (**sequence**) is used to filter on Report Processing
		Status (``str``). This can contain any keys or values from
		``REPORT_STATUSES``. Default is ``None`` to not filter on Report
		Processing Status.
		
		*from_date* (``datetime`` or ``float``) is the start of the date
		range to use for selecting Report Requests. Default is ``None`` for
		90 days ago.
		
		*to_date* (``datetime`` or ``float``) is the end of the date range
		to use for selecting Report Requests. Default is ``None`` for now.
		
		*marketplaces* (**sequence**) is the list of Amazon Marketplace IDs
		(``str``). Default is ``None`` for all marketplaces.
		
		Returns the raw XML response (``str``).
		"""
		if from_date is not None:
			from_date = datetime_to_iso8601(from_date, name='from_date')
			
		if to_date is not None:
			to_date = datetime_to_iso8601(to_date, name='to_date')
			
		# Build args.
		args = self.new_args()
		args['Action'] = 'GetReportRequestCount'
		
		if report_types is not None:
			args.update(report_type_args(report_types, name='report_types'))
			
		if statuses is not None:
			args.update(status_args(statuses, name='statuses'))
				
		if from_date:
			args['RequestedFromDate'] = from_date
			
		if to_date:
			args['RequestedToDate'] = to_date
			
		if marketplaces is not None:
			args.update(marketplace_args(marketplaces, name='marketplaces'))
			
		# Send request.
		return self.send_request(args, debug=debug)
Пример #10
0
	def update_report_acknowledgements(self, reports, acknowledged=None, marketplaces=None, debug=None):
		"""
		Updates the acknowledged status of the specified Reports.

		*reports* (**sequence**) is the list of Report IDs (``int``) to
		update. The maximum number of Reports that can be specified is 100.

		*acknowledged* (**boolean**) is whether or not to mark the reports
		passed as acknowledged. Default is ``None``. Amazon MWS treats the
		absense of acknowledged by defaulting the value to True.

		*marketplaces* (**sequence**) is the list of Amazon Marketplace IDs
		(``str``). Default is ``None`` for all marketplaces.
		"""
		if not is_sequence(reports):
			raise TypeError("reports:{!r} is not a sequence.".format(reports))
		elif len(reports) < 0 or 100 < len(reports):
			raise ValueError("reports len:{!r} must be between 1 and 100 inclusive.".format(len(reports)))

		# Build args.
		args = self.new_args()
		args['Action'] = 'UpdateReportAcknowledgements'

		if acknowledged is True:
			args['Acknowledged'] = 'true'
		elif acknowledged is False:
			args['Acknowledged'] = 'false'
		elif acknowledged is not None:
			raise TypeError("reports['acknowledged']:{!r} is not boolean.".format(acknowledged))

		for i, report_id in enumerate(reports, 1):
			if not isinstance(report_id, six.string_types):
				raise TypeError("reports[{}]:{!r} is not a string.".format(i, report_id))
			elif not report_id:
				raise ValueError("reports[{}]:{!r} cannot be empty.".format(i, report_id))
			report_id = encode_string(report_id, 'ASCII', name="reports[{}]".format(i))

			args['ReportIdList.Id.{}'.format(i)] = report_id

		if marketplaces is not None:
			args.update(marketplace_args(marketplaces, name='marketplaces'))

		# Send Request.
		return self.send_request(args, debug=debug)
Пример #11
0
    def SubmitFeed(self,
                   feed_type,
                   data,
                   content_type,
                   marketplaces=None,
                   debug=None):
        """
		Submits the specified feed.

		*feed_type* (``str``) is the type of feed being submitted. This can
		be any of the keys or values from ``FEED_TYPES``.

		*data* (``str`` or ``file``) is the feed data. This can be either
		the raw bytes (``str``) or a ``file`` object supporting ``read()``.

		*content_type* (``str``) is the content type of *data*.

		*marketplaces* (**sequence**) optionally contains the ID (``str``)
		of each Amazon Marketplace to apply the feed to. Default is ``None``
		for all Amazon Marketplaces.

		Returns the response XML (``str``).
		"""
        if not isinstance(feed_type, six.string_types):
            raise TypeError("feed_type:{!r} is not a str.".format(feed_type))
        if data is None:
            raise TypeError("data:{!r} is not a str or file.".format(data))

        args = self.new_args()
        args['Action'] = 'SubmitFeed'
        args['FeedType'] = FEED_TYPES.get(feed_type, feed_type)

        if marketplaces is not None:
            args.update(marketplace_args(marketplaces, name='marketplaces'))

        return self.send_request(args,
                                 body=data,
                                 content_type=content_type,
                                 debug=debug)
Пример #12
0
    def request_report(self,
                       report_type,
                       start_date=None,
                       end_date=None,
                       show_sales_channel=None,
                       marketplaces=None,
                       debug=None):
        """
		Requests that the specified Report be created.
		
		*report_type* (``str``) is the report type.
		
		*start_date* (``datetime`` or ``float``) is the start of the date
		range used for selecting the data to report. Default is ``None`` for
		now.
		
		*end_date* (``datetime`` or ``float``) is the end of the date range
		used for selecting the data to report. Default is ``None`` for now.
		
		*show_sales_channel* (``bool``) indicates that an additional column
		for several Order Reports should be shown (``True``), or not
		(``False``). Default is ``None`` to not show the additional column.
		
		*marketplaces* (**sequence**) is the list of Amazon Marketplace IDs
		(``str``). Default is ``None`` for all marketplaces.
		
		Returns the Report Request ID (``str``) if the response is to be
		parsed; otherwise, the raw XML response (``str``)
		"""
        report_type = REPORT_TYPES.get(report_type, report_type)
        if not isinstance(report_type, basestring):
            raise TypeError(
                "report_type:{!r} is not a string.".format(report_type))
        elif not report_type:
            raise ValueError(
                "report_type:{!r} cannot be empty.".format(report_type))
        report_type = report_type.encode('ASCII')

        if start_date is not None:
            start_date = datetime_to_iso8601(start_date, name='start_date')

        if end_date is not None:
            end_date = datetime_to_iso8601(end_date, name='end_date')

        if show_sales_channel is not None:
            show_sales_channel = bool(show_sales_channel)

        # Build request.
        args = self.new_args()
        args['Action'] = 'RequestReport'
        args['ReportType'] = report_type

        if start_date:
            args['StartDate'] = start_date

        if end_date:
            args['EndDate'] = end_date

        if show_sales_channel is not None:
            args[
                'ReportOptions=ShowSalesChannel'] = 'true' if show_sales_channel else 'false'

        if marketplaces is not None:
            args.update(marketplace_args(marketplaces, name='marketplaces'))

        # Send request.
        return self.send_request(args, debug=debug)
Пример #13
0
    def get_report_request_list(self,
                                requests=None,
                                max_count=None,
                                report_types=None,
                                statuses=None,
                                from_date=None,
                                to_date=None,
                                marketplaces=None,
                                debug=None):
        """
		Requests for the list of Report Requests that match the query.
		
		To list Report Requests based upon ID use *requests*.
		
		*requests* (**sequence**) is used to filter on Report Request ID
		(``str``). If not ``None``, no other query arguments will be used
		and only those Report Requests with matching IDs will be returned.
		Default is ``None`` to not use Report Request IDs.
		
		To list Report Requests based upon a query use any combination of
		the following: *max_count*, *report_types*, *statuses*, *from_date*,
		*to_date*, and *marketplaces*.
		
		*max_count* (``int``) is the maximum number of Report Requests to
		return per response. This must between 1 and 100 inclusive. Default
		is 10.
		
		*report_types* (**sequence**) is used to filter on Report Type
		(``str``). This can contain any keys or values from
		``REPORT_TYPES``. Default is ``None`` to not filter on Report Type.
		
		*statuses* (**sequence**) is used to filter on Report Processing
		Status (``str``). This can contain any keys or values from
		``REPORT_STATUSES``. Default is ``None`` to not filter on Report
		Processing Status.
		
		*from_date* (``datetime`` or ``float``) is the start of the date
		range to use for selecting Report Requests. Default is ``None`` for
		90 days ago.
		
		*to_date* (``datetime`` or ``float``) is the end of the date range
		to use for selecting Report Requests. Default is ``None`` for now.
		
		*marketplaces* (**sequence**) is the list of Amazon Marketplace IDs
		(``str``). Default is ``None`` for all marketplaces.
		
		Returns the raw XML response (``str``).
		"""
        if max_count is not None:
            if not isinstance(max_count, (int, long)):
                raise TypeError(
                    "max_count:{!r} is not an int.".format(max_count))
            elif max_count < 1 or 100 < max_count:
                raise ValueError(
                    "max_count:{!r} is not between 1 and 100 inclusive.".
                    format(max_count))

        if from_date is not None:
            from_date = datetime_to_iso8601(from_date, name='from_date')

        if to_date is not None:
            to_date = datetime_to_iso8601(to_date, name='to_date')

        # Build args.
        args = self.new_args()
        args['Action'] = 'GetReportRequestList'

        if requests:
            args.update(request_args(requests, name='requests'))

        else:
            if max_count:
                args['MaxCount'] = max_count

            if report_types is not None:
                args.update(report_type_args(report_types,
                                             name='report_types'))

            if statuses is not None:
                args.update(status_args(statuses, name='statuses'))

            if from_date:
                args['RequestedFromDate'] = from_date

            if to_date:
                args['RequestedToDate'] = to_date

            if marketplaces is not None:
                args.update(marketplace_args(marketplaces,
                                             name='marketplaces'))

        # Send request.
        return self.send_request(args, debug=debug)
Пример #14
0
    def get_report_count(self,
                         report_types=None,
                         acknowledged=None,
                         from_date=None,
                         to_date=None,
                         marketplaces=None,
                         debug=None):
        """
		Gets the total number of Reports that match the query.
		
		*report_types* (**sequence**) is used to filter on Report Type
		(``str``). This can contain any keys or values from
		``REPORT_TYPES``. Default is ``None`` to not filter on Report Type.
		
		*acknowledged* (``bool``) is used to filter on whether Order Reports
		have been acknowledged (``True``), or not (``False``). Default is
		``None`` to not filter on Acknowledged state. 
		
		.. NOTE:: Setting *acknowledged* to ``True`` will result in only
		   Order Reports (not Listing Reports) being returned.
		
		*from_date* (``datetime`` or ``float``) is the start of the date
		range to use for selecting Report Requests. Default is ``None`` for
		90 days ago.
		
		*to_date* (``datetime`` or ``float``) is the end of the date range
		to use for selecting Report Requests. Default is ``None`` for now.
		
		*marketplaces* (**sequence**) is the list of Amazon Marketplace IDs
		(``str``). Default is ``None`` for all marketplaces.
		
		Returns the raw XML response (``str``).
		"""
        if acknowledged is not None:
            acknowledged = bool(acknowledged)

        if from_date is not None:
            from_date = datetime_to_iso8601(from_date, name='from_date')

        if to_date is not None:
            to_date = datetime_to_iso8601(to_date, name='to_date')

        # Build args.
        args = self.new_args()
        args['Action'] = 'GetReportCount'

        if report_types is not None:
            args.update(report_type_args(report_types, name='report_types'))

        if acknowledged is not None:
            args['Acknowledged'] = 'true' if acknowledged else 'false'

        if from_date:
            args['RequestedFromDate'] = from_date

        if to_date:
            args['RequestedToDate'] = to_date

        if marketplaces is not None:
            args.update(marketplace_args(marketplaces, name='marketplaces'))

        # Send request.
        return self.send_request(args, debug=debug)
Пример #15
0
    def cancel_report_requests(self,
                               requests=None,
                               report_types=None,
                               statuses=None,
                               from_date=None,
                               to_date=None,
                               marketplaces=None,
                               debug=None):
        """
		Cancels all Report Requests that match the query.
		
		.. NOTE:: Report Requests that have already begun processing cannot
		   be cancelled.
		
		To cancel Report Requests based upon ID use *requests*.
		
		*requests* (**sequence**) is used to filter on Report Request ID
		(``str``). If not ``None``, no other query arguments will be used
		and only those Report Requests with matching IDs will be returned.
		Default is ``None`` to not use Report Request IDs.
		
		To cancel Report Requests based upon a query use any combination of
		the following: *report_types*, *statuses*, *from_date*, *to_date*,
		and *marketplaces*.
		
		*report_types* (**sequence**) is used to filter on Report Type
		(``str``). This can contain any keys or values from
		``REPORT_TYPES``. Default is ``None`` to not filter on Report Type.
		
		*statuses* (**sequence**) is used to filter on Report Processing
		Status (``str``). This can contain any keys or values from
		``REPORT_STATUSES``. Default is ``None`` to not filter on Report
		Processing Status.
		
		*from_date* (``datetime`` or ``float``) is the start of the date
		range to use for selecting Report Requests. Default is ``None`` for
		90 days ago.
		
		*to_date* (``datetime`` or ``float``) is the end of the date range
		to use for selecting Report Requests. Default is ``None`` for now.
		
		*marketplaces* (**sequence**) is the list of Amazon Marketplace IDs
		(``str``). Default is ``None`` for all marketplaces.
		
		Returns the raw XML response (``str``).
		"""
        if from_date is not None:
            from_date = datetime_to_iso8601(from_date, name='from_date')

        if to_date is not None:
            to_date = datetime_to_iso8601(to_date, name='to_date')

        # Build args.
        args = self.new_args()
        args['Action'] = 'CancelReportRequests'

        if requests:
            args.update(request_args(requests, name='requests'))

        else:
            if report_types is not None:
                args.update(report_type_args(report_types,
                                             name='report_types'))

            if statuses is not None:
                args.update(status_args(statuses, name='statuses'))

            if from_date:
                args['RequestedFromDate'] = from_date

            if to_date:
                args['RequestedToDate'] = to_date

            if marketplaces is not None:
                args.update(marketplace_args(marketplaces,
                                             name='marketplaces'))

        # Send request.
        return self.send_request(args, debug=debug)
Пример #16
0
	def get_report_request_list(self, requests=None, max_count=None, report_types=None, statuses=None, from_date=None, to_date=None, marketplaces=None, debug=None):
		"""
		Requests for the list of Report Requests that match the query.
		
		To list Report Requests based upon ID use *requests*.
		
		*requests* (**sequence**) is used to filter on Report Request ID
		(``str``). If not ``None``, no other query arguments will be used
		and only those Report Requests with matching IDs will be returned.
		Default is ``None`` to not use Report Request IDs.
		
		To list Report Requests based upon a query use any combination of
		the following: *max_count*, *report_types*, *statuses*, *from_date*,
		*to_date*, and *marketplaces*.
		
		*max_count* (``int``) is the maximum number of Report Requests to
		return per response. This must between 1 and 100 inclusive. Default
		is 10.
		
		*report_types* (**sequence**) is used to filter on Report Type
		(``str``). This can contain any keys or values from
		``REPORT_TYPES``. Default is ``None`` to not filter on Report Type.
		
		*statuses* (**sequence**) is used to filter on Report Processing
		Status (``str``). This can contain any keys or values from
		``REPORT_STATUSES``. Default is ``None`` to not filter on Report
		Processing Status.
		
		*from_date* (``datetime`` or ``float``) is the start of the date
		range to use for selecting Report Requests. Default is ``None`` for
		90 days ago.
		
		*to_date* (``datetime`` or ``float``) is the end of the date range
		to use for selecting Report Requests. Default is ``None`` for now.
		
		*marketplaces* (**sequence**) is the list of Amazon Marketplace IDs
		(``str``). Default is ``None`` for all marketplaces.
		
		Returns the raw XML response (``str``).
		"""
		if max_count is not None:
			if not isinstance(max_count, (int, long)):
				raise TypeError("max_count:{!r} is not an int.".format(max_count))
			elif max_count < 1 or 100 < max_count:
				raise ValueError("max_count:{!r} is not between 1 and 100 inclusive.".format(max_count))
				
		if from_date is not None:
			from_date = datetime_to_iso8601(from_date, name='from_date')
		
		if to_date is not None:
			to_date = datetime_to_iso8601(to_date, name='to_date')
			
		# Build args.
		args = self.new_args()
		args['Action'] = 'GetReportRequestList'
		
		if requests:
			args.update(request_args(requests, name='requests'))
				
		else:
			if max_count:
				args['MaxCount'] = max_count
			
			if report_types is not None:
				args.update(report_type_args(report_types, name='report_types'))
					
			if statuses is not None:
				args.update(status_args(statuses, name='statuses'))
					
			if from_date:
				args['RequestedFromDate'] = from_date
				
			if to_date:
				args['RequestedToDate'] = to_date
				
			if marketplaces is not None:
				args.update(marketplace_args(marketplaces, name='marketplaces'))
		
		# Send request.
		return self.send_request(args, debug=debug)
Пример #17
0
    def get_report_list(self,
                        requests=None,
                        max_count=None,
                        report_types=None,
                        acknowledged=None,
                        from_date=None,
                        to_date=None,
                        marketplaces=None,
                        debug=None):
        """
		Lists the Reports that match the query.
		
		To list Reports based upon Request ID use *requests*.
		
		*requests* (**sequence**) is used to filter on Report Request ID
		(``str``). If not ``None``, no other query arguments will be used
		and only those Report Requests with matching IDs will be returned.
		Default is ``None`` to not use Report Request IDs.
		
		To list Reports based upon a query use any combination of the
		following: *max_count*, *report_types*, *acknowledged*, *from_date*,
		*to_date*, and *marketplaces*.
		
		*max_count* (``int``) is the maximum number of Reports to return per
		response. This must between 1 and 100 inclusive. Default is 10.
		
		*report_types* (**sequence**) is used to filter on Report Type
		(``str``). This can contain any keys or values from
		``REPORT_TYPES``. Default is ``None`` to not filter on Report Type.
		
		*acknowledged* (``bool``) is used to filter on whether Order Reports
		have been acknowledged (``True``), or not (``False``). Default is
		``None`` to not filter on Acknowledged state.
		
		.. NOTE:: Setting *acknowledged* to ``True`` will result in only
		   Order Reports (not Listing Reports) being returned.
		
		*from_date* (``datetime`` or ``float``) is the start of the date
		range to use for selecting Report Requests. Default is ``None`` for
		90 days ago.
		
		*to_date* (``datetime`` or ``float``) is the end of the date range
		to use for selecting Report Requests. Default is ``None`` for now.
		
		*marketplaces* (**sequence**) is the list of Amazon Marketplace IDs
		(``str``). Default is ``None`` for all marketplaces.
		
		Returns the raw XML response (``str``).
		"""
        if max_count is not None:
            if not isinstance(max_count, six.integer_types):
                raise TypeError(
                    "max_count:{!r} is not an int.".format(max_count))
            elif max_count < 1 or 100 < max_count:
                raise ValueError(
                    "max_count:{!r} is not between 1 and 100 inclusive.".
                    format(max_count))

        if acknowledged is not None:
            acknowledged = bool(acknowledged)

        if from_date is not None:
            from_date = datetime_to_iso8601(from_date, name='from_date')

        if to_date is not None:
            to_date = datetime_to_iso8601(to_date, name='to_date')

        # Build args.
        args = self.new_args()
        args['Action'] = 'GetReportList'

        if requests:
            args.update(request_args(requests, name='requests'))

        else:
            if max_count:
                args['MaxCount'] = max_count

            if report_types is not None:
                args.update(report_type_args(report_types,
                                             name='report_types'))

            if acknowledged is not None:
                args['Acknowledged'] = 'true' if acknowledged else 'false'

            if from_date:
                args['RequestedFromDate'] = from_date

            if to_date:
                args['RequestedToDate'] = to_date

            if marketplaces is not None:
                args.update(marketplace_args(marketplaces,
                                             name='marketplaces'))

        # Send request.
        return self.send_request(args, debug=debug)
Пример #18
0
	def cancel_report_requests(self, requests=None, report_types=None, statuses=None, from_date=None, to_date=None, marketplaces=None, debug=None):
		"""
		Cancels all Report Requests that match the query.
		
		.. NOTE:: Report Requests that have already begun processing cannot
		   be cancelled.
		
		To cancel Report Requests based upon ID use *requests*.
		
		*requests* (**sequence**) is used to filter on Report Request ID
		(``str``). If not ``None``, no other query arguments will be used
		and only those Report Requests with matching IDs will be returned.
		Default is ``None`` to not use Report Request IDs.
		
		To cancel Report Requests based upon a query use any combination of
		the following: *report_types*, *statuses*, *from_date*, *to_date*,
		and *marketplaces*.
		
		*report_types* (**sequence**) is used to filter on Report Type
		(``str``). This can contain any keys or values from
		``REPORT_TYPES``. Default is ``None`` to not filter on Report Type.
		
		*statuses* (**sequence**) is used to filter on Report Processing
		Status (``str``). This can contain any keys or values from
		``REPORT_STATUSES``. Default is ``None`` to not filter on Report
		Processing Status.
		
		*from_date* (``datetime`` or ``float``) is the start of the date
		range to use for selecting Report Requests. Default is ``None`` for
		90 days ago.
		
		*to_date* (``datetime`` or ``float``) is the end of the date range
		to use for selecting Report Requests. Default is ``None`` for now.
		
		*marketplaces* (**sequence**) is the list of Amazon Marketplace IDs
		(``str``). Default is ``None`` for all marketplaces.
		
		Returns the raw XML response (``str``).
		"""
		if from_date is not None:
			from_date = datetime_to_iso8601(from_date, name='from_date')
		
		if to_date is not None:
			to_date = datetime_to_iso8601(to_date, name='to_date')
		
		# Build args.
		args = self.new_args()
		args['Action'] = 'CancelReportRequests'
		
		if requests:
			args.update(request_args(requests, name='requests'))
				
		else:
			if report_types is not None:
				args.update(report_type_args(report_types, name='report_types'))
					
			if statuses is not None:
				args.update(status_args(statuses, name='statuses'))
					
			if from_date:
				args['RequestedFromDate'] = from_date
				
			if to_date:
				args['RequestedToDate'] = to_date
				
			if marketplaces is not None:
				args.update(marketplace_args(marketplaces, name='marketplaces'))
				
		# Send request.
		return self.send_request(args, debug=debug)
Пример #19
0
	def get_report_list(self, requests=None, max_count=None, report_types=None, acknowledged=None, from_date=None, to_date=None, marketplaces=None, debug=None):
		"""
		Lists the Reports that match the query.
		
		To list Reports based upon Request ID use *requests*.
		
		*requests* (**sequence**) is used to filter on Report Request ID
		(``str``). If not ``None``, no other query arguments will be used
		and only those Report Requests with matching IDs will be returned.
		Default is ``None`` to not use Report Request IDs.
		
		To list Reports based upon a query use any combination of the
		following: *max_count*, *report_types*, *acknowledged*, *from_date*,
		*to_date*, and *marketplaces*.
		
		*max_count* (``int``) is the maximum number of Reports to return per
		response. This must between 1 and 100 inclusive. Default is 10.
		
		*report_types* (**sequence**) is used to filter on Report Type
		(``str``). This can contain any keys or values from
		``REPORT_TYPES``. Default is ``None`` to not filter on Report Type.
		
		*acknowledged* (``bool``) is used to filter on whether Order Reports
		have been acknowledged (``True``), or not (``False``). Default is
		``None`` to not filter on Acknowledged state.
		
		.. NOTE:: Setting *acknowledged* to ``True`` will result in only
		   Order Reports (not Listing Reports) being returned.
		
		*from_date* (``datetime`` or ``float``) is the start of the date
		range to use for selecting Report Requests. Default is ``None`` for
		90 days ago.
		
		*to_date* (``datetime`` or ``float``) is the end of the date range
		to use for selecting Report Requests. Default is ``None`` for now.
		
		*marketplaces* (**sequence**) is the list of Amazon Marketplace IDs
		(``str``). Default is ``None`` for all marketplaces.
		
		Returns the raw XML response (``str``).
		"""
		if max_count is not None:
			if not isinstance(max_count, six.integer_types):
				raise TypeError("max_count:{!r} is not an int.".format(max_count))
			elif max_count < 1 or 100 < max_count:
				raise ValueError("max_count:{!r} is not between 1 and 100 inclusive.".format(max_count))
				
		if acknowledged is not None:
			acknowledged = bool(acknowledged)
			
		if from_date is not None:
			from_date = datetime_to_iso8601(from_date, name='from_date')
			
		if to_date is not None:
			to_date = datetime_to_iso8601(to_date, name='to_date')
			
		# Build args.
		args = self.new_args()
		args['Action'] = 'GetReportList'
		
		if requests:
			args.update(request_args(requests, name='requests'))
				
		else:
			if max_count:
				args['MaxCount'] = max_count
		
			if report_types is not None:
				args.update(report_type_args(report_types, name='report_types'))
					
			if acknowledged is not None:
				args['Acknowledged'] = 'true' if acknowledged else 'false'
				
			if from_date:
				args['RequestedFromDate'] = from_date
				
			if to_date:
				args['RequestedToDate'] = to_date
				
			if marketplaces is not None:
				args.update(marketplace_args(marketplaces, name='marketplaces'))
		
		# Send request.
		return self.send_request(args, debug=debug)