Class: Ably::Rest::Push::Admin
- Inherits:
-
Object
- Object
- Ably::Rest::Push::Admin
- Includes:
- Modules::Conversions
- Defined in:
- lib/submodules/ably-ruby/lib/ably/rest/push/admin.rb
Overview
Class providing push notification administrative functionality for registering devices and attaching to channels etc.
Instance Attribute Summary collapse
- #client ⇒ Object readonly private
- #push ⇒ Object readonly private
Instance Method Summary collapse
-
#channel_subscriptions ⇒ Ably::Rest::Push::ChannelSubscriptions
Manage channel subscriptions for devices or clients.
-
#device_registrations ⇒ Ably::Rest::Push::DeviceRegistrations
Manage device registrations.
-
#initialize(push) ⇒ Admin
constructor
A new instance of Admin.
-
#publish(recipient, data) ⇒ void
Publish a push message directly to a single recipient.
Constructor Details
#initialize(push) ⇒ Admin
Returns a new instance of Admin.
17 18 19 20 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/push/admin.rb', line 17 def initialize(push) @push = push @client = push.client end |
Instance Attribute Details
#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.
12 13 14 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/push/admin.rb', line 12 def client @client end |
#push ⇒ 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.
15 16 17 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/push/admin.rb', line 15 def push @push end |
Instance Method Details
#channel_subscriptions ⇒ Ably::Rest::Push::ChannelSubscriptions
Manage channel subscriptions for devices or clients
49 50 51 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/push/admin.rb', line 49 def channel_subscriptions @channel_subscriptions ||= ChannelSubscriptions.new(self) end |
#device_registrations ⇒ Ably::Rest::Push::DeviceRegistrations
Manage device registrations
43 44 45 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/push/admin.rb', line 43 def device_registrations @device_registrations ||= DeviceRegistrations.new(self) end |
#publish(recipient, data) ⇒ void
This method returns an undefined value.
Publish a push message directly to a single recipient
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/submodules/ably-ruby/lib/ably/rest/push/admin.rb', line 29 def publish(recipient, data) raise ArgumentError, "Expecting a Hash object for recipient, got #{recipient.class}" unless recipient.kind_of?(Hash) raise ArgumentError, "Recipient data is empty. You must provide recipient details" if recipient.empty? raise ArgumentError, "Expecting a Hash object for data, got #{data.class}" unless data.kind_of?(Hash) raise ArgumentError, "Push data field is empty. You must provide attributes for the push notification" if data.empty? publish_data = data.merge(recipient: IdiomaticRubyWrapper(recipient)) # Co-erce to camelCase for notitication fields which are always camelCase publish_data[:notification] = IdiomaticRubyWrapper(data[:notification]) if publish_data[:notification].kind_of?(Hash) client.post('/push/publish', publish_data) end |