Class: Peddler::APIs::Feeds20210630

Inherits:
Peddler::API show all
Includes:
Helpers::Feeds20210630
Defined in:
lib/peddler/apis/feeds_2021_06_30.rb,
lib/peddler/apis/feeds_2021_06_30/feed.rb,
lib/peddler/apis/feeds_2021_06_30/error.rb,
lib/peddler/apis/feeds_2021_06_30/feed_list.rb,
lib/peddler/apis/feeds_2021_06_30/error_list.rb,
lib/peddler/apis/feeds_2021_06_30/feed_document.rb,
lib/peddler/apis/feeds_2021_06_30/get_feeds_response.rb,
lib/peddler/apis/feeds_2021_06_30/create_feed_response.rb,
lib/peddler/apis/feeds_2021_06_30/create_feed_specification.rb,
lib/peddler/apis/feeds_2021_06_30/create_feed_document_response.rb,
lib/peddler/apis/feeds_2021_06_30/create_feed_document_specification.rb

Overview

Selling Partner API for Feeds

The Selling Partner API for Feeds lets you upload data to Amazon on behalf of a selling partner.

Defined Under Namespace

Classes: FeedList

Constant Summary collapse

Feed =

Detailed information about the feed.

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

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

  # @return [String] The feed type.
  attribute(:feed_type, String, from: "feedType")

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

  # @return [Array<String>] A list of identifiers for the marketplaces that the feed is applied to.
  attribute?(:marketplace_ids, [String], from: "marketplaceIds")

  # @return [Time] The date and time when feed processing completed, in ISO 8601 date time format.
  attribute?(:processing_end_time, Time, from: "processingEndTime")

  # @return [Time] The date and time when feed processing started, in ISO 8601 date time format.
  attribute?(:processing_start_time, Time, from: "processingStartTime")

  # @return [String] The identifier for the feed document. This identifier is unique only in combination with a
  # seller ID.
  attribute?(:result_feed_document_id, String, from: "resultFeedDocumentId")
end
Error =

An 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
ErrorList =

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

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

Information required for the feed document.

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

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

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

Response schema.

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

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

Response schema.

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

Information required to create the feed.

Structure.new do
  # @return [String] The feed type.
  attribute(:feed_type, String, from: "feedType")

  # @return [String] The document identifier returned by the createFeedDocument operation. Upload the feed
  # document contents before calling the createFeed operation.
  attribute(:input_feed_document_id, String, from: "inputFeedDocumentId")

  # @return [Array<String>] A list of identifiers for marketplaces that you want the feed to be applied to.
  attribute(:marketplace_ids, [String], from: "marketplaceIds")

  # @return [Hash]
  attribute?(:feed_options, Hash, from: "feedOptions")
end
CreateFeedDocumentResponse =

Information required to upload a feed document's contents.

Structure.new do
  # @return [String] The identifier of the feed document.
  attribute(:feed_document_id, String, from: "feedDocumentId")

  # @return [String] The presigned URL for uploading the feed contents. This URL expires after 5 minutes.
  attribute(:url, String)
end
CreateFeedDocumentSpecification =

Specifies the content type for the createFeedDocument operation.

Structure.new do
  # @return [String] The content type of the feed.
  attribute(:content_type, String, from: "contentType")
end

Instance Attribute Summary

Attributes inherited from Peddler::API

#access_token, #endpoint, #retries

Instance Method Summary collapse

Methods included from Helpers::Feeds20210630

#download_result_feed_document, #upload_feed_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_feed(feed_id, rate_limit: 2.0) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Cancels the feed that you specify. Only feeds with processingStatus=IN_QUEUE can be cancelled. Cancelled feeds are returned in subsequent calls to the getFeed and getFeeds operations.

ID.

Parameters:

  • feed_id (String)

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

  • rate_limit (Float) (defaults to: 2.0)

    Requests per second

Returns:



72
73
74
75
# File 'lib/peddler/apis/feeds_2021_06_30.rb', line 72

def cancel_feed(feed_id, rate_limit: 2.0)
  path = "/feeds/2021-06-30/feeds/#{percent_encode(feed_id)}"
  meter(rate_limit).delete(path)
end

#create_feed(body, rate_limit: 0.0083) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Creates a feed. Upload the contents of the feed document before calling this operation.

Parameters:

  • body (Hash)

    Information required to create the feed.

  • rate_limit (Float) (defaults to: 0.0083)

    Requests per second

Returns:



57
58
59
60
61
# File 'lib/peddler/apis/feeds_2021_06_30.rb', line 57

def create_feed(body, rate_limit: 0.0083)
  path = "/feeds/2021-06-30/feeds"
  parser = -> { CreateFeedResponse }
  meter(rate_limit).post(path, body:, parser:)
end

#create_feed_document(body, rate_limit: 0.5) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Creates a feed document for the feed type that you specify. This operation returns a presigned URL for uploading the feed document contents. It also returns a feedDocumentId value that you can pass in with a subsequent call to the createFeed operation.

Parameters:

  • body (Hash)

    Specifies the content type for the createFeedDocument operation.

  • rate_limit (Float) (defaults to: 0.5)

    Requests per second

Returns:



98
99
100
101
102
# File 'lib/peddler/apis/feeds_2021_06_30.rb', line 98

def create_feed_document(body, rate_limit: 0.5)
  path = "/feeds/2021-06-30/documents"
  parser = -> { CreateFeedDocumentResponse }
  meter(rate_limit).post(path, body:, parser:)
end

#get_feed(feed_id, rate_limit: 2.0) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

Returns feed details (including the resultDocumentId, if available) for the feed that you specify.

ID.

Parameters:

  • feed_id (String)

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

  • rate_limit (Float) (defaults to: 2.0)

    Requests per second

Returns:



84
85
86
87
88
# File 'lib/peddler/apis/feeds_2021_06_30.rb', line 84

def get_feed(feed_id, rate_limit: 2.0)
  path = "/feeds/2021-06-30/feeds/#{percent_encode(feed_id)}"
  parser = -> { Feed }
  meter(rate_limit).get(path, parser:)
end

#get_feed_document(feed_document_id, rate_limit: 0.0222) ⇒ Peddler::Response

Note:

This operation can make a static sandbox call.

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

Parameters:

  • feed_document_id (String)

    The identifier of the feed document.

  • rate_limit (Float) (defaults to: 0.0222)

    Requests per second

Returns:



110
111
112
113
114
# File 'lib/peddler/apis/feeds_2021_06_30.rb', line 110

def get_feed_document(feed_document_id, rate_limit: 0.0222)
  path = "/feeds/2021-06-30/documents/#{percent_encode(feed_document_id)}"
  parser = -> { FeedDocument }
  meter(rate_limit).get(path, parser:)
end

#get_feeds(feed_types: nil, marketplace_ids: nil, page_size: 10, processing_statuses: nil, 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 feed details for the feeds that match the filters that you specify.

other filter parameters (processingStatuses, marketplaceIds, createdSince, createdUntil) and pageSize may also be provided. Either feedTypes or nextToken is required. returned will match at least one of the marketplaces that you specify. ISO 8601 format. The default is 90 days ago. Feeds are retained for a maximum of 90 days. 8601 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 getFeeds operation and include this token as the only parameter. Specifying nextToken with any other parameters will cause the request to fail.

Parameters:

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

    A list of feed types used to filter feeds. When feedTypes is provided, the

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

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

  • page_size (Integer) (defaults to: 10)

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

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

    A list of processing statuses used to filter feeds.

  • created_since (String) (defaults to: nil)

    The earliest feed creation date and time for feeds included in the response, in

  • created_until (String) (defaults to: nil)

    The latest feed creation date and time for feeds included in the response, in ISO

  • 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:



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/peddler/apis/feeds_2021_06_30.rb', line 35

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