Exception: Ably::Models::PushChannelSubscription
- Inherits:
-
Exceptions::BaseAblyException
- Object
- StandardError
- Exceptions::BaseAblyException
- Ably::Models::PushChannelSubscription
- Includes:
- Ably::Modules::ModelCommon
- Defined in:
- lib/ably/models/push_channel_subscription.rb
Overview
Contains the subscriptions of a device, or a group of devices sharing the same clientId, has to a channel in order to receive push notifications.
Instance Attribute Summary
Attributes included from Ably::Modules::ModelCommon
Attributes inherited from Exceptions::BaseAblyException
#code, #message, #request_id, #status
Class Method Summary collapse
-
.for_client_id(channel, client_id) ⇒ PushChannelSubscription
A static factory method to create a PushChannelSubscription object for a channel and group of devices sharing the same clientId.
-
.for_device(channel, device_id) ⇒ PushChannelSubscription
A static factory method to create a PushChannelSubscription object for a channel and single device.
Instance Method Summary collapse
- #attributes ⇒ Object
-
#channel ⇒ String
The channel the push notification subscription is for.
-
#client_id ⇒ String
The ID of the client the device, or devices are associated to.
-
#device_id ⇒ String
The unique ID of the device.
-
#initialize(hash_object = {}) ⇒ PushChannelSubscription
constructor
A new instance of PushChannelSubscription.
Methods included from Ably::Modules::ModelCommon
#==, #[], #as_json, included, #to_json, #to_s
Methods included from Ably::Modules::MessagePack
Methods inherited from Exceptions::BaseAblyException
Constructor Details
#initialize(hash_object = {}) ⇒ PushChannelSubscription
Returns a new instance of PushChannelSubscription.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ably/models/push_channel_subscription.rb', line 30 def initialize(hash_object = {}) @raw_hash_object = hash_object || {} @hash_object = IdiomaticRubyWrapper(hash_object) if !attributes[:client_id] && !attributes[:device_id] raise ArgumentError, 'Either client_id or device_id must be provided' end if attributes[:client_id] && attributes[:device_id] raise ArgumentError, 'client_id and device_id cannot both be provided, they are mutually exclusive' end if !attributes[:channel] raise ArgumentError, 'channel is required' end end |
Class Method Details
.for_client_id(channel, client_id) ⇒ PushChannelSubscription
A static factory method to create a PushChannelSubscription object for a channel and group of devices sharing the same clientId.
67 68 69 |
# File 'lib/ably/models/push_channel_subscription.rb', line 67 def self.for_client_id(channel, client_id) PushChannelSubscription.new(channel: channel, client_id: client_id) end |
.for_device(channel, device_id) ⇒ PushChannelSubscription
A static factory method to create a PushChannelSubscription object for a channel and single device.
54 55 56 |
# File 'lib/ably/models/push_channel_subscription.rb', line 54 def self.for_device(channel, device_id) PushChannelSubscription.new(channel: channel, device_id: device_id) end |
Instance Method Details
#attributes ⇒ Object
110 111 112 |
# File 'lib/ably/models/push_channel_subscription.rb', line 110 def attributes @hash_object end |
#channel ⇒ String
The channel the push notification subscription is for.
77 78 79 |
# File 'lib/ably/models/push_channel_subscription.rb', line 77 def channel attributes[:channel] end |
#client_id ⇒ String
The ID of the client the device, or devices are associated to.
87 88 89 |
# File 'lib/ably/models/push_channel_subscription.rb', line 87 def client_id attributes[:client_id] end |
#device_id ⇒ String
The unique ID of the device.
97 98 99 |
# File 'lib/ably/models/push_channel_subscription.rb', line 97 def device_id attributes[:device_id] end |