Sha256: b220cce28f4cd37dced12ce027c4a891a2f39155a7bda954ee36911e92b39115

Contents?: true

Size: 1.59 KB

Versions: 4

Compression:

Stored size: 1.59 KB

Contents

require_relative "model.rb"
module Figo
  # Retrieve list of registered notifications.
  #
  # @return [Notification] an array of `Notification` objects, one for each registered notification
  def notifications
    query_api_object Notification, "/rest/notifications", nil, "GET", "notifications"
  end

  # Retrieve specific notification.
  #
  # @param notification_id [String] ID of the notification to be retrieved
  # @return [Notification] `Notification` object for the respective notification
  def get_notification(notification_id)
    query_api_object Notification, "/rest/notifications/#{notification_id}"
  end

  # Register a new notification.
  #
  # @param notification [Notification] notification to be crated. It should not have a notification_id set.
  # @return [Notification] newly created `Notification` object
  def add_notification(notification)
    query_api_object Notification, "/rest/notifications", notification.dump(), "POST"
  end

  # Modify notification.
  #
  # @param notification [Notification] modified notification object
  # @return [Notification] modified notification returned by server
  def modify_notification(notification)
    query_api_object Notification, "/rest/notifications/#{notification.notification_id}", notification.dump(), "PUT"
  end

  # Unregister notification.
  #
  # @param notification [Notification, String] notification object which should be deleted or its ID
  def remove_notification(notification)
    query_api notification.is_a?(String) ? "/rest/notifications/#{notification}" : "/rest/notifications/#{notification.notification_id}", nil, "DELETE"
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
figo-1.4.2 lib/notification/api_call.rb
figo-1.4.1 lib/notification/api_call.rb
figo-1.4.0 lib/notification/api_call.rb
figo-1.3.3 lib/notification/api_call.rb