Sha256: 2fcdfe7c5a490892a2524c271961128d7029cb1f5fbbbf9c36dca160c68dc8c1
Contents?: true
Size: 1.31 KB
Versions: 36
Compression:
Stored size: 1.31 KB
Contents
module SparkApi module Models class Notification < Base self.element_name = 'notifications' 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 def save!(arguments={}) results = connection.post self.class.path, attributes, arguments result = results.first attributes['ResourceUri'] = result['ResourceUri'] true end def self.unread() # force pagination so response knows to deal with returned pagination info result = connection.get "#{self.path}/unread", {:_pagination => 'count'} result end 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 def listing_search_role :public end end end end
Version data entries
36 entries across 36 versions & 1 rubygems