Class: ModernTreasury::LineItemRequest

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

Overview

LineItemRequest 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(amount = nil, metadata = SKIP, description = SKIP, accounting_category_id = SKIP) ⇒ LineItemRequest

Returns a new instance of LineItemRequest.



58
59
60
61
62
63
64
# File 'lib/modern_treasury/models/line_item_request.rb', line 58

def initialize(amount = nil,  = SKIP, description = SKIP,
               accounting_category_id = SKIP)
  @amount = amount
  @metadata =  unless  == SKIP
  @description = description unless description == SKIP
  @accounting_category_id = accounting_category_id unless accounting_category_id == SKIP
end

Instance Attribute Details

#accounting_category_idString

The ID of one of your accounting categories. Note that these will only be accessible if your accounting system has been connected.

Returns:

  • (String)


29
30
31
# File 'lib/modern_treasury/models/line_item_request.rb', line 29

def accounting_category_id
  @accounting_category_id
end

#amountInteger

Value in specified currency’s smallest unit. e.g. $10 would be represented as 1000.

Returns:

  • (Integer)


15
16
17
# File 'lib/modern_treasury/models/line_item_request.rb', line 15

def amount
  @amount
end

#descriptionString

A free-form description of the line item.

Returns:

  • (String)


24
25
26
# File 'lib/modern_treasury/models/line_item_request.rb', line 24

def description
  @description
end

#metadataHash[String, String]

Additional data represented as key-value pairs. Both the key and value must be strings.

Returns:

  • (Hash[String, String])


20
21
22
# File 'lib/modern_treasury/models/line_item_request.rb', line 20

def 
  @metadata
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/modern_treasury/models/line_item_request.rb', line 67

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  amount = hash.key?('amount') ? hash['amount'] : nil
   = hash.key?('metadata') ? hash['metadata'] : SKIP
  description = hash.key?('description') ? hash['description'] : SKIP
  accounting_category_id =
    hash.key?('accounting_category_id') ? hash['accounting_category_id'] : SKIP

  # Create object from extracted values.
  LineItemRequest.new(amount,
                      ,
                      description,
                      accounting_category_id)
end

.namesObject

A mapping from model property names to API property names.



32
33
34
35
36
37
38
39
# File 'lib/modern_treasury/models/line_item_request.rb', line 32

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['amount'] = 'amount'
  @_hash['metadata'] = 'metadata'
  @_hash['description'] = 'description'
  @_hash['accounting_category_id'] = 'accounting_category_id'
  @_hash
end

.nullablesObject

An array for nullable fields



51
52
53
54
55
56
# File 'lib/modern_treasury/models/line_item_request.rb', line 51

def self.nullables
  %w[
    description
    accounting_category_id
  ]
end

.optionalsObject

An array for optional fields



42
43
44
45
46
47
48
# File 'lib/modern_treasury/models/line_item_request.rb', line 42

def self.optionals
  %w[
    metadata
    description
    accounting_category_id
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



92
93
94
95
96
# File 'lib/modern_treasury/models/line_item_request.rb', line 92

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} amount: #{@amount.inspect}, metadata: #{@metadata.inspect}, description:"\
  " #{@description.inspect}, accounting_category_id: #{@accounting_category_id.inspect}>"
end

#to_sObject

Provides a human-readable string representation of the object.



85
86
87
88
89
# File 'lib/modern_treasury/models/line_item_request.rb', line 85

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} amount: #{@amount}, metadata: #{@metadata}, description: #{@description},"\
  " accounting_category_id: #{@accounting_category_id}>"
end