Class: UspsApi::FilesApi

Inherits:
BaseApi show all
Defined in:
lib/usps_api/apis/files_api.rb

Overview

FilesApi

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 UspsApi::BaseApi

Instance Method Details

#generate_signed_url(scope, file_id) ⇒ ApiResponse

Generate a secure, temporary URL for downloading a specific file using its file ID. determines the level of access and permissions for the API. The value of this parameter should be set to “service-standards-files” for service-standards-files-related operations.

Parameters:

  • scope (Scope25)

    Required parameter: The scope of the request, which

  • file_id (String)

    Required parameter: TODO: type description here

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/usps_api/apis/files_api.rb', line 57

def generate_signed_url(scope,
                        file_id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/{scope}/v3/files/{fileID}/generate-signed-url',
                                 Server::DEFAULT)
               .template_param(new_parameter(scope, key: 'scope')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(file_id, key: 'fileID')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Or.new('OAuth_authorization_code', 'OAuth_client_credentials')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(V3FilesGenerateSignedUrlResponse.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'Bad Request',
                             AddressesErrorException)
                .local_error('401',
                             'Unauthorized request',
                             AddressesErrorException)
                .local_error('403',
                             'Access is denied',
                             AddressesErrorException)
                .local_error('404',
                             'Resource Not Found',
                             AddressesErrorException)
                .local_error('503',
                             'Service Unavailable',
                             AddressesErrorException))
    .execute
end

#get_files(scope) ⇒ ApiResponse

Retrieve a list of files available for download from the Service Standards API. determines the level of access and permissions for the API. The value of this parameter should be set to “service-standards-files” for service-standards-files-related operations.

Parameters:

  • scope (Scope25)

    Required parameter: The scope of the request, which

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



16
17
18
19
20
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
# File 'lib/usps_api/apis/files_api.rb', line 16

def get_files(scope)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/{scope}/v3/files',
                                 Server::DEFAULT)
               .template_param(new_parameter(scope, key: 'scope')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Or.new('OAuth_authorization_code', 'OAuth_client_credentials')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ServiceStandardsFilesHypermediaLink.method(:from_hash))
                .is_api_response(true)
                .is_response_array(true)
                .local_error('400',
                             'Bad Request',
                             AddressesErrorException)
                .local_error('401',
                             'Unauthorized request',
                             AddressesErrorException)
                .local_error('403',
                             'Access is denied',
                             AddressesErrorException)
                .local_error('404',
                             'Resource Not Found',
                             AddressesErrorException)
                .local_error('503',
                             'Service Unavailable',
                             AddressesErrorException))
    .execute
end