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)


414
415
416
417
418
419
420
421
422
423
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 414

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



427
428
429
430
431
432
433
434
435
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 427

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



440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 440

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:



459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 459

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:



479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 479

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



624
625
626
627
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 624

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:



507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 507

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:



532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 532

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



617
618
619
620
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 617

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:



563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 563

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:



588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 588

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