Class: ModernTreasury::LedgerableEventCreateRequest

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

Overview

LedgerableEventCreateRequest 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 = nil, amount = nil, description = SKIP, direction = SKIP, currency = SKIP, currency_exponent = SKIP, custom_data = SKIP, metadata = SKIP) ⇒ LedgerableEventCreateRequest

Returns a new instance of LedgerableEventCreateRequest.



84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/modern_treasury/models/ledgerable_event_create_request.rb', line 84

def initialize(name = nil, amount = nil, description = SKIP,
               direction = SKIP, currency = SKIP, currency_exponent = SKIP,
               custom_data = SKIP,  = SKIP)
  @name = name
  @description = description unless description == SKIP
  @direction = direction unless direction == SKIP
  @amount = amount
  @currency = currency unless currency == SKIP
  @currency_exponent = currency_exponent unless currency_exponent == SKIP
  @custom_data = custom_data unless custom_data == SKIP
  @metadata =  unless  == SKIP
end

Instance Attribute Details

#amountInteger

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

Returns:

  • (Integer)


27
28
29
# File 'lib/modern_treasury/models/ledgerable_event_create_request.rb', line 27

def amount
  @amount
end

#currencyString

An ISO 4217 conformed currency or a custom currency.

Returns:

  • (String)


31
32
33
# File 'lib/modern_treasury/models/ledgerable_event_create_request.rb', line 31

def currency
  @currency
end

#currency_exponentInteger

Must be included if currency is a custom currency. The currency_exponent cannot exceed 30.

Returns:

  • (Integer)


36
37
38
# File 'lib/modern_treasury/models/ledgerable_event_create_request.rb', line 36

def currency_exponent
  @currency_exponent
end

#custom_dataObject

Additionally data to be used by the Ledger Event Handler.

Returns:

  • (Object)


40
41
42
# File 'lib/modern_treasury/models/ledgerable_event_create_request.rb', line 40

def custom_data
  @custom_data
end

#descriptionString

Description of the ledgerable event.

Returns:

  • (String)


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

def description
  @description
end

#directionString

One of ‘credit`, `debit`.

Returns:

  • (String)


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

def direction
  @direction
end

#metadataHash[String, String]

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

Returns:

  • (Hash[String, String])


45
46
47
# File 'lib/modern_treasury/models/ledgerable_event_create_request.rb', line 45

def 
  @metadata
end

#nameString

Name of the ledgerable event.

Returns:

  • (String)


14
15
16
# File 'lib/modern_treasury/models/ledgerable_event_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.



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/modern_treasury/models/ledgerable_event_create_request.rb', line 98

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  name = hash.key?('name') ? hash['name'] : nil
  amount = hash.key?('amount') ? hash['amount'] : nil
  description = hash.key?('description') ? hash['description'] : SKIP
  direction = hash.key?('direction') ? hash['direction'] : SKIP
  currency = hash.key?('currency') ? hash['currency'] : SKIP
  currency_exponent =
    hash.key?('currency_exponent') ? hash['currency_exponent'] : SKIP
  custom_data = hash.key?('custom_data') ? hash['custom_data'] : SKIP
   = hash.key?('metadata') ? hash['metadata'] : SKIP

  # Create object from extracted values.
  LedgerableEventCreateRequest.new(name,
                                   amount,
                                   description,
                                   direction,
                                   currency,
                                   currency_exponent,
                                   custom_data,
                                   )
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['name'] = 'name'
  @_hash['description'] = 'description'
  @_hash['direction'] = 'direction'
  @_hash['amount'] = 'amount'
  @_hash['currency'] = 'currency'
  @_hash['currency_exponent'] = 'currency_exponent'
  @_hash['custom_data'] = 'custom_data'
  @_hash['metadata'] = 'metadata'
  @_hash
end

.nullablesObject

An array for nullable fields



74
75
76
77
78
79
80
81
82
# File 'lib/modern_treasury/models/ledgerable_event_create_request.rb', line 74

def self.nullables
  %w[
    description
    direction
    currency
    currency_exponent
    custom_data
  ]
end

.optionalsObject

An array for optional fields



62
63
64
65
66
67
68
69
70
71
# File 'lib/modern_treasury/models/ledgerable_event_create_request.rb', line 62

def self.optionals
  %w[
    description
    direction
    currency
    currency_exponent
    custom_data
    metadata
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



132
133
134
135
136
137
138
# File 'lib/modern_treasury/models/ledgerable_event_create_request.rb', line 132

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

#to_sObject

Provides a human-readable string representation of the object.



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

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