Class: TqlOtrFactoringDataExchange::Base64Document

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/tql_otr_factoring_data_exchange/models/base64_document.rb

Overview

An optional document to include with the request, encoded as a base64 string.

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(content:, file_name:, content_type:, additional_properties: nil) ⇒ Base64Document

Returns a new instance of Base64Document.



44
45
46
47
48
49
50
51
52
53
# File 'lib/tql_otr_factoring_data_exchange/models/base64_document.rb', line 44

def initialize(content:, file_name:, content_type:,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @content = content
  @file_name = file_name
  @content_type = content_type
  @additional_properties = additional_properties
end

Instance Attribute Details

#contentString

Base64-encoded document content.

Returns:

  • (String)


15
16
17
# File 'lib/tql_otr_factoring_data_exchange/models/base64_document.rb', line 15

def content
  @content
end

#content_typeString

MIME type of the document.

Returns:

  • (String)


23
24
25
# File 'lib/tql_otr_factoring_data_exchange/models/base64_document.rb', line 23

def content_type
  @content_type
end

#file_nameString

Original file name including extension.

Returns:

  • (String)


19
20
21
# File 'lib/tql_otr_factoring_data_exchange/models/base64_document.rb', line 19

def file_name
  @file_name
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/tql_otr_factoring_data_exchange/models/base64_document.rb', line 56

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  content = hash.key?('content') ? hash['content'] : nil
  file_name = hash.key?('fileName') ? hash['fileName'] : nil
  content_type = hash.key?('contentType') ? hash['contentType'] : nil

  # 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.
  Base64Document.new(content: content,
                     file_name: file_name,
                     content_type: content_type,
                     additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



26
27
28
29
30
31
32
# File 'lib/tql_otr_factoring_data_exchange/models/base64_document.rb', line 26

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['content'] = 'content'
  @_hash['file_name'] = 'fileName'
  @_hash['content_type'] = 'contentType'
  @_hash
end

.nullablesObject

An array for nullable fields



40
41
42
# File 'lib/tql_otr_factoring_data_exchange/models/base64_document.rb', line 40

def self.nullables
  []
end

.optionalsObject

An array for optional fields



35
36
37
# File 'lib/tql_otr_factoring_data_exchange/models/base64_document.rb', line 35

def self.optionals
  []
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (Base64Document | Hash)

    value against the validation is performed.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/tql_otr_factoring_data_exchange/models/base64_document.rb', line 80

def self.validate(value)
  if value.instance_of? self
    return (
      APIHelper.valid_type?(value.content,
                            ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.file_name,
                              ->(val) { val.instance_of? String }) and
        APIHelper.valid_type?(value.content_type,
                              ->(val) { val.instance_of? String })
    )
  end

  return false unless value.instance_of? Hash

  (
    APIHelper.valid_type?(value['content'],
                          ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['fileName'],
                            ->(val) { val.instance_of? String }) and
      APIHelper.valid_type?(value['contentType'],
                            ->(val) { val.instance_of? String })
  )
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



112
113
114
115
116
# File 'lib/tql_otr_factoring_data_exchange/models/base64_document.rb', line 112

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

#to_sObject

Provides a human-readable string representation of the object.



105
106
107
108
109
# File 'lib/tql_otr_factoring_data_exchange/models/base64_document.rb', line 105

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