Class: Peddler::APIs::Uploads20201101

Inherits:
Peddler::API show all
Defined in:
lib/peddler/apis/uploads_2020_11_01.rb,
lib/peddler/apis/uploads_2020_11_01/error.rb,
lib/peddler/apis/uploads_2020_11_01/error_list.rb,
lib/peddler/apis/uploads_2020_11_01/upload_destination.rb,
lib/peddler/apis/uploads_2020_11_01/create_upload_destination_response.rb,
sig/peddler/apis/uploads_2020_11_01.rbs

Overview

Selling Partner API for Uploads

The Uploads API lets you upload files that you can programmatically access using other Selling Partner APIs, such as the A+ Content API and the Messaging API.

Defined Under Namespace

Classes: CreateUploadDestinationResponse, Error, ErrorList, UploadDestination

Constant Summary

Constants inherited from Peddler::API

Peddler::API::TRANSIENT_STATUSES

Instance Attribute Summary

Attributes inherited from Peddler::API

#access_token, #base_url, #endpoint, #retries

Instance Method Summary collapse

Methods inherited from Peddler::API

#cannot_sandbox!, #delete, #endpoint_uri, #get, #host_header, #http, #initialize, #must_sandbox!, #parse_base_url, #patch, #percent_encode, #post, #put, #request, #sandbox, #sandbox?, #stringify_array, #timestamp, #user_agent

Constructor Details

This class inherits a constructor from Peddler::API

Instance Method Details

#create_upload_destination_for_resource(marketplace_ids, content_md5, resource, content_type: nil, rate_limit: 10.0) ⇒ Peddler::Response

Creates an upload destination, returning the information required to upload a file to the destination and to programmatically access the file.

Parameters:

  • marketplace_ids (Array<String>) —

    The marketplace ID is the globally unique identifier of a marketplace. To find the ID for your marketplace, refer to Marketplace IDs.

  • content_md5 (String) —

    An MD5 hash of the content to be submitted to the upload destination. This value is used to determine if the data has been corrupted or tampered with during transit.

  • resource (String) —

    The upload destination for your resource. For example, if you create an upload destination for the createLegalDisclosure operation of the Messaging API, the {resource} would be /messaging/v1/orders/{amazonOrderId}/messages/legalDisclosure, and the entire path would be /uploads/2020-11-01/uploadDestinations/messaging/v1/orders/{amazonOrderId}/messages/legalDisclosure. If you create an upload destination for an Aplus content document, the {resource} would be aplus/2020-11-01/contentDocuments and the path would be /uploads/2020-11-01/uploadDestinations/aplus/2020-11-01/contentDocuments.

  • content_type (String) (defaults to: nil) —

    The content type of the file you upload. This parameter is required for A+ content.

  • rate_limit (Float) (defaults to: 10.0) —

    Requests per second

  • (Array[String])
  • (String)
  • (String)
  • content_type: (String, nil) (defaults to: nil)
  • rate_limit: (Float) (defaults to: 10.0)

Returns:



32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/peddler/apis/uploads_2020_11_01.rb', line 32

def create_upload_destination_for_resource(marketplace_ids, content_md5, resource, content_type: nil,
  rate_limit: 10.0)
  cannot_sandbox!

  path = "/uploads/2020-11-01/uploadDestinations/#{percent_encode(resource)}"
  params = {
    "marketplaceIds" => stringify_array(marketplace_ids),
    "contentMD5" => content_md5,
    "contentType" => content_type,
  }.compact
  parser = -> { CreateUploadDestinationResponse }
  post(path, params:, rate_limit:, parser:)
end