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.



282
283
284
285
286
287
288
289
290
291
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/member.rb', line 282

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



296
297
298
299
300
301
302
303
304
305
306
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/member.rb', line 296

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



312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/member.rb', line 312

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],
      )
      MemberInstanceMetadata.new(@version, member_instance, response.headers, response.status_code)
end

#fetchMemberInstance

Fetch the MemberInstance

Returns:



333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/member.rb', line 333

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:



354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/member.rb', line 354

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],
    )
    MemberInstanceMetadata.new(
        @version,
        member_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



484
485
486
487
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/member.rb', line 484

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

#to_sObject

Provide a user friendly representation



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

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:



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
414
415
416
417
418
419
420
421
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/member.rb', line 388

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:



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
465
466
467
468
469
470
471
472
# File 'lib/twilio-ruby/rest/chat/v2/service/channel/member.rb', line 433

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],
    )
    MemberInstanceMetadata.new(
        @version,
        member_instance,
        response.headers,
        response.status_code
    )
end