Sha256: a6a6a4f9a44950c9925b68b622d7e21c88bc2c8f1eacf181538366d2fd9fd863

Contents?: true

Size: 1.08 KB

Versions: 1

Compression:

Stored size: 1.08 KB

Contents

# -*- encoding : utf-8 -*-
require 'cgi'
require 'parse/error'

module Parse
  class Push
    attr_accessor :channels
    attr_accessor :channel
    attr_accessor :where
    attr_accessor :type
    attr_accessor :expiration_time_interval
    attr_accessor :expiration_time
    attr_accessor :push_time
    attr_accessor :data

    def initialize(data, channel = "")
      @data = data
      @channel = channel
    end

    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

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

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
parse-ruby-client-0.3.0 lib/parse/push.rb