Class: Pubnub::GrantToken
- Inherits:
-
SingleEvent
- Object
- Event
- SingleEvent
- Pubnub::GrantToken
- Includes:
- Concurrent::Async, Validator::GrantToken
- Defined in:
- lib/pubnub/events/grant_token.rb
Overview
Holds grant token functionality
Instance Attribute Summary
Attributes inherited from Event
#callback, #channel, #channel_group, #fresh_clone, #given_options, #group, #idle_timeout, #open_timeout, #origin, #presence_callback, #read_timeout, #ssl, #state, #wildcard_channel, #with_presence
Instance Method Summary collapse
- #fire ⇒ Object
-
#initialize(options, app) ⇒ GrantToken
constructor
A new instance of GrantToken.
Methods included from Validator::GrantToken
Methods included from Validator::CommonValidator
#validate_origin, #validate_publish_key, #validate_subscribe_key, #validate_user_id
Methods inherited from Event
#finalized?, #send_request, #sync?, #uri
Methods included from Event::EFormatter
#format_channels, #format_envelopes, #format_group
Constructor Details
#initialize(options, app) ⇒ GrantToken
Returns a new instance of GrantToken.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/pubnub/events/grant_token.rb', line 7 def initialize(, app) @event = current_operation @telemetry_name = :l_pamv3 @uuids = [:uuids] || {} [:channels] = [:channels] || {} [:channel_groups] = [:channel_groups] || {} = [:spaces_permissions] || {} = [:users_permissions] || {} super end |
Instance Method Details
#fire ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/pubnub/events/grant_token.rb', line 18 def fire Pubnub.logger.debug('Pubnub::GrantToken') { "Fired event #{self.class}" } if != nil uuid = elsif != nil uuid = else uuid = nil end raw_body = { ttl: @ttl, permissions: { meta: , uuid: uuid, resources: (:resource, @channels, @channel_groups, @uuids, , ), patterns: (:pattern, @channels, @channel_groups, @uuids, , ) }.select { |_, v| v } } body = Formatter.(raw_body, nil, false) response = send_request(body, { "Content-Type": "application/json" }) envelopes = fire_callbacks(handle(response, uri)) finalize_event(envelopes) envelopes end |