Module: Amazon::MWS::Feed

Defined in:
lib/amazon/mws/request/feed.rb

Constant Summary collapse

FEED_TYPES =

Note: We do not handle flat file feed types

{
  :product_data              => '_POST_PRODUCT_DATA_',
  :product_relationship_data => '_POST_PRODUCT_RELATIONSHIP_DATA_',
  :item_data                 => '_POST_ITEM_DATA_',
  :product_overrides         => '_POST_PRODUCT_OVERRIDES_DATA_',
  :product_image_data        => '_POST_PRODUCT_IMAGE_DATA_',
  :product_pricing           => '_POST_PRODUCT_PRICING_DATA_',
  :inventory_availability    => '_POST_INVENTORY_AVAILABILITY_DATA_',
  :order_acknowledgement     => '_POST_ORDER_ACKNOWLEDGEMENT_DATA_',
  :order_fulfillment         => '_POST_ORDER_FULFILLMENT_DATA_',
  :payment_adjustment        => '_POST_PAYMENT_ADJUSTMENT_DATA_',
  :invoice_confirmation      => '_POST_INVOICE_CONFIRMATION_DATA_'
  # :flat_file_listings              => '_POST_FLAT_FILE_LISTINGS_DATA_',
  # :flat_file_order_acknowledgement => '_POST_FLAT_FILE_ORDER_ACKNOWLEDGEMENT_DATA_',
  # :flat_file_fulfillment_data      => '_POST_FLAT_FILE_FULFILLMENT_DATA_',
  # :flat_file_payment_adjustment    => '_POST_FLAT_FILE_PAYMENT_ADJUSTMENT_DATA_',
  # :flat_file_invloader             => '_POST_FLAT_FILE_INVLOADER_DATA_'
}
MESSAGE_TYPES =
[
  "FulfillmentCenter",
  "Inventory",
  "OrderAcknowledgement",
  "OrderAdjustment",
  "OrderFulfillment",
  "OrderReport",
  "Override",
  "Price",
  "ProcessingReport",
  "Product",
  "ProductImage",
  "Relationship",
  "SettlementReport",
  "InvoiceConfirmation"
]
PRODUCT_MESSAGE_TYPES =
[
  "Product",
  "Price",
  "ProductImage",
  "Relationship",
  "Inventory"
]
PROCESSING_STATUSES =
{
  :submitted => '_SUBMITTED_',
  :in_progress => '_IN_PROGRESS_',
  :done => '_DONE_',
  :completed => '_COMPLETED_'
}

Instance Method Summary collapse

Instance Method Details

#cancel_feed_submissions(params = {}) ⇒ Object

SubmittedToDate The latest submission 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”).



237
238
239
240
241
242
# File 'lib/amazon/mws/request/feed.rb', line 237

def cancel_feed_submissions(params = {})
  response =
  get("/", {"Action" => "CancelFeedSubmissions"}.merge(params))

  CancelFeedSubmissionsResponse.format(response)
end

#get_feed_submission_count(params = {}) ⇒ Object Also known as: feed_submission_count

SubmittedToDate The latest submission 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”).



197
198
199
200
# File 'lib/amazon/mws/request/feed.rb', line 197

def get_feed_submission_count(params = {})
  response = get("/", {"Action" => "GetFeedSubmissionCount"}.merge(params))
  GetFeedSubmissionCountResponse.format(response)
end

#get_feed_submission_list(params = {}) ⇒ Object Also known as: feed_submission_list

SubmittedToDate The latest submission 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”).



139
140
141
142
# File 'lib/amazon/mws/request/feed.rb', line 139

def get_feed_submission_list(params = {})
 response = get("/", {"Action" => "GetFeedSubmissionList"}.merge(params))
 result = GetFeedSubmissionListResponse.format(response)
end

#get_feed_submission_list_by_next_token(next_token) ⇒ Object Also known as: feed_submission_list_by_next_token

The GetFeedSubmissionListByNextToken operation returns a list of feed submissions that match the query parameters, using the NextToken, which was supplied by a previous call to either GetFeedSubmissionListByNextToken or a call to GetFeedSubmissionList, where the value of HasNext was true in that previous call.

Request Parameters


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



157
158
159
160
161
162
163
164
165
# File 'lib/amazon/mws/request/feed.rb', line 157

def get_feed_submission_list_by_next_token(next_token)
  response =
   get("/", {
     "Action"   => "GetFeedSubmissionListByNextToken",
     "NextToken" => next_token
   })

   GetFeedSubmissionListByNextTokenResponse.format(response)
end

#get_feed_submission_result(feed_submission_id, params = {}) ⇒ Object Also known as: feed_submission_result

FeedSubmissionId The identifier of the feed submission to get results for. Obtained by a call to GetFeedSubmissionList.



261
262
263
264
265
266
267
268
# File 'lib/amazon/mws/request/feed.rb', line 261

def get_feed_submission_result(feed_submission_id, params = {})
  response = get("/", {
    "Action"           => "GetFeedSubmissionResult",
    "FeedSubmissionId" => feed_submission_id
  }.merge(params))

  GetFeedSubmissionResultResponse.format(response)
end

#submit_feed(feed_type, message_type, messages = [], params = {}) ⇒ Object Also known as: submit

params can only contain => true

Raises:



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/amazon/mws/request/feed.rb', line 75

def submit_feed(feed_type, message_type, messages = [], params = {})
  message_type= message_type.to_s.camelize
  raise InvalidMessageType if !MESSAGE_TYPES.include?(message_type)
  raise "Missing merchant_id" unless @merchant_id
  
  body = Amazon::MWS::FeedBuilder.new(message_type, messages, params.merge({:merchant_id => @merchant_id})).render
  puts body if Amazon::MWS::Base.debug
  
  response =
    post("/", {
    "Action"   => "SubmitFeed",
    "FeedType" => FEED_TYPES[feed_type]
  }, body)

  result = SubmitFeedResponse.format(response)
end

#submit_flat_file_feed(records, purge_flag = false) ⇒ Object

Amazon MWS limits calls to 1,000 total calls per hour per seller account. For best performance, you should limit your calls to SubmitFeed to no more than three feeds per hour per seller account, although you can successfully call SubmitFeed up to 30 times per hour. Feed size is limited to 2,147,483,647 bytes (2^32 -1) per feed.



66
67
68
69
70
71
72
# File 'lib/amazon/mws/request/feed.rb', line 66

def submit_flat_file_feed(records, purge_flag = false)
  header = "sku\tproduct-id\tproduct-id-type\tprice\titem-condition\tquantity\tadd-delete\twill-ship-internationally\texpedited-shipping\titem-note\tfulfillment-center-id"
  query_params = {"Action" => "SubmitFeed","FeedType" => "_POST_FLAT_FILE_INVLOADER_DATA_"}
  query_params['PurgeAndReplace'] = 'true' if purge_flag
  response = post("/", query_params, ([header] + records).join("\r"))
  result = SubmitFeedResponse.format(response)
end