Class: FeatureFlagClient::Session

Inherits:
Object
  • Object
show all
Defined in:
lib/feature_flag_client/session.rb

Overview

Takes care of getting access_token necessary to call features service

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client_id:, client_secret:) {|_self| ... } ⇒ Session

Returns a new instance of Session.

Yields:

  • (_self)

Yield Parameters:



10
11
12
13
14
# File 'lib/feature_flag_client/session.rb', line 10

def initialize(client_id:, client_secret:)
  @client_id = client_id
  @client_secret = client_secret
  yield(self) if block_given?
end

Instance Attribute Details

#auth_service_urlObject

Returns the value of attribute auth_service_url.



8
9
10
# File 'lib/feature_flag_client/session.rb', line 8

def auth_service_url
  @auth_service_url
end

#client_idObject

Returns the value of attribute client_id.



8
9
10
# File 'lib/feature_flag_client/session.rb', line 8

def client_id
  @client_id
end

#client_secretObject

Returns the value of attribute client_secret.



8
9
10
# File 'lib/feature_flag_client/session.rb', line 8

def client_secret
  @client_secret
end

Instance Method Details

#access_tokenObject



16
17
18
19
20
# File 'lib/feature_flag_client/session.rb', line 16

def access_token
  @token ||= request_access_token
  @token = request_access_token(refresh: true) if token_expired?
  @token
end

#refresh_tokenObject



22
23
24
25
# File 'lib/feature_flag_client/session.rb', line 22

def refresh_token
  access_token if @parsed_auth_response.nil?
  @parsed_auth_response['refresh_token']
end