Class: Little::Notification

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

Overview

retrieve and repond to notifications

Class Method Summary collapse

Class Method Details

.get(user, type) ⇒ Hash

gets the notification for a user and type

Parameters:

  • user (String)

    the user to get the notification for

  • type (int)

    the type of notifiation to get

Returns:

  • (Hash)

    containing the notification id and body, nil if the type is valid or if the user has already responded



8
9
10
# File 'lib/little/notification.rb', line 8

def self.get(user, type)
  Little.get(:notifications, {:user => user, :type => type})
end

.respond(user, notification_id, response) ⇒ Object

responds to a particular notification

Parameters:

  • user (String)

    the user responding to the notificaiton

  • notificaiton_id (String)

    the id of the notificaiton

  • response (int)

    the user’s response



16
17
18
# File 'lib/little/notification.rb', line 16

def self.respond(user, notification_id, response)
  Little.post(:notifications, {:user => user, :notification => notification_id, :response => response}, [:user, :notification], 'respond')
end

.sign_respond(user, notification_id) ⇒ Object

generates a signature for sending a response(useful when using the javascript library)



21
22
23
# File 'lib/little/notification.rb', line 21

def self.sign_respond(user, notification_id)
  Little.sign(:notification, {:user => user, :notification => notification_id})
end