def submission_args(submissions, name=None): """ Converts the specified Feed Submission IDs into their resepctive URL query arguments. *submissions* (**sequence**) contains each Feed Submission ID (``str``). *name* (``str``) is the name to use when an error occurs. Returns a ``list`` containing each *key*-*submission_id* ``tuple``. - *key* (``str``) is the query argument key for *submission_id*. - *submission_id* (``str``) is the Feed Submission ID. """ if not name: name = 'submissions' if not is_sequence(submissions): raise TypeError("{}:{!r} is not a sequence.".format(name, submissions)) args = [] for i, sub_id in enumerate(submissions): if not isinstance(sub_id, basestring): raise TypeError("{}[{}]:{!r} is not a string.".format(name, i, sub_id)) elif not sub_id: raise ValueError("{}[{}]:{!r} cannot be empty.".format(name, i, sub_id)) sub_id = encode_string(sub_id, 'ASCII', name="{}[{}]".format(name, i)) args.append(('FeedSubmissionIdList.Id.{}'.format(i + 1), sub_id)) return args
def feed_type_args(feed_types, name=None): """ Converts the specified Feed Types into their resepctive URL query arguments. *feed_types* (**sequence**) contains each Feed Type (``str``). This can contain any of the keys or values from ``FEED_TYPES``. *name* (``str``) is the name to use when an error occurs. Returns a ``list`` containing each *key*-*feed_type* ``tuple``. - *key* (``str``) is the query argument key for *feed_type*. - *feed_type* (``str``) is the Feed Type ID. """ if not name: name = 'feed_types' if not is_sequence(feed_types): raise TypeError("{}:{!r} is not a sequence.".format(name, feed_types)) args = [] for i, feed_type in enumerate(feed_types): feed_type = FEED_TYPES.get(feed_type, feed_type) if not isinstance(feed_type, str): raise TypeError("{}[{}]:{!r} is not a str.".format(name, i, feed_type)) elif not feed_type: raise ValueError("{}[{}]:{!r} cannot be empty.".format(name, i, feed_type)) feed_type = encode_string(feed_type, 'ASCII', name="{}[{}]".format(name, i)) args.append(('FeedTypeList.Type.{}'.format(i + 1), feed_type)) return args
def status_args(statuses, name=None): """ Converts the specified Feed Processing Statuses into their respective URL query arguments. *statuses* (**sequence**) contains each Feed Processing Status (``str``). This can contain any of the keys or value from ``PROCESSING_STATUSES``. *name* (``str``) is the name to use when an error occurs. Returns a ``list`` containing each *key*-*status* ``tuple``. - *key* (``str``) is the query argument key for *status*. - *status* (``str``) is the Feed Processing Status. """ if not name: name = 'statuses' if not is_sequence(statuses): raise TypeError("{}:{!r} is not a sequence.".format(name, statuses)) args = [] for i, status in enumerate(statuses): status = PROCESSING_STATUSES.get(status, status) if not isinstance(status, str): raise TypeError("{}[{}]:{!r} is not a str.".format(name, i, status)) elif not status: raise ValueError("{}[{}]:{!r} cannot be empty.".format(name, i, status)) status = encode_string(status, 'ASCII', name="{}[{}]".format(name, i)) args.append(('FeedProcessingStatusList.Status.{}'.format(i + 1), status)) return args
def request_args(requests, name=None): """ Converts the specified Report Request IDs into their respective URL query arguments. *requests* (**sequence**) contains each Report Request ID (``str``). *name* (``str``) is the name to use when an error occurs. Returns a ``list`` containing each *key*-*request_id* ``tuple``. - *key* (``str``) is the query argument key for *request_id*. - *request_id* (``str``) is the Report Request ID. """ if not name: name = 'requests' if not is_sequence(requests): raise TypeError("{}:{!r} is not a sequence.".format(name, requests)) args = [] for i, request_id in enumerate(requests, 0): if not isinstance(request_id, basestring): raise TypeError("{}[{}]:{!r} is not a string.".format(name, i, request_id)) elif not request_id: raise ValueError("{}[{}]:{!r} cannot be empty.".format(name, i, request_id)) request_id = encode_string(request_id, 'ASCII', name="{}[{}]".format(name, i)) args.append(('ReportRequestIdList.Id.{}'.format(i + 1), request_id)) return args
def submission_args(submissions, name=None): """ Converts the specified Feed Submission IDs into their resepctive URL query arguments. *submissions* (**sequence**) contains each Feed Submission ID (``str``). *name* (``str``) is the name to use when an error occurs. Returns a ``list`` containing each *key*-*submission_id* ``tuple``. - *key* (``str``) is the query argument key for *submission_id*. - *submission_id* (``str``) is the Feed Submission ID. """ if not name: name = 'submissions' if not is_sequence(submissions): raise TypeError("{}:{!r} is not a sequence.".format(name, submissions)) args = [] for i, sub_id in enumerate(submissions): if not isinstance(sub_id, six.string_types): raise TypeError("{}[{}]:{!r} is not a string.".format( name, i, sub_id)) elif not sub_id: raise ValueError("{}[{}]:{!r} cannot be empty.".format( name, i, sub_id)) sub_id = encode_string(sub_id, 'ASCII', name="{}[{}]".format(name, i)) args.append(('FeedSubmissionIdList.Id.{}'.format(i + 1), sub_id)) return args
def report_type_args(report_types, name=None): """ Converts the specified Report Types into their respective URL query arguments. *report_types* (**sequence**) contains each Report Type (``str``). This can contain any keys or values from ``REPORT_TYPES``. *name* (``str``) is the name to use when an error occurs. Returns a ``list`` containing each *key*-*report_type* ``tuple``. - *key* (``str``) is the query argument key for *report_type*. - *report_type* (``str``) is the Report Type. """ if not name: name = 'report_types' if not is_sequence(report_types): raise TypeError("{}:{!r} is not a sequence.".format(name, report_types)) args = [] for i, report_type in enumerate(report_types, 0): report_type = REPORT_TYPES.get(report_type, report_type) if not isinstance(report_type, basestring): raise TypeError("{}[{}]:{!r} is not a string.".format(name, i, report_type)) elif not report_type: raise ValueError("{}[{}]:{!r} cannot be empty.".format(name, i, report_type)) report_type = encode_string(report_type, 'ASCII', name="{}[{}]".format(name, i)) args.append(('ReportTypeList.Type.{}'.format(i + 1), report_type)) return args
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)
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)
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)
def report_type_args(report_types, name=None): """ Converts the specified Report Types into their respective URL query arguments. *report_types* (**sequence**) contains each Report Type (``str``). This can contain any keys or values from ``REPORT_TYPES``. *name* (``str``) is the name to use when an error occurs. Returns a ``list`` containing each *key*-*report_type* ``tuple``. - *key* (``str``) is the query argument key for *report_type*. - *report_type* (``str``) is the Report Type. """ if not name: name = 'report_types' if not is_sequence(report_types): raise TypeError("{}:{!r} is not a sequence.".format( name, report_types)) args = [] for i, report_type in enumerate(report_types, 0): report_type = REPORT_TYPES.get(report_type, report_type) if not isinstance(report_type, basestring): raise TypeError("{}[{}]:{!r} is not a string.".format( name, i, report_type)) elif not report_type: raise ValueError("{}[{}]:{!r} cannot be empty.".format( name, i, report_type)) report_type = encode_string(report_type, 'ASCII', name="{}[{}]".format(name, i)) args.append(('ReportTypeList.Type.{}'.format(i + 1), report_type)) return args
def feed_type_args(feed_types, name=None): """ Converts the specified Feed Types into their resepctive URL query arguments. *feed_types* (**sequence**) contains each Feed Type (``str``). This can contain any of the keys or values from ``FEED_TYPES``. *name* (``str``) is the name to use when an error occurs. Returns a ``list`` containing each *key*-*feed_type* ``tuple``. - *key* (``str``) is the query argument key for *feed_type*. - *feed_type* (``str``) is the Feed Type ID. """ if not name: name = 'feed_types' if not is_sequence(feed_types): raise TypeError("{}:{!r} is not a sequence.".format(name, feed_types)) args = [] for i, feed_type in enumerate(feed_types): feed_type = FEED_TYPES.get(feed_type, feed_type) if not isinstance(feed_type, six.string_types): raise TypeError("{}[{}]:{!r} is not a str.".format( name, i, feed_type)) elif not feed_type: raise ValueError("{}[{}]:{!r} cannot be empty.".format( name, i, feed_type)) feed_type = encode_string(feed_type, 'ASCII', name="{}[{}]".format(name, i)) args.append(('FeedTypeList.Type.{}'.format(i + 1), feed_type)) return args
def status_args(statuses, name=None): """ Converts the specified Feed Processing Statuses into their respective URL query arguments. *statuses* (**sequence**) contains each Feed Processing Status (``str``). This can contain any of the keys or value from ``PROCESSING_STATUSES``. *name* (``str``) is the name to use when an error occurs. Returns a ``list`` containing each *key*-*status* ``tuple``. - *key* (``str``) is the query argument key for *status*. - *status* (``str``) is the Feed Processing Status. """ if not name: name = 'statuses' if not is_sequence(statuses): raise TypeError("{}:{!r} is not a sequence.".format(name, statuses)) args = [] for i, status in enumerate(statuses): status = PROCESSING_STATUSES.get(status, status) if not isinstance(status, six.string_types): raise TypeError("{}[{}]:{!r} is not a str.".format( name, i, status)) elif not status: raise ValueError("{}[{}]:{!r} cannot be empty.".format( name, i, status)) status = encode_string(status, 'ASCII', name="{}[{}]".format(name, i)) args.append( ('FeedProcessingStatusList.Status.{}'.format(i + 1), status)) return args
def status_args(statuses, name=None): """ Converts the specified Report Processing Status into their respective URL query arguments. *statuses* (**sequence**) contains each Report Processing Status (``str``). This contain any keys or values from ``REPORT_STATUSES``. *name* (``str``) is the name to use when an error occurs. Returns a ``list`` containing each *key*-*status* ``tuple``. - *key* (``str``) is the query argument key for *status*. - *request_id* (``str``) is the Report Processing Status. """ if not name: name = 'statuses' if not is_sequence(statuses): raise TypeError("{}:{!r} is not a statuses.".format(name, statuses)) args = [] for i, status in enumerate(statuses, 0): if not isinstance(status, basestring): raise TypeError("{}[{}]:{!r} is not a string.".format( name, i, status)) elif not status: raise ValueError("{}[{}]:{!r} cannot be empty.".format( name, i, status)) status = encode_string(status, 'ASCII', name="{}[{}]".format(name, i)) args.append( ('ReportProcessingStatusList.Status.{}'.format(i + 1), status)) return args
def request_args(requests, name=None): """ Converts the specified Report Request IDs into their respective URL query arguments. *requests* (**sequence**) contains each Report Request ID (``str``). *name* (``str``) is the name to use when an error occurs. Returns a ``list`` containing each *key*-*request_id* ``tuple``. - *key* (``str``) is the query argument key for *request_id*. - *request_id* (``str``) is the Report Request ID. """ if not name: name = 'requests' if not is_sequence(requests): raise TypeError("{}:{!r} is not a sequence.".format(name, requests)) args = [] for i, request_id in enumerate(requests, 0): if not isinstance(request_id, basestring): raise TypeError("{}[{}]:{!r} is not a string.".format( name, i, request_id)) elif not request_id: raise ValueError("{}[{}]:{!r} cannot be empty.".format( name, i, request_id)) request_id = encode_string(request_id, 'ASCII', name="{}[{}]".format(name, i)) args.append(('ReportRequestIdList.Id.{}'.format(i + 1), request_id)) return args