Class: Anthropic::Credentials::AccessToken
- Inherits:
-
Object
- Object
- Anthropic::Credentials::AccessToken
- Defined in:
- lib/anthropic/credentials/access_token.rb
Overview
An Anthropic API access token with optional expiry.
This is a frozen value object representing an access token and its expiration time. The expires_at is a Unix timestamp in seconds; nil means no expiry information (the token will be treated as never-expires by TokenCache).
Instance Attribute Summary collapse
-
#expires_at ⇒ Integer?
readonly
Unix timestamp in seconds when the token expires, or
nilif the token never expires. -
#token ⇒ String
readonly
The access token string.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
-
#hash ⇒ Integer
Hash code for the token.
-
#initialize(token:, expires_at: nil) ⇒ AccessToken
constructor
A new instance of AccessToken.
Constructor Details
#initialize(token:, expires_at: nil) ⇒ AccessToken
Returns a new instance of AccessToken.
21 22 23 24 25 |
# File 'lib/anthropic/credentials/access_token.rb', line 21 def initialize(token:, expires_at: nil) @token = token @expires_at = expires_at freeze end |
Instance Attribute Details
#expires_at ⇒ Integer? (readonly)
Returns Unix timestamp in seconds when the token expires, or nil if the token never expires.
17 18 19 |
# File 'lib/anthropic/credentials/access_token.rb', line 17 def expires_at @expires_at end |
#token ⇒ String (readonly)
Returns the access token string.
13 14 15 |
# File 'lib/anthropic/credentials/access_token.rb', line 13 def token @token end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
32 33 34 35 |
# File 'lib/anthropic/credentials/access_token.rb', line 32 def ==(other) return false unless other.is_a?(AccessToken) token == other.token && expires_at == other.expires_at end |
#hash ⇒ Integer
Returns hash code for the token.
28 29 30 |
# File 'lib/anthropic/credentials/access_token.rb', line 28 def hash [token, expires_at].hash end |