class Twilio::REST::Chat::V2::ServiceContext::ChannelInstance

Public Class Methods

new(version, payload, service_sid: nil, sid: nil) click to toggle source

Initialize the ChannelInstance @param [Version] version Version that contains the resource @param [Hash] payload payload that contains response from Twilio @param [String] service_sid The SID of the

{Service}[https://www.twilio.com/docs/chat/rest/service-resource] the Channel
resource is associated with.

@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 [ChannelInstance] ChannelInstance

Calls superclass method Twilio::REST::InstanceResource::new
    # File lib/twilio-ruby/rest/chat/v2/service/channel.rb
394 def initialize(version, payload, service_sid: nil, sid: nil)
395   super(version)
396 
397   # Marshaled Properties
398   @properties = {
399       'sid' => payload['sid'],
400       'account_sid' => payload['account_sid'],
401       'service_sid' => payload['service_sid'],
402       'friendly_name' => payload['friendly_name'],
403       'unique_name' => payload['unique_name'],
404       'attributes' => payload['attributes'],
405       'type' => payload['type'],
406       'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
407       'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
408       'created_by' => payload['created_by'],
409       'members_count' => payload['members_count'].to_i,
410       'messages_count' => payload['messages_count'].to_i,
411       'url' => payload['url'],
412       'links' => payload['links'],
413   }
414 
415   # Context
416   @instance_context = nil
417   @params = {'service_sid' => service_sid, 'sid' => sid || @properties['sid'], }
418 end

Public Instance Methods

account_sid() click to toggle source

@return [String] The SID of the Account that created the resource

    # File lib/twilio-ruby/rest/chat/v2/service/channel.rb
439 def account_sid
440   @properties['account_sid']
441 end
attributes() click to toggle source

@return [String] The JSON string that stores application-specific data

    # File lib/twilio-ruby/rest/chat/v2/service/channel.rb
463 def attributes
464   @properties['attributes']
465 end
context() click to toggle source

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context @return [ChannelContext] ChannelContext for this ChannelInstance

    # File lib/twilio-ruby/rest/chat/v2/service/channel.rb
424 def context
425   unless @instance_context
426     @instance_context = ChannelContext.new(@version, @params['service_sid'], @params['sid'], )
427   end
428   @instance_context
429 end
created_by() click to toggle source

@return [String] The identity of the User that created the channel

    # File lib/twilio-ruby/rest/chat/v2/service/channel.rb
487 def created_by
488   @properties['created_by']
489 end
date_created() click to toggle source

@return [Time] The ISO 8601 date and time in GMT when the resource was created

    # File lib/twilio-ruby/rest/chat/v2/service/channel.rb
475 def date_created
476   @properties['date_created']
477 end
date_updated() click to toggle source

@return [Time] The ISO 8601 date and time in GMT when the resource was last updated

    # File lib/twilio-ruby/rest/chat/v2/service/channel.rb
481 def date_updated
482   @properties['date_updated']
483 end
delete(x_twilio_webhook_enabled: :unset) click to toggle source

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
527 def delete(x_twilio_webhook_enabled: :unset)
528   context.delete(x_twilio_webhook_enabled: x_twilio_webhook_enabled, )
529 end
fetch() click to toggle source

Fetch the ChannelInstance @return [ChannelInstance] Fetched ChannelInstance

    # File lib/twilio-ruby/rest/chat/v2/service/channel.rb
518 def fetch
519   context.fetch
520 end
friendly_name() click to toggle source

@return [String] The string that you assigned to describe the resource

    # File lib/twilio-ruby/rest/chat/v2/service/channel.rb
451 def friendly_name
452   @properties['friendly_name']
453 end
inspect() click to toggle source

Provide a detailed, user friendly representation

    # File lib/twilio-ruby/rest/chat/v2/service/channel.rb
603 def inspect
604   values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
605   "<Twilio.Chat.V2.ChannelInstance #{values}>"
606 end
invites() click to toggle source

Access the invites @return [invites] invites

    # File lib/twilio-ruby/rest/chat/v2/service/channel.rb
583 def invites
584   context.invites
585 end
members() click to toggle source

Access the members @return [members] members

    # File lib/twilio-ruby/rest/chat/v2/service/channel.rb
569 def members
570   context.members
571 end
members_count() click to toggle source

@return [String] The number of Members in the Channel

    # File lib/twilio-ruby/rest/chat/v2/service/channel.rb
493 def members_count
494   @properties['members_count']
495 end
messages() click to toggle source

Access the messages @return [messages] messages

    # File lib/twilio-ruby/rest/chat/v2/service/channel.rb
576 def messages
577   context.messages
578 end
messages_count() click to toggle source

@return [String] The number of Messages that have been passed in the Channel

    # File lib/twilio-ruby/rest/chat/v2/service/channel.rb
499 def messages_count
500   @properties['messages_count']
501 end
service_sid() click to toggle source

@return [String] The SID of the Service that the resource is associated with

    # File lib/twilio-ruby/rest/chat/v2/service/channel.rb
445 def service_sid
446   @properties['service_sid']
447 end
sid() click to toggle source

@return [String] The unique string that identifies the resource

    # File lib/twilio-ruby/rest/chat/v2/service/channel.rb
433 def sid
434   @properties['sid']
435 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/chat/v2/service/channel.rb
596 def to_s
597   values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
598   "<Twilio.Chat.V2.ChannelInstance #{values}>"
599 end
type() click to toggle source

@return [channel.ChannelType] The visibility of the channel. Can be: `public` or `private`

    # File lib/twilio-ruby/rest/chat/v2/service/channel.rb
469 def type
470   @properties['type']
471 end
unique_name() click to toggle source

@return [String] An application-defined string that uniquely identifies the resource

    # File lib/twilio-ruby/rest/chat/v2/service/channel.rb
457 def unique_name
458   @properties['unique_name']
459 end
update(friendly_name: :unset, unique_name: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, created_by: :unset, x_twilio_webhook_enabled: :unset) click to toggle source

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
554 def update(friendly_name: :unset, unique_name: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, created_by: :unset, x_twilio_webhook_enabled: :unset)
555   context.update(
556       friendly_name: friendly_name,
557       unique_name: unique_name,
558       attributes: attributes,
559       date_created: date_created,
560       date_updated: date_updated,
561       created_by: created_by,
562       x_twilio_webhook_enabled: x_twilio_webhook_enabled,
563   )
564 end
url() click to toggle source

@return [String] The absolute URL of the Channel resource

    # File lib/twilio-ruby/rest/chat/v2/service/channel.rb
505 def url
506   @properties['url']
507 end
webhooks() click to toggle source

Access the webhooks @return [webhooks] webhooks

    # File lib/twilio-ruby/rest/chat/v2/service/channel.rb
590 def webhooks
591   context.webhooks
592 end