Class: SparkApi::Models::Notification
- Defined in:
- lib/spark_api/models/notification.rb
Constant Summary
Constants included from Paginate
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Base
connection, #connection, count, element_name, element_name=, first, get, #id, #initialize, #load, #method_missing, #parse_id, path, #path, #persisted?, prefix, prefix=, #resource_pluralized, #resource_uri, #respond_to?, #to_param, #to_partial_path
Methods included from Paginate
#collect, #paginate, #per_page
Methods included from Dirty
#changed, #changed?, #changed_attributes, #changes, #dirty_attributes, #previous_changes
Constructor Details
This class inherits a constructor from SparkApi::Models::Base
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class SparkApi::Models::Base
Class Method Details
.mark_read(notifications, arguments = {}) ⇒ Object
33 34 35 36 37 38 |
# 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 ⇒ Object
27 28 29 30 31 |
# 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 |
Instance Method Details
#listing_search_role ⇒ Object
40 41 42 |
# File 'lib/spark_api/models/notification.rb', line 40 def listing_search_role :public end |
#save(arguments = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 |
# 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.} SparkApi.logger.warn("Failed to save resource #{self}: #{e.}") rescue NotFound => e SparkApi.logger.error("Failed to save resource #{self}: #{e.}") end false end |
#save!(arguments = {}) ⇒ Object
20 21 22 23 24 25 |
# 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 |