Class: Files::Notification
- Inherits:
-
Object
- Object
- Files::Notification
- Defined in:
- lib/files.com/models/notification.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
- .all(params = {}, options = {}) ⇒ Object
-
.create(params = {}, options = {}) ⇒ Object
Parameters: user_id - integer - The id of the user to notify.
- .delete(id, params = {}, options = {}) ⇒ Object
- .destroy(id, params = {}, options = {}) ⇒ Object
-
.find(id, params = {}, options = {}) ⇒ Object
Parameters: id (required) - integer - Notification ID.
- .get(id, params = {}, options = {}) ⇒ Object
-
.list(params = {}, options = {}) ⇒ Object
Parameters: user_id - integer - Show notifications for this User ID.
-
.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.
Instance Method Summary collapse
- #delete(params = {}) ⇒ Object
- #destroy(params = {}) ⇒ Object
-
#group_id ⇒ Object
int64 - Notification group id.
- #group_id=(value) ⇒ Object
-
#group_name ⇒ Object
string - Group name if applicable.
- #group_name=(value) ⇒ Object
-
#id ⇒ Object
int64 - Notification ID.
- #id=(value) ⇒ Object
-
#initialize(attributes = {}, options = {}) ⇒ Notification
constructor
A new instance of Notification.
-
#notify_on_copy ⇒ Object
boolean - Triggers notification when moving or copying files to this path.
- #notify_on_copy=(value) ⇒ Object
-
#notify_user_actions ⇒ Object
boolean - Trigger notification on notification user actions?.
- #notify_user_actions=(value) ⇒ Object
-
#path ⇒ Object
string - Folder path to notify on This must be slash-delimited, but it must neither start nor end with a slash.
- #path=(value) ⇒ Object
- #save ⇒ Object
-
#send_interval ⇒ Object
string - The time interval that notifications are aggregated to.
- #send_interval=(value) ⇒ Object
-
#unsubscribed ⇒ Object
boolean - Is the user unsubscribed from this notification?.
- #unsubscribed=(value) ⇒ Object
-
#unsubscribed_reason ⇒ Object
string - The reason that the user unsubscribed.
- #unsubscribed_reason=(value) ⇒ Object
-
#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.
-
#user_id ⇒ Object
int64 - Notification user ID.
- #user_id=(value) ⇒ Object
-
#username ⇒ Object
string - Notification username.
- #username=(value) ⇒ Object
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 = {}, = {}) @attributes = attributes || {} @options = || {} end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
5 6 7 |
# File 'lib/files.com/models/notification.rb', line 5 def attributes @attributes end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/files.com/models/notification.rb', line 5 def @options end |
Class Method Details
.all(params = {}, options = {}) ⇒ Object
166 167 168 |
# File 'lib/files.com/models/notification.rb', line 166 def self.all(params = {}, = {}) list(params, ) end |
.create(params = {}, options = {}) ⇒ Object
Parameters:
user_id - integer - 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_user_actions - boolean - If `true` actions initiated by the user will still result in a notification
send_interval - string - The time interval that notifications are aggregated by. Can be `five_minutes`, `fifteen_minutes`, `hourly`, or `daily`.
group_id - integer - The ID of the group to notify. Provide `user_id`, `username` or `group_id`.
path - string - Path
username - string - The username of the user to notify. Provide `user_id`, `username` or `group_id`.
194 195 196 197 198 199 200 201 202 203 |
# File 'lib/files.com/models/notification.rb', line 194 def self.create(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params.dig(:user_id) and !params.dig(:user_id).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: send_interval must be an String") if params.dig(:send_interval) and !params.dig(:send_interval).is_a?(String) raise InvalidParameterError.new("Bad parameter: group_id must be an Integer") if params.dig(:group_id) and !params.dig(:group_id).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: path must be an String") if params.dig(:path) and !params.dig(:path).is_a?(String) raise InvalidParameterError.new("Bad parameter: username must be an String") if params.dig(:username) and !params.dig(:username).is_a?(String) response, = Api.send_request("/notifications", :post, params, ) Notification.new(response.data, ) end |
.delete(id, params = {}, options = {}) ⇒ Object
220 221 222 223 224 225 226 227 228 |
# File 'lib/files.com/models/notification.rb', line 220 def self.delete(id, params = {}, = {}) params ||= {} params[:id] = id raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id) response, = Api.send_request("/notifications/#{params[:id]}", :delete, params, ) response.data end |
.destroy(id, params = {}, options = {}) ⇒ Object
230 231 232 |
# File 'lib/files.com/models/notification.rb', line 230 def self.destroy(id, params = {}, = {}) delete(id, params, ) end |
.find(id, params = {}, options = {}) ⇒ Object
Parameters:
id (required) - integer - Notification ID.
172 173 174 175 176 177 178 179 180 |
# File 'lib/files.com/models/notification.rb', line 172 def self.find(id, params = {}, = {}) params ||= {} params[:id] = id raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id) response, = Api.send_request("/notifications/#{params[:id]}", :get, params, ) Notification.new(response.data, ) end |
.get(id, params = {}, options = {}) ⇒ Object
182 183 184 |
# File 'lib/files.com/models/notification.rb', line 182 def self.get(id, params = {}, = {}) find(id, params, ) end |
.list(params = {}, options = {}) ⇒ Object
Parameters:
user_id - integer - Show notifications for this User ID.
page - integer - Current page number.
per_page - integer - Number of records to show per page. (Max: 10,000, 1,000 or less is recommended).
action - string - Deprecated: If set to `count` returns a count of matching records rather than the records themselves.
group_id - integer - Show notifications for this Group ID.
155 156 157 158 159 160 161 162 163 164 |
# File 'lib/files.com/models/notification.rb', line 155 def self.list(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: user_id must be an Integer") if params.dig(:user_id) and !params.dig(:user_id).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: page must be an Integer") if params.dig(:page) and !params.dig(:page).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params.dig(:per_page) and !params.dig(:per_page).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: action must be an String") if params.dig(:action) and !params.dig(:action).is_a?(String) raise InvalidParameterError.new("Bad parameter: group_id must be an Integer") if params.dig(:group_id) and !params.dig(:group_id).is_a?(Integer) response, = Api.send_request("/notifications", :get, params, ) response.data.map { |object| Notification.new(object, ) } 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_user_actions - boolean - If `true` actions initiated by the user will still result in a notification
send_interval - string - The time interval that notifications are aggregated by. Can be `five_minutes`, `fifteen_minutes`, `hourly`, or `daily`.
209 210 211 212 213 214 215 216 217 218 |
# File 'lib/files.com/models/notification.rb', line 209 def self.update(id, params = {}, = {}) params ||= {} params[:id] = id raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params.dig(:id) and !params.dig(:id).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: send_interval must be an String") if params.dig(:send_interval) and !params.dig(:send_interval).is_a?(String) raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id) response, = Api.send_request("/notifications/#{params[:id]}", :patch, params, ) Notification.new(response.data, ) end |
Instance Method Details
#delete(params = {}) ⇒ Object
126 127 128 129 130 131 132 133 134 |
# File 'lib/files.com/models/notification.rb', line 126 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.dig(:id) and !params.dig(:id).is_a?(Integer) raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id) Api.send_request("/notifications/#{@attributes[:id]}", :delete, params, @options) end |
#destroy(params = {}) ⇒ Object
136 137 138 |
# File 'lib/files.com/models/notification.rb', line 136 def destroy(params = {}) delete(params) end |
#group_id ⇒ Object
int64 - Notification group id
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_name ⇒ Object
string - Group name if applicable
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 |
#id ⇒ Object
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 |
#notify_on_copy ⇒ Object
boolean - Triggers notification when moving or copying files to this path
58 59 60 |
# File 'lib/files.com/models/notification.rb', line 58 def notify_on_copy @attributes[:notify_on_copy] end |
#notify_on_copy=(value) ⇒ Object
62 63 64 |
# File 'lib/files.com/models/notification.rb', line 62 def notify_on_copy=(value) @attributes[:notify_on_copy] = value end |
#notify_user_actions ⇒ Object
boolean - Trigger notification on notification user actions?
49 50 51 |
# File 'lib/files.com/models/notification.rb', line 49 def notify_user_actions @attributes[:notify_user_actions] end |
#notify_user_actions=(value) ⇒ Object
53 54 55 |
# File 'lib/files.com/models/notification.rb', line 53 def notify_user_actions=(value) @attributes[:notify_user_actions] = value end |
#path ⇒ Object
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 |
#save ⇒ Object
140 141 142 143 144 145 146 147 |
# File 'lib/files.com/models/notification.rb', line 140 def save if @attributes[:id] update(@attributes) else new_obj = Notification.create(@attributes, @options) @attributes = new_obj.attributes end end |
#send_interval ⇒ Object
string - The time interval that notifications are aggregated to
67 68 69 |
# File 'lib/files.com/models/notification.rb', line 67 def send_interval @attributes[:send_interval] end |
#send_interval=(value) ⇒ Object
71 72 73 |
# File 'lib/files.com/models/notification.rb', line 71 def send_interval=(value) @attributes[:send_interval] = value end |
#unsubscribed ⇒ Object
boolean - Is the user unsubscribed from this notification?
76 77 78 |
# File 'lib/files.com/models/notification.rb', line 76 def unsubscribed @attributes[:unsubscribed] end |
#unsubscribed=(value) ⇒ Object
80 81 82 |
# File 'lib/files.com/models/notification.rb', line 80 def unsubscribed=(value) @attributes[:unsubscribed] = value end |
#unsubscribed_reason ⇒ Object
string - The reason that the user unsubscribed
85 86 87 |
# File 'lib/files.com/models/notification.rb', line 85 def unsubscribed_reason @attributes[:unsubscribed_reason] end |
#unsubscribed_reason=(value) ⇒ Object
89 90 91 |
# File 'lib/files.com/models/notification.rb', line 89 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_user_actions - boolean - If `true` actions initiated by the user will still result in a notification
send_interval - string - The time interval that notifications are aggregated by. Can be `five_minutes`, `fifteen_minutes`, `hourly`, or `daily`.
115 116 117 118 119 120 121 122 123 124 |
# File 'lib/files.com/models/notification.rb', line 115 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.dig(:id) and !params.dig(:id).is_a?(Integer) raise InvalidParameterError.new("Bad parameter: send_interval must be an String") if params.dig(:send_interval) and !params.dig(:send_interval).is_a?(String) raise MissingParameterError.new("Parameter missing: id") unless params.dig(:id) Api.send_request("/notifications/#{@attributes[:id]}", :patch, params, @options) end |
#user_id ⇒ Object
int64 - Notification user ID
94 95 96 |
# File 'lib/files.com/models/notification.rb', line 94 def user_id @attributes[:user_id] end |
#user_id=(value) ⇒ Object
98 99 100 |
# File 'lib/files.com/models/notification.rb', line 98 def user_id=(value) @attributes[:user_id] = value end |
#username ⇒ Object
string - Notification username
103 104 105 |
# File 'lib/files.com/models/notification.rb', line 103 def username @attributes[:username] end |
#username=(value) ⇒ Object
107 108 109 |
# File 'lib/files.com/models/notification.rb', line 107 def username=(value) @attributes[:username] = value end |