Class: Twilio::REST::Conversations::V1::RoleContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/conversations/v1/role.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ RoleContext

Initialize the RoleContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    The SID of the Role resource to update.



235
236
237
238
239
240
241
242
243
244
# File 'lib/twilio-ruby/rest/conversations/v1/role.rb', line 235

def initialize(version, sid)
    super(version)
    

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

    
end

Instance Method Details

#deleteBoolean

Delete the RoleInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



248
249
250
251
252
253
254
255
256
# File 'lib/twilio-ruby/rest/conversations/v1/role.rb', line 248

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 RoleInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
# File 'lib/twilio-ruby/rest/conversations/v1/role.rb', line 261

def 

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

#fetchRoleInstance

Fetch the RoleInstance

Returns:



280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'lib/twilio-ruby/rest/conversations/v1/role.rb', line 280

def fetch

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

#fetch_with_metadataRoleInstance

Fetch the RoleInstanceMetadata

Returns:



299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
# File 'lib/twilio-ruby/rest/conversations/v1/role.rb', line 299

def 

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

#inspectObject

Provide a detailed, user friendly representation



389
390
391
392
# File 'lib/twilio-ruby/rest/conversations/v1/role.rb', line 389

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

#to_sObject

Provide a user friendly representation



382
383
384
385
# File 'lib/twilio-ruby/rest/conversations/v1/role.rb', line 382

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

#update(permission: nil) ⇒ RoleInstance

Update the RoleInstance

Parameters:

  • permission (Array[String]) (defaults to: nil)

    A permission that you grant to the role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. Note that the update action replaces all previously assigned permissions with those defined in the update action. To remove a permission, do not include it in the subsequent update action. The values for this parameter depend on the role’s ‘type`.

Returns:



325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
# File 'lib/twilio-ruby/rest/conversations/v1/role.rb', line 325

def update(
  permission: nil
)

    data = Twilio::Values.of({
        'Permission' => Twilio.serialize_list(permission) { |e| e },
    })

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

#update_with_metadata(permission: nil) ⇒ RoleInstance

Update the RoleInstanceMetadata

Parameters:

  • permission (Array[String]) (defaults to: nil)

    A permission that you grant to the role. Only one permission can be granted per parameter. To assign more than one permission, repeat this parameter for each permission value. Note that the update action replaces all previously assigned permissions with those defined in the update action. To remove a permission, do not include it in the subsequent update action. The values for this parameter depend on the role’s ‘type`.

Returns:



351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
# File 'lib/twilio-ruby/rest/conversations/v1/role.rb', line 351

def (
  permission: nil
)

    data = Twilio::Values.of({
        'Permission' => Twilio.serialize_list(permission) { |e| e },
    })

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