class Twilio::REST::Chat::V2::ServiceContext::ChannelContext
Public Class Methods
Initialize the ChannelContext
@param [Version] version Version
that contains the resource @param [String] service_sid The SID of the
{Service}[https://www.twilio.com/docs/chat/rest/service-resource] to fetch the Channel resource from.
@param [String] sid The SID of the Channel resource to fetch. This value can be
either the `sid` or the `unique_name` of the Channel resource to fetch.
@return [ChannelContext] ChannelContext
Twilio::REST::InstanceContext::new
# File lib/twilio-ruby/rest/chat/v2/service/channel.rb 207 def initialize(version, service_sid, sid) 208 super(version) 209 210 # Path Solution 211 @solution = {service_sid: service_sid, sid: sid, } 212 @uri = "/Services/#{@solution[:service_sid]}/Channels/#{@solution[:sid]}" 213 214 # Dependents 215 @members = nil 216 @messages = nil 217 @invites = nil 218 @webhooks = nil 219 end
Public Instance Methods
Delete the ChannelInstance
@param [channel.WebhookEnabledType] x_twilio_webhook_enabled The
X-Twilio-Webhook-Enabled HTTP request header
@return [Boolean] true if delete succeeds, false otherwise
# File lib/twilio-ruby/rest/chat/v2/service/channel.rb 235 def delete(x_twilio_webhook_enabled: :unset) 236 headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) 237 238 @version.delete('DELETE', @uri, headers: headers) 239 end
Fetch the ChannelInstance
@return [ChannelInstance] Fetched ChannelInstance
# File lib/twilio-ruby/rest/chat/v2/service/channel.rb 224 def fetch 225 payload = @version.fetch('GET', @uri) 226 227 ChannelInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], ) 228 end
Provide a detailed, user friendly representation
# File lib/twilio-ruby/rest/chat/v2/service/channel.rb 377 def inspect 378 context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') 379 "#<Twilio.Chat.V2.ChannelContext #{context}>" 380 end
Access the invites @return [InviteList] @return [InviteContext] if sid was passed.
# File lib/twilio-ruby/rest/chat/v2/service/channel.rb 328 def invites(sid=:unset) 329 raise ArgumentError, 'sid cannot be nil' if sid.nil? 330 331 if sid != :unset 332 return InviteContext.new(@version, @solution[:service_sid], @solution[:sid], sid, ) 333 end 334 335 unless @invites 336 @invites = InviteList.new( 337 @version, 338 service_sid: @solution[:service_sid], 339 channel_sid: @solution[:sid], 340 ) 341 end 342 343 @invites 344 end
Access the members @return [MemberList] @return [MemberContext] if sid was passed.
# File lib/twilio-ruby/rest/chat/v2/service/channel.rb 284 def members(sid=:unset) 285 raise ArgumentError, 'sid cannot be nil' if sid.nil? 286 287 if sid != :unset 288 return MemberContext.new(@version, @solution[:service_sid], @solution[:sid], sid, ) 289 end 290 291 unless @members 292 @members = MemberList.new( 293 @version, 294 service_sid: @solution[:service_sid], 295 channel_sid: @solution[:sid], 296 ) 297 end 298 299 @members 300 end
Access the messages @return [MessageList] @return [MessageContext] if sid was passed.
# File lib/twilio-ruby/rest/chat/v2/service/channel.rb 306 def messages(sid=:unset) 307 raise ArgumentError, 'sid cannot be nil' if sid.nil? 308 309 if sid != :unset 310 return MessageContext.new(@version, @solution[:service_sid], @solution[:sid], sid, ) 311 end 312 313 unless @messages 314 @messages = MessageList.new( 315 @version, 316 service_sid: @solution[:service_sid], 317 channel_sid: @solution[:sid], 318 ) 319 end 320 321 @messages 322 end
Provide a user friendly representation
# File lib/twilio-ruby/rest/chat/v2/service/channel.rb 370 def to_s 371 context = @solution.map {|k, v| "#{k}: #{v}"}.join(',') 372 "#<Twilio.Chat.V2.ChannelContext #{context}>" 373 end
Update the ChannelInstance
@param [String] friendly_name A descriptive string that you create to describe
the resource. It can be up to 256 characters long.
@param [String] unique_name An application-defined string that uniquely
identifies the resource. It can be used to address the resource in place of the resource's `sid` in the URL. This value must be 256 characters or less in length and unique within the Service.
@param [String] attributes A valid JSON string that contains
application-specific data.
@param [Time] date_created The date, specified in {ISO
8601}[https://en.wikipedia.org/wiki/ISO_8601] format, to assign to the resource as the date it was created. The default value is the current time set by the Chat service. Note that this should only be used in cases where a Channel is being recreated from a backup/separate source.
@param [Time] date_updated The date, specified in {ISO
8601}[https://en.wikipedia.org/wiki/ISO_8601] format, to assign to the resource as the date it was last updated.
@param [String] created_by The `identity` of the User that created the channel.
Default is: `system`.
@param [channel.WebhookEnabledType] x_twilio_webhook_enabled The
X-Twilio-Webhook-Enabled HTTP request header
@return [ChannelInstance] Updated ChannelInstance
# File lib/twilio-ruby/rest/chat/v2/service/channel.rb 264 def update(friendly_name: :unset, unique_name: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, created_by: :unset, x_twilio_webhook_enabled: :unset) 265 data = Twilio::Values.of({ 266 'FriendlyName' => friendly_name, 267 'UniqueName' => unique_name, 268 'Attributes' => attributes, 269 'DateCreated' => Twilio.serialize_iso8601_datetime(date_created), 270 'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated), 271 'CreatedBy' => created_by, 272 }) 273 headers = Twilio::Values.of({'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, }) 274 275 payload = @version.update('POST', @uri, data: data, headers: headers) 276 277 ChannelInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], ) 278 end
Access the webhooks @return [WebhookList] @return [WebhookContext] if sid was passed.
# File lib/twilio-ruby/rest/chat/v2/service/channel.rb 350 def webhooks(sid=:unset) 351 raise ArgumentError, 'sid cannot be nil' if sid.nil? 352 353 if sid != :unset 354 return WebhookContext.new(@version, @solution[:service_sid], @solution[:sid], sid, ) 355 end 356 357 unless @webhooks 358 @webhooks = WebhookList.new( 359 @version, 360 service_sid: @solution[:service_sid], 361 channel_sid: @solution[:sid], 362 ) 363 end 364 365 @webhooks 366 end