Class: ModernTreasury::DocumentCreateRequest

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/modern_treasury/models/document_create_request.rb

Overview

DocumentCreateRequest 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(documentable_id:, documentable_type:, file:, document_type: SKIP, additional_properties: nil) ⇒ DocumentCreateRequest

Returns a new instance of DocumentCreateRequest.



50
51
52
53
54
55
56
57
58
59
60
# File 'lib/modern_treasury/models/document_create_request.rb', line 50

def initialize(documentable_id:, documentable_type:, file:,
               document_type: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @documentable_id = documentable_id
  @documentable_type = documentable_type
  @document_type = document_type unless document_type == SKIP
  @file = file
  @additional_properties = additional_properties
end

Instance Attribute Details

#document_typeString

A category given to the document, can be ‘null`.

Returns:

  • (String)


22
23
24
# File 'lib/modern_treasury/models/document_create_request.rb', line 22

def document_type
  @document_type
end

#documentable_idString

The unique identifier for the associated object.

Returns:

  • (String)


14
15
16
# File 'lib/modern_treasury/models/document_create_request.rb', line 14

def documentable_id
  @documentable_id
end

#documentable_typeDocumentableType1

The unique identifier for the associated object.

Returns:



18
19
20
# File 'lib/modern_treasury/models/document_create_request.rb', line 18

def documentable_type
  @documentable_type
end

#fileBinary

A category given to the document, can be ‘null`.

Returns:

  • (Binary)


26
27
28
# File 'lib/modern_treasury/models/document_create_request.rb', line 26

def file
  @file
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/modern_treasury/models/document_create_request.rb', line 63

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  documentable_id =
    hash.key?('documentable_id') ? hash['documentable_id'] : nil
  documentable_type =
    hash.key?('documentable_type') ? hash['documentable_type'] : nil
  file = hash.key?('file') ? hash['file'] : nil
  document_type = hash.key?('document_type') ? hash['document_type'] : 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.
  DocumentCreateRequest.new(documentable_id: documentable_id,
                            documentable_type: documentable_type,
                            file: file,
                            document_type: document_type,
                            additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



29
30
31
32
33
34
35
36
# File 'lib/modern_treasury/models/document_create_request.rb', line 29

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['documentable_id'] = 'documentable_id'
  @_hash['documentable_type'] = 'documentable_type'
  @_hash['document_type'] = 'document_type'
  @_hash['file'] = 'file'
  @_hash
end

.nullablesObject

An array for nullable fields



46
47
48
# File 'lib/modern_treasury/models/document_create_request.rb', line 46

def self.nullables
  []
end

.optionalsObject

An array for optional fields



39
40
41
42
43
# File 'lib/modern_treasury/models/document_create_request.rb', line 39

def self.optionals
  %w[
    document_type
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



98
99
100
101
102
103
# File 'lib/modern_treasury/models/document_create_request.rb', line 98

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} documentable_id: #{@documentable_id.inspect}, documentable_type:"\
  " #{@documentable_type.inspect}, document_type: #{@document_type.inspect}, file:"\
  " #{@file.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



90
91
92
93
94
95
# File 'lib/modern_treasury/models/document_create_request.rb', line 90

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} documentable_id: #{@documentable_id}, documentable_type:"\
  " #{@documentable_type}, document_type: #{@document_type}, file: #{@file},"\
  " additional_properties: #{@additional_properties}>"
end