Class: BridgeBankin::Authorization

Inherits:
Object
  • Object
show all
Extended by:
BridgeBankin::API::Resource
Defined in:
lib/bridge_bankin/authorization.rb

Overview

User authentication & authorization

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(access_token, expires_at) ⇒ Authorization

Initializes Authorization

Parameters:

  • access_token (String)

    access token the access token provided by the API

  • expires_at (Time)

    the expiration time for the provided access token



18
19
20
21
# File 'lib/bridge_bankin/authorization.rb', line 18

def initialize(access_token, expires_at)
  @access_token = access_token
  @expires_at = Time.parse(expires_at)
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



10
11
12
# File 'lib/bridge_bankin/authorization.rb', line 10

def access_token
  @access_token
end

#expires_atObject (readonly)

Returns the value of attribute expires_at.



10
11
12
# File 'lib/bridge_bankin/authorization.rb', line 10

def expires_at
  @expires_at
end

Class Method Details

.generate_token(email:, password:) ⇒ Authorization

Authenticate user with the corresponding credentials

Parameters:

  • email (String)

    the registered user email

  • password (String)

    the registered user password

Returns:

  • (Authorization)

    the authorization informations provided by the API



34
35
36
37
# File 'lib/bridge_bankin/authorization.rb', line 34

def generate_token(email:, password:)
  response = api_client.post("/v2/authenticate", email: email, password: password)
  new(response[:access_token], response[:expires_at])
end