Class: ThePlaidApi::Wallet

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/the_plaid_api/models/wallet.rb

Overview

An object representing the e-wallet

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(wallet_id:, balance:, numbers:, status:, recipient_id: SKIP, additional_properties: nil) ⇒ Wallet

Returns a new instance of Wallet.



60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/the_plaid_api/models/wallet.rb', line 60

def initialize(wallet_id:, balance:, numbers:, status:, recipient_id: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @wallet_id = wallet_id
  @balance = balance
  @numbers = numbers
  @recipient_id = recipient_id unless recipient_id == SKIP
  @status = status
  @additional_properties = additional_properties
end

Instance Attribute Details

#balanceWalletBalance

An object representing the e-wallet balance

Returns:



18
19
20
# File 'lib/the_plaid_api/models/wallet.rb', line 18

def balance
  @balance
end

#numbersWalletNumbers

An object representing the e-wallet account numbers

Returns:



22
23
24
# File 'lib/the_plaid_api/models/wallet.rb', line 22

def numbers
  @numbers
end

#recipient_idString

The ID of the recipient that corresponds to the e-wallet account numbers

Returns:

  • (String)


26
27
28
# File 'lib/the_plaid_api/models/wallet.rb', line 26

def recipient_id
  @recipient_id
end

#statusWalletStatus

The status of the wallet. ‘UNKNOWN`: The wallet status is unknown. `ACTIVE`: The wallet is active and ready to send money to and receive money from. `CLOSED`: The wallet is closed. Any transactions made to or from this wallet will error.

Returns:



35
36
37
# File 'lib/the_plaid_api/models/wallet.rb', line 35

def status
  @status
end

#wallet_idString

A unique ID identifying the e-wallet

Returns:

  • (String)


14
15
16
# File 'lib/the_plaid_api/models/wallet.rb', line 14

def wallet_id
  @wallet_id
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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
# File 'lib/the_plaid_api/models/wallet.rb', line 74

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  wallet_id = hash.key?('wallet_id') ? hash['wallet_id'] : nil
  balance = WalletBalance.from_hash(hash['balance']) if hash['balance']
  numbers = WalletNumbers.from_hash(hash['numbers']) if hash['numbers']
  status = hash.key?('status') ? hash['status'] : nil
  recipient_id = hash.key?('recipient_id') ? hash['recipient_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.
  Wallet.new(wallet_id: wallet_id,
             balance: balance,
             numbers: numbers,
             status: status,
             recipient_id: recipient_id,
             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
# File 'lib/the_plaid_api/models/wallet.rb', line 38

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['wallet_id'] = 'wallet_id'
  @_hash['balance'] = 'balance'
  @_hash['numbers'] = 'numbers'
  @_hash['recipient_id'] = 'recipient_id'
  @_hash['status'] = 'status'
  @_hash
end

.nullablesObject

An array for nullable fields



56
57
58
# File 'lib/the_plaid_api/models/wallet.rb', line 56

def self.nullables
  []
end

.optionalsObject

An array for optional fields



49
50
51
52
53
# File 'lib/the_plaid_api/models/wallet.rb', line 49

def self.optionals
  %w[
    recipient_id
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



109
110
111
112
113
114
# File 'lib/the_plaid_api/models/wallet.rb', line 109

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} wallet_id: #{@wallet_id.inspect}, balance: #{@balance.inspect}, numbers:"\
  " #{@numbers.inspect}, recipient_id: #{@recipient_id.inspect}, status: #{@status.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



101
102
103
104
105
106
# File 'lib/the_plaid_api/models/wallet.rb', line 101

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} wallet_id: #{@wallet_id}, balance: #{@balance}, numbers: #{@numbers},"\
  " recipient_id: #{@recipient_id}, status: #{@status}, additional_properties:"\
  " #{@additional_properties}>"
end