Class: SynapsePayRest::BaseNode
- Inherits:
-
Object
- Object
- SynapsePayRest::BaseNode
- Defined in:
- lib/synapse_pay_rest/models/node/base_node.rb
Overview
use mixins to remove duplication between Node and BaseNode. May be better to refactor this into a mixin altogether since this shouldn’t be instantiated.
reduce duplicated logic between User/BaseNode/Transaction
Ancestor of all node types. Should never be instantiated. Represents a Node record and holds methods for constructing Node instances from API calls. This is built on top of the SynapsePayRest::Nodes class and is intended to make it easier to use the API without knowing payload formats or knowledge of REST.
Direct Known Subclasses
AchUsNode, CardUsNode, CheckUsNode, ClearingUsNode, CryptoUsNode, CustodyUsNode, DepositUsNode, EftIndNode, EftNpNode, IbDepositUsNode, IbSubaccountUsNode, InterchangeUsNode, IouNode, ReserveUsNode, SubaccountUsNode, SubcardUsNode, SynapseIndNode, SynapseNpNode, SynapseUsNode, TriumphSubaccountUsNode, WireIntNode, WireUsNode
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#account_class ⇒ Object
readonly
Returns the value of attribute account_class.
-
#account_id ⇒ Object
readonly
Returns the value of attribute account_id.
-
#account_number ⇒ Object
readonly
Returns the value of attribute account_number.
-
#account_type ⇒ Object
readonly
Returns the value of attribute account_type.
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#address_city ⇒ Object
readonly
Returns the value of attribute address_city.
-
#address_country_code ⇒ Object
readonly
Returns the value of attribute address_country_code.
-
#address_postal_code ⇒ Object
readonly
Returns the value of attribute address_postal_code.
-
#address_street ⇒ Object
readonly
Returns the value of attribute address_street.
-
#address_subdivision ⇒ Object
readonly
Returns the value of attribute address_subdivision.
-
#allow_foreign_transactions ⇒ Object
readonly
Returns the value of attribute allow_foreign_transactions.
-
#atm_withdrawal_limit ⇒ Object
readonly
Returns the value of attribute atm_withdrawal_limit.
-
#balance ⇒ Object
readonly
Returns the value of attribute balance.
-
#bank_id ⇒ Object
readonly
Returns the value of attribute bank_id.
-
#bank_long_name ⇒ Object
readonly
Returns the value of attribute bank_long_name.
-
#bank_name ⇒ Object
readonly
Returns the value of attribute bank_name.
-
#bank_pw ⇒ Object
readonly
Returns the value of attribute bank_pw.
-
#card_hash ⇒ Object
readonly
Returns the value of attribute card_hash.
-
#card_style_id ⇒ Object
readonly
Returns the value of attribute card_style_id.
-
#card_type ⇒ Object
readonly
Returns the value of attribute card_type.
-
#correspondent_address ⇒ Object
readonly
Returns the value of attribute correspondent_address.
-
#correspondent_bank_name ⇒ Object
readonly
Returns the value of attribute correspondent_bank_name.
-
#correspondent_routing_number ⇒ Object
readonly
Returns the value of attribute correspondent_routing_number.
-
#correspondent_swift ⇒ Object
readonly
Returns the value of attribute correspondent_swift.
-
#currency ⇒ Object
readonly
Returns the value of attribute currency.
-
#document_id ⇒ Object
readonly
Returns the value of attribute document_id.
-
#email_match ⇒ Object
readonly
Returns the value of attribute email_match.
-
#gateway_restricted ⇒ Object
readonly
Returns the value of attribute gateway_restricted.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#ifsc ⇒ Object
readonly
Returns the value of attribute ifsc.
-
#interchange_type ⇒ Object
readonly
Returns the value of attribute interchange_type.
-
#is_active ⇒ Object
readonly
Returns the value of attribute is_active.
-
#is_international ⇒ Object
readonly
Returns the value of attribute is_international.
-
#max_pin_attempts ⇒ Object
readonly
Returns the value of attribute max_pin_attempts.
-
#monthly_withdrawals_remaining ⇒ Object
readonly
Returns the value of attribute monthly_withdrawals_remaining.
-
#name_match ⇒ Object
readonly
Returns the value of attribute name_match.
-
#name_on_account ⇒ Object
readonly
Returns the value of attribute name_on_account.
-
#network ⇒ Object
readonly
Returns the value of attribute network.
-
#nickname ⇒ Object
readonly
Returns the value of attribute nickname.
-
#other ⇒ Object
readonly
Returns the value of attribute other.
-
#payee_address ⇒ Object
readonly
Returns the value of attribute payee_address.
-
#payee_name ⇒ Object
readonly
Returns the value of attribute payee_name.
-
#permission ⇒ String
readonly
Https://docs.synapsepay.com/docs/node-resources#section-node-permissions.
-
#phonenumber_match ⇒ Object
readonly
Returns the value of attribute phonenumber_match.
-
#portfolio_BTC ⇒ Object
readonly
Returns the value of attribute portfolio_BTC.
-
#portfolio_ETH ⇒ Object
readonly
Returns the value of attribute portfolio_ETH.
-
#pos_withdrawal_limit ⇒ Object
readonly
Returns the value of attribute pos_withdrawal_limit.
-
#routing_number ⇒ Object
readonly
Returns the value of attribute routing_number.
-
#security_alerts ⇒ Object
readonly
Returns the value of attribute security_alerts.
-
#supp_id ⇒ Object
readonly
Returns the value of attribute supp_id.
-
#swift ⇒ Object
readonly
Returns the value of attribute swift.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#user ⇒ SynapsePayRest::User
The user to which the node belongs.
Class Method Summary collapse
-
.all(user:, page: nil, per_page: nil) ⇒ Array<SynapsePayRest::BaseNode>
Queries the API for all nodes belonging to the supplied user (with optional filters) and matching the given type of this node.
-
.create(user:, nickname:, **options) ⇒ SynapsePayRest::BaseNode
Creates a new node in the API associated to the provided user and returns a node instance from the response data.
- .from_response(user, response) ⇒ Object
- .multiple_from_response(user, response) ⇒ Object
- .payload_for_create(type:, **options) ⇒ Object
Instance Method Summary collapse
-
#==(other) ⇒ Object
Checks if two BaseNode instances have same id (different instances of same record).
-
#create_subnet(**options) ⇒ SynapsePayRest::Subnet
Creates a subnet belonging to this node and returns it as a Subnet instance.
-
#create_transaction(**options) ⇒ SynapsePayRest::Transaction
Creates a transaction belonging to this node and returns it as a Transaction instance.
-
#deactivate ⇒ :success
Deactivates the node.
-
#find_subnet(id:) ⇒ SynapsePayRest::Subnet
Queries the API for a subnet belonging to this node by subnet id and returns a Subnet instance if found.
-
#find_transaction(id:) ⇒ SynapsePayRest::Transaction
Queries the API for a transaction belonging to this node by transaction id and returns a Transaction instance if found.
-
#get_statement ⇒ SynapsePayRest::Statement
Get statement for node Only available for native synapse nodes.
-
#initialize(**options) ⇒ BaseNode
constructor
A new instance of BaseNode.
-
#subnets(**options) ⇒ Array<SynapsePayRest::Subnet>
Queries the API for all subnets belonging to this node and returns them as Subnet instances.
-
#transactions(**options) ⇒ Array<SynapsePayRest::Transaction>
Queries the API for all transactions belonging to this node and returns them as Transaction instances.
Constructor Details
#initialize(**options) ⇒ BaseNode
Do not call directly. Use <BaseNode subclass>.create or other class method to instantiate via API action.
Returns a new instance of BaseNode.
294 295 296 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 294 def initialize(**) .each { |key, value| instance_variable_set("@#{key}", value) } end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def access_token @access_token end |
#account_class ⇒ Object (readonly)
Returns the value of attribute account_class.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def account_class @account_class end |
#account_id ⇒ Object (readonly)
Returns the value of attribute account_id.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def account_id @account_id end |
#account_number ⇒ Object (readonly)
Returns the value of attribute account_number.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def account_number @account_number end |
#account_type ⇒ Object (readonly)
Returns the value of attribute account_type.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def account_type @account_type end |
#address ⇒ Object (readonly)
Returns the value of attribute address.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def address @address end |
#address_city ⇒ Object (readonly)
Returns the value of attribute address_city.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def address_city @address_city end |
#address_country_code ⇒ Object (readonly)
Returns the value of attribute address_country_code.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def address_country_code @address_country_code end |
#address_postal_code ⇒ Object (readonly)
Returns the value of attribute address_postal_code.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def address_postal_code @address_postal_code end |
#address_street ⇒ Object (readonly)
Returns the value of attribute address_street.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def address_street @address_street end |
#address_subdivision ⇒ Object (readonly)
Returns the value of attribute address_subdivision.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def address_subdivision @address_subdivision end |
#allow_foreign_transactions ⇒ Object (readonly)
Returns the value of attribute allow_foreign_transactions.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def allow_foreign_transactions @allow_foreign_transactions end |
#atm_withdrawal_limit ⇒ Object (readonly)
Returns the value of attribute atm_withdrawal_limit.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def atm_withdrawal_limit @atm_withdrawal_limit end |
#balance ⇒ Object (readonly)
Returns the value of attribute balance.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def balance @balance end |
#bank_id ⇒ Object (readonly)
Returns the value of attribute bank_id.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def bank_id @bank_id end |
#bank_long_name ⇒ Object (readonly)
Returns the value of attribute bank_long_name.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def bank_long_name @bank_long_name end |
#bank_name ⇒ Object (readonly)
Returns the value of attribute bank_name.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def bank_name @bank_name end |
#bank_pw ⇒ Object (readonly)
Returns the value of attribute bank_pw.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def bank_pw @bank_pw end |
#card_hash ⇒ Object (readonly)
Returns the value of attribute card_hash.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def card_hash @card_hash end |
#card_style_id ⇒ Object (readonly)
Returns the value of attribute card_style_id.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def card_style_id @card_style_id end |
#card_type ⇒ Object (readonly)
Returns the value of attribute card_type.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def card_type @card_type end |
#correspondent_address ⇒ Object (readonly)
Returns the value of attribute correspondent_address.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def correspondent_address @correspondent_address end |
#correspondent_bank_name ⇒ Object (readonly)
Returns the value of attribute correspondent_bank_name.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def correspondent_bank_name @correspondent_bank_name end |
#correspondent_routing_number ⇒ Object (readonly)
Returns the value of attribute correspondent_routing_number.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def correspondent_routing_number @correspondent_routing_number end |
#correspondent_swift ⇒ Object (readonly)
Returns the value of attribute correspondent_swift.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def correspondent_swift @correspondent_swift end |
#currency ⇒ Object (readonly)
Returns the value of attribute currency.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def currency @currency end |
#document_id ⇒ Object (readonly)
Returns the value of attribute document_id.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def document_id @document_id end |
#email_match ⇒ Object (readonly)
Returns the value of attribute email_match.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def email_match @email_match end |
#gateway_restricted ⇒ Object (readonly)
Returns the value of attribute gateway_restricted.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def gateway_restricted @gateway_restricted end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def id @id end |
#ifsc ⇒ Object (readonly)
Returns the value of attribute ifsc.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def ifsc @ifsc end |
#interchange_type ⇒ Object (readonly)
Returns the value of attribute interchange_type.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def interchange_type @interchange_type end |
#is_active ⇒ Object (readonly)
Returns the value of attribute is_active.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def is_active @is_active end |
#is_international ⇒ Object (readonly)
Returns the value of attribute is_international.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def is_international @is_international end |
#max_pin_attempts ⇒ Object (readonly)
Returns the value of attribute max_pin_attempts.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def max_pin_attempts @max_pin_attempts end |
#monthly_withdrawals_remaining ⇒ Object (readonly)
Returns the value of attribute monthly_withdrawals_remaining.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def monthly_withdrawals_remaining @monthly_withdrawals_remaining end |
#name_match ⇒ Object (readonly)
Returns the value of attribute name_match.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def name_match @name_match end |
#name_on_account ⇒ Object (readonly)
Returns the value of attribute name_on_account.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def name_on_account @name_on_account end |
#network ⇒ Object (readonly)
Returns the value of attribute network.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def network @network end |
#nickname ⇒ Object (readonly)
Returns the value of attribute nickname.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def nickname @nickname end |
#other ⇒ Object (readonly)
Returns the value of attribute other.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def other @other end |
#payee_address ⇒ Object (readonly)
Returns the value of attribute payee_address.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def payee_address @payee_address end |
#payee_name ⇒ Object (readonly)
Returns the value of attribute payee_name.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def payee_name @payee_name end |
#permission ⇒ String (readonly)
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 attr_reader :user, :id, :nickname, :supp_id, :currency, :is_active, :permission, :account_number, :routing_number, :name_on_account, :address, :bank_name, :bank_id, :bank_pw, :account_class, :account_type, :correspondent_routing_number, :correspondent_bank_name, :correspondent_address, :correspondent_swift, :account_id, :balance, :ifsc, :swift, :bank_long_name, :type, :gateway_restricted, :email_match, :name_match, :phonenumber_match, :address_street, :address_city, :address_subdivision, :address_country_code, :address_postal_code, :payee_address, :payee_name, :other, :network, :document_id, :interchange_type, :card_hash, :is_international, :allow_foreign_transactions, :atm_withdrawal_limit, :max_pin_attempts, :pos_withdrawal_limit, :security_alerts, :card_type, :access_token, :portfolio_BTC, :portfolio_ETH, :card_style_id, :monthly_withdrawals_remaining |
#phonenumber_match ⇒ Object (readonly)
Returns the value of attribute phonenumber_match.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def phonenumber_match @phonenumber_match end |
#portfolio_BTC ⇒ Object (readonly)
Returns the value of attribute portfolio_BTC.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def portfolio_BTC @portfolio_BTC end |
#portfolio_ETH ⇒ Object (readonly)
Returns the value of attribute portfolio_ETH.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def portfolio_ETH @portfolio_ETH end |
#pos_withdrawal_limit ⇒ Object (readonly)
Returns the value of attribute pos_withdrawal_limit.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def pos_withdrawal_limit @pos_withdrawal_limit end |
#routing_number ⇒ Object (readonly)
Returns the value of attribute routing_number.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def routing_number @routing_number end |
#security_alerts ⇒ Object (readonly)
Returns the value of attribute security_alerts.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def security_alerts @security_alerts end |
#supp_id ⇒ Object (readonly)
Returns the value of attribute supp_id.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def supp_id @supp_id end |
#swift ⇒ Object (readonly)
Returns the value of attribute swift.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def swift @swift end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def type @type end |
#user ⇒ SynapsePayRest::User
Returns the user to which the node belongs.
17 18 19 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 17 def user @user end |
Class Method Details
.all(user:, page: nil, per_page: nil) ⇒ Array<SynapsePayRest::BaseNode>
Queries the API for all nodes belonging to the supplied user (with optional filters) and matching the given type of this node.
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 61 def all(user:, page: nil, per_page: nil) raise ArgumentError, 'user must be a User object' unless user.is_a?(User) [page, per_page].each do |arg| if arg && (!arg.is_a?(Integer) || arg < 1) raise ArgumentError, "#{arg} must be nil or an Integer >= 1" end end unless type.nil? || NODE_TYPES_TO_CLASSES.keys.include(type) raise ArgumentError, "type must be nil or in #{NODE_TYPES_TO_CLASSES.keys}" end response = user.client.nodes.get( user_id: user.id, page: page, per_page: per_page, type: self.type ) multiple_from_response(user, response['nodes']) end |
.create(user:, nickname:, **options) ⇒ SynapsePayRest::BaseNode
Creates a new node in the API associated to the provided user and returns a node instance from the response data. See subclasses for type-specific arguments.
42 43 44 45 46 47 48 49 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 42 def create(user:, nickname:, **) raise ArgumentError, 'user must be a User object' unless user.is_a?(User) raise ArgumentError, 'nickname must be a String' unless nickname.is_a?(String) payload = payload_for_create(nickname: nickname, **) response = user.client.nodes.add(user_id: user.id, payload: payload) from_response(user, response['nodes'].first) end |
.from_response(user, response) ⇒ Object
Not meant to be accessed directly on BaseNode but through children.
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 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 82 def from_response(user, response) args = { user: user, type: response['type'], id: response['_id'], is_active: response['is_active'], permission: response['allowed'], nickname: response['info']['nickname'], name_on_account: response['info']['name_on_account'], bank_long_name: response['info']['bank_long_name'], bank_name: response['info']['bank_name'], account_type: response['info']['type'], account_class: response['info']['class'], account_number: response['info']['account_num'], routing_number: response['info']['routing_num'], address: response['info']['address'], swift: response['info']['swift'], ifsc: response['info']['ifsc'], payee_name: response['info']['payee_name'], document_id: response['info']['document_id'], network: response['info']['network'], interchange_type: response['info']['type'], card_type: response['info']['card_type'], card_hash: response['info']['card_hash'], is_international: response['info']['is_international'], monthly_withdrawals_remaining: response['info']['monthly_withdrawals_remaining'], user_info: nil, transactions: nil, timeline: nil, billpay_info: nil, transaction_analysis: nil } if response['info']['correspondent_info'] correspondent_info = response['info']['correspondent_info'] args[:correspondent_swift] = correspondent_info['swift'] args[:correspondent_bank_name] = correspondent_info['bank_name'] args[:correspondent_routing_number] = correspondent_info['routing_num'] args[:correspondent_address] = correspondent_info['address'] end if response['info']['match_info'] match_info = response['info']['match_info'] args[:email_match] = match_info['email_match'] args[:name_match] = match_info['name_match'] args[:phonenumber_match] = match_info['phonenumber_match'] end if response['info']['balance'] balance = response['info']['balance'] args[:balance] = balance['amount'] args[:currency] = balance['currency'] end if response['extra'] extra = response['extra'] args[:supp_id] = extra['supp_id'] args[:gateway_restricted] = extra['gateway_restricted'] end if response['extra']['other'] user_info = response['extra']['other']['info'] args[:user_info] = user_info transactions = response['extra']['other']['transactions'] args[:transactions] = transactions billpay_info = response['extra']['other']['billpay_info'] args[:billpay_info] = billpay_info transaction_analysis = response['extra']['other']['transaction_analysis'] args[:transaction_analysis] = transaction_analysis access_token = response['extra']['other']['access_token'] args[:access_token] = access_token end if response['timeline'] timeline = response['timeline'] args[:timeline] = timeline end if response['info']['payee_address'] payee_address = response['info']['payee_address'] args[:address_street] = payee_address['address_street'] args[:address_city] = payee_address['address_city'] args[:address_subdivision] = payee_address['address_subdivision'] args[:address_country_code] = payee_address['address_country_code'] args[:address_postal_code] = payee_address['address_postal_code'] end if response['info']['preferences'] preferences = response['info']['preferences'] args[:allow_foreign_transactions] = preferences['allow_foreign_transactions'] args[:atm_withdrawal_limit] = preferences['atm_withdrawal_limit'] args[:max_pin_attempts] = preferences['max_pin_attempts'] args[:pos_withdrawal_limit] = preferences['pos_withdrawal_limit'] args[:security_alerts] = preferences['security_alerts'] end if response['info']['portfolio'] preferences = response['info']['portfolio'] args[:portfolio_BTC] = preferences['BTC'] args[:portfolio_ETH] = preferences['ETH'] end self.new(**args) end |
.multiple_from_response(user, response) ⇒ Object
Not meant to be accessed directly on BaseNode but through children.
192 193 194 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 192 def multiple_from_response(user, response) response.map { |node_data| from_response(user, node_data)} end |
.payload_for_create(type:, **options) ⇒ Object
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 196 def payload_for_create(type:, **) payload = { 'type' => type, 'info' => {} } info_fields = [ :swift, :name_on_account, :bank_name, :address, :ifsc, :nickname, :bank_name ] info_fields.each do |field| payload['info'][field.to_s] = [field] if [field] end # the rest are done individually since they are custom renamed correspondent_info = {} if [:correspondent_routing_number] correspondent_info['routing_num'] = [:correspondent_routing_number] end if [:correspondent_bank_name] correspondent_info['bank_name'] = [:correspondent_bank_name] end if [:correspondent_address] correspondent_info['address'] = [:correspondent_address] end if [:correspondent_swift] correspondent_info['swift'] = [:correspondent_swift] end payload['info']['correspondent_info'] = correspondent_info if correspondent_info.any? if [:account_number] payload['info']['account_num'] = [:account_number] end if [:routing_number] payload['info']['routing_num'] = [:routing_number] end if [:account_type] payload['info']['type'] = [:account_type] end if [:account_class] payload['info']['class'] = [:account_class] end if [:username] payload['info']['bank_id'] = [:username] end if [:password] payload['info']['bank_pw'] = [:password] end if [:payee_name] payload['info']['payee_name'] = [:payee_name] end if [:card_number] payload['info']['card_number'] = [:card_number] end if [:exp_date] payload['info']['exp_date'] = [:exp_date] end if [:document_id] payload['info']['document_id'] = [:document_id] end if [:card_type] payload['info']['card_type'] = [:card_type] end if [:card_style_id] payload['card_style_id'] = [:card_style_id] end balance_fields = [:currency] balance_fields.each do |field| if [field] payload['info']['balance'] ||= {} payload['info']['balance'][field.to_s] = [field] if [field] end end extra_fields = [:supp_id, :gateway_restricted, :other] extra_fields.each do |field| if [field] payload['extra'] ||= {} payload['extra'][field.to_s] = [field] end end payee_address_fields = [:address_street, :address_city, :address_subdivision, :address_country_code, :address_postal_code] payee_address_fields.each do |field| if [field] payload['info']['payee_address'] ||= {} payload['info']['payee_address'][field.to_s] = [field] if [field] end end payload end |
Instance Method Details
#==(other) ⇒ Object
Checks if two BaseNode instances have same id (different instances of same record).
414 415 416 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 414 def ==(other) other.instance_of?(self.class) && !id.nil? && id == other.id end |
#create_subnet(**options) ⇒ SynapsePayRest::Subnet
Creates a subnet belonging to this node and returns it as a Subnet instance.
356 357 358 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 356 def create_subnet(**) Subnet.create(node: self, **) end |
#create_transaction(**options) ⇒ SynapsePayRest::Transaction
Creates a transaction belonging to this node and returns it as a Transaction instance.
318 319 320 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 318 def create_transaction(**) Transaction.create(node: self, **) end |
#deactivate ⇒ :success
Deactivates the node.
402 403 404 405 406 407 408 409 410 411 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 402 def deactivate response = user.client.nodes.delete(user_id: user.id, node_id: id) if response['_id'] # api v3.1.1 self.class.from_response(user, response) else # api v3.1 nil end end |
#find_subnet(id:) ⇒ SynapsePayRest::Subnet
Queries the API for a subnet belonging to this node by subnet id and returns a Subnet instance if found.
381 382 383 384 385 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 381 def find_subnet(id:) raise ArgumentError, 'id must be a String' unless id.is_a?(String) Subnet.find(node: self, id: id) end |
#find_transaction(id:) ⇒ SynapsePayRest::Transaction
Queries the API for a transaction belonging to this node by transaction id and returns a Transaction instance if found.
343 344 345 346 347 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 343 def find_transaction(id:) raise ArgumentError, 'id must be a String' unless id.is_a?(String) Transaction.find(node: self, id: id) end |
#get_statement ⇒ SynapsePayRest::Statement
Get statement for node Only available for native synapse nodes
393 394 395 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 393 def get_statement() Statement.by_node(client: self.user.client, node: self) end |
#subnets(**options) ⇒ Array<SynapsePayRest::Subnet>
Queries the API for all subnets belonging to this node and returns them as Subnet instances.
369 370 371 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 369 def subnets(**) Subnet.all(node: self, **) end |
#transactions(**options) ⇒ Array<SynapsePayRest::Transaction>
Queries the API for all transactions belonging to this node and returns them as Transaction instances.
331 332 333 |
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 331 def transactions(**) Transaction.all(node: self, **) end |