class Ably::Models::PushChannelSubscription

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.

Public Class Methods

for_client_id(channel, client_id) click to toggle source

A static factory method to create a PushChannelSubscription object for a channel and group of devices sharing the same clientId.

@spec PSC5

@param channel [String] the realtime pub/sub channel this subscription is registered to @param client_id [String] Client ID that is assigned to one or more registered push devices

@return [PushChannelSubscription]

# File lib/submodules/ably-ruby/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) click to toggle source

A static factory method to create a PushChannelSubscription object for a channel and single device.

@spec PSC5

@param channel [String] the realtime pub/sub channel this subscription is registered to @param device_id [String] Unique device identifier assigned to the push device

@return [PushChannelSubscription]

# File lib/submodules/ably-ruby/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
new(hash_object = {}) click to toggle source

@param hash_object [Hash,nil] Device detail attributes

# File lib/submodules/ably-ruby/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

Public Instance Methods

attributes() click to toggle source
# File lib/submodules/ably-ruby/lib/ably/models/push_channel_subscription.rb, line 110
def attributes
  @hash_object
end
channel() click to toggle source

The channel the push notification subscription is for.

@spec PCS4

@return [String]

# File lib/submodules/ably-ruby/lib/ably/models/push_channel_subscription.rb, line 77
def channel
  attributes[:channel]
end
client_id() click to toggle source

The ID of the client the device, or devices are associated to.

@spec PCS3, PCS6

@return [String]

# File lib/submodules/ably-ruby/lib/ably/models/push_channel_subscription.rb, line 87
def client_id
  attributes[:client_id]
end
device_id() click to toggle source

The unique ID of the device.

@spec PCS2, PCS5, PCS6

@return [String]

# File lib/submodules/ably-ruby/lib/ably/models/push_channel_subscription.rb, line 97
def device_id
  attributes[:device_id]
end