Class: Ably::Realtime::Push::ChannelSubscriptions
- Inherits:
-
Object
- Object
- Ably::Realtime::Push::ChannelSubscriptions
- Includes:
- Modules::AsyncWrapper, Modules::Conversions
- Defined in:
- lib/ably/realtime/push/channel_subscriptions.rb
Overview
Manage push notification channel subscriptions for devices or clients
Instance Attribute Summary collapse
- #admin ⇒ Object readonly private
- #client ⇒ Object readonly private
Instance Method Summary collapse
-
#initialize(admin) ⇒ ChannelSubscriptions
constructor
A new instance of ChannelSubscriptions.
-
#list(params) { ... } ⇒ Ably::Models::PaginatedResult<Ably::Models::PushChannelSubscription>, Ably::Util::SafeDeferrable
List channel subscriptions filtered by optional params.
-
#list_channels(params = {}) { ... } ⇒ Ably::Models::PaginatedResult<String>, Ably::Util::SafeDeferrable
List channels with at least one subscribed device.
-
#remove(push_channel_subscription) { ... } ⇒ void, Ably::Util::SafeDeferrable
Remove a push channel subscription.
-
#remove_where(params) { ... } ⇒ void, Ably::Util::SafeDeferrable
Remove all matching push channel subscriptions.
-
#save(push_channel_subscription) { ... } ⇒ void, Ably::Util::SafeDeferrable
Save push channel subscription for a device or client ID.
Constructor Details
#initialize(admin) ⇒ ChannelSubscriptions
Returns a new instance of ChannelSubscriptions.
14 15 16 17 |
# File 'lib/ably/realtime/push/channel_subscriptions.rb', line 14 def initialize(admin) @admin = admin @client = admin.client end |
Instance Attribute Details
#admin ⇒ Object (readonly)
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.
12 13 14 |
# File 'lib/ably/realtime/push/channel_subscriptions.rb', line 12 def admin @admin end |
#client ⇒ Object (readonly)
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.
9 10 11 |
# File 'lib/ably/realtime/push/channel_subscriptions.rb', line 9 def client @client end |
Instance Method Details
#list(params) { ... } ⇒ Ably::Models::PaginatedResult<Ably::Models::PushChannelSubscription>, Ably::Util::SafeDeferrable
List channel subscriptions filtered by optional params
24 25 26 27 28 29 30 31 32 33 34 |
# File '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 = {}) { ... } ⇒ Ably::Models::PaginatedResult<String>, Ably::Util::SafeDeferrable
List channels with at least one subscribed device
41 42 43 44 45 46 47 48 |
# File '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) { ... } ⇒ void, Ably::Util::SafeDeferrable
Remove a push channel subscription
69 70 71 72 73 74 75 76 77 78 79 |
# File '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) { ... } ⇒ void, Ably::Util::SafeDeferrable
Remove all matching push channel subscriptions
86 87 88 89 90 91 92 93 94 95 96 |
# File '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) { ... } ⇒ void, Ably::Util::SafeDeferrable
Save push channel subscription for a device or client ID
55 56 57 58 59 60 61 62 |
# File '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 |