Class: WalmartApIs::UploadsApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/walmart_ap_is/apis/uploads_api.rb

Overview

UploadsApi

Constant Summary

Constants inherited from BaseApi

BaseApi::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseApi

#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from WalmartApIs::BaseApi

Instance Method Details

#create_upload_destination_for_resource(resource, content_md5, content_type, marketplace_ids) ⇒ ApiResponse

Returns a pre-signed URL and upload destination ID for uploading a document for the given resource (e.g. feeds, reports). Do not log the pre-signed URL — it contains temporary credentials. upload destination (e.g. feeds) be uploaded, encoded as base64 content to be uploaded type description here

Parameters:

  • resource (Resource)

    Required parameter: The resource type for the

  • content_md5 (String)

    Required parameter: MD5 hash of the content to

  • content_type (ContentType1)

    Required parameter: MIME type of the

  • marketplace_ids (Array[MarketplaceId])

    Required parameter: TODO:

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/walmart_ap_is/apis/uploads_api.rb', line 21

def create_upload_destination_for_resource(resource,
                                           content_md5,
                                           content_type,
                                           marketplace_ids)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/uploads/v4/uploadDestinations/{resource}',
                                 Server::DEFAULT1)
               .template_param(new_parameter(resource, key: 'resource')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter(content_md5, key: 'contentMD5')
                              .is_required(true))
               .query_param(new_parameter(content_type, key: 'contentType')
                             .is_required(true))
               .query_param(new_parameter(marketplace_ids, key: 'marketplaceIds')
                             .is_required(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('walletAuth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(CreateUploadDestinationResponse.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Bad Request',
                             ErrorListErrorException)
                .local_error('403',
                             'Forbidden',
                             ErrorListErrorException)
                .local_error('429',
                             'Rate limit exceeded',
                             ErrorListErrorException)
                .local_error('500',
                             'Internal Server Error',
                             ErrorListErrorException))
    .execute
end