Class: Polar::Authentication::CustomerAuth

Inherits:
Object
  • Object
show all
Defined in:
lib/polar/authentication.rb

Overview

Customer Access Token authentication

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(customer_session) ⇒ CustomerAuth

Returns a new instance of CustomerAuth.



44
45
46
47
# File 'lib/polar/authentication.rb', line 44

def initialize(customer_session)
  @customer_session = customer_session
  validate_token!
end

Instance Attribute Details

#customer_sessionObject (readonly)

Returns the value of attribute customer_session.



42
43
44
# File 'lib/polar/authentication.rb', line 42

def customer_session
  @customer_session
end

Instance Method Details

#headersObject



49
50
51
52
53
54
55
# File 'lib/polar/authentication.rb', line 49

def headers
  {
    'Authorization' => "Bearer #{customer_session}",
    'Content-Type' => 'application/json',
    'Accept' => 'application/json'
  }
end

#valid?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/polar/authentication.rb', line 57

def valid?
  !customer_session.nil? && !customer_session.empty?
end