Class: Fintecture::Authentication

Inherits:
Object
  • Object
show all
Defined in:
lib/fintecture/api/auth/authentication.rb

Class Method Summary collapse

Class Method Details

.authorize(redirect_uri, state = nil) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/fintecture/api/auth/authentication.rb', line 9

def authorize(redirect_uri, state = nil)
  query_string = "?#{{
    response_type: 'code',
    app_id: Fintecture.app_id,
    redirect_uri: redirect_uri,
    state: state
  }.map { |key, value| "#{key}=#{value}" }.join('&')}"

  ::Faraday.get "#{token_authorize_endpoint}#{query_string}"
end

.get_access_token(client, auth_code = nil) ⇒ Object



20
21
22
23
24
25
# File 'lib/fintecture/api/auth/authentication.rb', line 20

def get_access_token(client, auth_code = nil)
  @client = client
  body = access_token_data auth_code

  Fintecture::Faraday::Authentication::Connection.post url: access_token_url, req_body: body, client: client
end

.refresh_token(client, refresh_token) ⇒ Object



27
28
29
30
31
32
# File 'lib/fintecture/api/auth/authentication.rb', line 27

def refresh_token(client, refresh_token)
  @client = client
  body = refresh_token_data refresh_token

  Fintecture::Faraday::Authentication::Connection.post url: refresh_token_url, req_body: body, client: client
end