Class: ModernTreasury::Accounting

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

Overview

Accounting 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(account_id: SKIP, class_id: SKIP, additional_properties: nil) ⇒ Accounting

Returns a new instance of Accounting.



48
49
50
51
52
53
54
55
# File 'lib/modern_treasury/models/accounting.rb', line 48

def initialize(account_id: SKIP, class_id: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @account_id =  unless  == SKIP
  @class_id = class_id unless class_id == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#account_idUUID | String

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

Returns:

  • (UUID | String)


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

def 
  @account_id
end

#class_idUUID | 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.

Returns:

  • (UUID | String)


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

def class_id
  @class_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/modern_treasury/models/accounting.rb', line 58

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
   = hash.key?('account_id') ? hash['account_id'] : SKIP
  class_id = hash.key?('class_id') ? hash['class_id'] : 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.
  Accounting.new(account_id: ,
                 class_id: class_id,
                 additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



25
26
27
28
29
30
# File 'lib/modern_treasury/models/accounting.rb', line 25

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['account_id'] = 'account_id'
  @_hash['class_id'] = 'class_id'
  @_hash
end

.nullablesObject

An array for nullable fields



41
42
43
44
45
46
# File 'lib/modern_treasury/models/accounting.rb', line 41

def self.nullables
  %w[
    account_id
    class_id
  ]
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    account_id
    class_id
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (Accounting | Hash)

    value against the validation is performed.



80
81
82
83
84
85
86
# File 'lib/modern_treasury/models/accounting.rb', line 80

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



96
97
98
99
100
# File 'lib/modern_treasury/models/accounting.rb', line 96

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} account_id: #{@account_id.inspect}, class_id: #{@class_id.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



89
90
91
92
93
# File 'lib/modern_treasury/models/accounting.rb', line 89

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} account_id: #{@account_id}, class_id: #{@class_id}, additional_properties:"\
  " #{@additional_properties}>"
end