Sha256: b8fdb8c0e9f18a291b78902ce1a0b596f3b709781938ddf3f97f1e14ab4f8bf9

Contents?: true

Size: 962 Bytes

Versions: 2

Compression:

Stored size: 962 Bytes

Contents

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 :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 })
      end

      body.merge!({ :expiration_time_interval => @expiration_time_interval }) if @expiration_time_interval
      body.merge!({ :expiration_time => @expiration_time }) if @expiration_time
      body.merge!({ :type => @type }) if @type

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

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
parse-ruby-client-0.1.3 lib/parse/push.rb
parse-ruby-client-0.1.2 lib/parse/push.rb