Module: Peddler::Helpers::Feeds20210630

Included in:
APIs::Feeds20210630
Defined in:
lib/peddler/helpers/feeds_2021_06_30.rb

Instance Method Summary collapse

Instance Method Details

#upload_feed_document(upload_url, feed_content, content_type) ⇒ HTTP::Response

Uploads feed_content to a signed upload_url previously provided by create_feed_document. The upload_url is signed, the Host and content-type headers must match the signing. this must match the content-type requested in create_feed_document

Parameters:

  • upload_url (String)

    The signed url from the create_feed_document response.

  • feed_content (String)

    The body of the content to upload.

  • content_type (String)

    The content type of the upload,

Returns:

  • (HTTP::Response)

    The API response



14
15
16
17
18
19
20
21
22
23
# File 'lib/peddler/helpers/feeds_2021_06_30.rb', line 14

def upload_feed_document(upload_url, feed_content, content_type)
  response = HTTP.headers("content-type" => content_type).put(upload_url, body: feed_content)

  if response.status.client_error?
    error = Error.build(response)
    raise error if error
  end

  response
end