Class: Parse::Push
- Inherits:
-
Object
- Object
- Parse::Push
- Defined in:
- lib/parse/push.rb
Overview
Push notification parseplatform.github.io/docs/rest/guide/#push-notification
Instance Attribute Summary collapse
-
#channels ⇒ Object
Returns the value of attribute channels.
-
#client ⇒ Object
Returns the value of attribute client.
-
#data ⇒ Object
Returns the value of attribute data.
-
#expiration_time ⇒ Object
Returns the value of attribute expiration_time.
-
#expiration_time_interval ⇒ Object
Returns the value of attribute expiration_time_interval.
-
#push_time ⇒ Object
Returns the value of attribute push_time.
-
#type ⇒ Object
Returns the value of attribute type.
-
#where ⇒ Object
Returns the value of attribute where.
Instance Method Summary collapse
-
#initialize(data, channel = '', client = nil) ⇒ Push
constructor
A new instance of Push.
- #save ⇒ Object
Constructor Details
#initialize(data, channel = '', client = nil) ⇒ Push
Returns a new instance of Push.
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/parse/push.rb', line 18 def initialize(data, channel = '', client = nil) @data = data # NOTE: if no channel is specified, by setting "where" to an empty clause # a push is sent to all clients. if !channel || channel.empty? @where = {} else @channels = [channel] end @client = client || Parse.client end |
Instance Attribute Details
#channels ⇒ Object
Returns the value of attribute channels.
9 10 11 |
# File 'lib/parse/push.rb', line 9 def channels @channels end |
#client ⇒ Object
Returns the value of attribute client.
16 17 18 |
# File 'lib/parse/push.rb', line 16 def client @client end |
#data ⇒ Object
Returns the value of attribute data.
15 16 17 |
# File 'lib/parse/push.rb', line 15 def data @data end |
#expiration_time ⇒ Object
Returns the value of attribute expiration_time.
13 14 15 |
# File 'lib/parse/push.rb', line 13 def expiration_time @expiration_time end |
#expiration_time_interval ⇒ Object
Returns the value of attribute expiration_time_interval.
12 13 14 |
# File 'lib/parse/push.rb', line 12 def expiration_time_interval @expiration_time_interval end |
#push_time ⇒ Object
Returns the value of attribute push_time.
14 15 16 |
# File 'lib/parse/push.rb', line 14 def push_time @push_time end |
#type ⇒ Object
Returns the value of attribute type.
11 12 13 |
# File 'lib/parse/push.rb', line 11 def type @type end |
#where ⇒ Object
Returns the value of attribute where.
10 11 12 |
# File 'lib/parse/push.rb', line 10 def where @where end |
Instance Method Details
#save ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/parse/push.rb', line 32 def save body = { data: @data } if @type if @where @where[:deviceType] = @type else body[:deviceType] = @type end end # NOTE: Parse does not support channels and where at the same time # so we make channels part of the query conditions if @channels if @where @where[:channels] = { '$in' => @channels } else body[:channels] = @channels end end body[:where] = @where if @where body[:expiration_interval] = @expiration_time_interval if @expiration_time_interval body[:expiration_time] = @expiration_time if @expiration_time body[:push_time] = @push_time if @push_time @client.request Protocol.push_uri, :post, body.to_json end |