Class: Twilio::REST::Chat::V2::ServiceContext::ChannelContext::MemberContext

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

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid, channel_sid, sid) ⇒ MemberContext

Initialize the MemberContext

Parameters:

  • version (Version)

    Version that contains the resource

  • service_sid (String)

    The SID of the [Service](www.twilio.com/docs/chat/rest/services) to fetch the resource from.

  • channel_sid (String)

    The unique ID of the [Channel](www.twilio.com/docs/chat/channels) the member to fetch belongs to. Can be the Channel resource’s ‘sid` or `unique_name` value.

  • sid (String)

    The Twilio-provided string that uniquely identifies the Member resource to fetch.



240
241
242
243
244
245
246
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/member.rb', line 240

def initialize(version, service_sid, channel_sid, sid)
  super(version)

  # Path Solution
  @solution = {service_sid: service_sid, channel_sid: channel_sid, sid: sid, }
  @uri = "/Services/#{@solution[:service_sid]}/Channels/#{@solution[:channel_sid]}/Members/#{@solution[:sid]}"
end

Instance Method Details

#deleteBoolean

Deletes the MemberInstance

Returns:

  • (Boolean)

    true if delete succeeds, true otherwise



272
273
274
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/member.rb', line 272

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

#fetchMemberInstance

Fetch a MemberInstance

Returns:



251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/member.rb', line 251

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

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

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

#inspectObject

Provide a detailed, user friendly representation



336
337
338
339
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/member.rb', line 336

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

#to_sObject

Provide a user friendly representation



329
330
331
332
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/member.rb', line 329

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

#update(role_sid: :unset, last_consumed_message_index: :unset, last_consumption_timestamp: :unset, date_created: :unset, date_updated: :unset, attributes: :unset) ⇒ MemberInstance

Update the MemberInstance

Parameters:

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

    The SID of the [Role](www.twilio.com/docs/chat/rest/roles) to assign to the member. The default roles are those specified on the [Service](www.twilio.com/docs/chat/api/services).

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

    The index of the last [Message](www.twilio.com/docs/chat/rest/messages) that the Member has read within the [Channel](www.twilio.com/docs/chat/channels).

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

    The ISO 8601 timestamp string that represents the date-time of the last [Message](www.twilio.com/docs/chat/rest/messages) read event for the Member within the [Channel](www.twilio.com/docs/chat/channels).

  • 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 is the current time set by the Chat service. Note that this parameter should only be used when a Member 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. Note that this parameter should only be used when a Member is being recreated from a backup/separate source and where a Member was previously updated.

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

    A valid JSON string that contains application-specific data.

Returns:



302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/member.rb', line 302

def update(role_sid: :unset, last_consumed_message_index: :unset, last_consumption_timestamp: :unset, date_created: :unset, date_updated: :unset, attributes: :unset)
  data = Twilio::Values.of({
      'RoleSid' => role_sid,
      'LastConsumedMessageIndex' => last_consumed_message_index,
      'LastConsumptionTimestamp' => Twilio.serialize_iso8601_datetime(last_consumption_timestamp),
      'DateCreated' => Twilio.serialize_iso8601_datetime(date_created),
      'DateUpdated' => Twilio.serialize_iso8601_datetime(date_updated),
      'Attributes' => attributes,
  })

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

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