Class: ModernTreasury::LedgerEventHandlerCreateRequest

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

Overview

LedgerEventHandlerCreateRequest 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(name:, ledger_transaction_template:, description: SKIP, ledger_id: SKIP, conditions: SKIP, metadata: SKIP, additional_properties: nil) ⇒ LedgerEventHandlerCreateRequest

Returns a new instance of LedgerEventHandlerCreateRequest.



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

def initialize(name:, ledger_transaction_template:, description: SKIP,
               ledger_id: SKIP, conditions: SKIP, metadata: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @name = name
  @description = description unless description == SKIP
  @ledger_id = ledger_id unless ledger_id == SKIP
  @ledger_transaction_template = ledger_transaction_template
  @conditions = conditions unless conditions == SKIP
  @metadata =  unless  == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#conditionsLedgerEventHandlerConditions

The id of the ledger that this account belongs to.



30
31
32
# File 'lib/modern_treasury/models/ledger_event_handler_create_request.rb', line 30

def conditions
  @conditions
end

#descriptionString

An optional description.

Returns:

  • (String)


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

def description
  @description
end

#ledger_idUUID | String

The id of the ledger that this account belongs to.

Returns:

  • (UUID | String)


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

def ledger_id
  @ledger_id
end

#ledger_transaction_templateLedgerEventHandlerLedgerTransactionTemplate

The id of the ledger that this account belongs to.



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

def ledger_transaction_template
  @ledger_transaction_template
end

#metadataHash[String, String]

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

Returns:

  • (Hash[String, String])


35
36
37
# File 'lib/modern_treasury/models/ledger_event_handler_create_request.rb', line 35

def 
  @metadata
end

#nameString

Name of the ledger event handler.

Returns:

  • (String)


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

def name
  @name
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/modern_treasury/models/ledger_event_handler_create_request.rb', line 83

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  name = hash.key?('name') ? hash['name'] : nil
  if hash['ledger_transaction_template']
    ledger_transaction_template = LedgerEventHandlerLedgerTransactionTemplate.from_hash(hash['ledger_transaction_template'])
  end
  description = hash.key?('description') ? hash['description'] : SKIP
  ledger_id = hash.key?('ledger_id') ? hash['ledger_id'] : SKIP
  conditions = LedgerEventHandlerConditions.from_hash(hash['conditions']) if
    hash['conditions']
   = hash.key?('metadata') ? hash['metadata'] : 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.
  LedgerEventHandlerCreateRequest.new(name: name,
                                      ledger_transaction_template: ledger_transaction_template,
                                      description: description,
                                      ledger_id: ledger_id,
                                      conditions: conditions,
                                      metadata: ,
                                      additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



38
39
40
41
42
43
44
45
46
47
# File 'lib/modern_treasury/models/ledger_event_handler_create_request.rb', line 38

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['name'] = 'name'
  @_hash['description'] = 'description'
  @_hash['ledger_id'] = 'ledger_id'
  @_hash['ledger_transaction_template'] = 'ledger_transaction_template'
  @_hash['conditions'] = 'conditions'
  @_hash['metadata'] = 'metadata'
  @_hash
end

.nullablesObject

An array for nullable fields



60
61
62
63
64
65
# File 'lib/modern_treasury/models/ledger_event_handler_create_request.rb', line 60

def self.nullables
  %w[
    description
    metadata
  ]
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    description
    ledger_id
    conditions
    metadata
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



123
124
125
126
127
128
129
# File 'lib/modern_treasury/models/ledger_event_handler_create_request.rb', line 123

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

#to_sObject

Provides a human-readable string representation of the object.



115
116
117
118
119
120
# File 'lib/modern_treasury/models/ledger_event_handler_create_request.rb', line 115

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