Class: Ably::Rest::Push::ChannelSubscriptions
- Inherits:
-
Object
- Object
- Ably::Rest::Push::ChannelSubscriptions
- Includes:
- Modules::Conversions
- Defined in:
- lib/ably/rest/push/channel_subscriptions.rb
Overview
Manage push notification channel subscriptions for devices or client identifiers
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>
List channel subscriptions filtered by optional params.
-
#list_channels(params = {}) ⇒ Ably::Models::PaginatedResult<String>
List channels with at least one subscribed device.
-
#remove(push_channel_subscription) ⇒ void
Remove a push channel subscription.
-
#remove_where(params) ⇒ void
Remove all matching push channel subscriptions.
-
#save(push_channel_subscription) ⇒ void
Save push channel subscription for a device or client ID.
Constructor Details
#initialize(admin) ⇒ ChannelSubscriptions
Returns a new instance of ChannelSubscriptions.
13 14 15 16 |
# File 'lib/ably/rest/push/channel_subscriptions.rb', line 13 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.
11 12 13 |
# File 'lib/ably/rest/push/channel_subscriptions.rb', line 11 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.
8 9 10 |
# File 'lib/ably/rest/push/channel_subscriptions.rb', line 8 def client @client end |
Instance Method Details
#list(params) ⇒ Ably::Models::PaginatedResult<Ably::Models::PushChannelSubscription>
List channel subscriptions filtered by optional params
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ably/rest/push/channel_subscriptions.rb', line 28 def list(params) 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 params = params.clone = { coerce_into: 'Ably::Models::PushChannelSubscription', async_blocking_operations: params.delete(:async_blocking_operations), } response = client.get('/push/channelSubscriptions', IdiomaticRubyWrapper(params).as_json) Ably::Models::PaginatedResult.new(response, '', client, ) end |
#list_channels(params = {}) ⇒ Ably::Models::PaginatedResult<String>
List channels with at least one subscribed device
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/ably/rest/push/channel_subscriptions.rb', line 54 def list_channels(params = {}) params = {} if params.nil? raise ArgumentError, "params must be a Hash" unless params.kind_of?(Hash) params = params.clone = { coerce_into: 'String', async_blocking_operations: params.delete(:async_blocking_operations), } response = client.get('/push/channels', IdiomaticRubyWrapper(params).as_json) Ably::Models::PaginatedResult.new(response, '', client, ) end |
#remove(push_channel_subscription) ⇒ void
This method returns an undefined value.
Remove a push channel subscription
89 90 91 92 93 94 95 96 97 |
# File 'lib/ably/rest/push/channel_subscriptions.rb', line 89 def remove(push_channel_subscription) 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 client.delete("/push/channelSubscriptions", push_channel_subscription_object.as_json) end |
#remove_where(params) ⇒ void
This method returns an undefined value.
Remove all matching push channel subscriptions
108 109 110 111 112 113 114 115 116 117 118 |
# File 'lib/ably/rest/push/channel_subscriptions.rb', line 108 def remove_where(params) 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 params = params.clone client.delete("/push/channelSubscriptions", IdiomaticRubyWrapper(params).as_json) end |
#save(push_channel_subscription) ⇒ void
This method returns an undefined value.
Save push channel subscription for a device or client ID
76 77 78 79 80 81 |
# File 'lib/ably/rest/push/channel_subscriptions.rb', line 76 def save(push_channel_subscription) 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? client.post("/push/channelSubscriptions", push_channel_subscription_object.as_json) end |