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

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/chat/v1/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 to fetch the resource from.

  • channel_sid (String)

    The unique ID of the Channel 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.



208
209
210
211
212
213
214
# File 'lib/twilio-ruby/rest/chat/v1/service/channel/member.rb', line 208

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

Delete the MemberInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise



234
235
236
# File 'lib/twilio-ruby/rest/chat/v1/service/channel/member.rb', line 234

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

#fetchMemberInstance

Fetch the MemberInstance

Returns:



219
220
221
222
223
224
225
226
227
228
229
# File 'lib/twilio-ruby/rest/chat/v1/service/channel/member.rb', line 219

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

  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



275
276
277
278
# File 'lib/twilio-ruby/rest/chat/v1/service/channel/member.rb', line 275

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

#to_sObject

Provide a user friendly representation



268
269
270
271
# File 'lib/twilio-ruby/rest/chat/v1/service/channel/member.rb', line 268

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

#update(role_sid: :unset, last_consumed_message_index: :unset) ⇒ MemberInstance

Update the MemberInstance

Parameters:

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

    The SID of the Role to assign to the member. The default roles are those specified on the Service.

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

    The index of the last Message that the Member has read within the Channel.

Returns:



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

def update(role_sid: :unset, last_consumed_message_index: :unset)
  data = Twilio::Values.of({
      'RoleSid' => role_sid,
      'LastConsumedMessageIndex' => last_consumed_message_index,
  })

  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