Class: SynapsePayRest::BaseNode

Inherits:
Object
  • Object
show all
Defined in:
lib/synapse_pay_rest/models/node/base_node.rb

Overview

TODO:

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.

TODO:

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.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**options) ⇒ BaseNode

Note:

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(**options)
  options.each { |key, value| instance_variable_set("@#{key}", value) }
end

Instance Attribute Details

#access_tokenObject (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_classObject (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
end

#account_idObject (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
end

#account_numberObject (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
end

#account_typeObject (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
end

#addressObject (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_cityObject (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_codeObject (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_codeObject (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_streetObject (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_subdivisionObject (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_transactionsObject (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_limitObject (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

#balanceObject (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_idObject (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_nameObject (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_nameObject (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_pwObject (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_hashObject (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_idObject (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_typeObject (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_addressObject (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_nameObject (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_numberObject (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_swiftObject (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

#currencyObject (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_idObject (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_matchObject (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_restrictedObject (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

#idObject (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

#ifscObject (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_typeObject (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_activeObject (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_internationalObject (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_attemptsObject (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_remainingObject (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_matchObject (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_accountObject (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 
  
end

#networkObject (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

#nicknameObject (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

#otherObject (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_addressObject (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_nameObject (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

#permissionString (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_matchObject (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_BTCObject (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_ETHObject (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_limitObject (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_numberObject (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_alertsObject (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_idObject (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

#swiftObject (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

#typeObject (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

#userSynapsePayRest::User

Returns the user to which the node belongs.

Returns:



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.

Parameters:

  • user (SynapsePayRest::User)
  • page (String, Integer) (defaults to: nil)

    (optional) response will default to 1

  • per_page (String, Integer) (defaults to: nil)

    (optional) response will default to 20

Returns:

Raises:



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.

Parameters:

Returns:

Raises:



42
43
44
45
46
47
48
49
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 42

def create(user:, nickname:, **options)
  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, **options)
  response = user.client.nodes.add(user_id: user.id, payload: payload)
  from_response(user, response['nodes'].first)
end

.from_response(user, response) ⇒ Object

Note:

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']
     = response['extra']['other']['info']
    args[: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

Note:

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:, **options)
  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] = options[field] if options[field]
  end

  # the rest are done individually since they are custom renamed
  correspondent_info = {}
  if options[:correspondent_routing_number]
    correspondent_info['routing_num'] = options[:correspondent_routing_number]
  end
  if options[:correspondent_bank_name]
    correspondent_info['bank_name'] = options[:correspondent_bank_name]
  end
  if options[:correspondent_address]
    correspondent_info['address'] = options[:correspondent_address]
  end
  if options[:correspondent_swift]
    correspondent_info['swift'] = options[:correspondent_swift]
  end
  payload['info']['correspondent_info'] = correspondent_info if correspondent_info.any?

  if options[:account_number]
    payload['info']['account_num'] = options[:account_number]
  end
  if options[:routing_number]
    payload['info']['routing_num'] = options[:routing_number]
  end
  if options[:account_type]
    payload['info']['type'] = options[:account_type]
  end
  if options[:account_class]
    payload['info']['class'] = options[:account_class]
  end
  if options[:username]
    payload['info']['bank_id'] = options[:username]
  end
  if options[:password]
    payload['info']['bank_pw'] = options[:password]
  end
  if options[:payee_name]
    payload['info']['payee_name'] = options[:payee_name]
  end
  if options[:card_number]
    payload['info']['card_number'] = options[:card_number]
  end
  if options[:exp_date]
    payload['info']['exp_date'] = options[:exp_date]
  end
  if options[:document_id]
    payload['info']['document_id'] = options[:document_id]
  end
  if options[:card_type]
    payload['info']['card_type'] = options[:card_type]
  end
  if options[:card_style_id]
    payload['card_style_id'] = options[:card_style_id]
  end

  balance_fields = [:currency]
  balance_fields.each do |field|
    if options[field]
      payload['info']['balance'] ||= {}
      payload['info']['balance'][field.to_s] = options[field] if options[field]
    end
  end

  extra_fields = [:supp_id, :gateway_restricted, :other]
  extra_fields.each do |field|
    if options[field]
      payload['extra'] ||= {}
      payload['extra'][field.to_s] = options[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 options[field]
      payload['info']['payee_address'] ||= {}
      payload['info']['payee_address'][field.to_s] = options[field] if options[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.

Returns:

Raises:



356
357
358
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 356

def create_subnet(**options)
  Subnet.create(node: self, **options)
end

#create_transaction(**options) ⇒ SynapsePayRest::Transaction

Creates a transaction belonging to this node and returns it as a Transaction instance.

Parameters:

  • to_id (String)

    node id of the receiving node

  • to_type (String)

    node type of the receiving node

  • amount (Float)

    100.0 = $100.00 for example

  • currency (String)

    e.g. ‘USD’

  • ip (String)
  • note (String)

    (optional)

  • process_in (Integer)

    (optional) days until processed (default/minimum 1)

  • fee_amount (Float)

    (optional) fee amount to add to the transaction

  • fee_note (String)

    (optional)

  • fee_to_id (String)

    (optional) node id to which to send the fee

  • supp_id (String)

    (optional)

  • idempotency_key (String)

    (optional) avoid accidentally performing the same operation twice

Returns:

Raises:

See Also:



318
319
320
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 318

def create_transaction(**options)
  Transaction.create(node: self, **options)
end

#deactivate:success

Deactivates the node.

Returns:

  • (:success)

Raises:



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.

Parameters:

  • id (String)

    id of the subnet to find

Returns:

Raises:



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.

Parameters:

  • id (String)

    id of the transaction to find

Returns:

Raises:



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_statementSynapsePayRest::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.

Parameters:

  • page (String, Integer)

    (optional) response will default to 1

  • per_page (String, Integer)

    (optional) response will default to 20

Returns:

Raises:



369
370
371
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 369

def subnets(**options)
  Subnet.all(node: self, **options)
end

#transactions(**options) ⇒ Array<SynapsePayRest::Transaction>

Queries the API for all transactions belonging to this node and returns them as Transaction instances.

Parameters:

  • page (String, Integer)

    (optional) response will default to 1

  • per_page (String, Integer)

    (optional) response will default to 20

Returns:

Raises:



331
332
333
# File 'lib/synapse_pay_rest/models/node/base_node.rb', line 331

def transactions(**options)
  Transaction.all(node: self, **options)
end