Class: Twilio::REST::Chat::V2::ServiceContext::ChannelContext
- Inherits:
-
InstanceContext
- Object
- InstanceContext
- Twilio::REST::Chat::V2::ServiceContext::ChannelContext
- Defined in:
- lib/twilio-ruby/rest/chat/v2/service/channel.rb,
lib/twilio-ruby/rest/chat/v2/service/channel/invite.rb,
lib/twilio-ruby/rest/chat/v2/service/channel/member.rb,
lib/twilio-ruby/rest/chat/v2/service/channel/message.rb,
lib/twilio-ruby/rest/chat/v2/service/channel/webhook.rb
Defined Under Namespace
Classes: InviteContext, InviteInstance, InviteList, InvitePage, MemberContext, MemberInstance, MemberList, MemberPage, MessageContext, MessageInstance, MessageList, MessagePage, WebhookContext, WebhookInstance, WebhookList, WebhookPage
Instance Method Summary collapse
-
#delete(x_twilio_webhook_enabled: :unset) ⇒ Boolean
Delete the ChannelInstance.
-
#fetch ⇒ ChannelInstance
Fetch the ChannelInstance.
-
#initialize(version, service_sid, sid) ⇒ ChannelContext
constructor
Initialize the ChannelContext.
-
#inspect ⇒ Object
Provide a detailed, user friendly representation.
-
#invites(sid = :unset) ⇒ InviteList, InviteContext
Access the invites.
-
#members(sid = :unset) ⇒ MemberList, MemberContext
Access the members.
-
#messages(sid = :unset) ⇒ MessageList, MessageContext
Access the messages.
-
#to_s ⇒ Object
Provide a user friendly representation.
-
#update(friendly_name: :unset, unique_name: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, created_by: :unset, x_twilio_webhook_enabled: :unset) ⇒ ChannelInstance
Update the ChannelInstance.
-
#webhooks(sid = :unset) ⇒ WebhookList, WebhookContext
Access the webhooks.
Constructor Details
#initialize(version, service_sid, sid) ⇒ ChannelContext
Initialize the ChannelContext
192 193 194 195 196 197 198 199 200 201 202 203 204 |
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 192 def initialize(version, service_sid, sid) super(version) # Path Solution @solution = { service_sid: service_sid, sid: sid, } @uri = "/Services/#{@solution[:service_sid]}/Channels/#{@solution[:sid]}" # Dependents @webhooks = nil @members = nil @messages = nil @invites = nil end |
Instance Method Details
#delete(x_twilio_webhook_enabled: :unset) ⇒ Boolean
Delete the ChannelInstance
209 210 211 212 213 214 215 216 217 218 |
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 209 def delete( x_twilio_webhook_enabled: :unset ) headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) @version.delete('DELETE', @uri, headers: headers) end |
#fetch ⇒ ChannelInstance
Fetch the ChannelInstance
223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 223 def fetch headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', }) payload = @version.fetch('GET', @uri, headers: headers) ChannelInstance.new( @version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], ) end |
#inspect ⇒ Object
Provide a detailed, user friendly representation
370 371 372 373 |
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 370 def inspect context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') "#<Twilio.Chat.V2.ChannelContext #{context}>" end |
#invites(sid = :unset) ⇒ InviteList, InviteContext
Access the invites
345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 |
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 345 def invites(sid=:unset) raise ArgumentError, 'sid cannot be nil' if sid.nil? if sid != :unset return InviteContext.new(@version, @solution[:service_sid], @solution[:sid],sid ) end unless @invites @invites = InviteList.new( @version, service_sid: @solution[:service_sid], channel_sid: @solution[:sid], ) end @invites end |
#members(sid = :unset) ⇒ MemberList, MemberContext
Access the members
307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 307 def members(sid=:unset) raise ArgumentError, 'sid cannot be nil' if sid.nil? if sid != :unset return MemberContext.new(@version, @solution[:service_sid], @solution[:sid],sid ) end unless @members @members = MemberList.new( @version, service_sid: @solution[:service_sid], channel_sid: @solution[:sid], ) end @members end |
#messages(sid = :unset) ⇒ MessageList, MessageContext
Access the messages
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 |
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 326 def (sid=:unset) raise ArgumentError, 'sid cannot be nil' if sid.nil? if sid != :unset return MessageContext.new(@version, @solution[:service_sid], @solution[:sid],sid ) end unless @messages @messages = MessageList.new( @version, service_sid: @solution[:service_sid], channel_sid: @solution[:sid], ) end @messages end |
#to_s ⇒ Object
Provide a user friendly representation
363 364 365 366 |
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 363 def to_s context = @solution.map{|k, v| "#{k}: #{v}"}.join(',') "#<Twilio.Chat.V2.ChannelContext #{context}>" end |
#update(friendly_name: :unset, unique_name: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, created_by: :unset, x_twilio_webhook_enabled: :unset) ⇒ ChannelInstance
Update the ChannelInstance
250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 250 def update( friendly_name: :unset, unique_name: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, created_by: :unset, x_twilio_webhook_enabled: :unset ) data = Twilio::Values.of({ 'FriendlyName' => friendly_name, 'UniqueName' => unique_name, 'Attributes' => attributes, 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), 'CreatedBy' => created_by, }) headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) payload = @version.update('POST', @uri, data: data, headers: headers) ChannelInstance.new( @version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], ) end |
#webhooks(sid = :unset) ⇒ WebhookList, WebhookContext
Access the webhooks
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 288 def webhooks(sid=:unset) raise ArgumentError, 'sid cannot be nil' if sid.nil? if sid != :unset return WebhookContext.new(@version, @solution[:service_sid], @solution[:sid],sid ) end unless @webhooks @webhooks = WebhookList.new( @version, service_sid: @solution[:service_sid], channel_sid: @solution[:sid], ) end @webhooks end |