Class: FdxV660Api::SweepSecurityEntity

Inherits:
SecurityEntity show all
Defined in:
lib/fdx_v660_api/models/sweep_security_entity.rb

Overview

A sweep security

Instance Attribute Summary collapse

Attributes inherited from SecurityEntity

#fi_attributes, #security_category

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SecurityEntity

discriminators

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(current_balance: SKIP, available_balance: SKIP, balance_as_of: SKIP, checks: SKIP, security_category: 'Sweep Security entity', fi_attributes: SKIP, additional_properties: nil) ⇒ SweepSecurityEntity

Returns a new instance of SweepSecurityEntity.



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/fdx_v660_api/models/sweep_security_entity.rb', line 56

def initialize(current_balance: SKIP, available_balance: SKIP,
               balance_as_of: SKIP, checks: SKIP,
               security_category: 'Sweep Security entity',
               fi_attributes: SKIP, additional_properties: nil)
  @current_balance = current_balance unless current_balance == SKIP
  @available_balance = available_balance unless available_balance == SKIP
  @balance_as_of = balance_as_of unless balance_as_of == SKIP
  @checks = checks unless checks == SKIP
  @additional_properties = additional_properties

  # Call the constructor of the base class
  super(security_category: security_category,
        fi_attributes: fi_attributes,
        additional_properties: additional_properties)
end

Instance Attribute Details

#available_balanceFloat

Balance of funds available for use

Returns:

  • (Float)


18
19
20
# File 'lib/fdx_v660_api/models/sweep_security_entity.rb', line 18

def available_balance
  @available_balance
end

#balance_as_ofDateTime

As-of date of balances

Returns:

  • (DateTime)


22
23
24
# File 'lib/fdx_v660_api/models/sweep_security_entity.rb', line 22

def balance_as_of
  @balance_as_of
end

#checksTrueClass | FalseClass

Whether or not checks can be written on the account

Returns:

  • (TrueClass | FalseClass)


26
27
28
# File 'lib/fdx_v660_api/models/sweep_security_entity.rb', line 26

def checks
  @checks
end

#current_balanceFloat

Balance of funds in account

Returns:

  • (Float)


14
15
16
# File 'lib/fdx_v660_api/models/sweep_security_entity.rb', line 14

def current_balance
  @current_balance
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



73
74
75
76
77
78
79
80
81
82
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
113
114
# File 'lib/fdx_v660_api/models/sweep_security_entity.rb', line 73

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  current_balance =
    hash.key?('currentBalance') ? hash['currentBalance'] : SKIP
  available_balance =
    hash.key?('availableBalance') ? hash['availableBalance'] : SKIP
  balance_as_of = if hash.key?('balanceAsOf')
                    (DateTimeHelper.from_rfc3339(hash['balanceAsOf']) if hash['balanceAsOf'])
                  else
                    SKIP
                  end
  checks = hash.key?('checks') ? hash['checks'] : SKIP
  security_category = hash['securityCategory'] ||= 'Sweep Security entity'
  # Parameter is an array, so we need to iterate through it
  fi_attributes = nil
  unless hash['fiAttributes'].nil?
    fi_attributes = []
    hash['fiAttributes'].each do |structure|
      fi_attributes << (FiAttributeEntity.from_hash(structure) if structure)
    end
  end

  fi_attributes = SKIP unless hash.key?('fiAttributes')

  # 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.
  SweepSecurityEntity.new(current_balance: current_balance,
                          available_balance: available_balance,
                          balance_as_of: balance_as_of,
                          checks: checks,
                          security_category: security_category,
                          fi_attributes: fi_attributes,
                          additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



29
30
31
32
33
34
35
36
37
# File 'lib/fdx_v660_api/models/sweep_security_entity.rb', line 29

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['current_balance'] = 'currentBalance'
  @_hash['available_balance'] = 'availableBalance'
  @_hash['balance_as_of'] = 'balanceAsOf'
  @_hash['checks'] = 'checks'
  @_hash = super().merge(@_hash)
  @_hash
end

.nullablesObject

An array for nullable fields



51
52
53
54
# File 'lib/fdx_v660_api/models/sweep_security_entity.rb', line 51

def self.nullables
  _arr = []
  (_arr << super()).flatten!
end

.optionalsObject

An array for optional fields



40
41
42
43
44
45
46
47
48
# File 'lib/fdx_v660_api/models/sweep_security_entity.rb', line 40

def self.optionals
  _arr = %w[
    current_balance
    available_balance
    balance_as_of
    checks
  ]
  (_arr << super()).flatten!
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



122
123
124
125
126
127
128
# File 'lib/fdx_v660_api/models/sweep_security_entity.rb', line 122

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.



139
140
141
142
143
144
145
# File 'lib/fdx_v660_api/models/sweep_security_entity.rb', line 139

def inspect
  class_name = self.class.name.split('::').last
  super_string = super().inspect.sub(/^<[^ ]+ /, '').sub(/>$/, '')
  "<#{class_name} #{super_string}, current_balance: #{@current_balance.inspect},"\
  " available_balance: #{@available_balance.inspect}, balance_as_of:"\
  " #{@balance_as_of.inspect}, checks: #{@checks.inspect}>"
end

#to_custom_balance_as_ofObject



116
117
118
# File 'lib/fdx_v660_api/models/sweep_security_entity.rb', line 116

def to_custom_balance_as_of
  DateTimeHelper.to_rfc3339(balance_as_of)
end

#to_sObject

Provides a human-readable string representation of the object.



131
132
133
134
135
136
# File 'lib/fdx_v660_api/models/sweep_security_entity.rb', line 131

def to_s
  class_name = self.class.name.split('::').last
  super_string = super().sub(/^<[^ ]+ /, '').sub(/>$/, '')
  "<#{class_name} #{super_string}, current_balance: #{@current_balance}, available_balance:"\
  " #{@available_balance}, balance_as_of: #{@balance_as_of}, checks: #{@checks}>"
end