class Twilio::REST::Chat::V1::ServiceContext::ChannelContext

Public Class Methods

new(version, service_sid, sid) click to toggle source

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/api/chat/rest/services] to fetch the
resource from.

@param [String] sid The Twilio-provided string that uniquely identifies the

Channel resource to fetch.

@return [ChannelContext] ChannelContext

Calls superclass method Twilio::REST::InstanceContext::new
    # File lib/twilio-ruby/rest/chat/v1/service/channel.rb
189 def initialize(version, service_sid, sid)
190   super(version)
191 
192   # Path Solution
193   @solution = {service_sid: service_sid, sid: sid, }
194   @uri = "/Services/#{@solution[:service_sid]}/Channels/#{@solution[:sid]}"
195 
196   # Dependents
197   @members = nil
198   @messages = nil
199   @invites = nil
200 end

Public Instance Methods

delete() click to toggle source

Delete the ChannelInstance @return [Boolean] true if delete succeeds, false otherwise

    # File lib/twilio-ruby/rest/chat/v1/service/channel.rb
214 def delete
215    @version.delete('DELETE', @uri)
216 end
fetch() click to toggle source

Fetch the ChannelInstance @return [ChannelInstance] Fetched ChannelInstance

    # File lib/twilio-ruby/rest/chat/v1/service/channel.rb
205 def fetch
206   payload = @version.fetch('GET', @uri)
207 
208   ChannelInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], )
209 end
inspect() click to toggle source

Provide a detailed, user friendly representation

    # File lib/twilio-ruby/rest/chat/v1/service/channel.rb
316 def inspect
317   context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
318   "#<Twilio.Chat.V1.ChannelContext #{context}>"
319 end
invites(sid=:unset) click to toggle source

Access the invites @return [InviteList] @return [InviteContext] if sid was passed.

    # File lib/twilio-ruby/rest/chat/v1/service/channel.rb
289 def invites(sid=:unset)
290   raise ArgumentError, 'sid cannot be nil' if sid.nil?
291 
292   if sid != :unset
293     return InviteContext.new(@version, @solution[:service_sid], @solution[:sid], sid, )
294   end
295 
296   unless @invites
297     @invites = InviteList.new(
298         @version,
299         service_sid: @solution[:service_sid],
300         channel_sid: @solution[:sid],
301     )
302   end
303 
304   @invites
305 end
members(sid=:unset) click to toggle source

Access the members @return [MemberList] @return [MemberContext] if sid was passed.

    # File lib/twilio-ruby/rest/chat/v1/service/channel.rb
245 def members(sid=:unset)
246   raise ArgumentError, 'sid cannot be nil' if sid.nil?
247 
248   if sid != :unset
249     return MemberContext.new(@version, @solution[:service_sid], @solution[:sid], sid, )
250   end
251 
252   unless @members
253     @members = MemberList.new(
254         @version,
255         service_sid: @solution[:service_sid],
256         channel_sid: @solution[:sid],
257     )
258   end
259 
260   @members
261 end
messages(sid=:unset) click to toggle source

Access the messages @return [MessageList] @return [MessageContext] if sid was passed.

    # File lib/twilio-ruby/rest/chat/v1/service/channel.rb
267 def messages(sid=:unset)
268   raise ArgumentError, 'sid cannot be nil' if sid.nil?
269 
270   if sid != :unset
271     return MessageContext.new(@version, @solution[:service_sid], @solution[:sid], sid, )
272   end
273 
274   unless @messages
275     @messages = MessageList.new(
276         @version,
277         service_sid: @solution[:service_sid],
278         channel_sid: @solution[:sid],
279     )
280   end
281 
282   @messages
283 end
to_s() click to toggle source

Provide a user friendly representation

    # File lib/twilio-ruby/rest/chat/v1/service/channel.rb
309 def to_s
310   context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
311   "#<Twilio.Chat.V1.ChannelContext #{context}>"
312 end
update(friendly_name: :unset, unique_name: :unset, attributes: :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 64 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 64 characters or less in length
and be unique within the Service.

@param [String] attributes A valid JSON string that contains

application-specific data.

@return [ChannelInstance] Updated ChannelInstance

    # File lib/twilio-ruby/rest/chat/v1/service/channel.rb
229 def update(friendly_name: :unset, unique_name: :unset, attributes: :unset)
230   data = Twilio::Values.of({
231       'FriendlyName' => friendly_name,
232       'UniqueName' => unique_name,
233       'Attributes' => attributes,
234   })
235 
236   payload = @version.update('POST', @uri, data: data)
237 
238   ChannelInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], )
239 end