Class: IronBank::Authentications::Cookie

Inherits:
Object
  • Object
show all
Defined in:
lib/iron_bank/authentications/cookie.rb

Overview

Get a cookie to enable authenticated calls to Zuora through Session.

Constant Summary collapse

TEN_MINUTES =
600
ONE_HOUR =
3600

Instance Method Summary collapse

Constructor Details

#initialize(client_id:, client_secret:, base_url:) ⇒ Cookie

Returns a new instance of Cookie.



11
12
13
14
15
16
# File 'lib/iron_bank/authentications/cookie.rb', line 11

def initialize(client_id:, client_secret:, base_url:)
  @client_id     = client_id
  @client_secret = client_secret
  @base_url      = base_url
  fetch_cookie
end

Instance Method Details

#expired?Boolean

Returns:

  • (Boolean)


18
19
20
21
# File 'lib/iron_bank/authentications/cookie.rb', line 18

def expired?
  # Ten minutes as a margin of error in order to renew token in time
  expires_at < Time.now + TEN_MINUTES
end

#headerObject



23
24
25
# File 'lib/iron_bank/authentications/cookie.rb', line 23

def header
  { "Cookie" => use }
end