Class: ModernTreasury::Document
- Defined in:
- lib/modern_treasury/models/document.rb
Overview
Document Model.
Instance Attribute Summary collapse
-
#created_at ⇒ DateTime
This field will be true if this object exists in the live environment or false if it exists in the test environment.
-
#discarded_at ⇒ DateTime
This field will be true if this object exists in the live environment or false if it exists in the test environment.
-
#document_details ⇒ Array[DocumentDetail]
The type of the associated object.
-
#document_type ⇒ String
A category given to the document, can be ‘null`.
-
#documentable_id ⇒ UUID | String
The unique identifier for the associated object.
-
#documentable_type ⇒ DocumentableType
The type of the associated object.
-
#file ⇒ File
The type of the associated object.
-
#id ⇒ UUID | String
TODO: Write general description for this method.
-
#live_mode ⇒ TrueClass | FalseClass
This field will be true if this object exists in the live environment or false if it exists in the test environment.
-
#object ⇒ String
TODO: Write general description for this method.
-
#source ⇒ String
The source of the document.
-
#updated_at ⇒ DateTime
This field will be true if this object exists in the live environment or false if it exists in the test environment.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(id:, object:, live_mode:, created_at:, updated_at:, discarded_at:, document_type:, source:, documentable_id:, documentable_type:, document_details:, file:) ⇒ Document
constructor
A new instance of Document.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_created_at ⇒ Object
- #to_custom_discarded_at ⇒ Object
- #to_custom_updated_at ⇒ Object
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(id:, object:, live_mode:, created_at:, updated_at:, discarded_at:, document_type:, source:, documentable_id:, documentable_type:, document_details:, file:) ⇒ Document
Returns a new instance of Document.
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/modern_treasury/models/document.rb', line 106 def initialize(id:, object:, live_mode:, created_at:, updated_at:, discarded_at:, document_type:, source:, documentable_id:, documentable_type:, document_details:, file:) @id = id @object = object @live_mode = live_mode @created_at = created_at @updated_at = updated_at @discarded_at = discarded_at @document_type = document_type @source = source @documentable_id = documentable_id @documentable_type = documentable_type @document_details = document_details @file = file end |
Instance Attribute Details
#created_at ⇒ DateTime
This field will be true if this object exists in the live environment or false if it exists in the test environment.
29 30 31 |
# File 'lib/modern_treasury/models/document.rb', line 29 def created_at @created_at end |
#discarded_at ⇒ DateTime
This field will be true if this object exists in the live environment or false if it exists in the test environment.
39 40 41 |
# File 'lib/modern_treasury/models/document.rb', line 39 def discarded_at @discarded_at end |
#document_details ⇒ Array[DocumentDetail]
The type of the associated object. Currently can be one of ‘payment_order`, `transaction`, `paper_item`, `expected_payment`, `counterparty`, `organization`, `case`, `internal_account`, `decision`, or `external_account`.
66 67 68 |
# File 'lib/modern_treasury/models/document.rb', line 66 def document_details @document_details end |
#document_type ⇒ String
A category given to the document, can be ‘null`.
43 44 45 |
# File 'lib/modern_treasury/models/document.rb', line 43 def document_type @document_type end |
#documentable_id ⇒ UUID | String
The unique identifier for the associated object.
52 53 54 |
# File 'lib/modern_treasury/models/document.rb', line 52 def documentable_id @documentable_id end |
#documentable_type ⇒ DocumentableType
The type of the associated object. Currently can be one of ‘payment_order`, `transaction`, `paper_item`, `expected_payment`, `counterparty`, `organization`, `case`, `internal_account`, `decision`, or `external_account`.
59 60 61 |
# File 'lib/modern_treasury/models/document.rb', line 59 def documentable_type @documentable_type end |
#file ⇒ File
The type of the associated object. Currently can be one of ‘payment_order`, `transaction`, `paper_item`, `expected_payment`, `counterparty`, `organization`, `case`, `internal_account`, `decision`, or `external_account`.
73 74 75 |
# File 'lib/modern_treasury/models/document.rb', line 73 def file @file end |
#id ⇒ UUID | String
TODO: Write general description for this method
15 16 17 |
# File 'lib/modern_treasury/models/document.rb', line 15 def id @id end |
#live_mode ⇒ TrueClass | FalseClass
This field will be true if this object exists in the live environment or false if it exists in the test environment.
24 25 26 |
# File 'lib/modern_treasury/models/document.rb', line 24 def live_mode @live_mode end |
#object ⇒ String
TODO: Write general description for this method
19 20 21 |
# File 'lib/modern_treasury/models/document.rb', line 19 def object @object end |
#source ⇒ String
The source of the document. Can be ‘vendor`, `customer`, or `modern_treasury`.
48 49 50 |
# File 'lib/modern_treasury/models/document.rb', line 48 def source @source end |
#updated_at ⇒ DateTime
This field will be true if this object exists in the live environment or false if it exists in the test environment.
34 35 36 |
# File 'lib/modern_treasury/models/document.rb', line 34 def updated_at @updated_at end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/modern_treasury/models/document.rb', line 124 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : nil object = hash.key?('object') ? hash['object'] : nil live_mode = hash.key?('live_mode') ? hash['live_mode'] : nil created_at = if hash.key?('created_at') (DateTimeHelper.from_rfc3339(hash['created_at']) if hash['created_at']) end updated_at = if hash.key?('updated_at') (DateTimeHelper.from_rfc3339(hash['updated_at']) if hash['updated_at']) end discarded_at = if hash.key?('discarded_at') (DateTimeHelper.from_rfc3339(hash['discarded_at']) if hash['discarded_at']) end document_type = hash.key?('document_type') ? hash['document_type'] : nil source = hash.key?('source') ? hash['source'] : nil documentable_id = hash.key?('documentable_id') ? hash['documentable_id'] : nil documentable_type = hash.key?('documentable_type') ? hash['documentable_type'] : nil # Parameter is an array, so we need to iterate through it document_details = nil unless hash['document_details'].nil? document_details = [] hash['document_details'].each do |structure| document_details << (DocumentDetail.from_hash(structure) if structure) end end document_details = nil unless hash.key?('document_details') file = File.from_hash(hash['file']) if hash['file'] # Create object from extracted values. Document.new(id: id, object: object, live_mode: live_mode, created_at: created_at, updated_at: updated_at, discarded_at: discarded_at, document_type: document_type, source: source, documentable_id: documentable_id, documentable_type: documentable_type, document_details: document_details, file: file) end |
.names ⇒ Object
A mapping from model property names to API property names.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/modern_treasury/models/document.rb', line 76 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['object'] = 'object' @_hash['live_mode'] = 'live_mode' @_hash['created_at'] = 'created_at' @_hash['updated_at'] = 'updated_at' @_hash['discarded_at'] = 'discarded_at' @_hash['document_type'] = 'document_type' @_hash['source'] = 'source' @_hash['documentable_id'] = 'documentable_id' @_hash['documentable_type'] = 'documentable_type' @_hash['document_details'] = 'document_details' @_hash['file'] = 'file' @_hash end |
.nullables ⇒ Object
An array for nullable fields
99 100 101 102 103 104 |
# File 'lib/modern_treasury/models/document.rb', line 99 def self.nullables %w[ discarded_at document_type ] end |
.optionals ⇒ Object
An array for optional fields
94 95 96 |
# File 'lib/modern_treasury/models/document.rb', line 94 def self.optionals [] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
196 197 198 199 200 201 202 203 204 |
# File 'lib/modern_treasury/models/document.rb', line 196 def inspect class_name = self.class.name.split('::').last "<#{class_name} id: #{@id.inspect}, object: #{@object.inspect}, live_mode:"\ " #{@live_mode.inspect}, created_at: #{@created_at.inspect}, updated_at:"\ " #{@updated_at.inspect}, discarded_at: #{@discarded_at.inspect}, document_type:"\ " #{@document_type.inspect}, source: #{@source.inspect}, documentable_id:"\ " #{@documentable_id.inspect}, documentable_type: #{@documentable_type.inspect},"\ " document_details: #{@document_details.inspect}, file: #{@file.inspect}>" end |
#to_custom_created_at ⇒ Object
173 174 175 |
# File 'lib/modern_treasury/models/document.rb', line 173 def to_custom_created_at DateTimeHelper.to_rfc3339(created_at) end |
#to_custom_discarded_at ⇒ Object
181 182 183 |
# File 'lib/modern_treasury/models/document.rb', line 181 def to_custom_discarded_at DateTimeHelper.to_rfc3339(discarded_at) end |
#to_custom_updated_at ⇒ Object
177 178 179 |
# File 'lib/modern_treasury/models/document.rb', line 177 def to_custom_updated_at DateTimeHelper.to_rfc3339(updated_at) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
186 187 188 189 190 191 192 193 |
# File 'lib/modern_treasury/models/document.rb', line 186 def to_s class_name = self.class.name.split('::').last "<#{class_name} id: #{@id}, object: #{@object}, live_mode: #{@live_mode}, created_at:"\ " #{@created_at}, updated_at: #{@updated_at}, discarded_at: #{@discarded_at}, document_type:"\ " #{@document_type}, source: #{@source}, documentable_id: #{@documentable_id},"\ " documentable_type: #{@documentable_type}, document_details: #{@document_details}, file:"\ " #{@file}>" end |