Class: Twilio::REST::PreviewIam::Versionless::OrganizationContext::UserContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, organization_sid, id) ⇒ UserContext

Initialize the UserContext

Parameters:

  • version (Version)

    Version that contains the resource

  • organization_sid (String)
  • id (String)


406
407
408
409
410
411
412
413
414
415
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 406

def initialize(version, organization_sid, id)
    super(version)
    

    # Path Solution
    @solution = { organization_sid: organization_sid, id: id,  }
    @uri = "/#{@solution[:organization_sid]}/scim/Users/#{@solution[:id]}"

    
end

Instance Method Details

#deleteBoolean

Delete the UserInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



419
420
421
422
423
424
425
426
427
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 419

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    headers['Accept'] = '*/*'

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

#delete_with_metadataBoolean

Delete the UserInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 432

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    headers['Accept'] = '*/*'
      response = @version.('DELETE', @uri, headers: headers)
      user_instance = UserInstance.new(
          @version,
          response.body,
          account_sid: @solution[:account_sid],
          sid: @solution[:sid],
      )
      UserInstanceMetadata.new(@version, user_instance, response.headers, response.status_code)
end

#fetchUserInstance

Fetch the UserInstance

Returns:



451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 451

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    headers['Accept'] = 'application/scim+json'
    
    payload = @version.fetch('GET', @uri, headers: headers)
    UserInstance.new(
        @version,
        payload,
        organization_sid: @solution[:organization_sid],
        id: @solution[:id],
    )
end

#fetch_with_metadataUserInstance

Fetch the UserInstanceMetadata

Returns:



471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 471

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    headers['Accept'] = 'application/scim+json'
    
    response = @version.('GET', @uri, headers: headers)
    user_instance = UserInstance.new(
        @version,
        response.body,
        organization_sid: @solution[:organization_sid],
        id: @solution[:id],
    )
    UserInstanceMetadata.new(
        @version,
        user_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



612
613
614
615
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 612

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

#patch(if_match: :unset, scim_patch_request: nil) ⇒ UserInstance

Patch the UserInstance

Parameters:

  • if_match (String) (defaults to: :unset)
  • scim_patch_request (ScimPatchRequest) (defaults to: nil)

Returns:



499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 499

def patch(
    if_match: :unset,scim_patch_request: nil
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'If-Match' => if_match, })
    
    headers['Content-Type'] = 'application/scim+json'
    
    headers['Accept'] = 'application/scim+json'
    
    payload = @version.patch('PATCH', @uri, headers: headers, data: scim_patch_request.to_json)
    UserInstance.new(
        @version,
        payload,
        organization_sid: @solution[:organization_sid],
        id: @solution[:id],
    )
end

#patch_with_metadata(if_match: :unset, scim_patch_request: nil) ⇒ UserInstance

Patch the UserInstanceMetadata

Parameters:

  • if_match (String) (defaults to: :unset)
  • scim_patch_request (ScimPatchRequest) (defaults to: nil)

Returns:



523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 523

def (
  if_match: :unset,scim_patch_request: nil
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'If-Match' => if_match, })
    
    headers['Content-Type'] = 'application/scim+json'
    
    headers['Accept'] = 'application/scim+json'
    
    response = @version.('PATCH', @uri, headers: headers, data: scim_patch_request.to_json)
    user_instance = UserInstance.new(
        @version,
        response.body,
        organization_sid: @solution[:organization_sid],
        id: @solution[:id],
    )
    UserInstanceMetadata.new(
        @version,
        user_instance,
        response.headers,
        response.status_code
    )
end

#to_sObject

Provide a user friendly representation



605
606
607
608
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 605

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

#update(if_match: :unset, scim_user: nil) ⇒ UserInstance

Update the UserInstance

Parameters:

  • if_match (String) (defaults to: :unset)
  • scim_user (ScimUser) (defaults to: nil)

Returns:



553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 553

def update(
    if_match: :unset,scim_user: nil
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'If-Match' => if_match, })
    
    headers['Content-Type'] = 'application/scim+json'
    
    headers['Accept'] = 'application/scim+json'
    
    payload = @version.update('PUT', @uri, headers: headers, data: scim_user.to_json)
    UserInstance.new(
        @version,
        payload,
        organization_sid: @solution[:organization_sid],
        id: @solution[:id],
    )
end

#update_with_metadata(if_match: :unset, scim_user: nil) ⇒ UserInstance

Update the UserInstanceMetadata

Parameters:

  • if_match (String) (defaults to: :unset)
  • scim_user (ScimUser) (defaults to: nil)

Returns:



577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 577

def (
  if_match: :unset,scim_user: nil
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', 'If-Match' => if_match, })
    
    headers['Content-Type'] = 'application/scim+json'
    
    headers['Accept'] = 'application/scim+json'
    
    response = @version.('PUT', @uri, headers: headers, data: scim_user.to_json)
    user_instance = UserInstance.new(
        @version,
        response.body,
        organization_sid: @solution[:organization_sid],
        id: @solution[:id],
    )
    UserInstanceMetadata.new(
        @version,
        user_instance,
        response.headers,
        response.status_code
    )
end