Class: Twilio::REST::Assistants::V1::ToolContext

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

Instance Method Summary collapse

Constructor Details

#initialize(version, id) ⇒ ToolContext

Initialize the ToolContext

Parameters:

  • version (Version)

    Version that contains the resource

  • id (String)


397
398
399
400
401
402
403
404
405
406
# File 'lib/twilio-ruby/rest/assistants/v1/tool.rb', line 397

def initialize(version, id)
    super(version)
    

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

    
end

Instance Method Details

#deleteBoolean

Delete the ToolInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



410
411
412
413
414
415
416
417
418
# File 'lib/twilio-ruby/rest/assistants/v1/tool.rb', line 410

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 ToolInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
# File 'lib/twilio-ruby/rest/assistants/v1/tool.rb', line 423

def 

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

#fetchToolInstance

Fetch the ToolInstance

Returns:



442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
# File 'lib/twilio-ruby/rest/assistants/v1/tool.rb', line 442

def fetch

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

#fetch_with_metadataToolInstance

Fetch the ToolInstanceMetadata

Returns:



461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
# File 'lib/twilio-ruby/rest/assistants/v1/tool.rb', line 461

def 

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

#inspectObject

Provide a detailed, user friendly representation



541
542
543
544
# File 'lib/twilio-ruby/rest/assistants/v1/tool.rb', line 541

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

#to_sObject

Provide a user friendly representation



534
535
536
537
# File 'lib/twilio-ruby/rest/assistants/v1/tool.rb', line 534

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

#update(assistants_v1_service_update_tool_request: :unset) ⇒ ToolInstance

Update the ToolInstance

Parameters:

  • assistants_v1_service_update_tool_request (AssistantsV1ServiceUpdateToolRequest) (defaults to: :unset)

Returns:



487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
# File 'lib/twilio-ruby/rest/assistants/v1/tool.rb', line 487

def update(assistants_v1_service_update_tool_request: :unset
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    headers['Content-Type'] = 'application/json'
    
    
    
    
    payload = @version.update('PUT', @uri, headers: headers, data: assistants_v1_service_update_tool_request.to_json)
    ToolInstance.new(
        @version,
        payload,
        id: @solution[:id],
    )
end

#update_with_metadata(assistants_v1_service_update_tool_request: :unset) ⇒ ToolInstance

Update the ToolInstanceMetadata

Parameters:

  • assistants_v1_service_update_tool_request (AssistantsV1ServiceUpdateToolRequest) (defaults to: :unset)

Returns:



508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
# File 'lib/twilio-ruby/rest/assistants/v1/tool.rb', line 508

def (assistants_v1_service_update_tool_request: :unset
)

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    headers['Content-Type'] = 'application/json'
    
    
    
    
    response = @version.('PUT', @uri, headers: headers, data: assistants_v1_service_update_tool_request.to_json)
    tool_instance = ToolInstance.new(
        @version,
        response.body,
        id: @solution[:id],
    )
    ToolInstanceMetadata.new(
        @version,
        tool_instance,
        response.headers,
        response.status_code
    )
end