Class: Hashblue::API::Message
- Defined in:
- lib/hashblue/api/message.rb
Overview
A Message represents an SMS either sent or received by this Subscriber. It should not be instantiated directly; Messages can be loaded either using Subscriber#messages, or Contact#messages.
Class Method Summary collapse
-
.delete(subscriber_id, id) ⇒ Object
Deletes a specific message.
-
.favourite(subscriber_id, id) ⇒ Object
Favourites a specific message.
-
.unfavourite(subscriber_id, id) ⇒ Object
Un Favourite a specific message.
Instance Method Summary collapse
-
#delete ⇒ Object
Deletes this message.
-
#initialize(attributes = {}) ⇒ Message
constructor
:nodoc:.
-
#received? ⇒ Boolean
Returns true if the message was received by the Subscriber See also
sent?
, which is the inverse of this. -
#sent? ⇒ Boolean
Returns true if the message was sent by the Subscriber See also
received?
, which is the inverse of this.
Methods inherited from Model
from_json, #get, #id, #method_missing, model_name, #post, #to_param
Constructor Details
#initialize(attributes = {}) ⇒ Message
:nodoc:
27 28 29 30 |
# File 'lib/hashblue/api/message.rb', line 27 def initialize(attributes = {}) super @attributes["timestamp"] = Time.parse(@attributes["timestamp"]) if @attributes["timestamp"] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Hashblue::API::Model
Class Method Details
.delete(subscriber_id, id) ⇒ Object
Deletes a specific message. Note that you must be authenticated as the Subscriber in order to delete a message; otherwise an AccessDeniedError will be raised.
10 11 12 |
# File 'lib/hashblue/api/message.rb', line 10 def self.delete(subscriber_id, id) Hashblue::API.delete("/subscribers/#{subscriber_id}/messages/#{id}.json") end |
.favourite(subscriber_id, id) ⇒ Object
Favourites a specific message. You must be authenticated as the Subscriber in order to favourite a message; otherwise an AccessDeniedError will be raised.
17 18 19 |
# File 'lib/hashblue/api/message.rb', line 17 def self.favourite(subscriber_id, id) Hashblue::API.post("/subscribers/#{subscriber_id}/favourites.json", :query => {:id => id}) end |
.unfavourite(subscriber_id, id) ⇒ Object
Un Favourite a specific message. Once authenticated this will mark a message as not a favourite
22 23 24 |
# File 'lib/hashblue/api/message.rb', line 22 def self.unfavourite(subscriber_id, id) Hashblue::API.delete("/subscribers/#{subscriber_id}/favourites/#{id}.json") end |
Instance Method Details
#delete ⇒ Object
Deletes this message. Note that deletion is not permanent; the Subscriber provides a collection of deleted messages.
46 47 48 |
# File 'lib/hashblue/api/message.rb', line 46 def delete self.class.delete(self.subscriber_id, self.id) end |
#received? ⇒ Boolean
Returns true if the message was received by the Subscriber See also sent?
, which is the inverse of this.
40 41 42 |
# File 'lib/hashblue/api/message.rb', line 40 def received? !sent end |
#sent? ⇒ Boolean
Returns true if the message was sent by the Subscriber See also received?
, which is the inverse of this.
34 35 36 |
# File 'lib/hashblue/api/message.rb', line 34 def sent? sent end |