Class: UspsApi::V3FilesGenerateSignedUrlResponse

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/usps_api/models/v3_files_generate_signed_url_response.rb

Overview

V3FilesGenerateSignedUrlResponse Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(signed_url: SKIP, expiry: SKIP, content_length: SKIP, range_limit: SKIP, additional_properties: nil) ⇒ V3FilesGenerateSignedUrlResponse

Returns a new instance of V3FilesGenerateSignedUrlResponse.



60
61
62
63
64
65
66
67
68
69
70
# File 'lib/usps_api/models/v3_files_generate_signed_url_response.rb', line 60

def initialize(signed_url: SKIP, expiry: SKIP, content_length: SKIP,
               range_limit: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @signed_url = signed_url unless signed_url == SKIP
  @expiry = expiry unless expiry == SKIP
  @content_length = content_length unless content_length == SKIP
  @range_limit = range_limit unless range_limit == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#content_lengthInteger

Size of the file in bytes

Returns:

  • (Integer)


27
28
29
# File 'lib/usps_api/models/v3_files_generate_signed_url_response.rb', line 27

def content_length
  @content_length
end

#expiryDateTime

Expiration date and time of the signed URL

Returns:

  • (DateTime)


23
24
25
# File 'lib/usps_api/models/v3_files_generate_signed_url_response.rb', line 23

def expiry
  @expiry
end

#range_limitInteger

The maximum number of bytes that can be downloaded using the signed URL. This value is specified in bytes and ensures that users do not exceed the allocated download limit.

Returns:

  • (Integer)


33
34
35
# File 'lib/usps_api/models/v3_files_generate_signed_url_response.rb', line 33

def range_limit
  @range_limit
end

#signed_urlObject

A fully-qualified SAS URL appended with a secure token that provides temporary, restricted access to the requested file. This SAS URL supports HTTP Range requests, allowing consumers to download files in chunks. This is particularly useful for resuming interrupted downloads or handling very large files.

Returns:

  • (Object)


19
20
21
# File 'lib/usps_api/models/v3_files_generate_signed_url_response.rb', line 19

def signed_url
  @signed_url
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# File 'lib/usps_api/models/v3_files_generate_signed_url_response.rb', line 73

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  signed_url = hash.key?('signedURL') ? hash['signedURL'] : SKIP
  expiry = if hash.key?('expiry')
             (DateTimeHelper.from_rfc3339(hash['expiry']) if hash['expiry'])
           else
             SKIP
           end
  content_length = hash.key?('contentLength') ? hash['contentLength'] : SKIP
  range_limit = hash.key?('rangeLimit') ? hash['rangeLimit'] : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  V3FilesGenerateSignedUrlResponse.new(signed_url: signed_url,
                                       expiry: expiry,
                                       content_length: content_length,
                                       range_limit: range_limit,
                                       additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



36
37
38
39
40
41
42
43
# File 'lib/usps_api/models/v3_files_generate_signed_url_response.rb', line 36

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['signed_url'] = 'signedURL'
  @_hash['expiry'] = 'expiry'
  @_hash['content_length'] = 'contentLength'
  @_hash['range_limit'] = 'rangeLimit'
  @_hash
end

.nullablesObject

An array for nullable fields



56
57
58
# File 'lib/usps_api/models/v3_files_generate_signed_url_response.rb', line 56

def self.nullables
  []
end

.optionalsObject

An array for optional fields



46
47
48
49
50
51
52
53
# File 'lib/usps_api/models/v3_files_generate_signed_url_response.rb', line 46

def self.optionals
  %w[
    signed_url
    expiry
    content_length
    range_limit
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



114
115
116
117
118
119
# File 'lib/usps_api/models/v3_files_generate_signed_url_response.rb', line 114

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} signed_url: #{@signed_url.inspect}, expiry: #{@expiry.inspect},"\
  " content_length: #{@content_length.inspect}, range_limit: #{@range_limit.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_custom_expiryObject



101
102
103
# File 'lib/usps_api/models/v3_files_generate_signed_url_response.rb', line 101

def to_custom_expiry
  DateTimeHelper.to_rfc3339(expiry)
end

#to_sObject

Provides a human-readable string representation of the object.



106
107
108
109
110
111
# File 'lib/usps_api/models/v3_files_generate_signed_url_response.rb', line 106

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} signed_url: #{@signed_url}, expiry: #{@expiry}, content_length:"\
  " #{@content_length}, range_limit: #{@range_limit}, additional_properties:"\
  " #{@additional_properties}>"
end