Class: Files::EventChannel
- Inherits:
-
Object
- Object
- Files::EventChannel
- Defined in:
- lib/files.com/models/event_channel.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: name (required) - string - Event Channel name.
- .delete(id, params = {}, options = {}) ⇒ Object
- .destroy(id, params = {}, options = {}) ⇒ Object
-
.find(id, params = {}, options = {}) ⇒ Object
Parameters: id (required) - int64 - Event Channel ID.
- .get(id, params = {}, options = {}) ⇒ Object
-
.list(params = {}, options = {}) ⇒ Object
Parameters: cursor - string - Used for pagination.
-
.update(id, params = {}, options = {}) ⇒ Object
Parameters: name - string - Event Channel name.
Instance Method Summary collapse
-
#created_at ⇒ Object
date-time - Event Channel create date/time.
-
#default_channel ⇒ Object
boolean - Whether this Event Channel is the default destination for newly published events.
- #default_channel=(value) ⇒ Object
- #delete(params = {}) ⇒ Object
-
#description ⇒ Object
string - Event Channel description.
- #description=(value) ⇒ Object
- #destroy(params = {}) ⇒ Object
-
#enabled ⇒ Object
boolean - Whether this Event Channel can dispatch events.
- #enabled=(value) ⇒ Object
-
#id ⇒ Object
int64 - Event Channel ID.
- #id=(value) ⇒ Object
-
#initialize(attributes = {}, options = {}) ⇒ EventChannel
constructor
A new instance of EventChannel.
-
#name ⇒ Object
string - Event Channel name.
- #name=(value) ⇒ Object
- #save ⇒ Object
-
#update(params = {}) ⇒ Object
Parameters: name - string - Event Channel name.
-
#updated_at ⇒ Object
date-time - Event Channel update date/time.
-
#workspace_id ⇒ Object
int64 - Workspace ID.
- #workspace_id=(value) ⇒ Object
Constructor Details
#initialize(attributes = {}, options = {}) ⇒ EventChannel
Returns a new instance of EventChannel.
7 8 9 10 |
# File 'lib/files.com/models/event_channel.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_channel.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_channel.rb', line 5 def @options end |
Class Method Details
.all(params = {}, options = {}) ⇒ Object
137 138 139 |
# File 'lib/files.com/models/event_channel.rb', line 137 def self.all(params = {}, = {}) list(params, ) end |
.create(params = {}, options = {}) ⇒ Object
Parameters:
name (required) - string - Event Channel name.
workspace_id - int64 - Workspace ID. 0 means the default workspace.
description - string - Event Channel description.
enabled - boolean - Whether this Event Channel can dispatch events.
default_channel - boolean - Whether this Event Channel is the default destination for newly published events.
163 164 165 166 167 168 169 170 171 |
# File 'lib/files.com/models/event_channel.rb', line 163 def self.create(params = {}, = {}) raise InvalidParameterError.new("Bad parameter: name must be an String") if params[:name] and !params[:name].is_a?(String) 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: description must be an String") if params[:description] and !params[:description].is_a?(String) raise MissingParameterError.new("Parameter missing: name") unless params[:name] response, = Api.send_request("/event_channels", :post, params, ) EventChannel.new(response.data, ) end |
.delete(id, params = {}, options = {}) ⇒ Object
192 193 194 195 196 197 198 199 200 |
# File 'lib/files.com/models/event_channel.rb', line 192 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_channels/#{params[:id]}", :delete, params, ) nil end |
.destroy(id, params = {}, options = {}) ⇒ Object
202 203 204 205 |
# File 'lib/files.com/models/event_channel.rb', line 202 def self.destroy(id, params = {}, = {}) delete(id, params, ) nil end |
.find(id, params = {}, options = {}) ⇒ Object
Parameters:
id (required) - int64 - Event Channel ID.
143 144 145 146 147 148 149 150 151 |
# File 'lib/files.com/models/event_channel.rb', line 143 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_channels/#{params[:id]}", :get, params, ) EventChannel.new(response.data, ) end |
.get(id, params = {}, options = {}) ⇒ Object
153 154 155 |
# File 'lib/files.com/models/event_channel.rb', line 153 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: 10000, 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 `name`, `enabled`, `default_channel` or `workspace_id`.
filter - object - If set, return records where the specified field is equal to the supplied value. Valid fields are `enabled`, `default_channel` or `workspace_id`. Valid field combinations are `[ workspace_id, enabled ]` and `[ workspace_id, default_channel ]`.
126 127 128 129 130 131 132 133 134 135 |
# File 'lib/files.com/models/event_channel.rb', line 126 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(EventChannel, params) do Api.send_request("/event_channels", :get, params, ) end end |
.update(id, params = {}, options = {}) ⇒ Object
Parameters:
name - string - Event Channel name.
workspace_id - int64 - Workspace ID. 0 means the default workspace.
description - string - Event Channel description.
enabled - boolean - Whether this Event Channel can dispatch events.
default_channel - boolean - Whether this Event Channel is the default destination for newly published events.
179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/files.com/models/event_channel.rb', line 179 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: name must be an String") if params[:name] and !params[:name].is_a?(String) 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: description must be an String") if params[:description] and !params[:description].is_a?(String) raise MissingParameterError.new("Parameter missing: id") unless params[:id] response, = Api.send_request("/event_channels/#{params[:id]}", :patch, params, ) EventChannel.new(response.data, ) end |
Instance Method Details
#created_at ⇒ Object
date-time - Event Channel create date/time.
67 68 69 |
# File 'lib/files.com/models/event_channel.rb', line 67 def created_at @attributes[:created_at] end |
#default_channel ⇒ Object
boolean - Whether this Event Channel is the default destination for newly published events.
58 59 60 |
# File 'lib/files.com/models/event_channel.rb', line 58 def default_channel @attributes[:default_channel] end |
#default_channel=(value) ⇒ Object
62 63 64 |
# File 'lib/files.com/models/event_channel.rb', line 62 def default_channel=(value) @attributes[:default_channel] = value end |
#delete(params = {}) ⇒ Object
95 96 97 98 99 100 101 102 103 |
# File 'lib/files.com/models/event_channel.rb', line 95 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_channels/#{@attributes[:id]}", :delete, params, @options) end |
#description ⇒ Object
string - Event Channel description.
40 41 42 |
# File 'lib/files.com/models/event_channel.rb', line 40 def description @attributes[:description] end |
#description=(value) ⇒ Object
44 45 46 |
# File 'lib/files.com/models/event_channel.rb', line 44 def description=(value) @attributes[:description] = value end |
#destroy(params = {}) ⇒ Object
105 106 107 108 |
# File 'lib/files.com/models/event_channel.rb', line 105 def destroy(params = {}) delete(params) nil end |
#enabled ⇒ Object
boolean - Whether this Event Channel can dispatch events.
49 50 51 |
# File 'lib/files.com/models/event_channel.rb', line 49 def enabled @attributes[:enabled] end |
#enabled=(value) ⇒ Object
53 54 55 |
# File 'lib/files.com/models/event_channel.rb', line 53 def enabled=(value) @attributes[:enabled] = value end |
#id ⇒ Object
int64 - Event Channel ID
13 14 15 |
# File 'lib/files.com/models/event_channel.rb', line 13 def id @attributes[:id] end |
#id=(value) ⇒ Object
17 18 19 |
# File 'lib/files.com/models/event_channel.rb', line 17 def id=(value) @attributes[:id] = value end |
#name ⇒ Object
string - Event Channel name.
22 23 24 |
# File 'lib/files.com/models/event_channel.rb', line 22 def name @attributes[:name] end |
#name=(value) ⇒ Object
26 27 28 |
# File 'lib/files.com/models/event_channel.rb', line 26 def name=(value) @attributes[:name] = value end |
#save ⇒ Object
110 111 112 113 114 115 116 117 118 119 |
# File 'lib/files.com/models/event_channel.rb', line 110 def save if @attributes[:id] new_obj = update(@attributes) else new_obj = EventChannel.create(@attributes, @options) end @attributes = new_obj.attributes true end |
#update(params = {}) ⇒ Object
Parameters:
name - string - Event Channel name.
workspace_id - int64 - Workspace ID. 0 means the default workspace.
description - string - Event Channel description.
enabled - boolean - Whether this Event Channel can dispatch events.
default_channel - boolean - Whether this Event Channel is the default destination for newly published events.
82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/files.com/models/event_channel.rb', line 82 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: name must be an String") if params[:name] and !params[:name].is_a?(String) 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: description must be an String") if params[:description] and !params[:description].is_a?(String) raise MissingParameterError.new("Parameter missing: id") unless params[:id] Api.send_request("/event_channels/#{@attributes[:id]}", :patch, params, @options) end |
#updated_at ⇒ Object
date-time - Event Channel update date/time.
72 73 74 |
# File 'lib/files.com/models/event_channel.rb', line 72 def updated_at @attributes[:updated_at] end |
#workspace_id ⇒ Object
int64 - Workspace ID. 0 means the default workspace.
31 32 33 |
# File 'lib/files.com/models/event_channel.rb', line 31 def workspace_id @attributes[:workspace_id] end |
#workspace_id=(value) ⇒ Object
35 36 37 |
# File 'lib/files.com/models/event_channel.rb', line 35 def workspace_id=(value) @attributes[:workspace_id] = value end |