Class: Belvo::Link
Overview
A Link is a set of credentials associated to a end-user access
Defined Under Namespace
Classes: AccessMode
Instance Attribute Summary
Attributes inherited from Resource
Instance Method Summary collapse
-
#initialize(session) ⇒ Link
constructor
A new instance of Link.
-
#patch(id:, options: nil) ⇒ Hash
Patch an existing link.
-
#register(institution:, username:, password:, options: nil) ⇒ Hash
Register a new link.
-
#token(id:, scopes:) ⇒ Hash
Allows to create a token with client-specified scope and short TTL.
-
#update(id:, password: nil, password2: nil, options: nil) ⇒ Hash
Allows to change password, password2.
Methods inherited from Resource
#clean, #delete, #detail, #list, #resume
Constructor Details
#initialize(session) ⇒ Link
Returns a new instance of Link.
70 71 72 73 |
# File 'lib/belvo/resources.rb', line 70 def initialize(session) super(session) @endpoint = 'api/links/' end |
Instance Method Details
#patch(id:, options: nil) ⇒ Hash
Patch an existing link
135 136 137 138 139 140 141 142 143 144 145 146 |
# File 'lib/belvo/resources.rb', line 135 def patch( id:, options: nil ) = LinkOptions.from() body = { access_mode: .access_mode }.merge() body = clean body: body resource_path = format('%<path>s%<id>s/', path: @endpoint, id: id) @session.patch(resource_path, body) end |
#register(institution:, username:, password:, options: nil) ⇒ Hash
Register a new link
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/belvo/resources.rb', line 82 def register( institution:, username:, password:, options: nil ) = LinkOptions.from() body = { institution: institution, username: username, password: password, access_mode: .access_mode }.merge() body = clean body: body @session.post(@endpoint, body) end |
#token(id:, scopes:) ⇒ Hash
Allows to create a token with client-specified scope and short TTL.
123 124 125 126 127 128 |
# File 'lib/belvo/resources.rb', line 123 def token(id:, scopes:) body = { scopes: scopes } @session.token(@endpoint, id, body) end |
#update(id:, password: nil, password2: nil, options: nil) ⇒ Hash
Allows to change password, password2
106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/belvo/resources.rb', line 106 def update(id:, password: nil, password2: nil, options: nil) = LinkOptions.from() body = { password: password, password2: password2, token: .token, username_type: .username_type }.merge() body = clean body: body @session.put(@endpoint, id, body) end |