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/service-resource) to update the Member resource in.

  • channel_sid (String)

    The SID of the [Channel](www.twilio.com/docs/chat/channels) the Member resource to update belongs to. This value can be the Channel resource’s sid or unique_name.

  • sid (String)

    The SID of the Member resource to update. This value can be either the Member’s sid or its identity value.



274
275
276
277
278
279
280
281
282
283
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/member.rb', line 274

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

#delete(x_twilio_webhook_enabled: :unset) ⇒ Boolean

Delete the MemberInstance

Parameters:

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

    The X-Twilio-Webhook-Enabled HTTP request header

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



288
289
290
291
292
293
294
295
296
297
298
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/member.rb', line 288

def delete(
    x_twilio_webhook_enabled: :unset
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })
    
    
    

    @version.delete('DELETE', @uri, headers: headers)
end

#delete_with_metadata(x_twilio_webhook_enabled: :unset) ⇒ Boolean

Delete the MemberInstanceMetadata

Parameters:

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

    The X-Twilio-Webhook-Enabled HTTP request header

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



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

def (
  x_twilio_webhook_enabled: :unset
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })
    
    
    
      response = @version.('DELETE', @uri, headers: headers)
      member_instance = MemberInstance.new(
          @version,
          response.body,
          account_sid: @solution[:account_sid],
          sid: @solution[:sid],
      )
      .new(@version, member_instance, response.headers, response.status_code)
end

#fetchMemberInstance

Fetch the MemberInstance

Returns:



325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/member.rb', line 325

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    MemberInstance.new(
        @version,
        payload,
        service_sid: @solution[:service_sid],
        channel_sid: @solution[:channel_sid],
        sid: @solution[:sid],
    )
end

#fetch_with_metadataMemberInstance

Fetch the MemberInstanceMetadata

Returns:



346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/member.rb', line 346

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, headers: headers)
    member_instance = MemberInstance.new(
        @version,
        response.body,
        service_sid: @solution[:service_sid],
        channel_sid: @solution[:channel_sid],
        sid: @solution[:sid],
    )
    .new(
        @version,
        member_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



476
477
478
479
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/member.rb', line 476

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

#to_sObject

Provide a user friendly representation



469
470
471
472
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/member.rb', line 469

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, x_twilio_webhook_enabled: :unset) ⇒ MemberInstance

Update the MemberInstance

Parameters:

Returns:



380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/member.rb', line 380

def update(
    role_sid: :unset, 
    last_consumed_message_index: :unset, 
    last_consumption_timestamp: :unset, 
    date_created: :unset, 
    date_updated: :unset, 
    attributes: :unset, 
    x_twilio_webhook_enabled: :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,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })
    
    
    
    
    
    payload = @version.update('POST', @uri, data: data, headers: headers)
    MemberInstance.new(
        @version,
        payload,
        service_sid: @solution[:service_sid],
        channel_sid: @solution[:channel_sid],
        sid: @solution[:sid],
    )
end

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

Update the MemberInstanceMetadata

Parameters:

Returns:



425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/member.rb', line 425

def (
  role_sid: :unset, 
  last_consumed_message_index: :unset, 
  last_consumption_timestamp: :unset, 
  date_created: :unset, 
  date_updated: :unset, 
  attributes: :unset, 
  x_twilio_webhook_enabled: :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,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'X-Twilio-Webhook-Enabled' => x_twilio_webhook_enabled, })
    
    
    
    
    
    response = @version.('POST', @uri, data: data, headers: headers)
    member_instance = MemberInstance.new(
        @version,
        response.body,
        service_sid: @solution[:service_sid],
        channel_sid: @solution[:channel_sid],
        sid: @solution[:sid],
    )
    .new(
        @version,
        member_instance,
        response.headers,
        response.status_code
    )
end