Class: ChangeHealthcare::Eligibility::Wrapper::AuthToken

Inherits:
Struct
  • Object
show all
Defined in:
lib/change_healthcare/eligibility/wrapper.rb

Overview

Struct used to store auth tokens so we don’t need to fetch one every request.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#expires_atObject

Returns the value of attribute expires_at

Returns:

  • (Object)

    the current value of expires_at



77
78
79
# File 'lib/change_healthcare/eligibility/wrapper.rb', line 77

def expires_at
  @expires_at
end

#tokenObject

Returns the value of attribute token

Returns:

  • (Object)

    the current value of token



77
78
79
# File 'lib/change_healthcare/eligibility/wrapper.rb', line 77

def token
  @token
end

Instance Method Details

#authObject

The actual auth header to pass in to things



86
87
88
# File 'lib/change_healthcare/eligibility/wrapper.rb', line 86

def auth
  "Bearer #{token}"
end

#valid?Boolean

Is this token still usable?

Returns:

  • (Boolean)


80
81
82
# File 'lib/change_healthcare/eligibility/wrapper.rb', line 80

def valid?
  expires_at > (Time.new - 20)
end