Class: Twilio::REST::Chat::V3::ChannelContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/chat/v3/channel.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid, sid) ⇒ ChannelContext

Initialize the ChannelContext

Parameters:

  • version (Version)

    Version that contains the resource

  • service_sid (String)

    The unique SID identifier of the Service.

  • sid (String)

    A 34 character string that uniquely identifies this Channel.



49
50
51
52
53
54
55
56
57
# File 'lib/twilio-ruby/rest/chat/v3/channel.rb', line 49

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]}"

    
end

Instance Method Details

#inspectObject

Provide a detailed, user friendly representation



95
96
97
98
# File 'lib/twilio-ruby/rest/chat/v3/channel.rb', line 95

def inspect
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Chat.V3.ChannelContext #{context}>"
end

#to_sObject

Provide a user friendly representation



88
89
90
91
# File 'lib/twilio-ruby/rest/chat/v3/channel.rb', line 88

def to_s
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Chat.V3.ChannelContext #{context}>"
end

#update(type: :unset, messaging_service_sid: :unset, x_twilio_webhook_enabled: :unset) ⇒ ChannelInstance

Update the ChannelInstance

Parameters:

  • type (ChannelType) (defaults to: :unset)
  • messaging_service_sid (String) (defaults to: :unset)

    The unique ID of the [Messaging Service](www.twilio.com/docs/messaging/api/service-resource) this channel belongs to.

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

    The X-Twilio-Webhook-Enabled HTTP request header

Returns:



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/twilio-ruby/rest/chat/v3/channel.rb', line 64

def update(
    type: :unset, 
    messaging_service_sid: :unset, 
    x_twilio_webhook_enabled: :unset
)

    data = Twilio::Values.of({
        'Type' => type,
        'MessagingServiceSid' => messaging_service_sid,
    })

    headers = Twilio::Values.of({ '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