Class: SynapseClient::BankAccount

Inherits:
APIResource show all
Includes:
APIOperations::List
Defined in:
lib/synapse_client/bank_account.rb

Instance Attribute Summary collapse

Attributes inherited from APIResource

#id

Class Method Summary collapse

Instance Method Summary collapse

Methods included from APIOperations::List

included

Methods inherited from APIResource

class_name, #refresh, retrieve, #successful?, #to_hash, #url, url

Constructor Details

#initialize(options = {}) ⇒ BankAccount

Returns a new instance of BankAccount.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/synapse_client/bank_account.rb', line 12

def initialize(options = {})
  options = Map.new(options)

  @account_class         = options[:account_class]
  @account_number_string = options[:account_number_string]
  @account_type          = options[:account_type]
  @bank_name             = options[:bank_name]
  @date                  = options[:date]
  @id                    = options[:id] || options[:bank_id]
  @is_active             = options[:is_active]
  @is_buyer_default      = options[:is_buyer_default]
  @is_seller_default     = options[:is_seller_default]
  @is_verified           = options[:is_verified]
  @name_on_account       = options[:name_on_account]
  @nickname              = options[:nickname]
  @resource_uri          = options[:resource_uri]
  @routing_number_string = options[:routing_number_string]
end

Instance Attribute Details

#account_classObject

Returns the value of attribute account_class.



8
9
10
# File 'lib/synapse_client/bank_account.rb', line 8

def 
  @account_class
end

#account_number_stringObject

Returns the value of attribute account_number_string.



9
10
11
# File 'lib/synapse_client/bank_account.rb', line 9

def 
  @account_number_string
end

#account_typeObject

Returns the value of attribute account_type.



8
9
10
# File 'lib/synapse_client/bank_account.rb', line 8

def 
  @account_type
end

#bank_nameObject

Returns the value of attribute bank_name.



7
8
9
# File 'lib/synapse_client/bank_account.rb', line 7

def bank_name
  @bank_name
end

#dateObject

Returns the value of attribute date.



7
8
9
# File 'lib/synapse_client/bank_account.rb', line 7

def date
  @date
end

#is_activeObject

Returns the value of attribute is_active.



10
11
12
# File 'lib/synapse_client/bank_account.rb', line 10

def is_active
  @is_active
end

#is_buyer_defaultObject

Returns the value of attribute is_buyer_default.



10
11
12
# File 'lib/synapse_client/bank_account.rb', line 10

def is_buyer_default
  @is_buyer_default
end

#is_seller_defaultObject

Returns the value of attribute is_seller_default.



10
11
12
# File 'lib/synapse_client/bank_account.rb', line 10

def is_seller_default
  @is_seller_default
end

#is_verifiedObject

Returns the value of attribute is_verified.



10
11
12
# File 'lib/synapse_client/bank_account.rb', line 10

def is_verified
  @is_verified
end

#name_on_accountObject

Returns the value of attribute name_on_account.



6
7
8
# File 'lib/synapse_client/bank_account.rb', line 6

def 
  @name_on_account
end

#nicknameObject

Returns the value of attribute nickname.



6
7
8
# File 'lib/synapse_client/bank_account.rb', line 6

def nickname
  @nickname
end

#resource_uriObject

Returns the value of attribute resource_uri.



7
8
9
# File 'lib/synapse_client/bank_account.rb', line 7

def resource_uri
  @resource_uri
end

#routing_number_stringObject

Returns the value of attribute routing_number_string.



9
10
11
# File 'lib/synapse_client/bank_account.rb', line 9

def routing_number_string
  @routing_number_string
end

Class Method Details

.add(params = {}) ⇒ Object



40
41
42
43
44
# File 'lib/synapse_client/bank_account.rb', line 40

def self.add(params={})
  response = SynapseClient.request(:post, url + "add", params)
  return response unless response.successful?
  BankAccount.new(response.data.bank)
end

.all(params = {}) ⇒ Object



35
36
37
38
# File 'lib/synapse_client/bank_account.rb', line 35

def self.all(params={})
  bank_accounts = list(params).banks
  bank_accounts.map{|ba| BankAccount.new(ba)}
end

.api_resource_nameObject



31
32
33
# File 'lib/synapse_client/bank_account.rb', line 31

def self.api_resource_name
  "bank"
end

.finish_linking(params = {}) ⇒ Object



59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/synapse_client/bank_account.rb', line 59

def self.finish_linking(params={})
  unless params[:bank]
    raise ArgumentError.new("You must include the bank name when responding to an MFA question.")
  end
  unless params[:bank_account_token]
    raise ArgumentError.new("You must include the bank account token when responding to an MFA question.")
  end
  unless params[:mfa]
    raise ArgumentError.new("You must include the answer(s) when responding to an MFA question.")
  end

  response = SynapseClient.request(:post, url + "mfa", params)
  return response unless response.successful?

  if response.data["is_mfa"]
    MFA.new(response.data.response)
  else
    response.data.banks.map do |bank|
      BankAccount.new(bank)
    end
  end
end


46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/synapse_client/bank_account.rb', line 46

def self.link(params={})
  response = SynapseClient.request(:post, url + "login", params)
  return response unless response.successful?

  if response.data["is_mfa"]
    MFA.new(response.data.response)
  else
    response.data.banks.map do |bank|
      BankAccount.new(bank)
    end
  end
end