Class: MythicBeasts::Auth

Inherits:
Object
  • Object
show all
Defined in:
lib/mythic_beasts/auth.rb

Constant Summary collapse

AUTH_URL =
"https://auth.mythic-beasts.com/login"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, api_secret:) ⇒ Auth

Returns a new instance of Auth.



7
8
9
10
11
12
# File 'lib/mythic_beasts/auth.rb', line 7

def initialize(api_key:, api_secret:)
  @api_key = api_key
  @api_secret = api_secret
  @token = nil
  @token_expires_at = nil
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



5
6
7
# File 'lib/mythic_beasts/auth.rb', line 5

def api_key
  @api_key
end

#api_secretObject (readonly)

Returns the value of attribute api_secret.



5
6
7
# File 'lib/mythic_beasts/auth.rb', line 5

def api_secret
  @api_secret
end

Instance Method Details

#tokenObject



14
15
16
17
18
19
# File 'lib/mythic_beasts/auth.rb', line 14

def token
  return @token if @token && !token_expired?

  fetch_token
  @token
end