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.
71 72 73 74 |
# File 'lib/belvo/resources.rb', line 71 def initialize(session) super(session) @endpoint = 'api/links/' end |
Instance Method Details
#patch(id:, options: nil) ⇒ Hash
Patch an existing link
142 143 144 145 146 147 148 149 150 151 152 153 |
# File 'lib/belvo/resources.rb', line 142 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
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/belvo/resources.rb', line 83 def register( institution:, username:, password:, options: nil ) = LinkOptions.from() .certificate = Utils.read_file_to_b64(.certificate) .private_key = Utils.read_file_to_b64(.private_key) 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.
130 131 132 133 134 135 |
# File 'lib/belvo/resources.rb', line 130 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
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/belvo/resources.rb', line 109 def update(id:, password: nil, password2: nil, options: nil) = LinkOptions.from() .certificate = Utils.read_file_to_b64(.certificate) .private_key = Utils.read_file_to_b64(.private_key) body = { password: password, password2: password2, token: .token, username_type: .username_type, certificate: .certificate, private_key: .private_key }.merge() body = clean body: body @session.put(@endpoint, id, body) end |