Class: Glass::SubscriptionNotification
- Inherits:
-
Object
- Object
- Glass::SubscriptionNotification
- Defined in:
- lib/glass/subscription_notification.rb
Defined Under Namespace
Classes: VerificationError
Instance Attribute Summary collapse
-
#collection ⇒ Object
Returns the value of attribute collection.
-
#glass_item_id ⇒ Object
Returns the value of attribute glass_item_id.
-
#google_account ⇒ Object
Returns the value of attribute google_account.
-
#params ⇒ Object
Returns the value of attribute params.
-
#reply_request_hash ⇒ Object
Returns the value of attribute reply_request_hash.
-
#user_actions ⇒ Object
Returns the value of attribute user_actions.
Class Method Summary collapse
Instance Method Summary collapse
-
#handle! ⇒ Object
Perform the corresponding notification actions.
-
#initialize(params) ⇒ SubscriptionNotification
constructor
A new instance of SubscriptionNotification.
Constructor Details
#initialize(params) ⇒ SubscriptionNotification
Returns a new instance of SubscriptionNotification.
12 13 14 15 16 17 18 |
# File 'lib/glass/subscription_notification.rb', line 12 def initialize(params) self.params = params self.collection = params[:collection] self.user_actions = params[:userActions] self.google_account = find_google_account(params) verify_authenticity! end |
Instance Attribute Details
#collection ⇒ Object
Returns the value of attribute collection.
3 4 5 |
# File 'lib/glass/subscription_notification.rb', line 3 def collection @collection end |
#glass_item_id ⇒ Object
Returns the value of attribute glass_item_id.
3 4 5 |
# File 'lib/glass/subscription_notification.rb', line 3 def glass_item_id @glass_item_id end |
#google_account ⇒ Object
Returns the value of attribute google_account.
3 4 5 |
# File 'lib/glass/subscription_notification.rb', line 3 def google_account @google_account end |
#params ⇒ Object
Returns the value of attribute params.
3 4 5 |
# File 'lib/glass/subscription_notification.rb', line 3 def params @params end |
#reply_request_hash ⇒ Object
Returns the value of attribute reply_request_hash.
3 4 5 |
# File 'lib/glass/subscription_notification.rb', line 3 def reply_request_hash @reply_request_hash end |
#user_actions ⇒ Object
Returns the value of attribute user_actions.
3 4 5 |
# File 'lib/glass/subscription_notification.rb', line 3 def user_actions @user_actions end |
Class Method Details
.create(params) ⇒ Object
8 9 10 11 |
# File 'lib/glass/subscription_notification.rb', line 8 def self.create(params) notification = new(params) notification.handle! end |
Instance Method Details
#handle! ⇒ Object
Perform the corresponding notification actions
28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/glass/subscription_notification.rb', line 28 def handle! if collection == "locations" # TODO: This is a location update - should the GoogleAccount handle these updates? # When your Glassware receives a location update, send a request to the glass.locations.get endpoint to retrieve the latest known location. # Something like: google_account.handle_location_update else self.glass_item_id = params[:itemId] handle_reply(params) handle_action end end |