Class: Files::EventSubscription
- Inherits:
-
Object
- Object
- Files::EventSubscription
- Defined in:
- lib/files.com/models/event_subscription.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: event_channel_id - int64 - Event Channel ID workspace_id - int64 - Workspace ID.
- .delete(id, params = {}, options = {}) ⇒ Object
- .destroy(id, params = {}, options = {}) ⇒ Object
-
.find(id, params = {}, options = {}) ⇒ Object
Parameters: id (required) - int64 - Event Subscription ID.
- .get(id, params = {}, options = {}) ⇒ Object
-
.list(params = {}, options = {}) ⇒ Object
Parameters: cursor - string - Used for pagination.
-
.update(id, params = {}, options = {}) ⇒ Object
Parameters: event_channel_id - int64 - Event Channel ID workspace_id - int64 - Workspace ID.
Instance Method Summary collapse
-
#apply_to_all_workspaces ⇒ Object
boolean - If true, this default-workspace subscription applies to events from all workspaces.
- #apply_to_all_workspaces=(value) ⇒ Object
-
#created_at ⇒ Object
date-time - Event Subscription create date/time.
- #delete(params = {}) ⇒ Object
-
#delivery_policy ⇒ Object
object - Event Subscription delivery policy.
- #delivery_policy=(value) ⇒ Object
- #destroy(params = {}) ⇒ Object
-
#enabled ⇒ Object
boolean - Whether this Event Subscription can dispatch events.
- #enabled=(value) ⇒ Object
-
#event_channel_id ⇒ Object
int64 - Event Channel ID.
- #event_channel_id=(value) ⇒ Object
-
#event_target_ids ⇒ Object
array(int64) - Event Target IDs this subscription sends to.
- #event_target_ids=(value) ⇒ Object
-
#event_types ⇒ Object
array(string) - Event type strings matched by this subscription.
- #event_types=(value) ⇒ Object
-
#filter ⇒ Object
object - Structured event payload filter.
- #filter=(value) ⇒ Object
-
#id ⇒ Object
int64 - Event Subscription ID.
- #id=(value) ⇒ Object
-
#initialize(attributes = {}, options = {}) ⇒ EventSubscription
constructor
A new instance of EventSubscription.
-
#name ⇒ Object
string - Event Subscription name.
- #name=(value) ⇒ Object
- #save ⇒ Object
-
#update(params = {}) ⇒ Object
Parameters: event_channel_id - int64 - Event Channel ID workspace_id - int64 - Workspace ID.
-
#updated_at ⇒ Object
date-time - Event Subscription update date/time.
-
#workspace_id ⇒ Object
int64 - Workspace ID.
- #workspace_id=(value) ⇒ Object
Constructor Details
#initialize(attributes = {}, options = {}) ⇒ EventSubscription
Returns a new instance of EventSubscription.
7 8 9 10 |
# File 'lib/files.com/models/event_subscription.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/event_subscription.rb', line 5 def attributes @attributes end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
5 6 7 |
# File 'lib/files.com/models/event_subscription.rb', line 5 def @options end |
Class Method Details
.all(params = {}, options = {}) ⇒ Object
179 180 181 |
# File 'lib/files.com/models/event_subscription.rb', line 179 def self.all(params = {}, = {}) list(params, ) end |
.create(params = {}, options = {}) ⇒ Object
Parameters:
event_channel_id - int64 - Event Channel ID
workspace_id - int64 - Workspace ID. 0 means the default workspace or site-wide.
apply_to_all_workspaces - boolean - If true, this default-workspace subscription applies to events from all workspaces.
name (required) - string - Event Subscription name.
enabled - boolean - Whether this Event Subscription can dispatch events.
event_types - array(string) - Event type strings matched by this subscription. Blank means all event types.
filter - object - Structured event payload filter.
delivery_policy - object - Event Subscription delivery policy.
event_target_ids - array(int64) - Event Target IDs this subscription sends to.
209 210 211 212 213 214 215 216 217 218 219 220 221 |
# File 'lib/files.com/models/event_subscription.rb', line 209 def self.create(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: event_channel_id must be an Integer") if params[:event_channel_id] and !params[:event_channel_id].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: workspace_id must be an Integer") if params[:workspace_id] and !params[:workspace_id].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: name must be an String") if params[:name] and !params[:name].is_a?(String) raise InvalidParameterError.new("Bad parameter: event_types must be an Array") if params[:event_types] and !params[:event_types].is_a?(Array) raise InvalidParameterError.new("Bad parameter: filter must be an Hash") if params[:filter] and !params[:filter].is_a?(Hash) raise InvalidParameterError.new("Bad parameter: delivery_policy must be an Hash") if params[:delivery_policy] and !params[:delivery_policy].is_a?(Hash) raise InvalidParameterError.new("Bad parameter: event_target_ids must be an Array") if params[:event_target_ids] and !params[:event_target_ids].is_a?(Array) raise MissingParameterError.new("Parameter missing: name") unless params[:name] response, = Api.send_request("/event_subscriptions", :post, params, ) EventSubscription.new(response.data, ) end |
.delete(id, params = {}, options = {}) ⇒ Object
250 251 252 253 254 255 256 257 258 |
# File 'lib/files.com/models/event_subscription.rb', line 250 def self.delete(id, params = {}, = {}) 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("/event_subscriptions/#{params[:id]}", :delete, params, ) nil end |
.destroy(id, params = {}, options = {}) ⇒ Object
260 261 262 263 |
# File 'lib/files.com/models/event_subscription.rb', line 260 def self.destroy(id, params = {}, = {}) delete(id, params, ) nil end |
.find(id, params = {}, options = {}) ⇒ Object
Parameters:
id (required) - int64 - Event Subscription ID.
185 186 187 188 189 190 191 192 193 |
# File 'lib/files.com/models/event_subscription.rb', line 185 def self.find(id, params = {}, = {}) 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, = Api.send_request("/event_subscriptions/#{params[:id]}", :get, params, ) EventSubscription.new(response.data, ) end |
.get(id, params = {}, options = {}) ⇒ Object
195 196 197 |
# File 'lib/files.com/models/event_subscription.rb', line 195 def self.get(id, params = {}, = {}) find(id, params, ) 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 `enabled`, `event_channel_id` or `workspace_id`.
filter - object - If set, return records where the specified field is equal to the supplied value. Valid fields are `enabled`, `event_channel_id` or `workspace_id`. Valid field combinations are `[ enabled, event_channel_id ]`, `[ workspace_id, enabled ]` or `[ workspace_id, enabled, event_channel_id ]`.
168 169 170 171 172 173 174 175 176 177 |
# File 'lib/files.com/models/event_subscription.rb', line 168 def self.list(params = {}, = {}) 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) List.new(EventSubscription, params) do Api.send_request("/event_subscriptions", :get, params, ) end end |
.update(id, params = {}, options = {}) ⇒ Object
Parameters:
event_channel_id - int64 - Event Channel ID
workspace_id - int64 - Workspace ID. 0 means the default workspace or site-wide.
apply_to_all_workspaces - boolean - If true, this default-workspace subscription applies to events from all workspaces.
name - string - Event Subscription name.
enabled - boolean - Whether this Event Subscription can dispatch events.
event_types - array(string) - Event type strings matched by this subscription. Blank means all event types.
filter - object - Structured event payload filter.
delivery_policy - object - Event Subscription delivery policy.
event_target_ids - array(int64) - Event Target IDs this subscription sends to.
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 |
# File 'lib/files.com/models/event_subscription.rb', line 233 def self.update(id, params = {}, = {}) 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: event_channel_id must be an Integer") if params[:event_channel_id] and !params[:event_channel_id].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: workspace_id must be an Integer") if params[:workspace_id] and !params[:workspace_id].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: name must be an String") if params[:name] and !params[:name].is_a?(String) raise InvalidParameterError.new("Bad parameter: event_types must be an Array") if params[:event_types] and !params[:event_types].is_a?(Array) raise InvalidParameterError.new("Bad parameter: filter must be an Hash") if params[:filter] and !params[:filter].is_a?(Hash) raise InvalidParameterError.new("Bad parameter: delivery_policy must be an Hash") if params[:delivery_policy] and !params[:delivery_policy].is_a?(Hash) raise InvalidParameterError.new("Bad parameter: event_target_ids must be an Array") if params[:event_target_ids] and !params[:event_target_ids].is_a?(Array) raise MissingParameterError.new("Parameter missing: id") unless params[:id] response, = Api.send_request("/event_subscriptions/#{params[:id]}", :patch, params, ) EventSubscription.new(response.data, ) end |
Instance Method Details
#apply_to_all_workspaces ⇒ Object
boolean - If true, this default-workspace subscription applies to events from all workspaces.
40 41 42 |
# File 'lib/files.com/models/event_subscription.rb', line 40 def apply_to_all_workspaces @attributes[:apply_to_all_workspaces] end |
#apply_to_all_workspaces=(value) ⇒ Object
44 45 46 |
# File 'lib/files.com/models/event_subscription.rb', line 44 def apply_to_all_workspaces=(value) @attributes[:apply_to_all_workspaces] = value end |
#created_at ⇒ Object
date-time - Event Subscription create date/time.
103 104 105 |
# File 'lib/files.com/models/event_subscription.rb', line 103 def created_at @attributes[:created_at] end |
#delete(params = {}) ⇒ Object
137 138 139 140 141 142 143 144 145 |
# File 'lib/files.com/models/event_subscription.rb', line 137 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("/event_subscriptions/#{@attributes[:id]}", :delete, params, @options) end |
#delivery_policy ⇒ Object
object - Event Subscription delivery policy.
85 86 87 |
# File 'lib/files.com/models/event_subscription.rb', line 85 def delivery_policy @attributes[:delivery_policy] end |
#delivery_policy=(value) ⇒ Object
89 90 91 |
# File 'lib/files.com/models/event_subscription.rb', line 89 def delivery_policy=(value) @attributes[:delivery_policy] = value end |
#destroy(params = {}) ⇒ Object
147 148 149 150 |
# File 'lib/files.com/models/event_subscription.rb', line 147 def destroy(params = {}) delete(params) nil end |
#enabled ⇒ Object
boolean - Whether this Event Subscription can dispatch events.
58 59 60 |
# File 'lib/files.com/models/event_subscription.rb', line 58 def enabled @attributes[:enabled] end |
#enabled=(value) ⇒ Object
62 63 64 |
# File 'lib/files.com/models/event_subscription.rb', line 62 def enabled=(value) @attributes[:enabled] = value end |
#event_channel_id ⇒ Object
int64 - Event Channel ID
22 23 24 |
# File 'lib/files.com/models/event_subscription.rb', line 22 def event_channel_id @attributes[:event_channel_id] end |
#event_channel_id=(value) ⇒ Object
26 27 28 |
# File 'lib/files.com/models/event_subscription.rb', line 26 def event_channel_id=(value) @attributes[:event_channel_id] = value end |
#event_target_ids ⇒ Object
array(int64) - Event Target IDs this subscription sends to.
94 95 96 |
# File 'lib/files.com/models/event_subscription.rb', line 94 def event_target_ids @attributes[:event_target_ids] end |
#event_target_ids=(value) ⇒ Object
98 99 100 |
# File 'lib/files.com/models/event_subscription.rb', line 98 def event_target_ids=(value) @attributes[:event_target_ids] = value end |
#event_types ⇒ Object
array(string) - Event type strings matched by this subscription. Blank means all event types.
67 68 69 |
# File 'lib/files.com/models/event_subscription.rb', line 67 def event_types @attributes[:event_types] end |
#event_types=(value) ⇒ Object
71 72 73 |
# File 'lib/files.com/models/event_subscription.rb', line 71 def event_types=(value) @attributes[:event_types] = value end |
#filter ⇒ Object
object - Structured event payload filter.
76 77 78 |
# File 'lib/files.com/models/event_subscription.rb', line 76 def filter @attributes[:filter] end |
#filter=(value) ⇒ Object
80 81 82 |
# File 'lib/files.com/models/event_subscription.rb', line 80 def filter=(value) @attributes[:filter] = value end |
#id ⇒ Object
int64 - Event Subscription ID
13 14 15 |
# File 'lib/files.com/models/event_subscription.rb', line 13 def id @attributes[:id] end |
#id=(value) ⇒ Object
17 18 19 |
# File 'lib/files.com/models/event_subscription.rb', line 17 def id=(value) @attributes[:id] = value end |
#name ⇒ Object
string - Event Subscription name.
49 50 51 |
# File 'lib/files.com/models/event_subscription.rb', line 49 def name @attributes[:name] end |
#name=(value) ⇒ Object
53 54 55 |
# File 'lib/files.com/models/event_subscription.rb', line 53 def name=(value) @attributes[:name] = value end |
#save ⇒ Object
152 153 154 155 156 157 158 159 160 161 |
# File 'lib/files.com/models/event_subscription.rb', line 152 def save if @attributes[:id] new_obj = update(@attributes) else new_obj = EventSubscription.create(@attributes, @options) end @attributes = new_obj.attributes true end |
#update(params = {}) ⇒ Object
Parameters:
event_channel_id - int64 - Event Channel ID
workspace_id - int64 - Workspace ID. 0 means the default workspace or site-wide.
apply_to_all_workspaces - boolean - If true, this default-workspace subscription applies to events from all workspaces.
name - string - Event Subscription name.
enabled - boolean - Whether this Event Subscription can dispatch events.
event_types - array(string) - Event type strings matched by this subscription. Blank means all event types.
filter - object - Structured event payload filter.
delivery_policy - object - Event Subscription delivery policy.
event_target_ids - array(int64) - Event Target IDs this subscription sends to.
122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/files.com/models/event_subscription.rb', line 122 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: event_channel_id must be an Integer") if params[:event_channel_id] and !params[:event_channel_id].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: workspace_id must be an Integer") if params[:workspace_id] and !params[:workspace_id].is_a?(Integer) raise InvalidParameterError.new("Bad parameter: name must be an String") if params[:name] and !params[:name].is_a?(String) raise InvalidParameterError.new("Bad parameter: event_types must be an Array") if params[:event_types] and !params[:event_types].is_a?(Array) raise InvalidParameterError.new("Bad parameter: event_target_ids must be an Array") if params[:event_target_ids] and !params[:event_target_ids].is_a?(Array) raise MissingParameterError.new("Parameter missing: id") unless params[:id] Api.send_request("/event_subscriptions/#{@attributes[:id]}", :patch, params, @options) end |
#updated_at ⇒ Object
date-time - Event Subscription update date/time.
108 109 110 |
# File 'lib/files.com/models/event_subscription.rb', line 108 def updated_at @attributes[:updated_at] end |
#workspace_id ⇒ Object
int64 - Workspace ID. 0 means the default workspace or site-wide.
31 32 33 |
# File 'lib/files.com/models/event_subscription.rb', line 31 def workspace_id @attributes[:workspace_id] end |
#workspace_id=(value) ⇒ Object
35 36 37 |
# File 'lib/files.com/models/event_subscription.rb', line 35 def workspace_id=(value) @attributes[:workspace_id] = value end |