Class: Files::Notification

Inherits:
Object
  • Object
show all
Defined in:
lib/files.com/models/notification.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}, options = {}) ⇒ Notification

Returns a new instance of Notification.



7
8
9
10
# File 'lib/files.com/models/notification.rb', line 7

def initialize(attributes = {}, options = {})
  @attributes = attributes || {}
  @options = options || {}
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



5
6
7
# File 'lib/files.com/models/notification.rb', line 5

def attributes
  @attributes
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/files.com/models/notification.rb', line 5

def options
  @options
end

Class Method Details

.all(params = {}, options = {}) ⇒ Object



306
307
308
# File 'lib/files.com/models/notification.rb', line 306

def self.all(params = {}, options = {})
  list(params, options)
end

.create(params = {}, options = {}) ⇒ Object

Parameters:

user_id - int64 - The id of the user to notify. Provide `user_id`, `username` or `group_id`.
notify_on_copy - boolean - If `true`, copying or moving resources into this path will trigger a notification, in addition to just uploads.
notify_on_delete - boolean - Trigger on files deleted in this path?
notify_on_download - boolean - Trigger on files downloaded in this path?
notify_on_move - boolean - Trigger on files moved to this path?
notify_on_upload - boolean - Trigger on files created/uploaded/updated/changed in this path?
notify_user_actions - boolean - If `true` actions initiated by the user will still result in a notification
recursive - boolean - If `true`, enable notifications for each subfolder in this path
send_interval - string - The time interval that notifications are aggregated by.  Can be `five_minutes`, `fifteen_minutes`, `hourly`, or `daily`.
message - string - Custom message to include in notification emails
triggering_filenames - array(string) - Array of filenames (possibly with wildcards) to scope trigger
triggering_group_ids - array(int64) - If set, will only notify on actions made by a member of one of the specified groups
triggering_user_ids - array(int64) - If set, will only notify on actions made one of the specified users
trigger_by_share_recipients - boolean - Notify when actions are performed by a share recipient?
group_id - int64 - The ID of the group to notify.  Provide `user_id`, `username` or `group_id`.
group_ids - string - Group IDs when the notification requires multiple groups. If sent as a string, it should be comma-delimited.
path - string - Path
username - string - The username of the user to notify.  Provide `user_id`, `username` or `group_id`.


345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
# File 'lib/files.com/models/notification.rb', line 345

def self.create(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params[:user_id] and !params[:user_id].is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: send_interval must be an String") if params[:send_interval] and !params[:send_interval].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: message must be an String") if params[:message] and !params[:message].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: triggering_filenames must be an Array") if params[:triggering_filenames] and !params[:triggering_filenames].is_a?(Array)
  raise InvalidParameterError.new("Bad parameter: triggering_group_ids must be an Array") if params[:triggering_group_ids] and !params[:triggering_group_ids].is_a?(Array)
  raise InvalidParameterError.new("Bad parameter: triggering_user_ids must be an Array") if params[:triggering_user_ids] and !params[:triggering_user_ids].is_a?(Array)
  raise InvalidParameterError.new("Bad parameter: group_id must be an Integer") if params[:group_id] and !params[:group_id].is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: group_ids must be an String") if params[:group_ids] and !params[:group_ids].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: path must be an String") if params[:path] and !params[:path].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: username must be an String") if params[:username] and !params[:username].is_a?(String)

  response, options = Api.send_request("/notifications", :post, params, options)
  Notification.new(response.data, options)
end

.delete(id, params = {}, options = {}) ⇒ Object



390
391
392
393
394
395
396
397
398
# File 'lib/files.com/models/notification.rb', line 390

def self.delete(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params[:id]

  Api.send_request("/notifications/#{params[:id]}", :delete, params, options)
  nil
end

.destroy(id, params = {}, options = {}) ⇒ Object



400
401
402
403
# File 'lib/files.com/models/notification.rb', line 400

def self.destroy(id, params = {}, options = {})
  delete(id, params, options)
  nil
end

.find(id, params = {}, options = {}) ⇒ Object

Parameters:

id (required) - int64 - Notification ID.


312
313
314
315
316
317
318
319
320
# File 'lib/files.com/models/notification.rb', line 312

def self.find(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params[:id]

  response, options = Api.send_request("/notifications/#{params[:id]}", :get, params, options)
  Notification.new(response.data, options)
end

.get(id, params = {}, options = {}) ⇒ Object



322
323
324
# File 'lib/files.com/models/notification.rb', line 322

def self.get(id, params = {}, options = {})
  find(id, params, options)
end

.list(params = {}, options = {}) ⇒ Object

Parameters:

cursor - string - Used for pagination.  When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`.  Send one of those cursor value here to resume an existing list from the next available record.  Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
per_page - int64 - Number of records to show per page.  (Max: 10,000, 1,000 or less is recommended).
sort_by - object - If set, sort records by the specified field in either `asc` or `desc` direction. Valid fields are `path`, `user_id` or `group_id`.
filter - object - If set, return records where the specified field is equal to the supplied value. Valid fields are `path`, `user_id` or `group_id`.
filter_prefix - object - If set, return records where the specified field is prefixed by the supplied value. Valid fields are `path`.
path - string - Show notifications for this Path.
include_ancestors - boolean - If `include_ancestors` is `true` and `path` is specified, include notifications for any parent paths. Ignored if `path` is not specified.
group_id - string


292
293
294
295
296
297
298
299
300
301
302
303
304
# File 'lib/files.com/models/notification.rb', line 292

def self.list(params = {}, options = {})
  raise InvalidParameterError.new("Bad parameter: cursor must be an String") if params[:cursor] and !params[:cursor].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params[:per_page] and !params[:per_page].is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: sort_by must be an Hash") if params[:sort_by] and !params[:sort_by].is_a?(Hash)
  raise InvalidParameterError.new("Bad parameter: filter must be an Hash") if params[:filter] and !params[:filter].is_a?(Hash)
  raise InvalidParameterError.new("Bad parameter: filter_prefix must be an Hash") if params[:filter_prefix] and !params[:filter_prefix].is_a?(Hash)
  raise InvalidParameterError.new("Bad parameter: path must be an String") if params[:path] and !params[:path].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: group_id must be an String") if params[:group_id] and !params[:group_id].is_a?(String)

  List.new(Notification, params) do
    Api.send_request("/notifications", :get, params, options)
  end
end

.update(id, params = {}, options = {}) ⇒ Object

Parameters:

notify_on_copy - boolean - If `true`, copying or moving resources into this path will trigger a notification, in addition to just uploads.
notify_on_delete - boolean - Trigger on files deleted in this path?
notify_on_download - boolean - Trigger on files downloaded in this path?
notify_on_move - boolean - Trigger on files moved to this path?
notify_on_upload - boolean - Trigger on files created/uploaded/updated/changed in this path?
notify_user_actions - boolean - If `true` actions initiated by the user will still result in a notification
recursive - boolean - If `true`, enable notifications for each subfolder in this path
send_interval - string - The time interval that notifications are aggregated by.  Can be `five_minutes`, `fifteen_minutes`, `hourly`, or `daily`.
message - string - Custom message to include in notification emails
triggering_filenames - array(string) - Array of filenames (possibly with wildcards) to scope trigger
triggering_group_ids - array(int64) - If set, will only notify on actions made by a member of one of the specified groups
triggering_user_ids - array(int64) - If set, will only notify on actions made one of the specified users
trigger_by_share_recipients - boolean - Notify when actions are performed by a share recipient?


375
376
377
378
379
380
381
382
383
384
385
386
387
388
# File 'lib/files.com/models/notification.rb', line 375

def self.update(id, params = {}, options = {})
  params ||= {}
  params[:id] = id
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: send_interval must be an String") if params[:send_interval] and !params[:send_interval].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: message must be an String") if params[:message] and !params[:message].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: triggering_filenames must be an Array") if params[:triggering_filenames] and !params[:triggering_filenames].is_a?(Array)
  raise InvalidParameterError.new("Bad parameter: triggering_group_ids must be an Array") if params[:triggering_group_ids] and !params[:triggering_group_ids].is_a?(Array)
  raise InvalidParameterError.new("Bad parameter: triggering_user_ids must be an Array") if params[:triggering_user_ids] and !params[:triggering_user_ids].is_a?(Array)
  raise MissingParameterError.new("Parameter missing: id") unless params[:id]

  response, options = Api.send_request("/notifications/#{params[:id]}", :patch, params, options)
  Notification.new(response.data, options)
end

Instance Method Details

#delete(params = {}) ⇒ Object



257
258
259
260
261
262
263
264
265
# File 'lib/files.com/models/notification.rb', line 257

def delete(params = {})
  params ||= {}
  params[:id] = @attributes[:id]
  raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id]
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer)
  raise MissingParameterError.new("Parameter missing: id") unless params[:id]

  Api.send_request("/notifications/#{@attributes[:id]}", :delete, params, @options)
end

#destroy(params = {}) ⇒ Object



267
268
269
270
# File 'lib/files.com/models/notification.rb', line 267

def destroy(params = {})
  delete(params)
  nil
end

#group_idObject

int64 - ID of Group to receive notifications



31
32
33
# File 'lib/files.com/models/notification.rb', line 31

def group_id
  @attributes[:group_id]
end

#group_id=(value) ⇒ Object



35
36
37
# File 'lib/files.com/models/notification.rb', line 35

def group_id=(value)
  @attributes[:group_id] = value
end

#group_idsObject

array(int64) - Group IDs when the notification requires multiple groups



49
50
51
# File 'lib/files.com/models/notification.rb', line 49

def group_ids
  @attributes[:group_ids]
end

#group_ids=(value) ⇒ Object



53
54
55
# File 'lib/files.com/models/notification.rb', line 53

def group_ids=(value)
  @attributes[:group_ids] = value
end

#group_nameObject

string - Group name, if a Group ID is set



40
41
42
# File 'lib/files.com/models/notification.rb', line 40

def group_name
  @attributes[:group_name]
end

#group_name=(value) ⇒ Object



44
45
46
# File 'lib/files.com/models/notification.rb', line 44

def group_name=(value)
  @attributes[:group_name] = value
end

#group_namesObject

array(string) - Group names when the notification requires multiple groups



58
59
60
# File 'lib/files.com/models/notification.rb', line 58

def group_names
  @attributes[:group_names]
end

#group_names=(value) ⇒ Object



62
63
64
# File 'lib/files.com/models/notification.rb', line 62

def group_names=(value)
  @attributes[:group_names] = value
end

#idObject

int64 - Notification ID



13
14
15
# File 'lib/files.com/models/notification.rb', line 13

def id
  @attributes[:id]
end

#id=(value) ⇒ Object



17
18
19
# File 'lib/files.com/models/notification.rb', line 17

def id=(value)
  @attributes[:id] = value
end

#messageObject

string - Custom message to include in notification emails



166
167
168
# File 'lib/files.com/models/notification.rb', line 166

def message
  @attributes[:message]
end

#message=(value) ⇒ Object



170
171
172
# File 'lib/files.com/models/notification.rb', line 170

def message=(value)
  @attributes[:message] = value
end

#notify_on_copyObject

boolean - Trigger on files copied to this path?



103
104
105
# File 'lib/files.com/models/notification.rb', line 103

def notify_on_copy
  @attributes[:notify_on_copy]
end

#notify_on_copy=(value) ⇒ Object



107
108
109
# File 'lib/files.com/models/notification.rb', line 107

def notify_on_copy=(value)
  @attributes[:notify_on_copy] = value
end

#notify_on_deleteObject

boolean - Trigger on files deleted in this path?



112
113
114
# File 'lib/files.com/models/notification.rb', line 112

def notify_on_delete
  @attributes[:notify_on_delete]
end

#notify_on_delete=(value) ⇒ Object



116
117
118
# File 'lib/files.com/models/notification.rb', line 116

def notify_on_delete=(value)
  @attributes[:notify_on_delete] = value
end

#notify_on_downloadObject

boolean - Trigger on files downloaded in this path?



121
122
123
# File 'lib/files.com/models/notification.rb', line 121

def notify_on_download
  @attributes[:notify_on_download]
end

#notify_on_download=(value) ⇒ Object



125
126
127
# File 'lib/files.com/models/notification.rb', line 125

def notify_on_download=(value)
  @attributes[:notify_on_download] = value
end

#notify_on_moveObject

boolean - Trigger on files moved to this path?



130
131
132
# File 'lib/files.com/models/notification.rb', line 130

def notify_on_move
  @attributes[:notify_on_move]
end

#notify_on_move=(value) ⇒ Object



134
135
136
# File 'lib/files.com/models/notification.rb', line 134

def notify_on_move=(value)
  @attributes[:notify_on_move] = value
end

#notify_on_uploadObject

boolean - Trigger on files created/uploaded/updated/changed in this path?



139
140
141
# File 'lib/files.com/models/notification.rb', line 139

def notify_on_upload
  @attributes[:notify_on_upload]
end

#notify_on_upload=(value) ⇒ Object



143
144
145
# File 'lib/files.com/models/notification.rb', line 143

def notify_on_upload=(value)
  @attributes[:notify_on_upload] = value
end

#notify_user_actionsObject

boolean - If true, will send notifications about a user’s own activity to that user. If false, only activity performed by other users (or anonymous users) will be sent in notifications.



94
95
96
# File 'lib/files.com/models/notification.rb', line 94

def 
  @attributes[:notify_user_actions]
end

#notify_user_actions=(value) ⇒ Object



98
99
100
# File 'lib/files.com/models/notification.rb', line 98

def notify_user_actions=(value)
  @attributes[:notify_user_actions] = value
end

#pathObject

string - Folder path to notify on. This must be slash-delimited, but it must neither start nor end with a slash. Maximum of 5000 characters.



22
23
24
# File 'lib/files.com/models/notification.rb', line 22

def path
  @attributes[:path]
end

#path=(value) ⇒ Object



26
27
28
# File 'lib/files.com/models/notification.rb', line 26

def path=(value)
  @attributes[:path] = value
end

#recursiveObject

boolean - Apply notification recursively? This will enable notifications for each subfolder.



148
149
150
# File 'lib/files.com/models/notification.rb', line 148

def recursive
  @attributes[:recursive]
end

#recursive=(value) ⇒ Object



152
153
154
# File 'lib/files.com/models/notification.rb', line 152

def recursive=(value)
  @attributes[:recursive] = value
end

#saveObject



272
273
274
275
276
277
278
279
280
281
# File 'lib/files.com/models/notification.rb', line 272

def save
  if @attributes[:id]
    new_obj = update(@attributes)
  else
    new_obj = Notification.create(@attributes, @options)
  end

  @attributes = new_obj.attributes
  true
end

#send_intervalObject

string - The time interval that notifications are aggregated to



157
158
159
# File 'lib/files.com/models/notification.rb', line 157

def send_interval
  @attributes[:send_interval]
end

#send_interval=(value) ⇒ Object



161
162
163
# File 'lib/files.com/models/notification.rb', line 161

def send_interval=(value)
  @attributes[:send_interval] = value
end

#suppressed_emailObject

boolean - If true, it means that the recipient at this user’s email address has manually unsubscribed from all emails, or had their email “hard bounce”, which means that we are unable to send mail to this user’s current email address. Notifications will resume if the user changes their email address.



220
221
222
# File 'lib/files.com/models/notification.rb', line 220

def suppressed_email
  @attributes[:suppressed_email]
end

#suppressed_email=(value) ⇒ Object



224
225
226
# File 'lib/files.com/models/notification.rb', line 224

def suppressed_email=(value)
  @attributes[:suppressed_email] = value
end

#trigger_by_share_recipientsObject

boolean - Notify when actions are performed by a share recipient?



85
86
87
# File 'lib/files.com/models/notification.rb', line 85

def trigger_by_share_recipients
  @attributes[:trigger_by_share_recipients]
end

#trigger_by_share_recipients=(value) ⇒ Object



89
90
91
# File 'lib/files.com/models/notification.rb', line 89

def trigger_by_share_recipients=(value)
  @attributes[:trigger_by_share_recipients] = value
end

#triggering_filenamesObject

array(string) - Array of filenames (possibly with wildcards) to scope trigger



175
176
177
# File 'lib/files.com/models/notification.rb', line 175

def triggering_filenames
  @attributes[:triggering_filenames]
end

#triggering_filenames=(value) ⇒ Object



179
180
181
# File 'lib/files.com/models/notification.rb', line 179

def triggering_filenames=(value)
  @attributes[:triggering_filenames] = value
end

#triggering_group_idsObject

array(int64) - If set, will only notify on actions made by a member of one of the specified groups



67
68
69
# File 'lib/files.com/models/notification.rb', line 67

def triggering_group_ids
  @attributes[:triggering_group_ids]
end

#triggering_group_ids=(value) ⇒ Object



71
72
73
# File 'lib/files.com/models/notification.rb', line 71

def triggering_group_ids=(value)
  @attributes[:triggering_group_ids] = value
end

#triggering_user_idsObject

array(int64) - If set, will only notify on actions made one of the specified users



76
77
78
# File 'lib/files.com/models/notification.rb', line 76

def triggering_user_ids
  @attributes[:triggering_user_ids]
end

#triggering_user_ids=(value) ⇒ Object



80
81
82
# File 'lib/files.com/models/notification.rb', line 80

def triggering_user_ids=(value)
  @attributes[:triggering_user_ids] = value
end

#unsubscribedObject

boolean - Is the user unsubscribed from this notification?



184
185
186
# File 'lib/files.com/models/notification.rb', line 184

def unsubscribed
  @attributes[:unsubscribed]
end

#unsubscribed=(value) ⇒ Object



188
189
190
# File 'lib/files.com/models/notification.rb', line 188

def unsubscribed=(value)
  @attributes[:unsubscribed] = value
end

#unsubscribed_reasonObject

string - The reason that the user unsubscribed



193
194
195
# File 'lib/files.com/models/notification.rb', line 193

def unsubscribed_reason
  @attributes[:unsubscribed_reason]
end

#unsubscribed_reason=(value) ⇒ Object



197
198
199
# File 'lib/files.com/models/notification.rb', line 197

def unsubscribed_reason=(value)
  @attributes[:unsubscribed_reason] = value
end

#update(params = {}) ⇒ Object

Parameters:

notify_on_copy - boolean - If `true`, copying or moving resources into this path will trigger a notification, in addition to just uploads.
notify_on_delete - boolean - Trigger on files deleted in this path?
notify_on_download - boolean - Trigger on files downloaded in this path?
notify_on_move - boolean - Trigger on files moved to this path?
notify_on_upload - boolean - Trigger on files created/uploaded/updated/changed in this path?
notify_user_actions - boolean - If `true` actions initiated by the user will still result in a notification
recursive - boolean - If `true`, enable notifications for each subfolder in this path
send_interval - string - The time interval that notifications are aggregated by.  Can be `five_minutes`, `fifteen_minutes`, `hourly`, or `daily`.
message - string - Custom message to include in notification emails
triggering_filenames - array(string) - Array of filenames (possibly with wildcards) to scope trigger
triggering_group_ids - array(int64) - If set, will only notify on actions made by a member of one of the specified groups
triggering_user_ids - array(int64) - If set, will only notify on actions made one of the specified users
trigger_by_share_recipients - boolean - Notify when actions are performed by a share recipient?


242
243
244
245
246
247
248
249
250
251
252
253
254
255
# File 'lib/files.com/models/notification.rb', line 242

def update(params = {})
  params ||= {}
  params[:id] = @attributes[:id]
  raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id]
  raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer)
  raise InvalidParameterError.new("Bad parameter: send_interval must be an String") if params[:send_interval] and !params[:send_interval].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: message must be an String") if params[:message] and !params[:message].is_a?(String)
  raise InvalidParameterError.new("Bad parameter: triggering_filenames must be an Array") if params[:triggering_filenames] and !params[:triggering_filenames].is_a?(Array)
  raise InvalidParameterError.new("Bad parameter: triggering_group_ids must be an Array") if params[:triggering_group_ids] and !params[:triggering_group_ids].is_a?(Array)
  raise InvalidParameterError.new("Bad parameter: triggering_user_ids must be an Array") if params[:triggering_user_ids] and !params[:triggering_user_ids].is_a?(Array)
  raise MissingParameterError.new("Parameter missing: id") unless params[:id]

  Api.send_request("/notifications/#{@attributes[:id]}", :patch, params, @options)
end

#user_idObject

int64 - Notification user ID



202
203
204
# File 'lib/files.com/models/notification.rb', line 202

def user_id
  @attributes[:user_id]
end

#user_id=(value) ⇒ Object



206
207
208
# File 'lib/files.com/models/notification.rb', line 206

def user_id=(value)
  @attributes[:user_id] = value
end

#usernameObject

string - Notification username



211
212
213
# File 'lib/files.com/models/notification.rb', line 211

def username
  @attributes[:username]
end

#username=(value) ⇒ Object



215
216
217
# File 'lib/files.com/models/notification.rb', line 215

def username=(value)
  @attributes[:username] = value
end