Class: Glass::Subscription::Notification

Inherits:
Object
  • Object
show all
Defined in:
lib/glass/subscriptions/subscription.rb

Defined Under Namespace

Classes: Action

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#collectionObject

The collection that generated the notification.



127
128
129
# File 'lib/glass/subscriptions/subscription.rb', line 127

def collection
  @collection
end

#itemIdObject

The ID of the item that generated the notification.



132
133
134
# File 'lib/glass/subscriptions/subscription.rb', line 132

def itemId
  @itemId
end

#operationObject

The type of operation that generated the notification.



137
138
139
# File 'lib/glass/subscriptions/subscription.rb', line 137

def operation
  @operation
end

#userActionsObject

A list of actions taken by the user that triggered the notification.



152
153
154
# File 'lib/glass/subscriptions/subscription.rb', line 152

def userActions
  @userActions
end

#userTokenObject

The user token provided by the service when it subscribed for notifications.



147
148
149
# File 'lib/glass/subscriptions/subscription.rb', line 147

def userToken
  @userToken
end

#verifyTokenObject

The secret verify token provided by the service when it subscribed for notifications.



142
143
144
# File 'lib/glass/subscriptions/subscription.rb', line 142

def verifyToken
  @verifyToken
end

Instance Method Details

#delete(mirror = @mirror) ⇒ Object

Delete a subscription to a collection.

Parameters:

  • client (Google::APIClient)

    Authorized client instance.

Returns:

  • nil



209
210
211
212
213
214
215
216
# File 'lib/glass/subscriptions/subscription.rb', line 209

def delete(mirror=@mirror)
  result = client.execute(
      :api_method => mirror.subscriptions.delete,
      :parameters => { 'id' => collection })
  if result.error?
    puts "An error occurred: #{result.data['error']['message']}"
  end
end

#insert(mirror = @mirror) ⇒ Object

Subscribe to notifications for the current user.

Parameters:

  • Mirror (Google::APIClient)

    Authorized client instance.

Returns:

  • nil



193
194
195
196
197
198
199
200
201
# File 'lib/glass/subscriptions/subscription.rb', line 193

def insert(mirror=@mirror)
  subscription = mirror.subscriptions.insert.request_schema.new(to_json)
  result = client.execute(
      :api_method => mirror.subscriptions.insert,
      :body_object => subscription)
  if result.error?
    puts "An error occurred: #{result.data['error']['message']}"
  end
end