Class: Twilio::REST::IpMessaging::V2::ServiceContext::ChannelContext

Inherits:
Twilio::REST::InstanceContext show all
Defined in:
lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb,
lib/twilio-ruby/rest/ip_messaging/v2/service/channel/invite.rb,
lib/twilio-ruby/rest/ip_messaging/v2/service/channel/member.rb,
lib/twilio-ruby/rest/ip_messaging/v2/service/channel/message.rb,
lib/twilio-ruby/rest/ip_messaging/v2/service/channel/webhook.rb

Defined Under Namespace

Classes: InviteContext, InviteInstance, InviteList, InvitePage, MemberContext, MemberInstance, MemberList, MemberPage, MessageContext, MessageInstance, MessageList, MessagePage, WebhookContext, WebhookInstance, WebhookList, WebhookPage

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)

    Sid of the [Service](www.twilio.com/docs/api/chat/rest/services) channel belongs to.

  • sid (String)

    Key that uniquely defines the channel to fetch. Could be Sid or UniqueName.



209
210
211
212
213
214
215
216
217
218
219
220
221
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 209

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

  # Dependents
  @members = nil
  @messages = nil
  @invites = nil
  @webhooks = nil
end

Instance Method Details

#deleteBoolean

Deletes the ChannelInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



241
242
243
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 241

def delete
  @version.delete('delete', @uri)
end

#fetchChannelInstance

Fetch a ChannelInstance

Returns:



226
227
228
229
230
231
232
233
234
235
236
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 226

def fetch
  params = Twilio::Values.of({})

  payload = @version.fetch(
      'GET',
      @uri,
      params,
  )

  ChannelInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], )
end

#invites(sid = :unset) ⇒ InviteList, InviteContext

Access the invites

Returns:

Raises:

  • (ArgumentError)


328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 328

def invites(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return InviteContext.new(@version, @solution[:service_sid], @solution[:sid], sid, )
  end

  unless @invites
    @invites = InviteList.new(
        @version,
        service_sid: @solution[:service_sid],
        channel_sid: @solution[:sid],
    )
  end

  @invites
end

#members(sid = :unset) ⇒ MemberList, MemberContext

Access the members

Returns:

Raises:

  • (ArgumentError)


284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 284

def members(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return MemberContext.new(@version, @solution[:service_sid], @solution[:sid], sid, )
  end

  unless @members
    @members = MemberList.new(
        @version,
        service_sid: @solution[:service_sid],
        channel_sid: @solution[:sid],
    )
  end

  @members
end

#messages(sid = :unset) ⇒ MessageList, MessageContext

Access the messages

Returns:

Raises:

  • (ArgumentError)


306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 306

def messages(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return MessageContext.new(@version, @solution[:service_sid], @solution[:sid], sid, )
  end

  unless @messages
    @messages = MessageList.new(
        @version,
        service_sid: @solution[:service_sid],
        channel_sid: @solution[:sid],
    )
  end

  @messages
end

#to_sObject

Provide a user friendly representation



370
371
372
373
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 370

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

#update(friendly_name: :unset, unique_name: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, created_by: :unset) ⇒ ChannelInstance

Update the ChannelInstance

Parameters:

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

    A human-readable name for the Channel. Optional.

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

    A unique, addressable name for the Channel. Optional.

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

    An optional string metadata field you can use to store any data you wish. The string value must contain structurally valid JSON if specified. Note that if the attributes are not set “{}” will be returned.

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

    The optional ISO8601 time specifying the datetime the Channel should be set as being created.

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

    The optional ISO8601 time specifying the datetime the Channel should be set as having been last updated.

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

    Optional field to specify the Identity of the User that created the Channel.

Returns:



261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 261

def update(friendly_name: :unset, unique_name: :unset, attributes: :unset, date_created: :unset, date_updated: :unset, created_by: :unset)
  data = Twilio::Values.of({
      'FriendlyName' => friendly_name,
      'UniqueName' => unique_name,
      'Attributes' => attributes,
      'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
      'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
      'CreatedBy' => created_by,
  })

  payload = @version.update(
      'POST',
      @uri,
      data: data,
  )

  ChannelInstance.new(@version, payload, service_sid: @solution[:service_sid], sid: @solution[:sid], )
end

#webhooks(sid = :unset) ⇒ WebhookList, WebhookContext

Access the webhooks

Returns:

Raises:

  • (ArgumentError)


350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
# File 'lib/twilio-ruby/rest/ip_messaging/v2/service/channel.rb', line 350

def webhooks(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

  if sid != :unset
    return WebhookContext.new(@version, @solution[:service_sid], @solution[:sid], sid, )
  end

  unless @webhooks
    @webhooks = WebhookList.new(
        @version,
        service_sid: @solution[:service_sid],
        channel_sid: @solution[:sid],
    )
  end

  @webhooks
end