class Ably::Realtime::Push::ChannelSubscriptions

Manage push notification channel subscriptions for devices or clients

Attributes

admin[R]

@api private

client[R]

@api private

Public Class Methods

new(admin) click to toggle source
# File lib/submodules/ably-ruby/lib/ably/realtime/push/channel_subscriptions.rb, line 14
def initialize(admin)
  @admin = admin
  @client = admin.client
end

Public Instance Methods

list(params, &callback) click to toggle source

(see Ably::Rest::Push::ChannelSubscriptions#list)

@yield Block is invoked when request succeeds @return [Ably::Util::SafeDeferrable]

# File lib/submodules/ably-ruby/lib/ably/realtime/push/channel_subscriptions.rb, line 24
def list(params, &callback)
  raise ArgumentError, "params must be a Hash" unless params.kind_of?(Hash)

  if (IdiomaticRubyWrapper(params).keys & [:channel, :client_id, :device_id]).length == 0
    raise ArgumentError, "at least one channel, client_id or device_id filter param must be provided"
  end

  async_wrap(callback) do
    rest_channel_subscriptions.list(params.merge(async_blocking_operations: true))
  end
end
list_channels(params = {}, &callback) click to toggle source

(see Ably::Rest::Push::ChannelSubscriptions#list_channels)

@yield Block is invoked when request succeeds @return [Ably::Util::SafeDeferrable]

# File lib/submodules/ably-ruby/lib/ably/realtime/push/channel_subscriptions.rb, line 41
def list_channels(params = {}, &callback)
  params = {} if params.nil?
  raise ArgumentError, "params must be a Hash" unless params.kind_of?(Hash)

  async_wrap(callback) do
    rest_channel_subscriptions.list_channels(params.merge(async_blocking_operations: true))
  end
end
remove(push_channel_subscription, &callback) click to toggle source

(see Ably::Rest::Push::ChannelSubscriptions#remove)

@yield Block is invoked when request succeeds @return [Ably::Util::SafeDeferrable]

# File lib/submodules/ably-ruby/lib/ably/realtime/push/channel_subscriptions.rb, line 69
def remove(push_channel_subscription, &callback)
  push_channel_subscription_object = PushChannelSubscription(push_channel_subscription)
  raise ArgumentError, "Channel is required yet is empty" if push_channel_subscription_object.channel.to_s.empty?
  if push_channel_subscription_object.client_id.to_s.empty? && push_channel_subscription_object.device_id.to_s.empty?
    raise ArgumentError, "Either client_id or device_id must be present"
  end

  async_wrap(callback) do
    rest_channel_subscriptions.remove(push_channel_subscription)
  end
end
remove_where(params, &callback) click to toggle source

(see Ably::Rest::Push::ChannelSubscriptions#remove_where)

@yield Block is invoked when request succeeds @return [Ably::Util::SafeDeferrable]

# File lib/submodules/ably-ruby/lib/ably/realtime/push/channel_subscriptions.rb, line 86
def remove_where(params, &callback)
  raise ArgumentError, "params must be a Hash" unless params.kind_of?(Hash)

  if (IdiomaticRubyWrapper(params).keys & [:channel, :client_id, :device_id]).length == 0
    raise ArgumentError, "at least one channel, client_id or device_id filter param must be provided"
  end

  async_wrap(callback) do
    rest_channel_subscriptions.remove_where(params)
  end
end
save(push_channel_subscription, &callback) click to toggle source

(see Ably::Rest::Push::ChannelSubscriptions#save)

@yield Block is invoked when request succeeds @return [Ably::Util::SafeDeferrable]

# File lib/submodules/ably-ruby/lib/ably/realtime/push/channel_subscriptions.rb, line 55
def save(push_channel_subscription, &callback)
  push_channel_subscription_object = PushChannelSubscription(push_channel_subscription)
  raise ArgumentError, "Channel is required yet is empty" if push_channel_subscription_object.channel.to_s.empty?

  async_wrap(callback) do
    rest_channel_subscriptions.save(push_channel_subscription)
  end
end

Private Instance Methods

logger() click to toggle source
# File lib/submodules/ably-ruby/lib/ably/realtime/push/channel_subscriptions.rb, line 103
def logger
  client.logger
end
rest_channel_subscriptions() click to toggle source
# File lib/submodules/ably-ruby/lib/ably/realtime/push/channel_subscriptions.rb, line 99
def rest_channel_subscriptions
  client.rest_client.push.admin.channel_subscriptions
end