Class: Notifo

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/notifo.rb

Instance Method Summary collapse

Constructor Details

#initialize(username, apisecret) ⇒ Notifo

Required Parameters username - notifo service username apikey - notifo service apisecret



10
11
12
# File 'lib/notifo.rb', line 10

def initialize(username, apisecret)
  @auth = {:username => username, :password => apisecret}
end

Instance Method Details

#post(username, msg, title = nil, uri = nil) ⇒ Object

Required Parameters to - notifo username of recipient msg - message being sent; must be url encoded Optional Parameters title - name of “notification event” uri - the uri that will be loaded when the notification is opened; if specified, must be urlencoded; if a web address, must start with http:// or https://



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

def post(username, msg, title=nil, uri=nil)
  options = { :body => {:to => username, :msg => msg, :title=>uri, :uri=>uri}, :basic_auth => @auth }
  self.class.post('/send_notification', options)
end

#subscribe_user(username) ⇒ Object

Required Parameters username - notifo username to subscribe to your service



16
17
18
19
# File 'lib/notifo.rb', line 16

def subscribe_user(username)
  options = { :body => {:username => username}, :basic_auth => @auth }
  self.class.post("/subscribe_user", options)
end