Class: Synapse::User

Inherits:
Object
  • Object
show all
Defined in:
lib/synapse_api/user.rb

Overview

Wrapper class for /users endpoints

Constant Summary collapse

VALID_QUERY_PARAMS =

Valid optional args for #get

[:query, :page, :per_page, :type, :full_dehydrate, :ship, :force_refresh].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user_id:, refresh_token:, client:, payload:, full_dehydrate:) ⇒ User

Returns a new instance of User.

Parameters:

  • user_id (String)
  • refresh_token (String)
  • client (Synapse::HTTPClient)
  • payload (Hash)
  • full_dehydrate (Boolean)


24
25
26
27
28
29
30
# File 'lib/synapse_api/user.rb', line 24

def initialize(user_id:,refresh_token:, client:,payload:, full_dehydrate:)
	@user_id = user_id
	@client = client
	@refresh_token = refresh_token
	@payload =payload
	@full_dehydrate =full_dehydrate
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



17
18
19
# File 'lib/synapse_api/user.rb', line 17

def client
  @client
end

#expires_inObject

Returns the value of attribute expires_in.



17
18
19
# File 'lib/synapse_api/user.rb', line 17

def expires_in
  @expires_in
end

#full_dehydrateObject

Returns the value of attribute full_dehydrate.



17
18
19
# File 'lib/synapse_api/user.rb', line 17

def full_dehydrate
  @full_dehydrate
end

#oauth_keyObject

Returns the value of attribute oauth_key.



17
18
19
# File 'lib/synapse_api/user.rb', line 17

def oauth_key
  @oauth_key
end

#payloadObject

Returns the value of attribute payload.



17
18
19
# File 'lib/synapse_api/user.rb', line 17

def payload
  @payload
end

#refresh_tokenObject

Returns the value of attribute refresh_token.



17
18
19
# File 'lib/synapse_api/user.rb', line 17

def refresh_token
  @refresh_token
end

#user_idObject

Returns the value of attribute user_id.



17
18
19
# File 'lib/synapse_api/user.rb', line 17

def user_id
  @user_id
end

Instance Method Details

#ach_mfa(payload:, **options) ⇒ Synapse::Node

Submit answer to a MFA question using access token from bank login attempt Please be sure to call ach_mfa again if you have more security questions

Parameters:

  • payload (Hash)
  • idempotency_key (String)

    (optional)

Returns:

See Also:



245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/synapse_api/user.rb', line 245

def ach_mfa(payload:, **options)
  path = get_user_path(user_id: self.user_id)
  path = path + nodes_path

  begin
    response = client.post(path,payload, options)
  rescue Synapse::Error::Unauthorized
    self.authenticate()
    response = client.post(path,payload, options)
  end

  if response["nodes"]
    nodes = response["nodes"].map { |nodes_data| Node.new(user_id: self.user_id, node_id: nodes_data["_id"], full_dehydrate: false, payload: response, type: nodes_data["type"])}
    nodes = Nodes.new(page: response["page"], limit: response["limit"], page_count: response["page_count"], nodes_count: response["node_count"], payload: nodes)
  else
    access_token = response
  end

  access_token ? access_token : nodes
end

#authenticate(**options) ⇒ Object

Parameters:

  • idempotency_key (String)

    (optional)

See Also:



125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/synapse_api/user.rb', line 125

def authenticate(**options)
    payload = {
      "refresh_token" => self.refresh_token
    }
    payload["scope"] = options[:scope] if options[:scope]

    path = oauth_path()

	oauth_response = client.post(path, payload,options)
    oauth_key = oauth_response['oauth_key']
    oauth_expires = oauth_response['expires_in']
    self.oauth_key = oauth_key
    self.expires_in = oauth_expires
    client.update_headers(oauth_key: oauth_key)

    oauth_response
end

#cancel_transaction(node_id:, trans_id:) ⇒ Object

Cancels transaction if it has not already settled

Parameters:

  • node_id
  • trans_id

Returns:

  • API response [Hash]



531
532
533
534
535
536
537
538
539
540
541
# File 'lib/synapse_api/user.rb', line 531

def cancel_transaction(node_id:, trans_id:)

  path = trans_path(user_id: self.user_id, node_id: node_id) + "/#{trans_id}"
  begin
    response = client.delete(path)
  rescue Synapse::Error::Unauthorized
    self.authenticate()
    response = client.delete(path)
  end
  response
end

#comment_transaction(node_id:, trans_id:, payload:) ⇒ Synapse::Transaction

Adds comment to the transactions

Parameters:

  • node_id (String)
  • trans_id (String)
  • payload (Hash)

Returns:



513
514
515
516
517
518
519
520
521
522
523
524
525
# File 'lib/synapse_api/user.rb', line 513

def comment_transaction(node_id:,trans_id:,payload:)

  path = trans_path(user_id: self.user_id, node_id: node_id) + "/#{trans_id}"

  begin
    trans = client.patch(path, payload)
  rescue Synapse::Error::Unauthorized
    self.authenticate()
    trans = client.patch(path, payload)
  end
  transaction = Transaction.new(trans_id: trans['_id'], payload: trans)
  transaction
end

#confirm_2fa_pin(pin:, **options) ⇒ Object

Supply pin for 2FA confirmation

Parameters:

  • pin (String)
  • idempotency_key (String)

    (optional)

  • scope (Array)

    (optional)

Returns:

  • API response [Hash]

See Also:



165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/synapse_api/user.rb', line 165

def confirm_2fa_pin(pin:, **options)
  payload = {
    "refresh_token": self.refresh_token,
    "validation_pin": pin
  }

  payload["scope"] = options[:scope] if options[:scope]

  path = oauth_path()

  pin_response = client.post(path, payload, options)
  oauth_key = pin_response['oauth_key']
  oauth_expires = pin_response['expires_in']
  self.oauth_key = oauth_key
  self.expires_in = oauth_expires
  client.update_headers(oauth_key: oauth_key)

  pin_response
end

#create_node(payload:, **options) ⇒ Synapse::Node

Note:

Types of nodes [Card, IB/Deposit-US, Check/Wire Instructions]

Creates Synapse node

Parameters:

  • payload (Hash)
  • idempotency_key (String)

    (optional)

Returns:

See Also:



218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
# File 'lib/synapse_api/user.rb', line 218

def create_node(payload:, **options)
	path = get_user_path(user_id: self.user_id)
	path = path + nodes_path

    begin
      response = client.post(path,payload, options)
    rescue Synapse::Error::Unauthorized
      self.authenticate()
      response = client.post(path,payload, options)
    end

    if response["nodes"]
      nodes = response["nodes"].map { |nodes_data| Node.new(user_id: self.user_id, node_id: nodes_data["_id"], full_dehydrate: false, payload: response, type: nodes_data["type"])}
      nodes = Nodes.new(page: response["page"], limit: response["limit"], page_count: response["page_count"], nodes_count: response["node_count"], payload: nodes)
    else
      access_token = response
    end

    access_token ? access_token : nodes
end

#create_subnet(node_id:, payload:, **options) ⇒ Synapse::Subnet

Creates subnet for a node

Parameters:

  • node_id (String)
  • payload (Hash)
  • idempotency_key (String)

    (optional)

Returns:



569
570
571
572
573
574
575
576
577
578
579
580
# File 'lib/synapse_api/user.rb', line 569

def create_subnet(node_id:,payload:, **options)
  path = subnet_path(user_id: self.user_id, node_id: node_id)

  begin
   subnet = client.post(path,payload, options)
  rescue Synapse::Error::Unauthorized
   self.authenticate()
   subnet = client.post(path,payload, options)
  end
  subnet = Subnet.new(subnet_id: subnet['_id'], payload: subnet, node_id: node_id)
  subnet
end

#create_transaction(node_id:, payload:, **options) ⇒ Synapse::Transaction

Creates a new transaction in the API belonging to the provided node

Parameters:

  • node_id (String)
  • payload (Hash)
  • idempotency_key (String)

    (optional)

Returns:



345
346
347
348
349
350
351
352
353
354
355
# File 'lib/synapse_api/user.rb', line 345

def create_transaction(node_id: ,payload:, **options)
  path = trans_path(user_id: self.user_id, node_id: node_id)

  begin
   transaction = client.post(path,payload, options)
  rescue Synapse::Error::Unauthorized
   self.authenticate()
   transaction = client.post(path,payload, options)
  end
  transaction = Transaction.new(trans_id: transaction['_id'], payload: transaction, node_id: node_id)
end

#create_ubo(payload:) ⇒ Object

Allows you to upload an Ultimate Beneficial Ownership document

Parameters:

  • payload (Hash)

Returns:

  • API response

See Also:



271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/synapse_api/user.rb', line 271

def create_ubo(payload:)
  path = get_user_path(user_id: self.user_id)
  path = path + nodes_path + "/ubo"

  begin
   response = client.patch(path,payload)
  rescue Synapse::Error::Unauthorized
   self.authenticate()
   response = client.patch(path,payload)
  end

  response
end

#delete_node(node_id:) ⇒ Object



473
474
475
476
477
478
479
480
481
482
483
# File 'lib/synapse_api/user.rb', line 473

def delete_node(node_id:)
  path = node(user_id: self.user_id, node_id: node_id)

  begin
    delete = client.delete(path)
  rescue Synapse::Error::Unauthorized
    self.authenticate()
    delete = client.delete(path)
  end
  delete
end

#dispute_card_transactions(node_id:, trans_id:) ⇒ Object

Dispute a transaction for a user

Parameters:

  • node_id
  • trans_id

Returns:

  • API response [Hash]

See Also:



548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
# File 'lib/synapse_api/user.rb', line 548

def dispute_card_transactions(node_id:, trans_id:)

  path = trans_path(user_id: user_id, node_id: node_id) + "/#{trans_id}"
  path += "/dispute"
  payload = {
    "dispute_reason":"CHARGE_BACK"
  }
  begin
    dispute = client.patch(path, payload)
  rescue Synapse::Error::Unauthorized
    self.authenticate()
    dispute = client.patch(path, payload)
  end
  dispute
end

#dummy_transactions(node_id:, is_credit: nil) ⇒ Object

Initiates dummy transactions to a node

Parameters:

  • node_id (String)
  • is_credit (Boolean) (defaults to: nil)

    , for credit send true, for debit send false

See Also:



489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
# File 'lib/synapse_api/user.rb', line 489

def dummy_transactions(node_id:, is_credit: nil)

  is_credit = "YES" if is_credit == true
  is_credit = "NO" if is_credit == false
  if is_credit
    path = node(user_id: self.user_id, node_id: node_id) + "/dummy-tran?#{is_credit}"
  else
    path = node(user_id: self.user_id, node_id: node_id) + "/dummy-tran"
  end

  begin
   response = client.get(path)
  rescue Synapse::Error::Unauthorized
   self.authenticate()
   response = client.get(path)
  end
  response
end

#generate_apple_pay_token(node_id:, payload:) ⇒ Object

Generate tokenized info for Apple Wallet

Parameters:

  • node_id (String)
  • payload (Hash)

See Also:



440
441
442
443
444
445
446
447
448
449
# File 'lib/synapse_api/user.rb', line 440

def generate_apple_pay_token(node_id:,payload:)
  path = node(user_id: self.user_id, node_id: node_id) + "/applepay"
  begin
    response = client.patch(path, payload)
  rescue Synapse::Error::Unauthorized
    self.authenticate()
    response = client.patch(path, payload)
  end
  response
end

#get_all_node_transaction(node_id:, **options) ⇒ Array<Synapse::Transaction>

Queries the API for all transactions belonging to the supplied node

Parameters:

  • node_id (String)

    node to which the transaction belongs

  • page (Integer)

    (optional) response will default to 1

  • per_page (Integer)

    (optional) response will default to 20

Returns:



380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
# File 'lib/synapse_api/user.rb', line 380

def get_all_node_transaction(node_id:, **options)
  [options[:page], options[: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

  path = node(user_id: self.user_id, node_id: node_id) + "/trans"

  params = VALID_QUERY_PARAMS.map do |p|
    options[p] ? "#{p}=#{options[p]}" : nil
  end.compact

  path += '?' + params.join('&') if params.any?

  begin
    trans = client.get(path)
  rescue Synapse::Error::Unauthorized
    self.authenticate()
    trans = client.get(path)
  end


  response = trans["trans"].map { |trans_data| Transaction.new(trans_id: trans_data['_id'], payload: trans_data, node_id: node_id)}
  trans = Transactions.new(limit: trans["limit"], page: trans["page"], page_count: trans["page_count"], trans_count: trans["trans_count"], payload: response)
  trans
end

#get_all_subnets(node_id:, **options) ⇒ Object

Gets all node subnets

Parameters:

  • node_id (String)
  • page (Integer)
  • per_page (Integer)

See Also:



588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
# File 'lib/synapse_api/user.rb', line 588

def get_all_subnets(node_id:,**options)
  [options[:page], options[: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

  path = node(user_id: self.user_id, node_id: node_id) + "/subnets"
  params = VALID_QUERY_PARAMS.map do |p|
    options[p] ? "#{p}=#{options[p]}" : nil
  end.compact
  path += '?' + params.join('&') if params.any?

  begin
   subnets = client.get(path)
  rescue Synapse::Error::Unauthorized
   self.authenticate()
   subnets = client.get(path)
  end

  response = subnets["subnets"].map { |subnets_data| Subnet.new(subnet_id: subnets_data['_id'], payload: subnets, node_id: node_id)}

  subnets = Subnets.new(limit: subnets["limit"], page: subnets["page"], page_count: subnets["page_count"], subnets_count: subnets["subnets_count"], payload: response, node_id: node_id)

  subnets
end

#get_all_user_nodes(**options) ⇒ Array<Synapse::Nodes>

Queries Synapse API for all nodes belonging to user

Parameters:

  • page (String, Integer)

    (optional) response will default to 1

  • per_page (String, Integer)

    (optional) response will default to 20

  • type (String)

    (optional)

Returns:

See Also:



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/synapse_api/user.rb', line 92

def get_all_user_nodes(**options)
	[options[:page], options[: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
	path = get_user_path(user_id: self.user_id) + nodes_path(options)

    begin
     nodes = client.get(path)
    rescue Synapse::Error::Unauthorized
     self.authenticate()
     nodes = client.get(path)
    end

	return [] if nodes["nodes"].empty?
	response = nodes["nodes"].map { |node_data| Node.new(node_id: node_data['_id'], user_id: node_data['user_id'], payload: node_data, full_dehydrate: "no", type: node_data["type"])}
    nodes = Nodes.new(limit: nodes["limit"], page: nodes["page"], page_count: nodes["page_count"], nodes_count: nodes["node_count"], payload: response)
end

#get_node_statements(node_id:, **options) ⇒ Object

Gets statement by node

Parameters:

  • page (Integer)
  • per_page (Integer)

Returns:

  • API response [Hash]

See Also:



638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
# File 'lib/synapse_api/user.rb', line 638

def get_node_statements(node_id:,**options)
  [options[:page], options[: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

  path = node(user_id: self.user_id, node_id: node_id) + "/statements"
  params = VALID_QUERY_PARAMS.map do |p|
    options[p] ? "#{p}=#{options[p]}" : nil
  end.compact
  path += '?' + params.join('&') if params.any?

  begin
   statements = client.get(path)
  rescue Synapse::Error::Unauthorized
   self.authenticate()
   statements = client.get(path)
  end

  statements
end

#get_node_transaction(node_id:, trans_id:) ⇒ Synapse::Transaction

Queries the API for a transaction belonging to the supplied node by transaction id

Parameters:

  • node_id (String)
  • trans_id (String)

    id of the transaction to find

Returns:



361
362
363
364
365
366
367
368
369
370
371
372
# File 'lib/synapse_api/user.rb', line 361

def get_node_transaction(node_id:, trans_id:)
  path = node(user_id: self.user_id, node_id: node_id) + "/trans/#{trans_id}"

  begin
    trans = client.get(path)
  rescue Synapse::Error::Unauthorized
    self.authenticate()
    trans = client.get(path)
  end
  transaction = Transaction.new(trans_id: trans['_id'], payload: trans, node_id: node_id)
  transaction
end

#get_subnet(node_id:, subnet_id:) ⇒ Synapse::Subnet

Queries a node for a specific subnet by subnet_id

Parameters:

  • node_id (String)

    id of node

  • subnet_id (String, void)

    (optional) id of a subnet to look up

Returns:



619
620
621
622
623
624
625
626
627
628
629
630
631
# File 'lib/synapse_api/user.rb', line 619

def get_subnet(node_id:,subnet_id:)

  path = node(user_id: self.user_id, node_id: node_id) + "/subnets/#{subnet_id}"

  begin
   subnet = client.get(path)
  rescue Synapse::Error::Unauthorized
   self.authenticate()
   subnet = client.get(path)
  end
  subnet = Subnet.new(subnet_id: subnet['_id'], payload: subnet, node_id: node_id)
  subnet
end

#get_user_node(node_id:, **options) ⇒ Synapse::Node

Queries the API for a node belonging to user for ACH node

Parameters:

  • node_id (String)
  • full_dehydrate (String)

    (optional) if true, returns all trans data on node

  • force_refresh (String)

    (optional) if true, force refresh yes will attempt updating the account balance and transactions

Returns:



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/synapse_api/user.rb', line 61

def get_user_node(node_id:, **options)
  options[:full_dehydrate] = "yes" if options[:full_dehydrate] == true
  options[:full_dehydrate] = "no" if options[:full_dehydrate] == false
  options[:force_refresh] = "yes" if options[:force_refresh] == true
  options[:force_refresh] = "no" if options[:force_refresh] == false

  path = node(node_id:node_id, full_dehydrate: options[:full_dehydrate],force_refresh: options[:force_refresh] )

  begin
    node = client.get(path)
  rescue Synapse::Error::Unauthorized

    self.authenticate()
    node = client.get(path)
  end

  node = Node.new(node_id: node['_id'],
    user_id: self.user_id,
    payload: node,
    full_dehydrate: options[:full_dehydrate] == "yes" ? true : false,
    type: node["type"]
    )
  node
end

#get_user_statement(**options) ⇒ Object

Gets user statement

Parameters:

  • page (Integer)
  • per_page (Integer)

Returns:

  • API response

See Also:



290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
# File 'lib/synapse_api/user.rb', line 290

def get_user_statement(**options)
  path = get_user_path(user_id: self.user_id) + "/statements"
  params = VALID_QUERY_PARAMS.map do |p|
    options[p] ? "#{p}=#{options[p]}" : nil
  end.compact
  path += '?' + params.join('&') if params.any?

  begin
   statements = client.get(path)
  rescue Synapse::Error::Unauthorized
   self.authenticate()
   statements = client.get(path)
  end

  statements
end

#get_user_transactions(**options) ⇒ Array<Synapse::Transactions>

Parameters:

  • page (Integer)

    (optional) response will default to 1

  • per_page (Integer)

    (optional) response will default to 20

Returns:



189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/synapse_api/user.rb', line 189

def get_user_transactions(**options)
[options[:page], options[: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

  path = transactions_path(user_id: self.user_id, options: options)

  begin
    trans = client.get(path)
  rescue Synapse::Error::Unauthorized
    self.authenticate()
    trans = client.get(path)
  end


  response = trans["trans"].map { |trans_data| Transaction.new(trans_id: trans_data['_id'], payload: trans_data)}
  trans = Transactions.new(limit: trans["limit"], page: trans["page"], page_count: trans["page_count"], trans_count: trans["trans_count"], payload: response)

	trans
end

#reinitiate_micro_deposit(node_id:) ⇒ Object

Reinitiate microdeposits on a node

Parameters:

  • node_id (String)


424
425
426
427
428
429
430
431
432
433
434
# File 'lib/synapse_api/user.rb', line 424

def reinitiate_micro_deposit(node_id:)
  payload = {}
  path = node(user_id: self.user_id, node_id: node_id) + "?resend_micro=YES"
  begin
    response = client.patch(path, payload)
  rescue Synapse::Error::Unauthorized
    self.authenticate()
    response = client.patch(path, payload)
  end
  Node.new(user_id: self.user_id, node_id:response["_id"], full_dehydrate: false, payload: response, type: response["type"])
end

#reset_debit_card(node_id:) ⇒ Synapse::Node

Resets debit card number, cvv, and expiration date

Parameters:

  • node_id (String)

Returns:

See Also:



328
329
330
331
332
333
334
335
336
337
338
# File 'lib/synapse_api/user.rb', line 328

def reset_debit_card(node_id:)
  path = node(user_id: self.user_id, node_id: node_id)  + "?reset=YES"
  payload = {}
  begin
   response = client.patch(path,payload)
  rescue Synapse::Error::Unauthorized
   self.authenticate()
   response = client.patch(path,payload)
  end
  Node.new(user_id: self.user_id, node_id:response["_id"], full_dehydrate: false, payload: response, type: response["type"])
end

#select_2fa_device(device:, **options) ⇒ Object

For registering new fingerprint Supply 2FA device which pin should be sent to

Parameters:

  • device (String)
  • idempotency_key (String)

    (optional)

Returns:

  • API response [Hash]

See Also:



149
150
151
152
153
154
155
156
157
# File 'lib/synapse_api/user.rb', line 149

def select_2fa_device(device:, **options)
  payload = {
    "refresh_token": self.refresh_token,
    "phone_number": device
  }
  path = oauth_path()
  device_response = client.post(path, payload, options)
  device_response
end

#ship_card(node_id:, payload:) ⇒ Synapse::Node

Request to ship a user card

Parameters:

  • node_id (String)
  • payload (Hash)

Returns:



311
312
313
314
315
316
317
318
319
320
321
322
# File 'lib/synapse_api/user.rb', line 311

def ship_card(node_id:, payload:)

  path = node(user_id: self.user_id, node_id: node_id) + "?ship=YES"

  begin
   response = client.patch(path,payload)
  rescue Synapse::Error::Unauthorized
   self.authenticate()
   response = client.patch(path,payload)
  end
  Node.new(user_id: self.user_id, node_id:response["_id"], full_dehydrate: false, payload: response, type: response["type"])
end

#update_node(node_id:, payload:) ⇒ Synapse::Node

Update supp_id, nickname, etc. for a node

Parameters:

  • node_id (String)
  • payload (Hash)

Returns:

See Also:



456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
# File 'lib/synapse_api/user.rb', line 456

def update_node(node_id:, payload:)
  path = node(user_id: self.user_id, node_id: node_id)

  begin
    update = client.patch(path, payload)
  rescue Synapse::Error::Unauthorized
    self.authenticate()
    update = client.patch(path, payload)
  end
  update = Node.new(node_id: node_id,
                    user_id: self.user_id,
                    payload: update,
                    full_dehydrate: false,
                    type: update["type"]
                    )
end

#user_update(payload:) ⇒ Synapse::User

Parameters:

  • payload (Hash)

Returns:



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/synapse_api/user.rb', line 36

def user_update(payload:)
	path = get_user_path(user_id: self.user_id)
   begin
     response = client.patch(path, payload)
   rescue Synapse::Error::Unauthorized
     self.authenticate()
     response =client.patch(path, payload)
   end
	user = User.new(
          user_id:                response['_id'],
          refresh_token:     response['refresh_token'],
          client:            client,
          full_dehydrate:    false,
          payload:           response
        )

    user
end

#verify_micro_deposit(node_id:, payload:) ⇒ Object

Verifies microdeposits for a node

Parameters:

  • node_id (String)
  • payload (Hash)


411
412
413
414
415
416
417
418
419
420
# File 'lib/synapse_api/user.rb', line 411

def verify_micro_deposit(node_id:,payload:)
  path = node(user_id: self.user_id, node_id: node_id)
  begin
    response = client.patch(path, payload)
  rescue Synapse::Error::Unauthorized
    self.authenticate()
    response = client.patch(path, payload)
  end
  Node.new(user_id: self.user_id, node_id:response["_id"], full_dehydrate: false, payload: response, type: response["type"])
end