Class: Pushco

Inherits:
Object
  • Object
show all
Defined in:
lib/pushco.rb

Instance Method Summary collapse

Constructor Details

#initialize(api_key, api_secret) ⇒ Pushco

Example:

>> Pushco.new("YOUR_API_KEY", "YOUR_API_SECRET")

Arguments:

String


10
11
12
13
14
15
16
17
18
19
# File 'lib/pushco.rb', line 10

def initialize api_key, api_secret

  if ((api_key.nil? || api_key.empty?) && (api_secret.nil? || api_secret.empty?))
    p "Please Provide Both API key and API Secret!"
  end

  @api_key = api_key
  @api_secret = api_secret

end

Instance Method Details

#connect_to_push(message, options) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/pushco.rb', line 31

def connect_to_push(message, options)

  data = {:message => message,
          :api_key => @api_key,
          :api_secret => @api_secret
  }.merge(options)

  p HTTParty.post('https://api.push.co/1.0/push', {:body => data}).body
end

#push(messsage, options = {}) ⇒ Object

Example:

>> Pushco.push("Hello Mum I am on TV", {:url => 'http://sky.com'})

Arguments:

String and Hashmap


27
28
29
# File 'lib/pushco.rb', line 27

def push messsage, options = {}
  connect_to_push(messsage, options)
end