Class: Twilio::REST::Chat::V2::ServiceContext::ChannelInstance

Inherits:
InstanceResource
  • Object
show all
Defined in:
lib/twilio-ruby/rest/chat/v2/service/channel.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, payload, service_sid: nil, sid: nil) ⇒ ChannelInstance

Initialize the ChannelInstance

Parameters:

  • version (Version)

    Version that contains the resource

  • payload (Hash)

    payload that contains response from Twilio

  • account_sid (String)

    The SID of the Account that created this Channel resource.

  • sid (String) (defaults to: nil)

    The SID of the Call resource to fetch.



396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 396

def initialize(version, payload , service_sid: nil, sid: nil)
    super(version)
    
    # Marshaled Properties
    @properties = { 
        'sid' => payload['sid'],
        'account_sid' => payload['account_sid'],
        'service_sid' => payload['service_sid'],
        'friendly_name' => payload['friendly_name'],
        'unique_name' => payload['unique_name'],
        'attributes' => payload['attributes'],
        'type' => payload['type'],
        'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
        'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
        'created_by' => payload['created_by'],
        'members_count' => payload['members_count'] == nil ? payload['members_count'] : payload['members_count'].to_i,
        'messages_count' => payload['messages_count'] == nil ? payload['messages_count'] : payload['messages_count'].to_i,
        'url' => payload['url'],
        'links' => payload['links'],
    }

    # Context
    @instance_context = nil
    @params = { 'service_sid' => service_sid  || @properties['service_sid']  ,'sid' => sid  || @properties['sid']  , }
end

Instance Method Details

#account_sidString

Returns The SID of the [Account](www.twilio.com/docs/iam/api/account) that created the Channel resource.

Returns:



441
442
443
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 441

def 
    @properties['account_sid']
end

#attributesString

Returns The JSON string that stores application-specific data. If attributes have not been set, ‘{}` is returned.

Returns:

  • (String)

    The JSON string that stores application-specific data. If attributes have not been set, ‘{}` is returned.



465
466
467
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 465

def attributes
    @properties['attributes']
end

#contextChannelContext

Generate an instance context for the instance, the context is capable of performing various actions. All instance actions are proxied to the context

Returns:



426
427
428
429
430
431
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 426

def context
    unless @instance_context
        @instance_context = ChannelContext.new(@version , @params['service_sid'], @params['sid'])
    end
    @instance_context
end

#created_byString

Returns The ‘identity` of the User that created the channel. If the Channel was created by using the API, the value is `system`.

Returns:

  • (String)

    The ‘identity` of the User that created the channel. If the Channel was created by using the API, the value is `system`.



489
490
491
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 489

def created_by
    @properties['created_by']
end

#date_createdTime

Returns The date and time in GMT when the resource was created specified in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format.

Returns:



477
478
479
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 477

def date_created
    @properties['date_created']
end

#date_updatedTime

Returns The date and time in GMT when the resource was last updated specified in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format.

Returns:



483
484
485
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 483

def date_updated
    @properties['date_updated']
end

#delete(x_twilio_webhook_enabled: :unset) ⇒ Boolean

Delete the ChannelInstance

Parameters:

  • x_twilio_webhook_enabled (ChannelEnumWebhookEnabledType) (defaults to: :unset)

    The X-Twilio-Webhook-Enabled HTTP request header

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



521
522
523
524
525
526
527
528
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 521

def delete(
    x_twilio_webhook_enabled: :unset
)

    context.delete(
        x_twilio_webhook_enabled: x_twilio_webhook_enabled, 
    )
end

#fetchChannelInstance

Fetch the ChannelInstance

Returns:



533
534
535
536
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 533

def fetch

    context.fetch
end

#friendly_nameString

Returns The string that you assigned to describe the resource.

Returns:

  • (String)

    The string that you assigned to describe the resource.



453
454
455
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 453

def friendly_name
    @properties['friendly_name']
end

#inspectObject

Provide a detailed, user friendly representation



606
607
608
609
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 606

def inspect
    values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
    "<Twilio.Chat.V2.ChannelInstance #{values}>"
end

#invitesinvites

Access the invites

Returns:



593
594
595
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 593

def invites
    context.invites
end

Returns The absolute URLs of the [Members](www.twilio.com/docs/chat/rest/member-resource), [Messages](www.twilio.com/docs/chat/rest/message-resource), [Invites](www.twilio.com/docs/chat/rest/invite-resource), Webhooks and, if it exists, the last [Message](www.twilio.com/docs/chat/rest/message-resource) for the Channel.

Returns:



513
514
515
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 513

def links
    @properties['links']
end

#membersmembers

Access the members

Returns:



579
580
581
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 579

def members
    context.members
end

#members_countString

Returns The number of Members in the Channel.

Returns:

  • (String)

    The number of Members in the Channel.



495
496
497
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 495

def members_count
    @properties['members_count']
end

#messagesmessages

Access the messages

Returns:



586
587
588
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 586

def messages
    context.messages
end

#messages_countString

Returns The number of Messages that have been passed in the Channel.

Returns:

  • (String)

    The number of Messages that have been passed in the Channel.



501
502
503
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 501

def messages_count
    @properties['messages_count']
end

#service_sidString

Returns The SID of the [Service](www.twilio.com/docs/chat/rest/service-resource) the Channel resource is associated with.

Returns:



447
448
449
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 447

def service_sid
    @properties['service_sid']
end

#sidString

Returns The unique string that we created to identify the Channel resource.

Returns:

  • (String)

    The unique string that we created to identify the Channel resource.



435
436
437
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 435

def sid
    @properties['sid']
end

#to_sObject

Provide a user friendly representation



599
600
601
602
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 599

def to_s
    values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
    "<Twilio.Chat.V2.ChannelInstance #{values}>"
end

#typeChannelType

Returns:

  • (ChannelType)


471
472
473
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 471

def type
    @properties['type']
end

#unique_nameString

Returns 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.

Returns:

  • (String)

    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.



459
460
461
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 459

def unique_name
    @properties['unique_name']
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

Parameters:

  • friendly_name (String) (defaults to: :unset)

    A descriptive string that you create to describe the resource. It can be up to 256 characters long.

  • unique_name (String) (defaults to: :unset)

    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.

  • attributes (String) (defaults to: :unset)

    A valid JSON string that contains application-specific data.

  • date_created (Time) (defaults to: :unset)

    The date, specified in [ISO 8601](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.

  • date_updated (Time) (defaults to: :unset)

    The date, specified in [ISO 8601](en.wikipedia.org/wiki/ISO_8601) format, to assign to the resource as the date it was last updated.

  • created_by (String) (defaults to: :unset)

    The ‘identity` of the User that created the channel. Default is: `system`.

  • x_twilio_webhook_enabled (ChannelEnumWebhookEnabledType) (defaults to: :unset)

    The X-Twilio-Webhook-Enabled HTTP request header

Returns:



548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 548

def update(
    friendly_name: :unset, 
    unique_name: :unset, 
    attributes: :unset, 
    date_created: :unset, 
    date_updated: :unset, 
    created_by: :unset, 
    x_twilio_webhook_enabled: :unset
)

    context.update(
        friendly_name: friendly_name, 
        unique_name: unique_name, 
        attributes: attributes, 
        date_created: date_created, 
        date_updated: date_updated, 
        created_by: created_by, 
        x_twilio_webhook_enabled: x_twilio_webhook_enabled, 
    )
end

#urlString

Returns The absolute URL of the Channel resource.

Returns:

  • (String)

    The absolute URL of the Channel resource.



507
508
509
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 507

def url
    @properties['url']
end

#webhookswebhooks

Access the webhooks

Returns:



572
573
574
# File 'lib/twilio-ruby/rest/chat/v2/service/channel.rb', line 572

def webhooks
    context.webhooks
end