Class: Vapi::ApiRequestTool

Inherits:
Object
  • Object
show all
Defined in:
lib/vapi_server_sdk/types/api_request_tool.rb

Constant Summary collapse

OMIT =
Object.new

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(method:, id:, org_id:, created_at:, updated_at:, url:, messages: OMIT, timeout_seconds: OMIT, function: OMIT, name: OMIT, description: OMIT, body: OMIT, headers: OMIT, backoff_plan: OMIT, variable_extraction_plan: OMIT, additional_properties: nil) ⇒ Vapi::ApiRequestTool



444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
# File 'lib/vapi_server_sdk/types/api_request_tool.rb', line 444

def initialize(method:, id:, org_id:, created_at:, updated_at:, url:, messages: OMIT, timeout_seconds: OMIT,
               function: OMIT, name: OMIT, description: OMIT, body: OMIT, headers: OMIT, backoff_plan: OMIT, variable_extraction_plan: OMIT, additional_properties: nil)
  @messages = messages if messages != OMIT
  @method = method
  @timeout_seconds = timeout_seconds if timeout_seconds != OMIT
  @id = id
  @org_id = org_id
  @created_at = created_at
  @updated_at = updated_at
  @function = function if function != OMIT
  @name = name if name != OMIT
  @description = description if description != OMIT
  @url = url
  @body = body if body != OMIT
  @headers = headers if headers != OMIT
  @backoff_plan = backoff_plan if backoff_plan != OMIT
  @variable_extraction_plan = variable_extraction_plan if variable_extraction_plan != OMIT
  @additional_properties = additional_properties
  @_field_set = {
    "messages": messages,
    "method": method,
    "timeoutSeconds": timeout_seconds,
    "id": id,
    "orgId": org_id,
    "createdAt": created_at,
    "updatedAt": updated_at,
    "function": function,
    "name": name,
    "description": description,
    "url": url,
    "body": body,
    "headers": headers,
    "backoffPlan": backoff_plan,
    "variableExtractionPlan": variable_extraction_plan
  }.reject do |_k, v|
    v == OMIT
  end
end

Instance Attribute Details

#additional_propertiesOpenStruct (readonly)



233
234
235
# File 'lib/vapi_server_sdk/types/api_request_tool.rb', line 233

def additional_properties
  @additional_properties
end

#backoff_planVapi::BackoffPlan (readonly)



58
59
60
# File 'lib/vapi_server_sdk/types/api_request_tool.rb', line 58

def backoff_plan
  @backoff_plan
end

#bodyVapi::JsonSchema (readonly)



52
53
54
# File 'lib/vapi_server_sdk/types/api_request_tool.rb', line 52

def body
  @body
end

#created_atDateTime (readonly)



30
31
32
# File 'lib/vapi_server_sdk/types/api_request_tool.rb', line 30

def created_at
  @created_at
end

#descriptionString (readonly)



48
49
50
# File 'lib/vapi_server_sdk/types/api_request_tool.rb', line 48

def description
  @description
end

#functionVapi::OpenAiFunction (readonly)



42
43
44
# File 'lib/vapi_server_sdk/types/api_request_tool.rb', line 42

def function
  @function
end

#headersVapi::JsonSchema (readonly)



54
55
56
# File 'lib/vapi_server_sdk/types/api_request_tool.rb', line 54

def headers
  @headers
end

#idString (readonly)



26
27
28
# File 'lib/vapi_server_sdk/types/api_request_tool.rb', line 26

def id
  @id
end

#messagesArray<Vapi::ApiRequestToolMessagesItem> (readonly)



19
20
21
# File 'lib/vapi_server_sdk/types/api_request_tool.rb', line 19

def messages
  @messages
end

#methodVapi::ApiRequestToolMethod (readonly)



21
22
23
# File 'lib/vapi_server_sdk/types/api_request_tool.rb', line 21

def method
  @method
end

#nameString (readonly)



46
47
48
# File 'lib/vapi_server_sdk/types/api_request_tool.rb', line 46

def name
  @name
end

#org_idString (readonly)



28
29
30
# File 'lib/vapi_server_sdk/types/api_request_tool.rb', line 28

def org_id
  @org_id
end

#timeout_secondsFloat (readonly)



24
25
26
# File 'lib/vapi_server_sdk/types/api_request_tool.rb', line 24

def timeout_seconds
  @timeout_seconds
end

#updated_atDateTime (readonly)



32
33
34
# File 'lib/vapi_server_sdk/types/api_request_tool.rb', line 32

def updated_at
  @updated_at
end

#urlString (readonly)



50
51
52
# File 'lib/vapi_server_sdk/types/api_request_tool.rb', line 50

def url
  @url
end

#variable_extraction_planVapi::VariableExtractionPlan (readonly)



231
232
233
# File 'lib/vapi_server_sdk/types/api_request_tool.rb', line 231

def variable_extraction_plan
  @variable_extraction_plan
end

Class Method Details

.from_json(json_object:) ⇒ Vapi::ApiRequestTool

Deserialize a JSON object to an instance of ApiRequestTool



487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
# File 'lib/vapi_server_sdk/types/api_request_tool.rb', line 487

def self.from_json(json_object:)
  struct = JSON.parse(json_object, object_class: OpenStruct)
  parsed_json = JSON.parse(json_object)
  messages = parsed_json["messages"]&.map do |item|
    item = item.to_json
    Vapi::ApiRequestToolMessagesItem.from_json(json_object: item)
  end
  method = parsed_json["method"]
  timeout_seconds = parsed_json["timeoutSeconds"]
  id = parsed_json["id"]
  org_id = parsed_json["orgId"]
  created_at = (DateTime.parse(parsed_json["createdAt"]) unless parsed_json["createdAt"].nil?)
  updated_at = (DateTime.parse(parsed_json["updatedAt"]) unless parsed_json["updatedAt"].nil?)
  if parsed_json["function"].nil?
    function = nil
  else
    function = parsed_json["function"].to_json
    function = Vapi::OpenAiFunction.from_json(json_object: function)
  end
  name = parsed_json["name"]
  description = parsed_json["description"]
  url = parsed_json["url"]
  if parsed_json["body"].nil?
    body = nil
  else
    body = parsed_json["body"].to_json
    body = Vapi::JsonSchema.from_json(json_object: body)
  end
  if parsed_json["headers"].nil?
    headers = nil
  else
    headers = parsed_json["headers"].to_json
    headers = Vapi::JsonSchema.from_json(json_object: headers)
  end
  if parsed_json["backoffPlan"].nil?
    backoff_plan = nil
  else
    backoff_plan = parsed_json["backoffPlan"].to_json
    backoff_plan = Vapi::BackoffPlan.from_json(json_object: backoff_plan)
  end
  if parsed_json["variableExtractionPlan"].nil?
    variable_extraction_plan = nil
  else
    variable_extraction_plan = parsed_json["variableExtractionPlan"].to_json
    variable_extraction_plan = Vapi::VariableExtractionPlan.from_json(json_object: variable_extraction_plan)
  end
  new(
    messages: messages,
    method: method,
    timeout_seconds: timeout_seconds,
    id: id,
    org_id: org_id,
    created_at: created_at,
    updated_at: updated_at,
    function: function,
    name: name,
    description: description,
    url: url,
    body: body,
    headers: headers,
    backoff_plan: backoff_plan,
    variable_extraction_plan: variable_extraction_plan,
    additional_properties: struct
  )
end

.validate_raw(obj:) ⇒ Void

Leveraged for Union-type generation, validate_raw attempts to parse the given

hash and check each fields type against the current object's property
definitions.


566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
# File 'lib/vapi_server_sdk/types/api_request_tool.rb', line 566

def self.validate_raw(obj:)
  obj.messages&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.")
  obj.method.is_a?(Vapi::ApiRequestToolMethod) != false || raise("Passed value for field obj.method is not the expected type, validation failed.")
  obj.timeout_seconds&.is_a?(Float) != false || raise("Passed value for field obj.timeout_seconds is not the expected type, validation failed.")
  obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.")
  obj.org_id.is_a?(String) != false || raise("Passed value for field obj.org_id is not the expected type, validation failed.")
  obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.")
  obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.")
  obj.function.nil? || Vapi::OpenAiFunction.validate_raw(obj: obj.function)
  obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.")
  obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.")
  obj.url.is_a?(String) != false || raise("Passed value for field obj.url is not the expected type, validation failed.")
  obj.body.nil? || Vapi::JsonSchema.validate_raw(obj: obj.body)
  obj.headers.nil? || Vapi::JsonSchema.validate_raw(obj: obj.headers)
  obj.backoff_plan.nil? || Vapi::BackoffPlan.validate_raw(obj: obj.backoff_plan)
  obj.variable_extraction_plan.nil? || Vapi::VariableExtractionPlan.validate_raw(obj: obj.variable_extraction_plan)
end

Instance Method Details

#to_json(*_args) ⇒ String

Serialize an instance of ApiRequestTool to a JSON object



556
557
558
# File 'lib/vapi_server_sdk/types/api_request_tool.rb', line 556

def to_json(*_args)
  @_field_set&.to_json
end