Class: SynapsePayRest::User
- Inherits:
-
Object
- Object
- SynapsePayRest::User
- Defined in:
- lib/synapse_pay_rest/models/user/user.rb
Overview
use mixins to remove duplication between Node and BaseNode.
reduce duplicated logic between User/BaseNode/Transaction
Represents a user record and holds methods for constructing user instances from API calls. This is built on top of the SynapsePayRest::Users class and is intended to make it easier to use the API without knowing payload formats or knowledge of REST.
Instance Attribute Summary collapse
- #base_documents ⇒ Array<SynapsePayRest::BaseDocument>
-
#cip_tag ⇒ Object
readonly
Returns the value of attribute cip_tag.
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#expires_in ⇒ Object
Returns the value of attribute expires_in.
-
#flag ⇒ Object
Returns the value of attribute flag.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#ips ⇒ Object
Returns the value of attribute ips.
-
#is_business ⇒ Object
readonly
Returns the value of attribute is_business.
-
#legal_names ⇒ Object
readonly
Returns the value of attribute legal_names.
-
#logins ⇒ Object
readonly
Returns the value of attribute logins.
-
#note ⇒ Object
readonly
Returns the value of attribute note.
-
#oauth_key ⇒ Object
Returns the value of attribute oauth_key.
-
#permission ⇒ Object
readonly
Returns the value of attribute permission.
-
#phone_numbers ⇒ Object
readonly
Returns the value of attribute phone_numbers.
-
#refresh_token ⇒ Object
Returns the value of attribute refresh_token.
-
#supp_id ⇒ Object
readonly
Returns the value of attribute supp_id.
Class Method Summary collapse
-
.all(client:, page: nil, per_page: nil, query: nil) ⇒ Array<SynapsePayRest::User>
Queries the API for all users (with optional filters) and returns them as User instances.
-
.create(client:, logins:, phone_numbers:, legal_names:, **options) ⇒ SynapsePayRest::User
Creates a new user in the API and returns a User instance from the response data.
-
.find(client:, id:, full_dehydrate: 'no') ⇒ SynapsePayRest::User
Queries the API for a user by id and returns a User instances if found.
-
.from_response(client, response, oauth: true) ⇒ Object
Constructs a user instance from a user response.
-
.multiple_from_response(client, response) ⇒ Object
Calls from_response on each member of a response collection.
-
.payload_for_create(logins:, phone_numbers:, legal_names:, **options) ⇒ Object
Maps args to API payload format.
-
.search(client:, query:, page: nil, per_page: nil) ⇒ Array<SynapsePayRest::User>
Queries the API for all users with name/email matching the given query and returns them as User instances.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Checks if two User instances have same id (different instances of same record).
-
#add_legal_name(legal_name) ⇒ SynapsePayRest::User
Add a legal_name to the user.
-
#add_login(email:, password: nil, read_only: nil) ⇒ SynapsePayRest::User
Adds a login for the user.
-
#add_phone_number(phone_number) ⇒ SynapsePayRest::User
Add a phone_number to the user.
-
#authenticate ⇒ SynapsePayRest::User
Updates the oauth token.
-
#confirm_2fa_pin(pin:, device:) ⇒ :success
Step 3 (final) step of fingerprint registration.
-
#create_ach_us_node(**options) ⇒ SynapsePayRest::AchUsNode
Creates an ACH-US node via account and routing numbers, belonging to this user.
-
#create_ach_us_nodes_via_bank_login(**options) ⇒ Array<SynapsePayRest::AchUsNode>
Creates an ACH-US node via bank login, belonging to this user.
-
#create_ach_us_nodes_via_bank_login_mfa(**options) ⇒ <SynapsePayRest::UnverifiedNode>
Creates an Unverified Node Class node via access token, belonging to this user.
-
#create_base_document(**args) ⇒ SynapsePayRest::User
Creates a new base document for the user.
-
#create_card_us_node(**options) ⇒ SynapsePayRest::CardUsNode
Creates a CARD-US node.
-
#create_check_us_node(**options) ⇒ SynapsePayRest::CheckUsNode
Creates a CHECK-US node.
-
#create_clearing_us_node(**options) ⇒ SynapsePayRest::ClearingUsNode
Creates a CLEARING-US node.
-
#create_crypto_us_node(**options) ⇒ SynapsePayRest::CryptoUsNode
Creates a CRYPTO-US node.
-
#create_custody_us_node(**options) ⇒ SynapsePayRest::CustodyUsNode
Creates a CUSTODY-US node.
-
#create_deposit_us_node(**options) ⇒ SynapsePayRest::SynapseUsNode
Creates a DEPOSIT-US node.
- #create_eft_ind_node(**options) ⇒ SynapsePayRest::EftIndNode deprecated Deprecated.
-
#create_eft_np_node(**options) ⇒ SynapsePayRest::EftNpNode
Creates an EFT-NP node.
-
#create_ib_deposit_us_node(**options) ⇒ SynapsePayRest::IbDepositUsNode
Creates a IB-DEPOSIT-US node.
-
#create_ib_subaccount_us_node(**options) ⇒ SynapsePayRest::IbSubaccountUsNode
Creates a IB-SUBACCOUNT-US node.
-
#create_interchange_us_node(**options) ⇒ SynapsePayRest::InterchangeUsNode
Creates a INTERCHANGE-US node.
-
#create_iou_node(**options) ⇒ SynapsePayRest::IouNode
Creates an IOU node.
-
#create_reserve_us_node(**options) ⇒ SynapsePayRest::IouNode
Creates a RESERVE-US node.
-
#create_subaccount_us_node(**options) ⇒ SynapsePayRest::SubaccountUsNode
Creates a SUBACCOUNT-US node.
-
#create_subcard_us_node(**options) ⇒ SynapsePayRest::SubcardUsNode
Creates a SUBCARD-US node.
- #create_synapse_ind_node(**options) ⇒ SynapsePayRest::SynapseIndNode deprecated Deprecated.
-
#create_synapse_np_node(**options) ⇒ SynapsePayRest::SynapseNpNode
Creates a SYNAPSE-NP node.
-
#create_synapse_us_node(**options) ⇒ SynapsePayRest::SynapseUsNode
Creates a SYNAPSE-US node.
-
#create_triumph_subaccount_us_node(**options) ⇒ SynapsePayRest::TriumphSubaccountUsNode
Creates a TRIUMPH-SUBACCOUNT-US node.
-
#create_wire_int_node(**options) ⇒ SynapsePayRest::WireIntNode
Creates a WIRE-INT node.
-
#create_wire_us_node(**options) ⇒ SynapsePayRest::WireUsNode
Creates a WIRE-US node.
-
#find_node(id:) ⇒ SynapsePayRest::BaseNode
Queries the API for a node belonging to this user by node id and returns a node instance if found.
-
#get_statement ⇒ SynapsePayRest::Statement
Gets statement for user.
-
#initialize(**options) ⇒ User
constructor
A new instance of User.
-
#nodes(**options) ⇒ Array<SynapsePayRest::BaseNode>
Queries the API for all nodes belonging to this user and returns them as node (SynapsePayRest::BaseNode) instances.
-
#register_fingerprint(fingerprint) ⇒ Array<String>
Step 1 of fingerprint registration.
-
#remove_legal_name(legal_name) ⇒ SynapsePayRest::User
Removes a legal_name from the user.
-
#remove_login(email:) ⇒ SynapsePayRest::User
Removes a login from the user.
-
#remove_phone_number(phone_number) ⇒ SynapsePayRest::User
Removes a phone_number from the user.
-
#select_2fa_device(device) ⇒ :success
Step 2 of fingerprint registration.
-
#update(**options) ⇒ SynapsePayRest::User
Updates the given key value pairs.
Constructor Details
#initialize(**options) ⇒ User
Do not call directly. Use User.create or other class method to instantiate via API action.
Returns a new instance of User.
193 194 195 196 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 193 def initialize(**) .each { |key, value| instance_variable_set("@#{key}", value) } @base_documents ||= [] end |
Instance Attribute Details
#base_documents ⇒ Array<SynapsePayRest::BaseDocument>
14 15 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 14 attr_reader :client, :id, :logins, :phone_numbers, :legal_names, :note, :supp_id, :is_business, :cip_tag, :permission |
#cip_tag ⇒ Object (readonly)
Returns the value of attribute cip_tag.
14 15 16 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 14 def cip_tag @cip_tag end |
#client ⇒ Object (readonly)
Returns the value of attribute client.
14 15 16 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 14 def client @client end |
#expires_in ⇒ Object
Returns the value of attribute expires_in.
16 17 18 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 16 def expires_in @expires_in end |
#flag ⇒ Object
Returns the value of attribute flag.
16 17 18 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 16 def flag @flag end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 14 def id @id end |
#ips ⇒ Object
Returns the value of attribute ips.
16 17 18 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 16 def ips @ips end |
#is_business ⇒ Object (readonly)
Returns the value of attribute is_business.
14 15 16 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 14 def is_business @is_business end |
#legal_names ⇒ Object (readonly)
Returns the value of attribute legal_names.
14 15 16 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 14 def legal_names @legal_names end |
#logins ⇒ Object (readonly)
Returns the value of attribute logins.
14 15 16 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 14 def logins @logins end |
#note ⇒ Object (readonly)
Returns the value of attribute note.
14 15 16 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 14 def note @note end |
#oauth_key ⇒ Object
Returns the value of attribute oauth_key.
16 17 18 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 16 def oauth_key @oauth_key end |
#permission ⇒ Object (readonly)
Returns the value of attribute permission.
14 15 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 14 attr_reader :client, :id, :logins, :phone_numbers, :legal_names, :note, :supp_id, :is_business, :cip_tag, :permission |
#phone_numbers ⇒ Object (readonly)
Returns the value of attribute phone_numbers.
14 15 16 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 14 def phone_numbers @phone_numbers end |
#refresh_token ⇒ Object
Returns the value of attribute refresh_token.
16 17 18 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 16 def refresh_token @refresh_token end |
#supp_id ⇒ Object (readonly)
Returns the value of attribute supp_id.
14 15 16 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 14 def supp_id @supp_id end |
Class Method Details
.all(client:, page: nil, per_page: nil, query: nil) ⇒ Array<SynapsePayRest::User>
users created this way are not automatically OAuthed
Queries the API for all users (with optional filters) and returns them as User instances.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 95 def all(client:, page: nil, per_page: nil, query: nil) raise ArgumentError, 'client must be a SynapsePayRest::Client' unless client.is_a?(Client) [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 if query && !query.is_a?(String) raise ArgumentError, 'query must be a String' end response = client.users.get(page: page, per_page: per_page, query: query) multiple_from_response(client, response['users']) end |
.create(client:, logins:, phone_numbers:, legal_names:, **options) ⇒ SynapsePayRest::User
simplify the logins argument somehow. separate class?
Creates a new user in the API and returns a User instance from the response data.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 43 def create(client:, logins:, phone_numbers:, legal_names:, **) raise ArgumentError, 'client must be a SynapsePayRest::Client' unless client.is_a?(Client) if [logins, phone_numbers, legal_names].any? { |arg| !arg.is_a? Array} raise ArgumentError, 'logins/phone_numbers/legal_names must be Array' end if [logins, phone_numbers, legal_names].any?(&:empty?) raise ArgumentError, 'logins/phone_numbers/legal_names cannot be empty' end unless logins.first.is_a? Hash raise ArgumentError, 'logins must contain at least one hash {email: (required), password:, read_only:}' end unless logins.first[:email].is_a?(String) && logins.first[:email].length > 0 raise ArgumentError, 'logins must contain at least one hash with :email key' end payload = payload_for_create(logins: logins, phone_numbers: phone_numbers, legal_names: legal_names, **) response = client.users.create(payload: payload) from_response(client, response) end |
.find(client:, id:, full_dehydrate: 'no') ⇒ SynapsePayRest::User
Queries the API for a user by id and returns a User instances if found.
72 73 74 75 76 77 78 79 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 72 def find(client:, id:, full_dehydrate:'no') raise ArgumentError, 'client must be a SynapsePayRest::Client' unless client.is_a?(Client) raise ArgumentError, 'id must be a String' unless id.is_a?(String) response = client.users.get(user_id: id, full_dehydrate: full_dehydrate) from_response(client, response) end |
.from_response(client, response, oauth: true) ⇒ Object
Do not call directly.
Constructs a user instance from a user response.
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 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 149 def from_response(client, response, oauth: true) user = self.new( client: client, id: response['_id'], refresh_token: response['refresh_token'], logins: response['logins'], phone_numbers: response['phone_numbers'], legal_names: response['legal_names'], permission: response['permission'], note: response['extra']['note'], supp_id: response['extra']['supp_id'], is_business: response['extra']['is_business'], cip_tag: response['extra']['cip_tag'], flag: nil, ips: nil, oauth_key: nil, expires_in: nil ) if response.has_key?('flag') user.flag = response['flag'] end if response.has_key?('ips') user.ips = response['ips'] end unless response['documents'].empty? base_documents = BaseDocument.from_response(user, response) user.base_documents = base_documents end oauth ? user.authenticate : user end |
.multiple_from_response(client, response) ⇒ Object
users created this way are not automatically OAuthed
Calls from_response on each member of a response collection.
185 186 187 188 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 185 def multiple_from_response(client, response) return [] if response.empty? response.map { |user_data| from_response(client.dup, user_data, oauth: false)} end |
.payload_for_create(logins:, phone_numbers:, legal_names:, **options) ⇒ Object
Do not call directly.
Maps args to API payload format.
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 130 def payload_for_create(logins:, phone_numbers:, legal_names:, **) payload = { 'logins' => logins, 'phone_numbers' => phone_numbers, 'legal_names' => legal_names, } # optional payload fields extra = {} extra['note'] = [:note] if [:note] extra['supp_id'] = [:supp_id] if [:supp_id] extra['is_business'] = [:is_business] if [:is_business] extra['cip_tag'] = [:cip_tag] if [:cip_tag] payload['extra'] = extra if extra.any? payload end |
.search(client:, query:, page: nil, per_page: nil) ⇒ Array<SynapsePayRest::User>
users created this way are not automatically OAuthed
Queries the API for all users with name/email matching the given query and returns them as User instances.
124 125 126 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 124 def search(client:, query:, page: nil, per_page: nil) all(client: client, query: query, page: page, per_page: per_page) end |
Instance Method Details
#==(other) ⇒ Object
Checks if two User instances have same id (different instances of same record).
805 806 807 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 805 def ==(other) other.instance_of?(self.class) && !id.nil? && id == other.id end |
#add_legal_name(legal_name) ⇒ SynapsePayRest::User
Add a legal_name to the user.
328 329 330 331 332 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 328 def add_legal_name(legal_name) raise ArgumentError, 'legal_name must be a String' unless legal_name.is_a? String update(legal_name: legal_name) end |
#add_login(email:, password: nil, read_only: nil) ⇒ SynapsePayRest::User
Adds a login for the user.
280 281 282 283 284 285 286 287 288 289 290 291 292 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 280 def add_login(email:, password: nil, read_only: nil) raise ArgumentError, 'email must be a String' unless email.is_a?(String) raise ArgumentError, 'password must be nil or String' if password && !password.is_a?(String) if read_only && ![true, false].include?(read_only) raise ArgumentError, 'read_only must be nil or Boolean' end login = {'email' => email} # optional login['password'] = password if password login['read_only'] = read_only if read_only update(login: login) end |
#add_phone_number(phone_number) ⇒ SynapsePayRest::User
Add a phone_number to the user.
315 316 317 318 319 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 315 def add_phone_number(phone_number) raise ArgumentError, 'phone_number must be a String' unless phone_number.is_a? String update(phone_number: phone_number) end |
#authenticate ⇒ SynapsePayRest::User
Updates the oauth token.
203 204 205 206 207 208 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 203 def authenticate response = client.users.refresh(user_id: id, payload: payload_for_refresh) self.oauth_key = response['oauth_key'] self.expires_in = response['expires_in'] self end |
#confirm_2fa_pin(pin:, device:) ⇒ :success
Step 3 (final) step of fingerprint registration. Confirms the PIN sent to the device after calling #select_2fa_device (step 2).
403 404 405 406 407 408 409 410 411 412 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 403 def confirm_2fa_pin(pin:, device:) raise ArgumentError, 'pin must be a String' unless pin.is_a?(String) raise ArgumentError, 'device must be a String' unless device.is_a?(String) payload = payload_for_refresh payload['phone_number'] = device payload['validation_pin'] = pin client.users.refresh(user_id: id, payload: payload) :success end |
#create_ach_us_node(**options) ⇒ SynapsePayRest::AchUsNode
Creates an ACH-US node via account and routing numbers, belonging to this user.
454 455 456 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 454 def create_ach_us_node(**) AchUsNode.create(user: self, **) end |
#create_ach_us_nodes_via_bank_login(**options) ⇒ Array<SynapsePayRest::AchUsNode>
Creates an ACH-US node via bank login, belonging to this user.
468 469 470 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 468 def create_ach_us_nodes_via_bank_login(**) AchUsNode.create_via_bank_login(user: self, **) end |
#create_ach_us_nodes_via_bank_login_mfa(**options) ⇒ <SynapsePayRest::UnverifiedNode>
Creates an Unverified Node Class node via access token, belonging to this user
480 481 482 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 480 def create_ach_us_nodes_via_bank_login_mfa(**) AchUsNode.create_via_bank_login_mfa(user: self, **) end |
#create_base_document(**args) ⇒ SynapsePayRest::User
Creates a new base document for the user. To update an existing base document, see SynapsePay::BaseDocument#update.
267 268 269 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 267 def create_base_document(**args) BaseDocument.create(user: self, **args) end |
#create_card_us_node(**options) ⇒ SynapsePayRest::CardUsNode
Creates a CARD-US node.
749 750 751 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 749 def create_card_us_node(**) CardUsNode.create(user: self, **) end |
#create_check_us_node(**options) ⇒ SynapsePayRest::CheckUsNode
Creates a CHECK-US node.
684 685 686 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 684 def create_check_us_node(**) CheckUsNode.create(user: self, **) end |
#create_clearing_us_node(**options) ⇒ SynapsePayRest::ClearingUsNode
Creates a CLEARING-US node.
697 698 699 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 697 def create_clearing_us_node(**) ClearingUsNode.create(user: self, **) end |
#create_crypto_us_node(**options) ⇒ SynapsePayRest::CryptoUsNode
Creates a CRYPTO-US node.
775 776 777 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 775 def create_crypto_us_node(**) CryptoUsNode.create(user: self, **) end |
#create_custody_us_node(**options) ⇒ SynapsePayRest::CustodyUsNode
Creates a CUSTODY-US node.
788 789 790 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 788 def create_custody_us_node(**) CustodyUsNode.create(user: self, **) end |
#create_deposit_us_node(**options) ⇒ SynapsePayRest::SynapseUsNode
Creates a DEPOSIT-US node.
593 594 595 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 593 def create_deposit_us_node(**) DepositUsNode.create(user: self, **) end |
#create_eft_ind_node(**options) ⇒ SynapsePayRest::EftIndNode
Creates an EFT-IND node.
497 498 499 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 497 def create_eft_ind_node(**) EftIndNode.create(user: self, **) end |
#create_eft_np_node(**options) ⇒ SynapsePayRest::EftNpNode
Creates an EFT-NP node.
512 513 514 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 512 def create_eft_np_node(**) EftNpNode.create(user: self, **) end |
#create_ib_deposit_us_node(**options) ⇒ SynapsePayRest::IbDepositUsNode
Creates a IB-DEPOSIT-US node.
710 711 712 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 710 def create_ib_deposit_us_node(**) IbDepositUsNode.create(user: self, **) end |
#create_ib_subaccount_us_node(**options) ⇒ SynapsePayRest::IbSubaccountUsNode
Creates a IB-SUBACCOUNT-US node.
723 724 725 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 723 def create_ib_subaccount_us_node(**) IbSubaccountUsNode.create(user: self, **) end |
#create_interchange_us_node(**options) ⇒ SynapsePayRest::InterchangeUsNode
Creates a INTERCHANGE-US node.
736 737 738 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 736 def create_interchange_us_node(**) InterchangeUsNode.create(user: self, **) end |
#create_iou_node(**options) ⇒ SynapsePayRest::IouNode
Creates an IOU node.
526 527 528 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 526 def create_iou_node(**) IouNode.create(user: self, **) end |
#create_reserve_us_node(**options) ⇒ SynapsePayRest::IouNode
Creates a RESERVE-US node.
539 540 541 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 539 def create_reserve_us_node(**) ReserveUsNode.create(user: self, **) end |
#create_subaccount_us_node(**options) ⇒ SynapsePayRest::SubaccountUsNode
Creates a SUBACCOUNT-US node.
606 607 608 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 606 def create_subaccount_us_node(**) SubaccountUsNode.create(user: self, **) end |
#create_subcard_us_node(**options) ⇒ SynapsePayRest::SubcardUsNode
Creates a SUBCARD-US node.
762 763 764 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 762 def create_subcard_us_node(**) SubcardUsNode.create(user: self, **) end |
#create_synapse_ind_node(**options) ⇒ SynapsePayRest::SynapseIndNode
Creates a SYNAPSE-IND node.
554 555 556 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 554 def create_synapse_ind_node(**) SynapseIndNode.create(user: self, **) end |
#create_synapse_np_node(**options) ⇒ SynapsePayRest::SynapseNpNode
Creates a SYNAPSE-NP node.
567 568 569 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 567 def create_synapse_np_node(**) SynapseNpNode.create(user: self, **) end |
#create_synapse_us_node(**options) ⇒ SynapsePayRest::SynapseUsNode
Creates a SYNAPSE-US node.
580 581 582 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 580 def create_synapse_us_node(**) SynapseUsNode.create(user: self, **) end |
#create_triumph_subaccount_us_node(**options) ⇒ SynapsePayRest::TriumphSubaccountUsNode
Creates a TRIUMPH-SUBACCOUNT-US node.
619 620 621 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 619 def create_triumph_subaccount_us_node(**) TriumphSubaccountUsNode.create(user: self, **) end |
#create_wire_int_node(**options) ⇒ SynapsePayRest::WireIntNode
Creates a WIRE-INT node.
642 643 644 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 642 def create_wire_int_node(**) WireIntNode.create(user: self, **) end |
#create_wire_us_node(**options) ⇒ SynapsePayRest::WireUsNode
Creates a WIRE-US node.
663 664 665 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 663 def create_wire_us_node(**) WireUsNode.create(user: self, **) end |
#find_node(id:) ⇒ SynapsePayRest::BaseNode
Queries the API for a node belonging to this user by node id and returns a node instance if found.
437 438 439 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 437 def find_node(id:) Node.find(user: self, id: id) end |
#get_statement ⇒ SynapsePayRest::Statement
Gets statement for user
800 801 802 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 800 def get_statement() Statement.by_user(client: self.client, user:self) end |
#nodes(**options) ⇒ Array<SynapsePayRest::BaseNode>
Queries the API for all nodes belonging to this user and returns them as node (SynapsePayRest::BaseNode) instances.
425 426 427 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 425 def nodes(**) Node.all(user: self, **) end |
#register_fingerprint(fingerprint) ⇒ Array<String>
Step 1 of fingerprint registration. Requests a new fingerprint be registered to the user.
368 369 370 371 372 373 374 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 368 def register_fingerprint(fingerprint) raise ArgumentError, 'fingerprint must be a String' unless fingerprint.is_a?(String) client.http_client.update_headers(fingerprint: fingerprint) response = client.users.refresh(user_id: id, payload: payload_for_refresh) response['phone_numbers'] end |
#remove_legal_name(legal_name) ⇒ SynapsePayRest::User
Removes a legal_name from the user
354 355 356 357 358 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 354 def remove_legal_name(legal_name) raise ArgumentError, 'legal_name must be a String' unless legal_name.is_a? String update(remove_legal_name: legal_name) end |
#remove_login(email:) ⇒ SynapsePayRest::User
Removes a login from the user.
301 302 303 304 305 306 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 301 def remove_login(email:) raise ArgumentError, 'email must be a String' unless email.is_a? String login = {email: email} update(remove_login: login) end |
#remove_phone_number(phone_number) ⇒ SynapsePayRest::User
Removes a phone_number from the user.
341 342 343 344 345 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 341 def remove_phone_number(phone_number) raise ArgumentError, 'phone_number must be a String' unless phone_number.is_a? String update(remove_phone_number: phone_number) end |
#select_2fa_device(device) ⇒ :success
Step 2 of fingerprint registration. Sends a request to the API to send a 2FA PIN to the device specified. The device must be selected from return value of #register_fingerprint.
385 386 387 388 389 390 391 392 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 385 def select_2fa_device(device) raise ArgumentError, 'device must be a String' unless device.is_a?(String) payload = payload_for_refresh payload['phone_number'] = device client.users.refresh(user_id: id, payload: payload) :success end |
#update(**options) ⇒ SynapsePayRest::User
Updates the given key value pairs.
230 231 232 233 234 235 236 237 238 |
# File 'lib/synapse_pay_rest/models/user/user.rb', line 230 def update(**) if .empty? raise ArgumentError, 'must provide a key-value pair to update. keys: login, read_only, phone_number, legal_name, remove_phone_number, remove_login' end response = client.users.update(user_id: id, payload: payload_for_update()) # return an updated user instance self.class.from_response(client, response) end |