Class: WalmartApIs::DocumentDownload

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/walmart_ap_is/models/document_download.rb

Overview

Resource to download the requested document.

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(download_type:, uri:, expiration: SKIP, additional_properties: nil) ⇒ DocumentDownload

Returns a new instance of DocumentDownload.



47
48
49
50
51
52
53
54
55
56
# File 'lib/walmart_ap_is/models/document_download.rb', line 47

def initialize(download_type:, uri:, expiration: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @download_type = download_type
  @expiration = expiration unless expiration == SKIP
  @uri = uri
  @additional_properties = additional_properties
end

Instance Attribute Details

#download_typeString

The type of download. Possible values: URL.

Returns:

  • (String)


15
16
17
# File 'lib/walmart_ap_is/models/document_download.rb', line 15

def download_type
  @download_type
end

#expirationDateTime

The URI's expiration time. In ISO 8601 datetime format with pattern yyyy-MM-ddTHH:mm:ss.sssZ.

Returns:

  • (DateTime)


20
21
22
# File 'lib/walmart_ap_is/models/document_download.rb', line 20

def expiration
  @expiration
end

#uriString

Uniform resource identifier to identify where the document is located.

Returns:

  • (String)


24
25
26
# File 'lib/walmart_ap_is/models/document_download.rb', line 24

def uri
  @uri
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/walmart_ap_is/models/document_download.rb', line 59

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  download_type = hash.key?('downloadType') ? hash['downloadType'] : nil
  uri = hash.key?('uri') ? hash['uri'] : nil
  expiration = if hash.key?('expiration')
                 (DateTimeHelper.from_rfc3339(hash['expiration']) if hash['expiration'])
               else
                 SKIP
               end

  # 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.
  DocumentDownload.new(download_type: download_type,
                       uri: uri,
                       expiration: expiration,
                       additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



27
28
29
30
31
32
33
# File 'lib/walmart_ap_is/models/document_download.rb', line 27

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['download_type'] = 'downloadType'
  @_hash['expiration'] = 'expiration'
  @_hash['uri'] = 'uri'
  @_hash
end

.nullablesObject

An array for nullable fields



43
44
45
# File 'lib/walmart_ap_is/models/document_download.rb', line 43

def self.nullables
  []
end

.optionalsObject

An array for optional fields



36
37
38
39
40
# File 'lib/walmart_ap_is/models/document_download.rb', line 36

def self.optionals
  %w[
    expiration
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



97
98
99
100
101
102
# File 'lib/walmart_ap_is/models/document_download.rb', line 97

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} download_type: #{@download_type.inspect}, expiration:"\
  " #{@expiration.inspect}, uri: #{@uri.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_custom_expirationObject



85
86
87
# File 'lib/walmart_ap_is/models/document_download.rb', line 85

def to_custom_expiration
  DateTimeHelper.to_rfc3339(expiration)
end

#to_sObject

Provides a human-readable string representation of the object.



90
91
92
93
94
# File 'lib/walmart_ap_is/models/document_download.rb', line 90

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} download_type: #{@download_type}, expiration: #{@expiration}, uri: #{@uri},"\
  " additional_properties: #{@additional_properties}>"
end