class LC::Push

Attributes

channel[RW]
channels[RW]
data[RW]
expiration_time[RW]
expiration_time_interval[RW]
production[RW]
push_time[RW]
type[RW]
where[RW]

Public Class Methods

new(data, channel = "") click to toggle source
# File lib/leancloud/push.rb, line 16
def initialize(data, channel = "")
  @data = data
  @channel = channel
end

Public Instance Methods

save() click to toggle source
# File lib/leancloud/push.rb, line 21
def save
  uri   = Protocol.push_uri

  body = { :data => @data, :channel => @channel }

  if @channels
    body.merge!({ :channels => @channels })
    body.delete :channel
  end

  if @where
    body.merge!({ :where => @where })
    body.delete :channel
  end

  body.merge!({ :expiration_interval => @expiration_time_interval }) if @expiration_time_interval
  body.merge!({ :expiration_time => @expiration_time }) if @expiration_time
  body.merge!({ :push_time => @push_time }) if @push_time
  body.merge!({ :type => @type }) if @type
  body.merge!({ :prod => 'dev' }) if not @production

  response = LC.client.request uri, :post, body.to_json, nil
end