class SparkApi::Models::Notification
Public Class Methods
mark_read(notifications, arguments={})
click to toggle source
# File lib/spark_api/models/notification.rb, line 33 def self.mark_read(notifications, arguments={}) notifications = Array(notifications) ids = notifications.map { |n| n.respond_to?('Id') ? n.Id : n } result = connection.put "#{self.path}/#{ids.join(',')}", {'Read' => true}, arguments end
unread()
click to toggle source
# File lib/spark_api/models/notification.rb, line 27 def self.unread() # force pagination so response knows to deal with returned pagination info result = connection.get "#{self.path}/unread", {:_pagination => 'count'} result end
Public Instance Methods
listing_search_role()
click to toggle source
# File lib/spark_api/models/notification.rb, line 40 def listing_search_role :public end
save(arguments={})
click to toggle source
# File lib/spark_api/models/notification.rb, line 7 def save(arguments={}) self.errors = [] # clear the errors hash begin return save!(arguments) rescue BadResourceRequest => e self.errors << {:code => e.code, :message => e.message} SparkApi.logger.warn("Failed to save resource #{self}: #{e.message}") rescue NotFound => e SparkApi.logger.error("Failed to save resource #{self}: #{e.message}") end false end
save!(arguments={})
click to toggle source
# File lib/spark_api/models/notification.rb, line 20 def save!(arguments={}) results = connection.post self.class.path, attributes, arguments result = results.first attributes['ResourceUri'] = result['ResourceUri'] true end