Class: ModernTreasury::LineItem
- Defined in:
- lib/modern_treasury/models/line_item.rb
Overview
LineItem Model.
Instance Attribute Summary collapse
-
#accounting ⇒ Accounting
Additional data represented as key-value pairs.
-
#accounting_category_id ⇒ UUID | String
The ID of one of your accounting categories.
-
#accounting_ledger_class_id ⇒ UUID | String
The ID of one of the class objects in your accounting system.
-
#amount ⇒ Integer
Value in specified currency’s smallest unit.
-
#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.
-
#description ⇒ String
A free-form description of the line item.
-
#id ⇒ UUID | String
TODO: Write general description for this method.
-
#itemizable_id ⇒ UUID | String
The ID of the payment order or expected payment.
-
#itemizable_type ⇒ ItemizableType
One of ‘payment_orders` or `expected_payments`.
-
#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.
-
#metadata ⇒ Hash[String, String]
Additional data represented as key-value pairs.
-
#object ⇒ String
TODO: Write general description for this method.
-
#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:, itemizable_id:, itemizable_type:, amount:, description:, metadata:, accounting:, accounting_category_id:, accounting_ledger_class_id:) ⇒ LineItem
constructor
A new instance of LineItem.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_created_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:, itemizable_id:, itemizable_type:, amount:, description:, metadata:, accounting:, accounting_category_id:, accounting_ledger_class_id:) ⇒ LineItem
Returns a new instance of LineItem.
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/modern_treasury/models/line_item.rb', line 108 def initialize(id:, object:, live_mode:, created_at:, updated_at:, itemizable_id:, itemizable_type:, amount:, description:, metadata:, accounting:, accounting_category_id:, accounting_ledger_class_id:) @id = id @object = object @live_mode = live_mode @created_at = created_at @updated_at = updated_at @itemizable_id = itemizable_id @itemizable_type = itemizable_type @amount = amount @description = description @metadata = @accounting = accounting @accounting_category_id = accounting_category_id @accounting_ledger_class_id = accounting_ledger_class_id end |
Instance Attribute Details
#accounting ⇒ Accounting
Additional data represented as key-value pairs. Both the key and value must be strings.
61 62 63 |
# File 'lib/modern_treasury/models/line_item.rb', line 61 def accounting @accounting end |
#accounting_category_id ⇒ UUID | String
The ID of one of your accounting categories. Note that these will only be accessible if your accounting system has been connected.
66 67 68 |
# File 'lib/modern_treasury/models/line_item.rb', line 66 def accounting_category_id @accounting_category_id end |
#accounting_ledger_class_id ⇒ UUID | String
The ID of one of the class objects in your accounting system. Class objects track segments of your business independent of client or project. Note that these will only be accessible if your accounting system has been connected.
73 74 75 |
# File 'lib/modern_treasury/models/line_item.rb', line 73 def accounting_ledger_class_id @accounting_ledger_class_id end |
#amount ⇒ Integer
Value in specified currency’s smallest unit. e.g. $10 would be represented as 1000.
47 48 49 |
# File 'lib/modern_treasury/models/line_item.rb', line 47 def amount @amount end |
#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/line_item.rb', line 29 def created_at @created_at end |
#description ⇒ String
A free-form description of the line item.
51 52 53 |
# File 'lib/modern_treasury/models/line_item.rb', line 51 def description @description end |
#id ⇒ UUID | String
TODO: Write general description for this method
15 16 17 |
# File 'lib/modern_treasury/models/line_item.rb', line 15 def id @id end |
#itemizable_id ⇒ UUID | String
The ID of the payment order or expected payment.
38 39 40 |
# File 'lib/modern_treasury/models/line_item.rb', line 38 def itemizable_id @itemizable_id end |
#itemizable_type ⇒ ItemizableType
One of ‘payment_orders` or `expected_payments`.
42 43 44 |
# File 'lib/modern_treasury/models/line_item.rb', line 42 def itemizable_type @itemizable_type 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/line_item.rb', line 24 def live_mode @live_mode end |
#metadata ⇒ Hash[String, String]
Additional data represented as key-value pairs. Both the key and value must be strings.
56 57 58 |
# File 'lib/modern_treasury/models/line_item.rb', line 56 def @metadata end |
#object ⇒ String
TODO: Write general description for this method
19 20 21 |
# File 'lib/modern_treasury/models/line_item.rb', line 19 def object @object 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/line_item.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.
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 |
# File 'lib/modern_treasury/models/line_item.rb', line 128 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 itemizable_id = hash.key?('itemizable_id') ? hash['itemizable_id'] : nil itemizable_type = hash.key?('itemizable_type') ? hash['itemizable_type'] : nil amount = hash.key?('amount') ? hash['amount'] : nil description = hash.key?('description') ? hash['description'] : nil = hash.key?('metadata') ? hash['metadata'] : nil accounting = Accounting.from_hash(hash['accounting']) if hash['accounting'] accounting_category_id = hash.key?('accounting_category_id') ? hash['accounting_category_id'] : nil accounting_ledger_class_id = hash.key?('accounting_ledger_class_id') ? hash['accounting_ledger_class_id'] : nil # Create object from extracted values. LineItem.new(id: id, object: object, live_mode: live_mode, created_at: created_at, updated_at: updated_at, itemizable_id: itemizable_id, itemizable_type: itemizable_type, amount: amount, description: description, metadata: , accounting: accounting, accounting_category_id: accounting_category_id, accounting_ledger_class_id: accounting_ledger_class_id) 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 92 |
# File 'lib/modern_treasury/models/line_item.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['itemizable_id'] = 'itemizable_id' @_hash['itemizable_type'] = 'itemizable_type' @_hash['amount'] = 'amount' @_hash['description'] = 'description' @_hash['metadata'] = 'metadata' @_hash['accounting'] = 'accounting' @_hash['accounting_category_id'] = 'accounting_category_id' @_hash['accounting_ledger_class_id'] = 'accounting_ledger_class_id' @_hash end |
.nullables ⇒ Object
An array for nullable fields
100 101 102 103 104 105 106 |
# File 'lib/modern_treasury/models/line_item.rb', line 100 def self.nullables %w[ description accounting_category_id accounting_ledger_class_id ] end |
.optionals ⇒ Object
An array for optional fields
95 96 97 |
# File 'lib/modern_treasury/models/line_item.rb', line 95 def self.optionals [] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
188 189 190 191 192 193 194 195 196 197 |
# File 'lib/modern_treasury/models/line_item.rb', line 188 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}, itemizable_id: #{@itemizable_id.inspect}, itemizable_type:"\ " #{@itemizable_type.inspect}, amount: #{@amount.inspect}, description:"\ " #{@description.inspect}, metadata: #{@metadata.inspect}, accounting:"\ " #{@accounting.inspect}, accounting_category_id: #{@accounting_category_id.inspect},"\ " accounting_ledger_class_id: #{@accounting_ledger_class_id.inspect}>" end |
#to_custom_created_at ⇒ Object
169 170 171 |
# File 'lib/modern_treasury/models/line_item.rb', line 169 def to_custom_created_at DateTimeHelper.to_rfc3339(created_at) end |
#to_custom_updated_at ⇒ Object
173 174 175 |
# File 'lib/modern_treasury/models/line_item.rb', line 173 def to_custom_updated_at DateTimeHelper.to_rfc3339(updated_at) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
178 179 180 181 182 183 184 185 |
# File 'lib/modern_treasury/models/line_item.rb', line 178 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}, itemizable_id: #{@itemizable_id},"\ " itemizable_type: #{@itemizable_type}, amount: #{@amount}, description: #{@description},"\ " metadata: #{@metadata}, accounting: #{@accounting}, accounting_category_id:"\ " #{@accounting_category_id}, accounting_ledger_class_id: #{@accounting_ledger_class_id}>" end |