Class: Twilio::REST::Chat::V1::ServiceContext::UserContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/chat/v1/service/user.rb,
lib/twilio-ruby/rest/chat/v1/service/user/user_channel.rb

Defined Under Namespace

Classes: UserChannelInstance, UserChannelList, UserChannelListResponse, UserChannelPage, UserChannelPageMetadata

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid, sid) ⇒ UserContext

Initialize the UserContext

Parameters:

  • version (Version)

    Version that contains the resource

  • service_sid (String)

    The SID of the [Service](www.twilio.com/docs/api/chat/rest/services) to update the resource from.

  • sid (String)

    The Twilio-provided string that uniquely identifies the User resource to update.



238
239
240
241
242
243
244
245
246
247
248
# File 'lib/twilio-ruby/rest/chat/v1/service/user.rb', line 238

def initialize(version, service_sid, sid)
    super(version)
    

    # Path Solution
    @solution = { service_sid: service_sid, sid: sid,  }
    @uri = "/Services/#{@solution[:service_sid]}/Users/#{@solution[:sid]}"

    # Dependents
    @user_channels = nil
end

Instance Method Details

#deleteBoolean

Delete the UserInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



252
253
254
255
256
257
258
259
260
# File 'lib/twilio-ruby/rest/chat/v1/service/user.rb', line 252

def delete

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

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

#delete_with_metadataBoolean

Delete the UserInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# File 'lib/twilio-ruby/rest/chat/v1/service/user.rb', line 265

def 

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

#fetchUserInstance

Fetch the UserInstance

Returns:



284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
# File 'lib/twilio-ruby/rest/chat/v1/service/user.rb', line 284

def fetch

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

#fetch_with_metadataUserInstance

Fetch the UserInstanceMetadata

Returns:



304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
# File 'lib/twilio-ruby/rest/chat/v1/service/user.rb', line 304

def 

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

#inspectObject

Provide a detailed, user friendly representation



420
421
422
423
# File 'lib/twilio-ruby/rest/chat/v1/service/user.rb', line 420

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

#to_sObject

Provide a user friendly representation



413
414
415
416
# File 'lib/twilio-ruby/rest/chat/v1/service/user.rb', line 413

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

#update(role_sid: :unset, attributes: :unset, friendly_name: :unset) ⇒ UserInstance

Update the UserInstance

Parameters:

  • role_sid (String) (defaults to: :unset)

    The SID of the [Role](www.twilio.com/docs/api/chat/rest/roles) assigned to this user.

  • attributes (String) (defaults to: :unset)

    A valid JSON string that contains application-specific data.

  • friendly_name (String) (defaults to: :unset)

    A descriptive string that you create to describe the resource. It is often used for display purposes.

Returns:



333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
# File 'lib/twilio-ruby/rest/chat/v1/service/user.rb', line 333

def update(
    role_sid: :unset, 
    attributes: :unset, 
    friendly_name: :unset
)

    data = Twilio::Values.of({
        'RoleSid' => role_sid,
        'Attributes' => attributes,
        'FriendlyName' => friendly_name,
    })

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

#update_with_metadata(role_sid: :unset, attributes: :unset, friendly_name: :unset) ⇒ UserInstance

Update the UserInstanceMetadata

Parameters:

  • role_sid (String) (defaults to: :unset)

    The SID of the [Role](www.twilio.com/docs/api/chat/rest/roles) assigned to this user.

  • attributes (String) (defaults to: :unset)

    A valid JSON string that contains application-specific data.

  • friendly_name (String) (defaults to: :unset)

    A descriptive string that you create to describe the resource. It is often used for display purposes.

Returns:



366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
# File 'lib/twilio-ruby/rest/chat/v1/service/user.rb', line 366

def (
  role_sid: :unset, 
  attributes: :unset, 
  friendly_name: :unset
)

    data = Twilio::Values.of({
        'RoleSid' => role_sid,
        'Attributes' => attributes,
        'FriendlyName' => friendly_name,
    })

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

#user_channelsUserChannelList, UserChannelContext

Access the user_channels

Returns:



403
404
405
406
407
408
409
# File 'lib/twilio-ruby/rest/chat/v1/service/user.rb', line 403

def user_channels
  unless @user_channels
    @user_channels = UserChannelList.new(
            @version, service_sid: @solution[:service_sid], user_sid: @solution[:sid], )
  end
  @user_channels
end