Class: Ably::Models::TokenRequest
- Inherits:
-
Object
- Object
- Ably::Models::TokenRequest
- Includes:
- Ably::Modules::ModelCommon
- Defined in:
- lib/submodules/ably-ruby/lib/ably/models/token_request.rb
Overview
TokenRequest is a class that stores the attributes of a token request
Ruby Time objects are supported in place of Ably ms since epoch time fields. However, if a numeric is provided it must always be expressed in milliseconds as the Ably API always uses milliseconds for time fields.
Instance Attribute Summary collapse
-
#capability ⇒ Hash
readonly
Capability of the token.
-
#client_id ⇒ String
readonly
The client ID to associate with this token.
-
#hash ⇒ Hash
readonly
The token request Hash object ruby’fied to use symbolized keys.
-
#key_name ⇒ String
readonly
API key name of the key against which this request is made.
-
#mac ⇒ String
readonly
The Message Authentication Code for this request.
-
#nonce ⇒ String
readonly
An opaque nonce string of at least 16 characters to ensure uniqueness of this request.
-
#timestamp ⇒ Time
readonly
The timestamp of this request.
-
#ttl ⇒ Integer
readonly
Requested time to live for the token in seconds.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ TokenRequest
constructor
A new instance of TokenRequest.
-
#persisted ⇒ Object
private
Requests that the token is always persisted.
Methods included from Ably::Modules::ModelCommon
Methods included from Ably::Modules::MessagePack
Constructor Details
#initialize(attributes = {}) ⇒ TokenRequest
Returns a new instance of TokenRequest.
35 36 37 38 39 |
# File 'lib/submodules/ably-ruby/lib/ably/models/token_request.rb', line 35 def initialize(attributes = {}) @hash_object = IdiomaticRubyWrapper(attributes.clone) hash[:timestamp] = (hash[:timestamp].to_f * 1000).round if hash[:timestamp].kind_of?(Time) hash.freeze end |
Instance Attribute Details
#capability ⇒ Hash (readonly)
60 61 62 |
# File 'lib/submodules/ably-ruby/lib/ably/models/token_request.rb', line 60 def capability JSON.parse(hash.fetch(:capability)) end |
#client_id ⇒ String (readonly)
67 68 69 |
# File 'lib/submodules/ably-ruby/lib/ably/models/token_request.rb', line 67 def client_id hash[:client_id] end |
#hash ⇒ Hash (readonly)
104 105 106 |
# File 'lib/submodules/ably-ruby/lib/ably/models/token_request.rb', line 104 def hash @hash_object end |
#key_name ⇒ String (readonly)
43 44 45 |
# File 'lib/submodules/ably-ruby/lib/ably/models/token_request.rb', line 43 def key_name hash.fetch(:key_name) end |
#mac ⇒ String (readonly)
91 92 93 |
# File 'lib/submodules/ably-ruby/lib/ably/models/token_request.rb', line 91 def mac hash.fetch(:mac) end |
#nonce ⇒ String (readonly)
84 85 86 |
# File 'lib/submodules/ably-ruby/lib/ably/models/token_request.rb', line 84 def nonce hash.fetch(:nonce) end |
#timestamp ⇒ Time (readonly)
76 77 78 |
# File 'lib/submodules/ably-ruby/lib/ably/models/token_request.rb', line 76 def as_time_from_epoch(hash.fetch(:timestamp), granularity: :ms) end |
#ttl ⇒ Integer (readonly)
52 53 54 |
# File 'lib/submodules/ably-ruby/lib/ably/models/token_request.rb', line 52 def ttl hash.fetch(:ttl) / 1000 end |
Instance Method Details
#persisted ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Requests that the token is always persisted
98 99 100 |
# File 'lib/submodules/ably-ruby/lib/ably/models/token_request.rb', line 98 def persisted hash.fetch(:persisted) end |