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)


225
226
227
228
229
230
231
232
233
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 225

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



237
238
239
240
241
242
243
244
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 237

def delete

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

#fetchUserInstance

Fetch the UserInstance

Returns:



249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 249

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

#inspectObject

Provide a detailed, user friendly representation



300
301
302
303
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 300

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

#to_sObject

Provide a user friendly representation



293
294
295
296
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 293

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:



271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
# File 'lib/twilio-ruby/rest/preview_iam/versionless/organization/user.rb', line 271

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