From 70d700e29c859a5bee972d85c4fb48f663b3a7fc Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Sat, 5 Oct 2024 16:47:27 +0000 Subject: [PATCH] Release 0.0.0-alpha2 --- lib/requests.rb | 4 +- lib/types_export.rb | 148 +++--- lib/vapi/assistants/client.rb | 12 +- .../types/update_assistant_dto_model.rb | 288 ++++++------ .../types/update_assistant_dto_transcriber.rb | 115 ++--- .../types/update_assistant_dto_voice.rb | 265 +++++------ lib/vapi/blocks/client.rb | 28 +- .../blocks/types/blocks_create_request.rb | 115 ++--- .../blocks/types/blocks_create_response.rb | 115 ++--- .../blocks/types/blocks_delete_response.rb | 115 ++--- lib/vapi/blocks/types/blocks_get_response.rb | 115 ++--- .../blocks/types/blocks_list_response_item.rb | 115 ++--- .../blocks/types/blocks_update_response.rb | 115 ++--- .../types/update_block_dto_messages_item.rb | 90 +--- .../types/update_block_dto_steps_item.rb | 90 +--- .../blocks/types/update_block_dto_tool.rb | 215 ++++----- lib/vapi/phone_numbers/client.rb | 28 +- .../types/phone_numbers_create_request.rb | 140 +++--- .../types/phone_numbers_create_response.rb | 140 +++--- .../types/phone_numbers_delete_response.rb | 140 +++--- .../types/phone_numbers_get_response.rb | 140 +++--- .../types/phone_numbers_list_response_item.rb | 140 +++--- .../types/phone_numbers_update_response.rb | 140 +++--- ...e_phone_number_dto_fallback_destination.rb | 90 +--- lib/vapi/tools/client.rb | 24 +- lib/vapi/tools/types/tools_create_request.rb | 215 ++++----- lib/vapi/tools/types/tools_create_response.rb | 215 ++++----- lib/vapi/tools/types/tools_delete_response.rb | 215 ++++----- lib/vapi/tools/types/tools_get_response.rb | 215 ++++----- .../tools/types/tools_list_response_item.rb | 215 ++++----- lib/vapi/tools/types/tools_update_response.rb | 215 ++++----- .../types/update_tool_dto_messages_item.rb | 140 +++--- lib/vapi/types/analysis_cost.rb | 10 +- lib/vapi/types/anthropic_model.rb | 12 +- lib/vapi/types/anthropic_model_tools_item.rb | 215 ++++----- lib/vapi/types/anyscale_model.rb | 12 +- lib/vapi/types/anyscale_model_tools_item.rb | 215 ++++----- .../assignment_mutation_conditions_item.rb | 90 +--- lib/vapi/types/assistant_model.rb | 288 ++++++------ lib/vapi/types/assistant_overrides_model.rb | 288 ++++++------ .../types/assistant_overrides_transcriber.rb | 115 ++--- lib/vapi/types/assistant_overrides_voice.rb | 265 +++++------ lib/vapi/types/assistant_transcriber.rb | 115 ++--- lib/vapi/types/assistant_voice.rb | 265 +++++------ lib/vapi/types/azure_voice.rb | 11 +- lib/vapi/types/block_complete_message.rb | 11 +- .../block_complete_message_conditions_item.rb | 90 +--- lib/vapi/types/block_start_message.rb | 11 +- .../block_start_message_conditions_item.rb | 90 +--- ...y_phone_number_dto_fallback_destination.rb | 90 +--- lib/vapi/types/byo_phone_number.rb | 10 +- .../byo_phone_number_fallback_destination.rb | 90 +--- lib/vapi/types/call_costs_item.rb | 190 ++++---- lib/vapi/types/call_destination.rb | 90 +--- lib/vapi/types/callback_step.rb | 22 +- lib/vapi/types/callback_step_block.rb | 115 ++--- lib/vapi/types/cartesia_voice.rb | 10 +- lib/vapi/types/chunk_plan.rb | 6 +- .../client_inbound_message_add_message.rb | 18 +- .../types/client_inbound_message_control.rb | 28 +- .../types/client_inbound_message_message.rb | 115 ++--- lib/vapi/types/client_inbound_message_say.rb | 17 +- .../client_message_conversation_update.rb | 17 +- lib/vapi/types/client_message_hang.rb | 26 +- .../types/client_message_language_changed.rb | 18 +- lib/vapi/types/client_message_message.rb | 311 ++++++------- lib/vapi/types/client_message_metadata.rb | 18 +- lib/vapi/types/client_message_model_output.rb | 18 +- .../types/client_message_speech_update.rb | 13 +- lib/vapi/types/client_message_tool_calls.rb | 17 +- .../types/client_message_tool_calls_result.rb | 18 +- ...ool_calls_tool_with_tool_call_list_item.rb | 115 ++--- lib/vapi/types/client_message_transcript.rb | 13 +- .../types/client_message_user_interrupted.rb | 18 +- lib/vapi/types/client_message_voice_input.rb | 18 +- lib/vapi/types/conversation_block.rb | 12 +- .../types/conversation_block_messages_item.rb | 90 +--- lib/vapi/types/create_assistant_dto_model.rb | 288 ++++++------ .../types/create_assistant_dto_transcriber.rb | 115 ++--- lib/vapi/types/create_assistant_dto_voice.rb | 265 +++++------ lib/vapi/types/create_byo_phone_number_dto.rb | 12 +- ...o_phone_number_dto_fallback_destination.rb | 90 +--- .../types/create_conversation_block_dto.rb | 10 +- ...te_conversation_block_dto_messages_item.rb | 90 +--- lib/vapi/types/create_dtmf_tool_dto.rb | 17 +- .../create_dtmf_tool_dto_messages_item.rb | 140 +++--- lib/vapi/types/create_end_call_tool_dto.rb | 17 +- .../create_end_call_tool_dto_messages_item.rb | 140 +++--- lib/vapi/types/create_function_tool_dto.rb | 17 +- .../create_function_tool_dto_messages_item.rb | 140 +++--- lib/vapi/types/create_ghl_tool_dto.rb | 11 +- .../create_ghl_tool_dto_messages_item.rb | 140 +++--- lib/vapi/types/create_make_tool_dto.rb | 11 +- .../create_make_tool_dto_messages_item.rb | 140 +++--- lib/vapi/types/create_output_tool_dto.rb | 17 +- .../create_output_tool_dto_messages_item.rb | 140 +++--- lib/vapi/types/create_tool_call_block_dto.rb | 12 +- ...reate_tool_call_block_dto_messages_item.rb | 90 +--- .../types/create_tool_call_block_dto_tool.rb | 215 ++++----- .../types/create_tool_template_dto_details.rb | 215 ++++----- ...eate_tool_template_dto_provider_details.rb | 115 ++--- .../types/create_transfer_call_tool_dto.rb | 10 +- ...ransfer_call_tool_dto_destinations_item.rb | 140 +++--- ...te_transfer_call_tool_dto_messages_item.rb | 140 +++--- .../types/create_twilio_phone_number_dto.rb | 10 +- ...o_phone_number_dto_fallback_destination.rb | 90 +--- .../types/create_vapi_phone_number_dto.rb | 10 +- ...i_phone_number_dto_fallback_destination.rb | 90 +--- lib/vapi/types/create_voicemail_tool_dto.rb | 21 +- ...create_voicemail_tool_dto_messages_item.rb | 140 +++--- .../types/create_vonage_phone_number_dto.rb | 12 +- ...e_phone_number_dto_fallback_destination.rb | 90 +--- lib/vapi/types/create_workflow_block_dto.rb | 10 +- ...create_workflow_block_dto_messages_item.rb | 90 +--- .../create_workflow_block_dto_steps_item.rb | 90 +--- lib/vapi/types/custom_llm_model.rb | 12 +- lib/vapi/types/custom_llm_model_tools_item.rb | 215 ++++----- lib/vapi/types/deep_infra_model.rb | 12 +- lib/vapi/types/deep_infra_model_tools_item.rb | 215 ++++----- lib/vapi/types/deepgram_transcriber.rb | 21 +- .../types/deepgram_transcriber_language.rb | 3 - lib/vapi/types/deepgram_transcriber_model.rb | 427 ++---------------- lib/vapi/types/deepgram_voice.rb | 10 +- lib/vapi/types/dtmf_tool.rb | 12 +- lib/vapi/types/dtmf_tool_messages_item.rb | 140 +++--- lib/vapi/types/eleven_labs_voice.rb | 12 +- lib/vapi/types/end_call_tool.rb | 12 +- lib/vapi/types/end_call_tool_messages_item.rb | 140 +++--- lib/vapi/types/exact_replacement.rb | 33 +- .../types/format_plan_replacements_item.rb | 90 +--- lib/vapi/types/function_tool.rb | 12 +- lib/vapi/types/function_tool_messages_item.rb | 140 +++--- .../types/function_tool_provider_details.rb | 15 +- .../types/function_tool_with_tool_call.rb | 11 +- ...ction_tool_with_tool_call_messages_item.rb | 140 +++--- lib/vapi/types/ghl_tool.rb | 10 +- lib/vapi/types/ghl_tool_messages_item.rb | 140 +++--- lib/vapi/types/ghl_tool_provider_details.rb | 10 +- lib/vapi/types/ghl_tool_with_tool_call.rb | 10 +- .../ghl_tool_with_tool_call_messages_item.rb | 140 +++--- lib/vapi/types/gladia_transcriber.rb | 12 +- lib/vapi/types/groq_model.rb | 12 +- lib/vapi/types/groq_model_tools_item.rb | 215 ++++----- lib/vapi/types/handoff_step.rb | 19 +- lib/vapi/types/handoff_step_block.rb | 115 ++--- ...o_phone_number_dto_fallback_destination.rb | 90 +--- ...e_phone_number_dto_fallback_destination.rb | 90 +--- lib/vapi/types/lmnt_voice.rb | 11 +- lib/vapi/types/make_tool.rb | 10 +- lib/vapi/types/make_tool_messages_item.rb | 140 +++--- lib/vapi/types/make_tool_provider_details.rb | 10 +- lib/vapi/types/make_tool_with_tool_call.rb | 10 +- .../make_tool_with_tool_call_messages_item.rb | 140 +++--- lib/vapi/types/model_based_condition.rb | 16 +- lib/vapi/types/model_cost.rb | 10 +- lib/vapi/types/neets_voice.rb | 10 +- lib/vapi/types/open_ai_model.rb | 10 +- lib/vapi/types/open_ai_model_tools_item.rb | 215 ++++----- lib/vapi/types/open_ai_voice.rb | 11 +- lib/vapi/types/open_router_model.rb | 12 +- .../types/open_router_model_tools_item.rb | 215 ++++----- lib/vapi/types/output_tool.rb | 12 +- lib/vapi/types/output_tool_messages_item.rb | 140 +++--- lib/vapi/types/perplexity_ai_model.rb | 12 +- .../types/perplexity_ai_model_tools_item.rb | 215 ++++----- lib/vapi/types/play_ht_voice.rb | 10 +- ...daries_item.rb => punctuation_boundary.rb} | 4 +- lib/vapi/types/regex_replacement.rb | 35 +- lib/vapi/types/rime_ai_voice.rb | 10 +- lib/vapi/types/rule_based_condition.rb | 11 +- .../types/server_message_assistant_request.rb | 14 +- ..._message_assistant_request_phone_number.rb | 140 +++--- .../server_message_conversation_update.rb | 14 +- ...essage_conversation_update_phone_number.rb | 140 +++--- .../server_message_end_of_call_report.rb | 12 +- ...r_message_end_of_call_report_costs_item.rb | 190 ++++---- ...message_end_of_call_report_phone_number.rb | 140 +++--- lib/vapi/types/server_message_hang.rb | 22 +- .../types/server_message_hang_phone_number.rb | 140 +++--- .../types/server_message_language_changed.rb | 12 +- ...r_message_language_changed_phone_number.rb | 140 +++--- lib/vapi/types/server_message_message.rb | 426 ++++++++--------- lib/vapi/types/server_message_model_output.rb | 12 +- ...erver_message_model_output_phone_number.rb | 140 +++--- .../server_message_phone_call_control.rb | 20 +- ..._message_phone_call_control_destination.rb | 90 +--- ...message_phone_call_control_phone_number.rb | 140 +++--- ..._response_assistant_request_destination.rb | 90 +--- ...ransfer_destination_request_destination.rb | 140 +++--- .../types/server_message_speech_update.rb | 12 +- ...rver_message_speech_update_phone_number.rb | 140 +++--- .../types/server_message_status_update.rb | 14 +- ...erver_message_status_update_destination.rb | 90 +--- ...rver_message_status_update_phone_number.rb | 140 +++--- lib/vapi/types/server_message_tool_calls.rb | 12 +- .../server_message_tool_calls_phone_number.rb | 140 +++--- ...ool_calls_tool_with_tool_call_list_item.rb | 115 ++--- lib/vapi/types/server_message_transcript.rb | 14 +- .../server_message_transcript_phone_number.rb | 140 +++--- ...er_message_transfer_destination_request.rb | 14 +- ...ansfer_destination_request_phone_number.rb | 140 +++--- .../types/server_message_transfer_update.rb | 12 +- ...ver_message_transfer_update_destination.rb | 140 +++--- ...er_message_transfer_update_phone_number.rb | 140 +++--- .../types/server_message_user_interrupted.rb | 14 +- ...r_message_user_interrupted_phone_number.rb | 140 +++--- lib/vapi/types/server_message_voice_input.rb | 12 +- ...server_message_voice_input_phone_number.rb | 140 +++--- .../types/server_message_voice_request.rb | 52 ++- ...rver_message_voice_request_phone_number.rb | 140 +++--- .../types/step_destination_conditions_item.rb | 90 +--- lib/vapi/types/talkscriber_transcriber.rb | 11 +- lib/vapi/types/template_details.rb | 215 ++++----- lib/vapi/types/template_provider_details.rb | 115 ++--- lib/vapi/types/together_ai_model.rb | 12 +- .../types/together_ai_model_tools_item.rb | 215 ++++----- lib/vapi/types/tool_call_block.rb | 12 +- .../types/tool_call_block_messages_item.rb | 90 +--- lib/vapi/types/tool_call_block_tool.rb | 215 ++++----- .../types/tool_call_result_message_item.rb | 90 +--- lib/vapi/types/tool_message_complete.rb | 20 +- lib/vapi/types/tool_message_delayed.rb | 20 +- lib/vapi/types/tool_message_failed.rb | 18 +- lib/vapi/types/tool_message_start.rb | 19 +- lib/vapi/types/transcriber_cost.rb | 11 +- lib/vapi/types/transfer_call_tool.rb | 10 +- .../transfer_call_tool_destinations_item.rb | 140 +++--- .../types/transfer_call_tool_messages_item.rb | 140 +++--- .../types/transfer_destination_assistant.rb | 19 +- ...fer_destination_assistant_transfer_mode.rb | 48 -- lib/vapi/types/transfer_destination_number.rb | 10 +- lib/vapi/types/transfer_destination_sip.rb | 16 +- lib/vapi/types/transfer_destination_step.rb | 16 +- lib/vapi/types/transfer_mode.rb | 8 + lib/vapi/types/transport_cost.rb | 11 +- lib/vapi/types/twilio_phone_number.rb | 12 +- ...wilio_phone_number_fallback_destination.rb | 90 +--- .../types/update_tool_template_dto_details.rb | 215 ++++----- ...date_tool_template_dto_provider_details.rb | 115 ++--- lib/vapi/types/vapi_cost.rb | 11 +- lib/vapi/types/vapi_model.rb | 10 +- lib/vapi/types/vapi_model_steps_item.rb | 90 +--- lib/vapi/types/vapi_model_tools_item.rb | 215 ++++----- lib/vapi/types/vapi_phone_number.rb | 12 +- .../vapi_phone_number_fallback_destination.rb | 90 +--- lib/vapi/types/voice_cost.rb | 11 +- lib/vapi/types/vonage_phone_number.rb | 12 +- ...onage_phone_number_fallback_destination.rb | 90 +--- lib/vapi/types/workflow_block.rb | 12 +- .../types/workflow_block_messages_item.rb | 90 +--- lib/vapi/types/workflow_block_steps_item.rb | 90 +--- vapi.gemspec | 2 +- 252 files changed, 8776 insertions(+), 12922 deletions(-) rename lib/vapi/types/{chunk_plan_punctuation_boundaries_item.rb => punctuation_boundary.rb} (85%) delete mode 100644 lib/vapi/types/transfer_destination_assistant_transfer_mode.rb create mode 100644 lib/vapi/types/transfer_mode.rb diff --git a/lib/requests.rb b/lib/requests.rb index ada666d..29d57ff 100644 --- a/lib/requests.rb +++ b/lib/requests.rb @@ -45,7 +45,7 @@ def get_url(request_options: nil) # @return [Hash{String => String}] def get_headers - headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "vapi", "X-Fern-SDK-Version": "0.0.16" } + headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "vapi", "X-Fern-SDK-Version": "0.0.0-alpha2" } headers["Authorization"] = ((@token.is_a? Method) ? @token.call : @token) unless @token.nil? headers end @@ -90,7 +90,7 @@ def get_url(request_options: nil) # @return [Hash{String => String}] def get_headers - headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "vapi", "X-Fern-SDK-Version": "0.0.16" } + headers = { "X-Fern-Language": "Ruby", "X-Fern-SDK-Name": "vapi", "X-Fern-SDK-Version": "0.0.0-alpha2" } headers["Authorization"] = ((@token.is_a? Method) ? @token.call : @token) unless @token.nil? headers end diff --git a/lib/types_export.rb b/lib/types_export.rb index a3de9ac..4d42b1d 100644 --- a/lib/types_export.rb +++ b/lib/types_export.rb @@ -1,139 +1,161 @@ # frozen_string_literal: true +require_relative "vapi/types/deepgram_transcriber" +require_relative "vapi/types/gladia_transcriber" +require_relative "vapi/types/talkscriber_transcriber" require_relative "vapi/assistants/types/update_assistant_dto_transcriber" +require_relative "vapi/types/anyscale_model" +require_relative "vapi/types/anthropic_model" +require_relative "vapi/types/custom_llm_model" +require_relative "vapi/types/deep_infra_model" +require_relative "vapi/types/groq_model" +require_relative "vapi/types/open_ai_model" +require_relative "vapi/types/open_router_model" +require_relative "vapi/types/perplexity_ai_model" +require_relative "vapi/types/together_ai_model" +require_relative "vapi/types/vapi_model" require_relative "vapi/assistants/types/update_assistant_dto_model" +require_relative "vapi/types/azure_voice" +require_relative "vapi/types/cartesia_voice" +require_relative "vapi/types/deepgram_voice" +require_relative "vapi/types/eleven_labs_voice" +require_relative "vapi/types/lmnt_voice" +require_relative "vapi/types/neets_voice" +require_relative "vapi/types/open_ai_voice" +require_relative "vapi/types/play_ht_voice" +require_relative "vapi/types/rime_ai_voice" require_relative "vapi/assistants/types/update_assistant_dto_voice" require_relative "vapi/assistants/types/update_assistant_dto_first_message_mode" require_relative "vapi/assistants/types/update_assistant_dto_client_messages_item" require_relative "vapi/assistants/types/update_assistant_dto_server_messages_item" require_relative "vapi/assistants/types/update_assistant_dto_background_sound" +require_relative "vapi/types/byo_phone_number" +require_relative "vapi/types/twilio_phone_number" +require_relative "vapi/types/vonage_phone_number" +require_relative "vapi/types/vapi_phone_number" require_relative "vapi/phone_numbers/types/phone_numbers_list_response_item" +require_relative "vapi/types/create_byo_phone_number_dto" +require_relative "vapi/types/create_twilio_phone_number_dto" +require_relative "vapi/types/create_vonage_phone_number_dto" +require_relative "vapi/types/create_vapi_phone_number_dto" require_relative "vapi/phone_numbers/types/phone_numbers_create_request" require_relative "vapi/phone_numbers/types/phone_numbers_create_response" require_relative "vapi/phone_numbers/types/phone_numbers_get_response" require_relative "vapi/phone_numbers/types/phone_numbers_delete_response" +require_relative "vapi/types/transfer_destination_number" +require_relative "vapi/types/transfer_destination_sip" require_relative "vapi/phone_numbers/types/update_phone_number_dto_fallback_destination" require_relative "vapi/phone_numbers/types/phone_numbers_update_response" +require_relative "vapi/types/conversation_block" +require_relative "vapi/types/tool_call_block" +require_relative "vapi/types/workflow_block" require_relative "vapi/blocks/types/blocks_list_response_item" +require_relative "vapi/types/create_conversation_block_dto" +require_relative "vapi/types/create_tool_call_block_dto" +require_relative "vapi/types/create_workflow_block_dto" require_relative "vapi/blocks/types/blocks_create_request" require_relative "vapi/blocks/types/blocks_create_response" require_relative "vapi/blocks/types/blocks_get_response" require_relative "vapi/blocks/types/blocks_delete_response" +require_relative "vapi/types/block_start_message" +require_relative "vapi/types/block_complete_message" require_relative "vapi/blocks/types/update_block_dto_messages_item" +require_relative "vapi/types/create_dtmf_tool_dto" +require_relative "vapi/types/create_end_call_tool_dto" +require_relative "vapi/types/create_voicemail_tool_dto" +require_relative "vapi/types/create_function_tool_dto" +require_relative "vapi/types/create_ghl_tool_dto" +require_relative "vapi/types/create_make_tool_dto" +require_relative "vapi/types/create_transfer_call_tool_dto" require_relative "vapi/blocks/types/update_block_dto_tool" +require_relative "vapi/types/handoff_step" +require_relative "vapi/types/callback_step" require_relative "vapi/blocks/types/update_block_dto_steps_item" require_relative "vapi/blocks/types/blocks_update_response" +require_relative "vapi/types/dtmf_tool" +require_relative "vapi/types/end_call_tool" +require_relative "vapi/types/function_tool" +require_relative "vapi/types/ghl_tool" +require_relative "vapi/types/make_tool" +require_relative "vapi/types/transfer_call_tool" +require_relative "vapi/types/output_tool" require_relative "vapi/tools/types/tools_list_response_item" +require_relative "vapi/types/create_output_tool_dto" require_relative "vapi/tools/types/tools_create_request" require_relative "vapi/tools/types/tools_create_response" require_relative "vapi/tools/types/tools_get_response" require_relative "vapi/tools/types/tools_delete_response" +require_relative "vapi/types/tool_message_start" +require_relative "vapi/types/tool_message_complete" +require_relative "vapi/types/tool_message_failed" +require_relative "vapi/types/tool_message_delayed" require_relative "vapi/tools/types/update_tool_dto_messages_item" require_relative "vapi/tools/types/tools_update_response" require_relative "vapi/logs/types/logs_get_request_type" require_relative "vapi/logs/types/logs_get_request_sort_order" -require_relative "vapi/types/deepgram_transcriber_model" -require_relative "vapi/types/deepgram_transcriber_language" -require_relative "vapi/types/deepgram_transcriber" require_relative "vapi/types/talkscriber_transcriber_language" -require_relative "vapi/types/talkscriber_transcriber" require_relative "vapi/types/gladia_transcriber_model" require_relative "vapi/types/gladia_transcriber_language_behaviour" require_relative "vapi/types/gladia_transcriber_language" -require_relative "vapi/types/gladia_transcriber" require_relative "vapi/types/condition_operator" require_relative "vapi/types/condition" -require_relative "vapi/types/tool_message_start" require_relative "vapi/types/tool_message_complete_role" -require_relative "vapi/types/tool_message_complete" -require_relative "vapi/types/tool_message_failed" -require_relative "vapi/types/tool_message_delayed" require_relative "vapi/types/json_schema_type" require_relative "vapi/types/json_schema" require_relative "vapi/types/open_ai_function_parameters" require_relative "vapi/types/open_ai_function" require_relative "vapi/types/server" require_relative "vapi/types/create_dtmf_tool_dto_messages_item" -require_relative "vapi/types/create_dtmf_tool_dto" require_relative "vapi/types/create_end_call_tool_dto_messages_item" -require_relative "vapi/types/create_end_call_tool_dto" require_relative "vapi/types/create_voicemail_tool_dto_messages_item" -require_relative "vapi/types/create_voicemail_tool_dto" require_relative "vapi/types/create_function_tool_dto_messages_item" -require_relative "vapi/types/create_function_tool_dto" require_relative "vapi/types/ghl_tool_metadata" require_relative "vapi/types/create_ghl_tool_dto_messages_item" -require_relative "vapi/types/create_ghl_tool_dto" require_relative "vapi/types/make_tool_metadata" require_relative "vapi/types/create_make_tool_dto_messages_item" -require_relative "vapi/types/create_make_tool_dto" -require_relative "vapi/types/transfer_destination_assistant_transfer_mode" require_relative "vapi/types/transfer_destination_assistant" require_relative "vapi/types/transfer_destination_step" -require_relative "vapi/types/transfer_destination_number" -require_relative "vapi/types/transfer_destination_sip" require_relative "vapi/types/create_transfer_call_tool_dto_messages_item" require_relative "vapi/types/create_transfer_call_tool_dto_destinations_item" -require_relative "vapi/types/create_transfer_call_tool_dto" require_relative "vapi/types/open_ai_message_role" require_relative "vapi/types/open_ai_message" require_relative "vapi/types/knowledge_base" require_relative "vapi/types/anyscale_model_tools_item" -require_relative "vapi/types/anyscale_model" require_relative "vapi/types/anthropic_model_tools_item" require_relative "vapi/types/anthropic_model_model" -require_relative "vapi/types/anthropic_model" require_relative "vapi/types/custom_llm_model_tools_item" require_relative "vapi/types/custom_llm_model_metadata_send_mode" -require_relative "vapi/types/custom_llm_model" require_relative "vapi/types/deep_infra_model_tools_item" -require_relative "vapi/types/deep_infra_model" require_relative "vapi/types/groq_model_tools_item" require_relative "vapi/types/groq_model_model" -require_relative "vapi/types/groq_model" require_relative "vapi/types/open_ai_model_tools_item" require_relative "vapi/types/open_ai_model_model" require_relative "vapi/types/open_ai_model_fallback_models_item" -require_relative "vapi/types/open_ai_model" require_relative "vapi/types/open_router_model_tools_item" -require_relative "vapi/types/open_router_model" require_relative "vapi/types/perplexity_ai_model_tools_item" -require_relative "vapi/types/perplexity_ai_model" require_relative "vapi/types/together_ai_model_tools_item" -require_relative "vapi/types/together_ai_model" require_relative "vapi/types/vapi_model_tools_item" require_relative "vapi/types/vapi_model_steps_item" -require_relative "vapi/types/vapi_model" require_relative "vapi/types/exact_replacement" require_relative "vapi/types/regex_option_type" require_relative "vapi/types/regex_option" require_relative "vapi/types/regex_replacement" require_relative "vapi/types/format_plan_replacements_item" require_relative "vapi/types/format_plan" -require_relative "vapi/types/chunk_plan_punctuation_boundaries_item" require_relative "vapi/types/chunk_plan" require_relative "vapi/types/azure_voice_voice_id" -require_relative "vapi/types/azure_voice" require_relative "vapi/types/cartesia_voice_model" require_relative "vapi/types/cartesia_voice_language" -require_relative "vapi/types/cartesia_voice" require_relative "vapi/types/deepgram_voice_voice_id" -require_relative "vapi/types/deepgram_voice" require_relative "vapi/types/eleven_labs_voice_voice_id" require_relative "vapi/types/eleven_labs_voice_model" -require_relative "vapi/types/eleven_labs_voice" require_relative "vapi/types/lmnt_voice_voice_id" -require_relative "vapi/types/lmnt_voice" require_relative "vapi/types/neets_voice_voice_id" -require_relative "vapi/types/neets_voice" require_relative "vapi/types/open_ai_voice_voice_id" -require_relative "vapi/types/open_ai_voice" require_relative "vapi/types/play_ht_voice_voice_id" require_relative "vapi/types/play_ht_voice_emotion" -require_relative "vapi/types/play_ht_voice" require_relative "vapi/types/rime_ai_voice_voice_id" require_relative "vapi/types/rime_ai_voice_model" -require_relative "vapi/types/rime_ai_voice" require_relative "vapi/types/transport_configuration_twilio_recording_channels" require_relative "vapi/types/transport_configuration_twilio" require_relative "vapi/types/twilio_voicemail_detection_voicemail_detection_types_item" @@ -183,6 +205,12 @@ require_relative "vapi/types/artifact_messages_item" require_relative "vapi/types/artifact" require_relative "vapi/types/call_type" +require_relative "vapi/types/transport_cost" +require_relative "vapi/types/transcriber_cost" +require_relative "vapi/types/model_cost" +require_relative "vapi/types/voice_cost" +require_relative "vapi/types/vapi_cost" +require_relative "vapi/types/analysis_cost" require_relative "vapi/types/call_costs_item" require_relative "vapi/types/call_messages_item" require_relative "vapi/types/call_phone_call_provider" @@ -204,74 +232,48 @@ require_relative "vapi/types/assistant_background_sound" require_relative "vapi/types/assistant" require_relative "vapi/types/byo_phone_number_fallback_destination" -require_relative "vapi/types/byo_phone_number" require_relative "vapi/types/twilio_phone_number_fallback_destination" -require_relative "vapi/types/twilio_phone_number" require_relative "vapi/types/vonage_phone_number_fallback_destination" -require_relative "vapi/types/vonage_phone_number" require_relative "vapi/types/vapi_phone_number_fallback_destination" -require_relative "vapi/types/vapi_phone_number" require_relative "vapi/types/create_byo_phone_number_dto_fallback_destination" -require_relative "vapi/types/create_byo_phone_number_dto" require_relative "vapi/types/create_twilio_phone_number_dto_fallback_destination" -require_relative "vapi/types/create_twilio_phone_number_dto" require_relative "vapi/types/create_vonage_phone_number_dto_fallback_destination" -require_relative "vapi/types/create_vonage_phone_number_dto" require_relative "vapi/types/create_vapi_phone_number_dto_fallback_destination" -require_relative "vapi/types/create_vapi_phone_number_dto" require_relative "vapi/types/buy_phone_number_dto_fallback_destination" require_relative "vapi/types/buy_phone_number_dto" require_relative "vapi/types/import_vonage_phone_number_dto_fallback_destination" require_relative "vapi/types/import_vonage_phone_number_dto" require_relative "vapi/types/squad" require_relative "vapi/types/conversation_block_messages_item" -require_relative "vapi/types/conversation_block" require_relative "vapi/types/tool_call_block_messages_item" require_relative "vapi/types/tool_call_block_tool" -require_relative "vapi/types/tool_call_block" require_relative "vapi/types/workflow_block_messages_item" require_relative "vapi/types/workflow_block_steps_item" -require_relative "vapi/types/workflow_block" require_relative "vapi/types/rule_based_condition_operator" require_relative "vapi/types/rule_based_condition" require_relative "vapi/types/model_based_condition" require_relative "vapi/types/block_start_message_conditions_item" -require_relative "vapi/types/block_start_message" require_relative "vapi/types/block_complete_message_conditions_item" -require_relative "vapi/types/block_complete_message" require_relative "vapi/types/create_conversation_block_dto_messages_item" -require_relative "vapi/types/create_conversation_block_dto" require_relative "vapi/types/create_tool_call_block_dto_messages_item" require_relative "vapi/types/create_tool_call_block_dto_tool" -require_relative "vapi/types/create_tool_call_block_dto" require_relative "vapi/types/step_destination_conditions_item" require_relative "vapi/types/step_destination" require_relative "vapi/types/handoff_step_block" -require_relative "vapi/types/handoff_step" require_relative "vapi/types/assignment_mutation_conditions_item" require_relative "vapi/types/assignment_mutation" require_relative "vapi/types/callback_step_block" -require_relative "vapi/types/callback_step" require_relative "vapi/types/create_workflow_block_dto_messages_item" require_relative "vapi/types/create_workflow_block_dto_steps_item" -require_relative "vapi/types/create_workflow_block_dto" require_relative "vapi/types/dtmf_tool_messages_item" -require_relative "vapi/types/dtmf_tool" require_relative "vapi/types/end_call_tool_messages_item" -require_relative "vapi/types/end_call_tool" require_relative "vapi/types/function_tool_messages_item" -require_relative "vapi/types/function_tool" require_relative "vapi/types/ghl_tool_messages_item" -require_relative "vapi/types/ghl_tool" require_relative "vapi/types/make_tool_messages_item" -require_relative "vapi/types/make_tool" require_relative "vapi/types/transfer_call_tool_messages_item" require_relative "vapi/types/transfer_call_tool_destinations_item" -require_relative "vapi/types/transfer_call_tool" require_relative "vapi/types/output_tool_messages_item" -require_relative "vapi/types/output_tool" require_relative "vapi/types/create_output_tool_dto_messages_item" -require_relative "vapi/types/create_output_tool_dto" require_relative "vapi/types/file_status" require_relative "vapi/types/file" require_relative "vapi/types/metrics" @@ -431,6 +433,9 @@ require_relative "vapi/types/client_message_transcript" require_relative "vapi/types/tool_call_function" require_relative "vapi/types/tool_call" +require_relative "vapi/types/function_tool_with_tool_call" +require_relative "vapi/types/ghl_tool_with_tool_call" +require_relative "vapi/types/make_tool_with_tool_call" require_relative "vapi/types/client_message_tool_calls_tool_with_tool_call_list_item" require_relative "vapi/types/client_message_tool_calls" require_relative "vapi/types/client_message_tool_calls_result" @@ -504,16 +509,11 @@ require_relative "vapi/types/client_inbound_message_say" require_relative "vapi/types/client_inbound_message_message" require_relative "vapi/types/client_inbound_message" -require_relative "vapi/types/transport_cost" -require_relative "vapi/types/transcriber_cost" -require_relative "vapi/types/model_cost" -require_relative "vapi/types/voice_cost" -require_relative "vapi/types/vapi_cost" require_relative "vapi/types/analysis_cost_analysis_type" -require_relative "vapi/types/analysis_cost" require_relative "vapi/types/function_tool_with_tool_call_messages_item" -require_relative "vapi/types/function_tool_with_tool_call" require_relative "vapi/types/ghl_tool_with_tool_call_messages_item" -require_relative "vapi/types/ghl_tool_with_tool_call" require_relative "vapi/types/make_tool_with_tool_call_messages_item" -require_relative "vapi/types/make_tool_with_tool_call" +require_relative "vapi/types/deepgram_transcriber_language" +require_relative "vapi/types/deepgram_transcriber_model" +require_relative "vapi/types/transfer_mode" +require_relative "vapi/types/punctuation_boundary" diff --git a/lib/vapi/assistants/client.rb b/lib/vapi/assistants/client.rb index 27ef015..b6cb667 100644 --- a/lib/vapi/assistants/client.rb +++ b/lib/vapi/assistants/client.rb @@ -255,9 +255,9 @@ def delete(id:, request_options: nil) end # @param id [String] - # @param transcriber [Vapi::Assistants::UpdateAssistantDtoTranscriber] These are the options for the assistant's transcriber. - # @param model [Vapi::Assistants::UpdateAssistantDtoModel] These are the options for the assistant's LLM. - # @param voice [Vapi::Assistants::UpdateAssistantDtoVoice] These are the options for the assistant's voice. + # @param transcriber [Vapi::DeepgramTranscriber, Vapi::GladiaTranscriber, Vapi::TalkscriberTranscriber] These are the options for the assistant's transcriber. + # @param model [Vapi::AnyscaleModel, Vapi::AnthropicModel, Vapi::CustomLlmModel, Vapi::DeepInfraModel, Vapi::GroqModel, Vapi::OpenAiModel, Vapi::OpenRouterModel, Vapi::PerplexityAiModel, Vapi::TogetherAiModel, Vapi::VapiModel] These are the options for the assistant's LLM. + # @param voice [Vapi::AzureVoice, Vapi::CartesiaVoice, Vapi::DeepgramVoice, Vapi::ElevenLabsVoice, Vapi::LmntVoice, Vapi::NeetsVoice, Vapi::OpenAiVoice, Vapi::PlayHtVoice, Vapi::RimeAiVoice] These are the options for the assistant's voice. # @param first_message_mode [Vapi::Assistants::UpdateAssistantDtoFirstMessageMode] This is the mode for the first message. Default is 'assistant-speaks-first'. # Use: # - 'assistant-speaks-first' to have the assistant speak first. @@ -720,9 +720,9 @@ def delete(id:, request_options: nil) end # @param id [String] - # @param transcriber [Vapi::Assistants::UpdateAssistantDtoTranscriber] These are the options for the assistant's transcriber. - # @param model [Vapi::Assistants::UpdateAssistantDtoModel] These are the options for the assistant's LLM. - # @param voice [Vapi::Assistants::UpdateAssistantDtoVoice] These are the options for the assistant's voice. + # @param transcriber [Vapi::DeepgramTranscriber, Vapi::GladiaTranscriber, Vapi::TalkscriberTranscriber] These are the options for the assistant's transcriber. + # @param model [Vapi::AnyscaleModel, Vapi::AnthropicModel, Vapi::CustomLlmModel, Vapi::DeepInfraModel, Vapi::GroqModel, Vapi::OpenAiModel, Vapi::OpenRouterModel, Vapi::PerplexityAiModel, Vapi::TogetherAiModel, Vapi::VapiModel] These are the options for the assistant's LLM. + # @param voice [Vapi::AzureVoice, Vapi::CartesiaVoice, Vapi::DeepgramVoice, Vapi::ElevenLabsVoice, Vapi::LmntVoice, Vapi::NeetsVoice, Vapi::OpenAiVoice, Vapi::PlayHtVoice, Vapi::RimeAiVoice] These are the options for the assistant's voice. # @param first_message_mode [Vapi::Assistants::UpdateAssistantDtoFirstMessageMode] This is the mode for the first message. Default is 'assistant-speaks-first'. # Use: # - 'assistant-speaks-first' to have the assistant speak first. diff --git a/lib/vapi/assistants/types/update_assistant_dto_model.rb b/lib/vapi/assistants/types/update_assistant_dto_model.rb index 9adce59..237f1b2 100644 --- a/lib/vapi/assistants/types/update_assistant_dto_model.rb +++ b/lib/vapi/assistants/types/update_assistant_dto_model.rb @@ -16,185 +16,153 @@ module Vapi class Assistants # These are the options for the assistant's LLM. class UpdateAssistantDtoModel - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::Assistants::UpdateAssistantDtoModel] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of UpdateAssistantDtoModel # # @param json_object [String] # @return [Vapi::Assistants::UpdateAssistantDtoModel] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "anyscale" - Vapi::AnyscaleModel.from_json(json_object: json_object) - when "anthropic" - Vapi::AnthropicModel.from_json(json_object: json_object) - when "custom-llm" - Vapi::CustomLlmModel.from_json(json_object: json_object) - when "deepinfra" - Vapi::DeepInfraModel.from_json(json_object: json_object) - when "groq" - Vapi::GroqModel.from_json(json_object: json_object) - when "openai" - Vapi::OpenAiModel.from_json(json_object: json_object) - when "openrouter" - Vapi::OpenRouterModel.from_json(json_object: json_object) - when "perplexity-ai" - Vapi::PerplexityAiModel.from_json(json_object: json_object) - when "together-ai" - Vapi::TogetherAiModel.from_json(json_object: json_object) - when "vapi" - Vapi::VapiModel.from_json(json_object: json_object) - else - Vapi::AnyscaleModel.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end - - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "anyscale" - { **@member.to_json, provider: @discriminant }.to_json - when "anthropic" - { **@member.to_json, provider: @discriminant }.to_json - when "custom-llm" - { **@member.to_json, provider: @discriminant }.to_json - when "deepinfra" - { **@member.to_json, provider: @discriminant }.to_json - when "groq" - { **@member.to_json, provider: @discriminant }.to_json - when "openai" - { **@member.to_json, provider: @discriminant }.to_json - when "openrouter" - { **@member.to_json, provider: @discriminant }.to_json - when "perplexity-ai" - { **@member.to_json, provider: @discriminant }.to_json - when "together-ai" - { **@member.to_json, provider: @discriminant }.to_json - when "vapi" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json - end - @member.to_json - end + begin + Vapi::AnyscaleModel.validate_raw(obj: struct) + return Vapi::AnyscaleModel.from_json(json_object: struct) unless struct.nil? - # 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. - # - # @param obj [Object] - # @return [Void] - def self.validate_raw(obj:) - case obj.provider - when "anyscale" - Vapi::AnyscaleModel.validate_raw(obj: obj) - when "anthropic" - Vapi::AnthropicModel.validate_raw(obj: obj) - when "custom-llm" - Vapi::CustomLlmModel.validate_raw(obj: obj) - when "deepinfra" - Vapi::DeepInfraModel.validate_raw(obj: obj) - when "groq" - Vapi::GroqModel.validate_raw(obj: obj) - when "openai" - Vapi::OpenAiModel.validate_raw(obj: obj) - when "openrouter" - Vapi::OpenRouterModel.validate_raw(obj: obj) - when "perplexity-ai" - Vapi::PerplexityAiModel.validate_raw(obj: obj) - when "together-ai" - Vapi::TogetherAiModel.validate_raw(obj: obj) - when "vapi" - Vapi::VapiModel.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + return nil + rescue StandardError + # noop end - end + begin + Vapi::AnthropicModel.validate_raw(obj: struct) + return Vapi::AnthropicModel.from_json(json_object: struct) unless struct.nil? - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::AnyscaleModel] - # @return [Vapi::Assistants::UpdateAssistantDtoModel] - def self.anyscale(member:) - new(member: member, discriminant: "anyscale") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::CustomLlmModel.validate_raw(obj: struct) + return Vapi::CustomLlmModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::AnthropicModel] - # @return [Vapi::Assistants::UpdateAssistantDtoModel] - def self.anthropic(member:) - new(member: member, discriminant: "anthropic") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::DeepInfraModel.validate_raw(obj: struct) + return Vapi::DeepInfraModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::CustomLlmModel] - # @return [Vapi::Assistants::UpdateAssistantDtoModel] - def self.custom_llm(member:) - new(member: member, discriminant: "custom-llm") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::GroqModel.validate_raw(obj: struct) + return Vapi::GroqModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::DeepInfraModel] - # @return [Vapi::Assistants::UpdateAssistantDtoModel] - def self.deepinfra(member:) - new(member: member, discriminant: "deepinfra") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::OpenAiModel.validate_raw(obj: struct) + return Vapi::OpenAiModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::GroqModel] - # @return [Vapi::Assistants::UpdateAssistantDtoModel] - def self.groq(member:) - new(member: member, discriminant: "groq") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::OpenRouterModel.validate_raw(obj: struct) + return Vapi::OpenRouterModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::OpenAiModel] - # @return [Vapi::Assistants::UpdateAssistantDtoModel] - def self.openai(member:) - new(member: member, discriminant: "openai") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::PerplexityAiModel.validate_raw(obj: struct) + return Vapi::PerplexityAiModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::OpenRouterModel] - # @return [Vapi::Assistants::UpdateAssistantDtoModel] - def self.openrouter(member:) - new(member: member, discriminant: "openrouter") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::TogetherAiModel.validate_raw(obj: struct) + return Vapi::TogetherAiModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::PerplexityAiModel] - # @return [Vapi::Assistants::UpdateAssistantDtoModel] - def self.perplexity_ai(member:) - new(member: member, discriminant: "perplexity-ai") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::VapiModel.validate_raw(obj: struct) + return Vapi::VapiModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::TogetherAiModel] - # @return [Vapi::Assistants::UpdateAssistantDtoModel] - def self.together_ai(member:) - new(member: member, discriminant: "together-ai") + return nil + rescue StandardError + # noop + end + struct end - # @param member [Vapi::VapiModel] - # @return [Vapi::Assistants::UpdateAssistantDtoModel] - def self.vapi(member:) - new(member: member, discriminant: "vapi") + # 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. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return Vapi::AnyscaleModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::AnthropicModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CustomLlmModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::DeepInfraModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::GroqModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::OpenAiModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::OpenRouterModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::PerplexityAiModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::TogetherAiModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::VapiModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/assistants/types/update_assistant_dto_transcriber.rb b/lib/vapi/assistants/types/update_assistant_dto_transcriber.rb index 3bc2579..b2ba927 100644 --- a/lib/vapi/assistants/types/update_assistant_dto_transcriber.rb +++ b/lib/vapi/assistants/types/update_assistant_dto_transcriber.rb @@ -9,56 +9,37 @@ module Vapi class Assistants # These are the options for the assistant's transcriber. class UpdateAssistantDtoTranscriber - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::Assistants::UpdateAssistantDtoTranscriber] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of UpdateAssistantDtoTranscriber # # @param json_object [String] # @return [Vapi::Assistants::UpdateAssistantDtoTranscriber] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "deepgram" - Vapi::DeepgramTranscriber.from_json(json_object: json_object) - when "gladia" - Vapi::GladiaTranscriber.from_json(json_object: json_object) - when "talkscriber" - Vapi::TalkscriberTranscriber.from_json(json_object: json_object) - else - Vapi::DeepgramTranscriber.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end + begin + Vapi::DeepgramTranscriber.validate_raw(obj: struct) + return Vapi::DeepgramTranscriber.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "deepgram" - { **@member.to_json, provider: @discriminant }.to_json - when "gladia" - { **@member.to_json, provider: @discriminant }.to_json - when "talkscriber" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::GladiaTranscriber.validate_raw(obj: struct) + return Vapi::GladiaTranscriber.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::TalkscriberTranscriber.validate_raw(obj: struct) + return Vapi::TalkscriberTranscriber.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -68,42 +49,22 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.provider - when "deepgram" - Vapi::DeepgramTranscriber.validate_raw(obj: obj) - when "gladia" - Vapi::GladiaTranscriber.validate_raw(obj: obj) - when "talkscriber" - Vapi::TalkscriberTranscriber.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::DeepgramTranscriber.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::DeepgramTranscriber] - # @return [Vapi::Assistants::UpdateAssistantDtoTranscriber] - def self.deepgram(member:) - new(member: member, discriminant: "deepgram") - end - - # @param member [Vapi::GladiaTranscriber] - # @return [Vapi::Assistants::UpdateAssistantDtoTranscriber] - def self.gladia(member:) - new(member: member, discriminant: "gladia") - end - - # @param member [Vapi::TalkscriberTranscriber] - # @return [Vapi::Assistants::UpdateAssistantDtoTranscriber] - def self.talkscriber(member:) - new(member: member, discriminant: "talkscriber") + begin + return Vapi::GladiaTranscriber.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::TalkscriberTranscriber.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/assistants/types/update_assistant_dto_voice.rb b/lib/vapi/assistants/types/update_assistant_dto_voice.rb index 39c06f7..86822ae 100644 --- a/lib/vapi/assistants/types/update_assistant_dto_voice.rb +++ b/lib/vapi/assistants/types/update_assistant_dto_voice.rb @@ -15,173 +15,140 @@ module Vapi class Assistants # These are the options for the assistant's voice. class UpdateAssistantDtoVoice - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::Assistants::UpdateAssistantDtoVoice] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of UpdateAssistantDtoVoice # # @param json_object [String] # @return [Vapi::Assistants::UpdateAssistantDtoVoice] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "azure" - Vapi::AzureVoice.from_json(json_object: json_object) - when "cartesia" - Vapi::CartesiaVoice.from_json(json_object: json_object) - when "deepgram" - Vapi::DeepgramVoice.from_json(json_object: json_object) - when "11labs" - Vapi::ElevenLabsVoice.from_json(json_object: json_object) - when "lmnt" - Vapi::LmntVoice.from_json(json_object: json_object) - when "neets" - Vapi::NeetsVoice.from_json(json_object: json_object) - when "openai" - Vapi::OpenAiVoice.from_json(json_object: json_object) - when "playht" - Vapi::PlayHtVoice.from_json(json_object: json_object) - when "rime-ai" - Vapi::RimeAiVoice.from_json(json_object: json_object) - else - Vapi::AzureVoice.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end - - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "azure" - { **@member.to_json, provider: @discriminant }.to_json - when "cartesia" - { **@member.to_json, provider: @discriminant }.to_json - when "deepgram" - { **@member.to_json, provider: @discriminant }.to_json - when "11labs" - { **@member.to_json, provider: @discriminant }.to_json - when "lmnt" - { **@member.to_json, provider: @discriminant }.to_json - when "neets" - { **@member.to_json, provider: @discriminant }.to_json - when "openai" - { **@member.to_json, provider: @discriminant }.to_json - when "playht" - { **@member.to_json, provider: @discriminant }.to_json - when "rime-ai" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json - end - @member.to_json - end + begin + Vapi::AzureVoice.validate_raw(obj: struct) + return Vapi::AzureVoice.from_json(json_object: struct) unless struct.nil? - # 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. - # - # @param obj [Object] - # @return [Void] - def self.validate_raw(obj:) - case obj.provider - when "azure" - Vapi::AzureVoice.validate_raw(obj: obj) - when "cartesia" - Vapi::CartesiaVoice.validate_raw(obj: obj) - when "deepgram" - Vapi::DeepgramVoice.validate_raw(obj: obj) - when "11labs" - Vapi::ElevenLabsVoice.validate_raw(obj: obj) - when "lmnt" - Vapi::LmntVoice.validate_raw(obj: obj) - when "neets" - Vapi::NeetsVoice.validate_raw(obj: obj) - when "openai" - Vapi::OpenAiVoice.validate_raw(obj: obj) - when "playht" - Vapi::PlayHtVoice.validate_raw(obj: obj) - when "rime-ai" - Vapi::RimeAiVoice.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + return nil + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end + begin + Vapi::CartesiaVoice.validate_raw(obj: struct) + return Vapi::CartesiaVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::AzureVoice] - # @return [Vapi::Assistants::UpdateAssistantDtoVoice] - def self.azure(member:) - new(member: member, discriminant: "azure") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::DeepgramVoice.validate_raw(obj: struct) + return Vapi::DeepgramVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::CartesiaVoice] - # @return [Vapi::Assistants::UpdateAssistantDtoVoice] - def self.cartesia(member:) - new(member: member, discriminant: "cartesia") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::ElevenLabsVoice.validate_raw(obj: struct) + return Vapi::ElevenLabsVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::DeepgramVoice] - # @return [Vapi::Assistants::UpdateAssistantDtoVoice] - def self.deepgram(member:) - new(member: member, discriminant: "deepgram") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::LmntVoice.validate_raw(obj: struct) + return Vapi::LmntVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::ElevenLabsVoice] - # @return [Vapi::Assistants::UpdateAssistantDtoVoice] - def self._11_labs(member:) - new(member: member, discriminant: "11labs") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::NeetsVoice.validate_raw(obj: struct) + return Vapi::NeetsVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::LmntVoice] - # @return [Vapi::Assistants::UpdateAssistantDtoVoice] - def self.lmnt(member:) - new(member: member, discriminant: "lmnt") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::OpenAiVoice.validate_raw(obj: struct) + return Vapi::OpenAiVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::NeetsVoice] - # @return [Vapi::Assistants::UpdateAssistantDtoVoice] - def self.neets(member:) - new(member: member, discriminant: "neets") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::PlayHtVoice.validate_raw(obj: struct) + return Vapi::PlayHtVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::OpenAiVoice] - # @return [Vapi::Assistants::UpdateAssistantDtoVoice] - def self.openai(member:) - new(member: member, discriminant: "openai") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::RimeAiVoice.validate_raw(obj: struct) + return Vapi::RimeAiVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::PlayHtVoice] - # @return [Vapi::Assistants::UpdateAssistantDtoVoice] - def self.playht(member:) - new(member: member, discriminant: "playht") + return nil + rescue StandardError + # noop + end + struct end - # @param member [Vapi::RimeAiVoice] - # @return [Vapi::Assistants::UpdateAssistantDtoVoice] - def self.rime_ai(member:) - new(member: member, discriminant: "rime-ai") + # 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. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return Vapi::AzureVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CartesiaVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::DeepgramVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ElevenLabsVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::LmntVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::NeetsVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::OpenAiVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::PlayHtVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::RimeAiVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/blocks/client.rb b/lib/vapi/blocks/client.rb index 0f94de7..faa278e 100644 --- a/lib/vapi/blocks/client.rb +++ b/lib/vapi/blocks/client.rb @@ -82,16 +82,16 @@ def list(limit: nil, created_at_gt: nil, created_at_lt: nil, created_at_ge: nil, end end - # @param request [Vapi::Blocks::BlocksCreateRequest] + # @param request [Vapi::CreateConversationBlockDto, Vapi::CreateToolCallBlockDto, Vapi::CreateWorkflowBlockDto] # @param request_options [Vapi::RequestOptions] - # @return [Vapi::Blocks::BlocksCreateResponse] + # @return [Vapi::ConversationBlock, Vapi::ToolCallBlock, Vapi::WorkflowBlock] # @example # api = Vapi::Client.new( # base_url: "https://api.example.com", # environment: Vapi::Environment::DEFAULT, # token: "YOUR_AUTH_TOKEN" # ) - # api.blocks.create + # api.blocks.create(request: { type: "conversation", instruction: "instruction" }) def create(request:, request_options: nil) response = @request_client.conn.post do |req| req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? @@ -112,7 +112,7 @@ def create(request:, request_options: nil) # @param id [String] # @param request_options [Vapi::RequestOptions] - # @return [Vapi::Blocks::BlocksGetResponse] + # @return [Vapi::ConversationBlock, Vapi::ToolCallBlock, Vapi::WorkflowBlock] # @example # api = Vapi::Client.new( # base_url: "https://api.example.com", @@ -142,7 +142,7 @@ def get(id:, request_options: nil) # @param id [String] # @param request_options [Vapi::RequestOptions] - # @return [Vapi::Blocks::BlocksDeleteResponse] + # @return [Vapi::ConversationBlock, Vapi::ToolCallBlock, Vapi::WorkflowBlock] # @example # api = Vapi::Client.new( # base_url: "https://api.example.com", @@ -204,7 +204,7 @@ def delete(id:, request_options: nil) # * :properties (Hash{String => Object}) # * :description (String) # * :required (Array) - # @param tool [Vapi::Blocks::UpdateBlockDtoTool] This is the tool that the block will call. To use an existing tool, use + # @param tool [Vapi::CreateDtmfToolDto, Vapi::CreateEndCallToolDto, Vapi::CreateVoicemailToolDto, Vapi::CreateFunctionToolDto, Vapi::CreateGhlToolDto, Vapi::CreateMakeToolDto, Vapi::CreateTransferCallToolDto] This is the tool that the block will call. To use an existing tool, use # `toolId`. # @param steps [Array] These are the steps in the workflow.Request of type Array, as a Hash # @param name [String] This is the name of the block. This is just for your reference. @@ -240,7 +240,7 @@ def delete(id:, request_options: nil) # @param tool_id [String] This is the id of the tool that the block will call. To use a transient tool, # use `tool`. # @param request_options [Vapi::RequestOptions] - # @return [Vapi::Blocks::BlocksUpdateResponse] + # @return [Vapi::ConversationBlock, Vapi::ToolCallBlock, Vapi::WorkflowBlock] # @example # api = Vapi::Client.new( # base_url: "https://api.example.com", @@ -346,16 +346,16 @@ def list(limit: nil, created_at_gt: nil, created_at_lt: nil, created_at_ge: nil, end end - # @param request [Vapi::Blocks::BlocksCreateRequest] + # @param request [Vapi::CreateConversationBlockDto, Vapi::CreateToolCallBlockDto, Vapi::CreateWorkflowBlockDto] # @param request_options [Vapi::RequestOptions] - # @return [Vapi::Blocks::BlocksCreateResponse] + # @return [Vapi::ConversationBlock, Vapi::ToolCallBlock, Vapi::WorkflowBlock] # @example # api = Vapi::Client.new( # base_url: "https://api.example.com", # environment: Vapi::Environment::DEFAULT, # token: "YOUR_AUTH_TOKEN" # ) - # api.blocks.create + # api.blocks.create(request: { type: "conversation", instruction: "instruction" }) def create(request:, request_options: nil) Async do response = @request_client.conn.post do |req| @@ -378,7 +378,7 @@ def create(request:, request_options: nil) # @param id [String] # @param request_options [Vapi::RequestOptions] - # @return [Vapi::Blocks::BlocksGetResponse] + # @return [Vapi::ConversationBlock, Vapi::ToolCallBlock, Vapi::WorkflowBlock] # @example # api = Vapi::Client.new( # base_url: "https://api.example.com", @@ -410,7 +410,7 @@ def get(id:, request_options: nil) # @param id [String] # @param request_options [Vapi::RequestOptions] - # @return [Vapi::Blocks::BlocksDeleteResponse] + # @return [Vapi::ConversationBlock, Vapi::ToolCallBlock, Vapi::WorkflowBlock] # @example # api = Vapi::Client.new( # base_url: "https://api.example.com", @@ -474,7 +474,7 @@ def delete(id:, request_options: nil) # * :properties (Hash{String => Object}) # * :description (String) # * :required (Array) - # @param tool [Vapi::Blocks::UpdateBlockDtoTool] This is the tool that the block will call. To use an existing tool, use + # @param tool [Vapi::CreateDtmfToolDto, Vapi::CreateEndCallToolDto, Vapi::CreateVoicemailToolDto, Vapi::CreateFunctionToolDto, Vapi::CreateGhlToolDto, Vapi::CreateMakeToolDto, Vapi::CreateTransferCallToolDto] This is the tool that the block will call. To use an existing tool, use # `toolId`. # @param steps [Array] These are the steps in the workflow.Request of type Array, as a Hash # @param name [String] This is the name of the block. This is just for your reference. @@ -510,7 +510,7 @@ def delete(id:, request_options: nil) # @param tool_id [String] This is the id of the tool that the block will call. To use a transient tool, # use `tool`. # @param request_options [Vapi::RequestOptions] - # @return [Vapi::Blocks::BlocksUpdateResponse] + # @return [Vapi::ConversationBlock, Vapi::ToolCallBlock, Vapi::WorkflowBlock] # @example # api = Vapi::Client.new( # base_url: "https://api.example.com", diff --git a/lib/vapi/blocks/types/blocks_create_request.rb b/lib/vapi/blocks/types/blocks_create_request.rb index 1c38fdf..9fff00a 100644 --- a/lib/vapi/blocks/types/blocks_create_request.rb +++ b/lib/vapi/blocks/types/blocks_create_request.rb @@ -8,56 +8,37 @@ module Vapi class Blocks class BlocksCreateRequest - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::Blocks::BlocksCreateRequest] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of BlocksCreateRequest # # @param json_object [String] # @return [Vapi::Blocks::BlocksCreateRequest] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "conversation" - Vapi::CreateConversationBlockDto.from_json(json_object: json_object) - when "tool-call" - Vapi::CreateToolCallBlockDto.from_json(json_object: json_object) - when "workflow" - Vapi::CreateWorkflowBlockDto.from_json(json_object: json_object) - else - Vapi::CreateConversationBlockDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::CreateConversationBlockDto.validate_raw(obj: struct) + return Vapi::CreateConversationBlockDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "conversation" - { **@member.to_json, type: @discriminant }.to_json - when "tool-call" - { **@member.to_json, type: @discriminant }.to_json - when "workflow" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::CreateToolCallBlockDto.validate_raw(obj: struct) + return Vapi::CreateToolCallBlockDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateWorkflowBlockDto.validate_raw(obj: struct) + return Vapi::CreateWorkflowBlockDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -67,42 +48,22 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "conversation" - Vapi::CreateConversationBlockDto.validate_raw(obj: obj) - when "tool-call" - Vapi::CreateToolCallBlockDto.validate_raw(obj: obj) - when "workflow" - Vapi::CreateWorkflowBlockDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateConversationBlockDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateConversationBlockDto] - # @return [Vapi::Blocks::BlocksCreateRequest] - def self.conversation(member:) - new(member: member, discriminant: "conversation") - end - - # @param member [Vapi::CreateToolCallBlockDto] - # @return [Vapi::Blocks::BlocksCreateRequest] - def self.tool_call(member:) - new(member: member, discriminant: "tool-call") - end - - # @param member [Vapi::CreateWorkflowBlockDto] - # @return [Vapi::Blocks::BlocksCreateRequest] - def self.workflow(member:) - new(member: member, discriminant: "workflow") + begin + return Vapi::CreateToolCallBlockDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateWorkflowBlockDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/blocks/types/blocks_create_response.rb b/lib/vapi/blocks/types/blocks_create_response.rb index 57430b5..b835735 100644 --- a/lib/vapi/blocks/types/blocks_create_response.rb +++ b/lib/vapi/blocks/types/blocks_create_response.rb @@ -8,56 +8,37 @@ module Vapi class Blocks class BlocksCreateResponse - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::Blocks::BlocksCreateResponse] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of BlocksCreateResponse # # @param json_object [String] # @return [Vapi::Blocks::BlocksCreateResponse] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "conversation" - Vapi::ConversationBlock.from_json(json_object: json_object) - when "tool-call" - Vapi::ToolCallBlock.from_json(json_object: json_object) - when "workflow" - Vapi::WorkflowBlock.from_json(json_object: json_object) - else - Vapi::ConversationBlock.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ConversationBlock.validate_raw(obj: struct) + return Vapi::ConversationBlock.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "conversation" - { **@member.to_json, type: @discriminant }.to_json - when "tool-call" - { **@member.to_json, type: @discriminant }.to_json - when "workflow" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::ToolCallBlock.validate_raw(obj: struct) + return Vapi::ToolCallBlock.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::WorkflowBlock.validate_raw(obj: struct) + return Vapi::WorkflowBlock.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -67,42 +48,22 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "conversation" - Vapi::ConversationBlock.validate_raw(obj: obj) - when "tool-call" - Vapi::ToolCallBlock.validate_raw(obj: obj) - when "workflow" - Vapi::WorkflowBlock.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ConversationBlock.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ConversationBlock] - # @return [Vapi::Blocks::BlocksCreateResponse] - def self.conversation(member:) - new(member: member, discriminant: "conversation") - end - - # @param member [Vapi::ToolCallBlock] - # @return [Vapi::Blocks::BlocksCreateResponse] - def self.tool_call(member:) - new(member: member, discriminant: "tool-call") - end - - # @param member [Vapi::WorkflowBlock] - # @return [Vapi::Blocks::BlocksCreateResponse] - def self.workflow(member:) - new(member: member, discriminant: "workflow") + begin + return Vapi::ToolCallBlock.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::WorkflowBlock.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/blocks/types/blocks_delete_response.rb b/lib/vapi/blocks/types/blocks_delete_response.rb index 5ab6725..d318052 100644 --- a/lib/vapi/blocks/types/blocks_delete_response.rb +++ b/lib/vapi/blocks/types/blocks_delete_response.rb @@ -8,56 +8,37 @@ module Vapi class Blocks class BlocksDeleteResponse - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::Blocks::BlocksDeleteResponse] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of BlocksDeleteResponse # # @param json_object [String] # @return [Vapi::Blocks::BlocksDeleteResponse] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "conversation" - Vapi::ConversationBlock.from_json(json_object: json_object) - when "tool-call" - Vapi::ToolCallBlock.from_json(json_object: json_object) - when "workflow" - Vapi::WorkflowBlock.from_json(json_object: json_object) - else - Vapi::ConversationBlock.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ConversationBlock.validate_raw(obj: struct) + return Vapi::ConversationBlock.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "conversation" - { **@member.to_json, type: @discriminant }.to_json - when "tool-call" - { **@member.to_json, type: @discriminant }.to_json - when "workflow" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::ToolCallBlock.validate_raw(obj: struct) + return Vapi::ToolCallBlock.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::WorkflowBlock.validate_raw(obj: struct) + return Vapi::WorkflowBlock.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -67,42 +48,22 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "conversation" - Vapi::ConversationBlock.validate_raw(obj: obj) - when "tool-call" - Vapi::ToolCallBlock.validate_raw(obj: obj) - when "workflow" - Vapi::WorkflowBlock.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ConversationBlock.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ConversationBlock] - # @return [Vapi::Blocks::BlocksDeleteResponse] - def self.conversation(member:) - new(member: member, discriminant: "conversation") - end - - # @param member [Vapi::ToolCallBlock] - # @return [Vapi::Blocks::BlocksDeleteResponse] - def self.tool_call(member:) - new(member: member, discriminant: "tool-call") - end - - # @param member [Vapi::WorkflowBlock] - # @return [Vapi::Blocks::BlocksDeleteResponse] - def self.workflow(member:) - new(member: member, discriminant: "workflow") + begin + return Vapi::ToolCallBlock.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::WorkflowBlock.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/blocks/types/blocks_get_response.rb b/lib/vapi/blocks/types/blocks_get_response.rb index 895691b..ab173eb 100644 --- a/lib/vapi/blocks/types/blocks_get_response.rb +++ b/lib/vapi/blocks/types/blocks_get_response.rb @@ -8,56 +8,37 @@ module Vapi class Blocks class BlocksGetResponse - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::Blocks::BlocksGetResponse] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of BlocksGetResponse # # @param json_object [String] # @return [Vapi::Blocks::BlocksGetResponse] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "conversation" - Vapi::ConversationBlock.from_json(json_object: json_object) - when "tool-call" - Vapi::ToolCallBlock.from_json(json_object: json_object) - when "workflow" - Vapi::WorkflowBlock.from_json(json_object: json_object) - else - Vapi::ConversationBlock.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ConversationBlock.validate_raw(obj: struct) + return Vapi::ConversationBlock.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "conversation" - { **@member.to_json, type: @discriminant }.to_json - when "tool-call" - { **@member.to_json, type: @discriminant }.to_json - when "workflow" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::ToolCallBlock.validate_raw(obj: struct) + return Vapi::ToolCallBlock.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::WorkflowBlock.validate_raw(obj: struct) + return Vapi::WorkflowBlock.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -67,42 +48,22 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "conversation" - Vapi::ConversationBlock.validate_raw(obj: obj) - when "tool-call" - Vapi::ToolCallBlock.validate_raw(obj: obj) - when "workflow" - Vapi::WorkflowBlock.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ConversationBlock.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ConversationBlock] - # @return [Vapi::Blocks::BlocksGetResponse] - def self.conversation(member:) - new(member: member, discriminant: "conversation") - end - - # @param member [Vapi::ToolCallBlock] - # @return [Vapi::Blocks::BlocksGetResponse] - def self.tool_call(member:) - new(member: member, discriminant: "tool-call") - end - - # @param member [Vapi::WorkflowBlock] - # @return [Vapi::Blocks::BlocksGetResponse] - def self.workflow(member:) - new(member: member, discriminant: "workflow") + begin + return Vapi::ToolCallBlock.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::WorkflowBlock.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/blocks/types/blocks_list_response_item.rb b/lib/vapi/blocks/types/blocks_list_response_item.rb index a651b57..ecb7c86 100644 --- a/lib/vapi/blocks/types/blocks_list_response_item.rb +++ b/lib/vapi/blocks/types/blocks_list_response_item.rb @@ -8,56 +8,37 @@ module Vapi class Blocks class BlocksListResponseItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::Blocks::BlocksListResponseItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of BlocksListResponseItem # # @param json_object [String] # @return [Vapi::Blocks::BlocksListResponseItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "conversation" - Vapi::ConversationBlock.from_json(json_object: json_object) - when "tool-call" - Vapi::ToolCallBlock.from_json(json_object: json_object) - when "workflow" - Vapi::WorkflowBlock.from_json(json_object: json_object) - else - Vapi::ConversationBlock.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ConversationBlock.validate_raw(obj: struct) + return Vapi::ConversationBlock.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "conversation" - { **@member.to_json, type: @discriminant }.to_json - when "tool-call" - { **@member.to_json, type: @discriminant }.to_json - when "workflow" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::ToolCallBlock.validate_raw(obj: struct) + return Vapi::ToolCallBlock.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::WorkflowBlock.validate_raw(obj: struct) + return Vapi::WorkflowBlock.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -67,42 +48,22 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "conversation" - Vapi::ConversationBlock.validate_raw(obj: obj) - when "tool-call" - Vapi::ToolCallBlock.validate_raw(obj: obj) - when "workflow" - Vapi::WorkflowBlock.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ConversationBlock.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ConversationBlock] - # @return [Vapi::Blocks::BlocksListResponseItem] - def self.conversation(member:) - new(member: member, discriminant: "conversation") - end - - # @param member [Vapi::ToolCallBlock] - # @return [Vapi::Blocks::BlocksListResponseItem] - def self.tool_call(member:) - new(member: member, discriminant: "tool-call") - end - - # @param member [Vapi::WorkflowBlock] - # @return [Vapi::Blocks::BlocksListResponseItem] - def self.workflow(member:) - new(member: member, discriminant: "workflow") + begin + return Vapi::ToolCallBlock.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::WorkflowBlock.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/blocks/types/blocks_update_response.rb b/lib/vapi/blocks/types/blocks_update_response.rb index d5d618c..a34057b 100644 --- a/lib/vapi/blocks/types/blocks_update_response.rb +++ b/lib/vapi/blocks/types/blocks_update_response.rb @@ -8,56 +8,37 @@ module Vapi class Blocks class BlocksUpdateResponse - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::Blocks::BlocksUpdateResponse] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of BlocksUpdateResponse # # @param json_object [String] # @return [Vapi::Blocks::BlocksUpdateResponse] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "conversation" - Vapi::ConversationBlock.from_json(json_object: json_object) - when "tool-call" - Vapi::ToolCallBlock.from_json(json_object: json_object) - when "workflow" - Vapi::WorkflowBlock.from_json(json_object: json_object) - else - Vapi::ConversationBlock.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ConversationBlock.validate_raw(obj: struct) + return Vapi::ConversationBlock.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "conversation" - { **@member.to_json, type: @discriminant }.to_json - when "tool-call" - { **@member.to_json, type: @discriminant }.to_json - when "workflow" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::ToolCallBlock.validate_raw(obj: struct) + return Vapi::ToolCallBlock.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::WorkflowBlock.validate_raw(obj: struct) + return Vapi::WorkflowBlock.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -67,42 +48,22 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "conversation" - Vapi::ConversationBlock.validate_raw(obj: obj) - when "tool-call" - Vapi::ToolCallBlock.validate_raw(obj: obj) - when "workflow" - Vapi::WorkflowBlock.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ConversationBlock.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ConversationBlock] - # @return [Vapi::Blocks::BlocksUpdateResponse] - def self.conversation(member:) - new(member: member, discriminant: "conversation") - end - - # @param member [Vapi::ToolCallBlock] - # @return [Vapi::Blocks::BlocksUpdateResponse] - def self.tool_call(member:) - new(member: member, discriminant: "tool-call") - end - - # @param member [Vapi::WorkflowBlock] - # @return [Vapi::Blocks::BlocksUpdateResponse] - def self.workflow(member:) - new(member: member, discriminant: "workflow") + begin + return Vapi::ToolCallBlock.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::WorkflowBlock.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/blocks/types/update_block_dto_messages_item.rb b/lib/vapi/blocks/types/update_block_dto_messages_item.rb index 2b2dfd4..a55eda3 100644 --- a/lib/vapi/blocks/types/update_block_dto_messages_item.rb +++ b/lib/vapi/blocks/types/update_block_dto_messages_item.rb @@ -7,52 +7,29 @@ module Vapi class Blocks class UpdateBlockDtoMessagesItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::Blocks::UpdateBlockDtoMessagesItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of UpdateBlockDtoMessagesItem # # @param json_object [String] # @return [Vapi::Blocks::UpdateBlockDtoMessagesItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "block-start" - Vapi::BlockStartMessage.from_json(json_object: json_object) - when "block-complete" - Vapi::BlockCompleteMessage.from_json(json_object: json_object) - else - Vapi::BlockStartMessage.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::BlockStartMessage.validate_raw(obj: struct) + return Vapi::BlockStartMessage.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "block-start" - { **@member.to_json, type: @discriminant }.to_json - when "block-complete" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::BlockCompleteMessage.validate_raw(obj: struct) + return Vapi::BlockCompleteMessage.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -62,34 +39,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "block-start" - Vapi::BlockStartMessage.validate_raw(obj: obj) - when "block-complete" - Vapi::BlockCompleteMessage.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::BlockStartMessage.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::BlockStartMessage] - # @return [Vapi::Blocks::UpdateBlockDtoMessagesItem] - def self.block_start(member:) - new(member: member, discriminant: "block-start") - end - - # @param member [Vapi::BlockCompleteMessage] - # @return [Vapi::Blocks::UpdateBlockDtoMessagesItem] - def self.block_complete(member:) - new(member: member, discriminant: "block-complete") + begin + return Vapi::BlockCompleteMessage.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/blocks/types/update_block_dto_steps_item.rb b/lib/vapi/blocks/types/update_block_dto_steps_item.rb index 8dc2036..dfe3d9b 100644 --- a/lib/vapi/blocks/types/update_block_dto_steps_item.rb +++ b/lib/vapi/blocks/types/update_block_dto_steps_item.rb @@ -7,52 +7,29 @@ module Vapi class Blocks class UpdateBlockDtoStepsItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::Blocks::UpdateBlockDtoStepsItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of UpdateBlockDtoStepsItem # # @param json_object [String] # @return [Vapi::Blocks::UpdateBlockDtoStepsItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "handoff" - Vapi::HandoffStep.from_json(json_object: json_object) - when "callback" - Vapi::CallbackStep.from_json(json_object: json_object) - else - Vapi::HandoffStep.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::HandoffStep.validate_raw(obj: struct) + return Vapi::HandoffStep.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "handoff" - { **@member.to_json, type: @discriminant }.to_json - when "callback" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::CallbackStep.validate_raw(obj: struct) + return Vapi::CallbackStep.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -62,34 +39,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "handoff" - Vapi::HandoffStep.validate_raw(obj: obj) - when "callback" - Vapi::CallbackStep.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::HandoffStep.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::HandoffStep] - # @return [Vapi::Blocks::UpdateBlockDtoStepsItem] - def self.handoff(member:) - new(member: member, discriminant: "handoff") - end - - # @param member [Vapi::CallbackStep] - # @return [Vapi::Blocks::UpdateBlockDtoStepsItem] - def self.callback(member:) - new(member: member, discriminant: "callback") + begin + return Vapi::CallbackStep.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/blocks/types/update_block_dto_tool.rb b/lib/vapi/blocks/types/update_block_dto_tool.rb index e2cb319..66ba779 100644 --- a/lib/vapi/blocks/types/update_block_dto_tool.rb +++ b/lib/vapi/blocks/types/update_block_dto_tool.rb @@ -14,72 +14,69 @@ class Blocks # This is the tool that the block will call. To use an existing tool, use # `toolId`. class UpdateBlockDtoTool - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::Blocks::UpdateBlockDtoTool] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of UpdateBlockDtoTool # # @param json_object [String] # @return [Vapi::Blocks::UpdateBlockDtoTool] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "dtmf" - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - when "endCall" - Vapi::CreateEndCallToolDto.from_json(json_object: json_object) - when "voicemail" - Vapi::CreateVoicemailToolDto.from_json(json_object: json_object) - when "function" - Vapi::CreateFunctionToolDto.from_json(json_object: json_object) - when "ghl" - Vapi::CreateGhlToolDto.from_json(json_object: json_object) - when "make" - Vapi::CreateMakeToolDto.from_json(json_object: json_object) - when "transferCall" - Vapi::CreateTransferCallToolDto.from_json(json_object: json_object) - else - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::CreateDtmfToolDto.validate_raw(obj: struct) + return Vapi::CreateDtmfToolDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "dtmf" - { **@member.to_json, type: @discriminant }.to_json - when "endCall" - { **@member.to_json, type: @discriminant }.to_json - when "voicemail" - { **@member.to_json, type: @discriminant }.to_json - when "function" - { **@member.to_json, type: @discriminant }.to_json - when "ghl" - { **@member.to_json, type: @discriminant }.to_json - when "make" - { **@member.to_json, type: @discriminant }.to_json - when "transferCall" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateEndCallToolDto.validate_raw(obj: struct) + return Vapi::CreateEndCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVoicemailToolDto.validate_raw(obj: struct) + return Vapi::CreateVoicemailToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateFunctionToolDto.validate_raw(obj: struct) + return Vapi::CreateFunctionToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::CreateGhlToolDto.validate_raw(obj: struct) + return Vapi::CreateGhlToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateMakeToolDto.validate_raw(obj: struct) + return Vapi::CreateMakeToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTransferCallToolDto.validate_raw(obj: struct) + return Vapi::CreateTransferCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -89,74 +86,42 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "dtmf" - Vapi::CreateDtmfToolDto.validate_raw(obj: obj) - when "endCall" - Vapi::CreateEndCallToolDto.validate_raw(obj: obj) - when "voicemail" - Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) - when "function" - Vapi::CreateFunctionToolDto.validate_raw(obj: obj) - when "ghl" - Vapi::CreateGhlToolDto.validate_raw(obj: obj) - when "make" - Vapi::CreateMakeToolDto.validate_raw(obj: obj) - when "transferCall" - Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateDtmfToolDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateDtmfToolDto] - # @return [Vapi::Blocks::UpdateBlockDtoTool] - def self.dtmf(member:) - new(member: member, discriminant: "dtmf") - end - - # @param member [Vapi::CreateEndCallToolDto] - # @return [Vapi::Blocks::UpdateBlockDtoTool] - def self.end_call(member:) - new(member: member, discriminant: "endCall") - end - - # @param member [Vapi::CreateVoicemailToolDto] - # @return [Vapi::Blocks::UpdateBlockDtoTool] - def self.voicemail(member:) - new(member: member, discriminant: "voicemail") - end - - # @param member [Vapi::CreateFunctionToolDto] - # @return [Vapi::Blocks::UpdateBlockDtoTool] - def self.function(member:) - new(member: member, discriminant: "function") - end - - # @param member [Vapi::CreateGhlToolDto] - # @return [Vapi::Blocks::UpdateBlockDtoTool] - def self.ghl(member:) - new(member: member, discriminant: "ghl") - end - - # @param member [Vapi::CreateMakeToolDto] - # @return [Vapi::Blocks::UpdateBlockDtoTool] - def self.make(member:) - new(member: member, discriminant: "make") - end - - # @param member [Vapi::CreateTransferCallToolDto] - # @return [Vapi::Blocks::UpdateBlockDtoTool] - def self.transfer_call(member:) - new(member: member, discriminant: "transferCall") + begin + return Vapi::CreateEndCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateFunctionToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateGhlToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateMakeToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/phone_numbers/client.rb b/lib/vapi/phone_numbers/client.rb index 91a862a..96723c5 100644 --- a/lib/vapi/phone_numbers/client.rb +++ b/lib/vapi/phone_numbers/client.rb @@ -79,16 +79,16 @@ def list(limit: nil, created_at_gt: nil, created_at_lt: nil, created_at_ge: nil, end end - # @param request [Vapi::PhoneNumbers::PhoneNumbersCreateRequest] + # @param request [Vapi::CreateByoPhoneNumberDto, Vapi::CreateTwilioPhoneNumberDto, Vapi::CreateVonagePhoneNumberDto, Vapi::CreateVapiPhoneNumberDto] # @param request_options [Vapi::RequestOptions] - # @return [Vapi::PhoneNumbers::PhoneNumbersCreateResponse] + # @return [Vapi::ByoPhoneNumber, Vapi::TwilioPhoneNumber, Vapi::VonagePhoneNumber, Vapi::VapiPhoneNumber] # @example # api = Vapi::Client.new( # base_url: "https://api.example.com", # environment: Vapi::Environment::DEFAULT, # token: "YOUR_AUTH_TOKEN" # ) - # api.phone_numbers.create + # api.phone_numbers.create(request: { provider: "byo-phone-number", credential_id: "credentialId" }) def create(request:, request_options: nil) response = @request_client.conn.post do |req| req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? @@ -109,7 +109,7 @@ def create(request:, request_options: nil) # @param id [String] # @param request_options [Vapi::RequestOptions] - # @return [Vapi::PhoneNumbers::PhoneNumbersGetResponse] + # @return [Vapi::ByoPhoneNumber, Vapi::TwilioPhoneNumber, Vapi::VonagePhoneNumber, Vapi::VapiPhoneNumber] # @example # api = Vapi::Client.new( # base_url: "https://api.example.com", @@ -139,7 +139,7 @@ def get(id:, request_options: nil) # @param id [String] # @param request_options [Vapi::RequestOptions] - # @return [Vapi::PhoneNumbers::PhoneNumbersDeleteResponse] + # @return [Vapi::ByoPhoneNumber, Vapi::TwilioPhoneNumber, Vapi::VonagePhoneNumber, Vapi::VapiPhoneNumber] # @example # api = Vapi::Client.new( # base_url: "https://api.example.com", @@ -168,7 +168,7 @@ def delete(id:, request_options: nil) end # @param id [String] - # @param fallback_destination [Vapi::PhoneNumbers::UpdatePhoneNumberDtoFallbackDestination] This is the fallback destination an inbound call will be transferred to if: + # @param fallback_destination [Vapi::TransferDestinationNumber, Vapi::TransferDestinationSip] This is the fallback destination an inbound call will be transferred to if: # 1. `assistantId` is not set # 2. `squadId` is not set # 3. and, `assistant-request` message to the `serverUrl` fails @@ -192,7 +192,7 @@ def delete(id:, request_options: nil) # as a header called x-vapi-secret. # Same precedence logic as serverUrl. # @param request_options [Vapi::RequestOptions] - # @return [Vapi::PhoneNumbers::PhoneNumbersUpdateResponse] + # @return [Vapi::ByoPhoneNumber, Vapi::TwilioPhoneNumber, Vapi::VonagePhoneNumber, Vapi::VapiPhoneNumber] # @example # api = Vapi::Client.new( # base_url: "https://api.example.com", @@ -296,16 +296,16 @@ def list(limit: nil, created_at_gt: nil, created_at_lt: nil, created_at_ge: nil, end end - # @param request [Vapi::PhoneNumbers::PhoneNumbersCreateRequest] + # @param request [Vapi::CreateByoPhoneNumberDto, Vapi::CreateTwilioPhoneNumberDto, Vapi::CreateVonagePhoneNumberDto, Vapi::CreateVapiPhoneNumberDto] # @param request_options [Vapi::RequestOptions] - # @return [Vapi::PhoneNumbers::PhoneNumbersCreateResponse] + # @return [Vapi::ByoPhoneNumber, Vapi::TwilioPhoneNumber, Vapi::VonagePhoneNumber, Vapi::VapiPhoneNumber] # @example # api = Vapi::Client.new( # base_url: "https://api.example.com", # environment: Vapi::Environment::DEFAULT, # token: "YOUR_AUTH_TOKEN" # ) - # api.phone_numbers.create + # api.phone_numbers.create(request: { provider: "byo-phone-number", credential_id: "credentialId" }) def create(request:, request_options: nil) Async do response = @request_client.conn.post do |req| @@ -328,7 +328,7 @@ def create(request:, request_options: nil) # @param id [String] # @param request_options [Vapi::RequestOptions] - # @return [Vapi::PhoneNumbers::PhoneNumbersGetResponse] + # @return [Vapi::ByoPhoneNumber, Vapi::TwilioPhoneNumber, Vapi::VonagePhoneNumber, Vapi::VapiPhoneNumber] # @example # api = Vapi::Client.new( # base_url: "https://api.example.com", @@ -360,7 +360,7 @@ def get(id:, request_options: nil) # @param id [String] # @param request_options [Vapi::RequestOptions] - # @return [Vapi::PhoneNumbers::PhoneNumbersDeleteResponse] + # @return [Vapi::ByoPhoneNumber, Vapi::TwilioPhoneNumber, Vapi::VonagePhoneNumber, Vapi::VapiPhoneNumber] # @example # api = Vapi::Client.new( # base_url: "https://api.example.com", @@ -391,7 +391,7 @@ def delete(id:, request_options: nil) end # @param id [String] - # @param fallback_destination [Vapi::PhoneNumbers::UpdatePhoneNumberDtoFallbackDestination] This is the fallback destination an inbound call will be transferred to if: + # @param fallback_destination [Vapi::TransferDestinationNumber, Vapi::TransferDestinationSip] This is the fallback destination an inbound call will be transferred to if: # 1. `assistantId` is not set # 2. `squadId` is not set # 3. and, `assistant-request` message to the `serverUrl` fails @@ -415,7 +415,7 @@ def delete(id:, request_options: nil) # as a header called x-vapi-secret. # Same precedence logic as serverUrl. # @param request_options [Vapi::RequestOptions] - # @return [Vapi::PhoneNumbers::PhoneNumbersUpdateResponse] + # @return [Vapi::ByoPhoneNumber, Vapi::TwilioPhoneNumber, Vapi::VonagePhoneNumber, Vapi::VapiPhoneNumber] # @example # api = Vapi::Client.new( # base_url: "https://api.example.com", diff --git a/lib/vapi/phone_numbers/types/phone_numbers_create_request.rb b/lib/vapi/phone_numbers/types/phone_numbers_create_request.rb index 92bd780..7cde858 100644 --- a/lib/vapi/phone_numbers/types/phone_numbers_create_request.rb +++ b/lib/vapi/phone_numbers/types/phone_numbers_create_request.rb @@ -9,60 +9,45 @@ module Vapi class PhoneNumbers class PhoneNumbersCreateRequest - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::PhoneNumbers::PhoneNumbersCreateRequest] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of PhoneNumbersCreateRequest # # @param json_object [String] # @return [Vapi::PhoneNumbers::PhoneNumbersCreateRequest] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: json_object) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.from_json(json_object: json_object) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.from_json(json_object: json_object) - else - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end + begin + Vapi::CreateByoPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateByoPhoneNumberDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "byo-phone-number" - { **@member.to_json, provider: @discriminant }.to_json - when "twilio" - { **@member.to_json, provider: @discriminant }.to_json - when "vonage" - { **@member.to_json, provider: @discriminant }.to_json - when "vapi" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVonagePhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVapiPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -72,50 +57,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateByoPhoneNumberDto] - # @return [Vapi::PhoneNumbers::PhoneNumbersCreateRequest] - def self.byo_phone_number(member:) - new(member: member, discriminant: "byo-phone-number") - end - - # @param member [Vapi::CreateTwilioPhoneNumberDto] - # @return [Vapi::PhoneNumbers::PhoneNumbersCreateRequest] - def self.twilio(member:) - new(member: member, discriminant: "twilio") - end - - # @param member [Vapi::CreateVonagePhoneNumberDto] - # @return [Vapi::PhoneNumbers::PhoneNumbersCreateRequest] - def self.vonage(member:) - new(member: member, discriminant: "vonage") - end - - # @param member [Vapi::CreateVapiPhoneNumberDto] - # @return [Vapi::PhoneNumbers::PhoneNumbersCreateRequest] - def self.vapi(member:) - new(member: member, discriminant: "vapi") + begin + return Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/phone_numbers/types/phone_numbers_create_response.rb b/lib/vapi/phone_numbers/types/phone_numbers_create_response.rb index b38ac87..3dd5d70 100644 --- a/lib/vapi/phone_numbers/types/phone_numbers_create_response.rb +++ b/lib/vapi/phone_numbers/types/phone_numbers_create_response.rb @@ -9,60 +9,45 @@ module Vapi class PhoneNumbers class PhoneNumbersCreateResponse - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::PhoneNumbers::PhoneNumbersCreateResponse] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of PhoneNumbersCreateResponse # # @param json_object [String] # @return [Vapi::PhoneNumbers::PhoneNumbersCreateResponse] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "byo-phone-number" - Vapi::ByoPhoneNumber.from_json(json_object: json_object) - when "twilio" - Vapi::TwilioPhoneNumber.from_json(json_object: json_object) - when "vonage" - Vapi::VonagePhoneNumber.from_json(json_object: json_object) - when "vapi" - Vapi::VapiPhoneNumber.from_json(json_object: json_object) - else - Vapi::ByoPhoneNumber.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end + begin + Vapi::ByoPhoneNumber.validate_raw(obj: struct) + return Vapi::ByoPhoneNumber.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "byo-phone-number" - { **@member.to_json, provider: @discriminant }.to_json - when "twilio" - { **@member.to_json, provider: @discriminant }.to_json - when "vonage" - { **@member.to_json, provider: @discriminant }.to_json - when "vapi" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::TwilioPhoneNumber.validate_raw(obj: struct) + return Vapi::TwilioPhoneNumber.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::VonagePhoneNumber.validate_raw(obj: struct) + return Vapi::VonagePhoneNumber.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::VapiPhoneNumber.validate_raw(obj: struct) + return Vapi::VapiPhoneNumber.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -72,50 +57,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.provider - when "byo-phone-number" - Vapi::ByoPhoneNumber.validate_raw(obj: obj) - when "twilio" - Vapi::TwilioPhoneNumber.validate_raw(obj: obj) - when "vonage" - Vapi::VonagePhoneNumber.validate_raw(obj: obj) - when "vapi" - Vapi::VapiPhoneNumber.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ByoPhoneNumber.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ByoPhoneNumber] - # @return [Vapi::PhoneNumbers::PhoneNumbersCreateResponse] - def self.byo_phone_number(member:) - new(member: member, discriminant: "byo-phone-number") - end - - # @param member [Vapi::TwilioPhoneNumber] - # @return [Vapi::PhoneNumbers::PhoneNumbersCreateResponse] - def self.twilio(member:) - new(member: member, discriminant: "twilio") - end - - # @param member [Vapi::VonagePhoneNumber] - # @return [Vapi::PhoneNumbers::PhoneNumbersCreateResponse] - def self.vonage(member:) - new(member: member, discriminant: "vonage") - end - - # @param member [Vapi::VapiPhoneNumber] - # @return [Vapi::PhoneNumbers::PhoneNumbersCreateResponse] - def self.vapi(member:) - new(member: member, discriminant: "vapi") + begin + return Vapi::TwilioPhoneNumber.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::VonagePhoneNumber.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::VapiPhoneNumber.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/phone_numbers/types/phone_numbers_delete_response.rb b/lib/vapi/phone_numbers/types/phone_numbers_delete_response.rb index 711a5b8..43af03f 100644 --- a/lib/vapi/phone_numbers/types/phone_numbers_delete_response.rb +++ b/lib/vapi/phone_numbers/types/phone_numbers_delete_response.rb @@ -9,60 +9,45 @@ module Vapi class PhoneNumbers class PhoneNumbersDeleteResponse - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::PhoneNumbers::PhoneNumbersDeleteResponse] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of PhoneNumbersDeleteResponse # # @param json_object [String] # @return [Vapi::PhoneNumbers::PhoneNumbersDeleteResponse] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "byo-phone-number" - Vapi::ByoPhoneNumber.from_json(json_object: json_object) - when "twilio" - Vapi::TwilioPhoneNumber.from_json(json_object: json_object) - when "vonage" - Vapi::VonagePhoneNumber.from_json(json_object: json_object) - when "vapi" - Vapi::VapiPhoneNumber.from_json(json_object: json_object) - else - Vapi::ByoPhoneNumber.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end + begin + Vapi::ByoPhoneNumber.validate_raw(obj: struct) + return Vapi::ByoPhoneNumber.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "byo-phone-number" - { **@member.to_json, provider: @discriminant }.to_json - when "twilio" - { **@member.to_json, provider: @discriminant }.to_json - when "vonage" - { **@member.to_json, provider: @discriminant }.to_json - when "vapi" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::TwilioPhoneNumber.validate_raw(obj: struct) + return Vapi::TwilioPhoneNumber.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::VonagePhoneNumber.validate_raw(obj: struct) + return Vapi::VonagePhoneNumber.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::VapiPhoneNumber.validate_raw(obj: struct) + return Vapi::VapiPhoneNumber.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -72,50 +57,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.provider - when "byo-phone-number" - Vapi::ByoPhoneNumber.validate_raw(obj: obj) - when "twilio" - Vapi::TwilioPhoneNumber.validate_raw(obj: obj) - when "vonage" - Vapi::VonagePhoneNumber.validate_raw(obj: obj) - when "vapi" - Vapi::VapiPhoneNumber.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ByoPhoneNumber.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ByoPhoneNumber] - # @return [Vapi::PhoneNumbers::PhoneNumbersDeleteResponse] - def self.byo_phone_number(member:) - new(member: member, discriminant: "byo-phone-number") - end - - # @param member [Vapi::TwilioPhoneNumber] - # @return [Vapi::PhoneNumbers::PhoneNumbersDeleteResponse] - def self.twilio(member:) - new(member: member, discriminant: "twilio") - end - - # @param member [Vapi::VonagePhoneNumber] - # @return [Vapi::PhoneNumbers::PhoneNumbersDeleteResponse] - def self.vonage(member:) - new(member: member, discriminant: "vonage") - end - - # @param member [Vapi::VapiPhoneNumber] - # @return [Vapi::PhoneNumbers::PhoneNumbersDeleteResponse] - def self.vapi(member:) - new(member: member, discriminant: "vapi") + begin + return Vapi::TwilioPhoneNumber.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::VonagePhoneNumber.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::VapiPhoneNumber.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/phone_numbers/types/phone_numbers_get_response.rb b/lib/vapi/phone_numbers/types/phone_numbers_get_response.rb index 71a1751..60372fb 100644 --- a/lib/vapi/phone_numbers/types/phone_numbers_get_response.rb +++ b/lib/vapi/phone_numbers/types/phone_numbers_get_response.rb @@ -9,60 +9,45 @@ module Vapi class PhoneNumbers class PhoneNumbersGetResponse - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::PhoneNumbers::PhoneNumbersGetResponse] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of PhoneNumbersGetResponse # # @param json_object [String] # @return [Vapi::PhoneNumbers::PhoneNumbersGetResponse] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "byo-phone-number" - Vapi::ByoPhoneNumber.from_json(json_object: json_object) - when "twilio" - Vapi::TwilioPhoneNumber.from_json(json_object: json_object) - when "vonage" - Vapi::VonagePhoneNumber.from_json(json_object: json_object) - when "vapi" - Vapi::VapiPhoneNumber.from_json(json_object: json_object) - else - Vapi::ByoPhoneNumber.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end + begin + Vapi::ByoPhoneNumber.validate_raw(obj: struct) + return Vapi::ByoPhoneNumber.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "byo-phone-number" - { **@member.to_json, provider: @discriminant }.to_json - when "twilio" - { **@member.to_json, provider: @discriminant }.to_json - when "vonage" - { **@member.to_json, provider: @discriminant }.to_json - when "vapi" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::TwilioPhoneNumber.validate_raw(obj: struct) + return Vapi::TwilioPhoneNumber.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::VonagePhoneNumber.validate_raw(obj: struct) + return Vapi::VonagePhoneNumber.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::VapiPhoneNumber.validate_raw(obj: struct) + return Vapi::VapiPhoneNumber.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -72,50 +57,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.provider - when "byo-phone-number" - Vapi::ByoPhoneNumber.validate_raw(obj: obj) - when "twilio" - Vapi::TwilioPhoneNumber.validate_raw(obj: obj) - when "vonage" - Vapi::VonagePhoneNumber.validate_raw(obj: obj) - when "vapi" - Vapi::VapiPhoneNumber.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ByoPhoneNumber.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ByoPhoneNumber] - # @return [Vapi::PhoneNumbers::PhoneNumbersGetResponse] - def self.byo_phone_number(member:) - new(member: member, discriminant: "byo-phone-number") - end - - # @param member [Vapi::TwilioPhoneNumber] - # @return [Vapi::PhoneNumbers::PhoneNumbersGetResponse] - def self.twilio(member:) - new(member: member, discriminant: "twilio") - end - - # @param member [Vapi::VonagePhoneNumber] - # @return [Vapi::PhoneNumbers::PhoneNumbersGetResponse] - def self.vonage(member:) - new(member: member, discriminant: "vonage") - end - - # @param member [Vapi::VapiPhoneNumber] - # @return [Vapi::PhoneNumbers::PhoneNumbersGetResponse] - def self.vapi(member:) - new(member: member, discriminant: "vapi") + begin + return Vapi::TwilioPhoneNumber.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::VonagePhoneNumber.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::VapiPhoneNumber.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/phone_numbers/types/phone_numbers_list_response_item.rb b/lib/vapi/phone_numbers/types/phone_numbers_list_response_item.rb index 0585e2e..e4dee25 100644 --- a/lib/vapi/phone_numbers/types/phone_numbers_list_response_item.rb +++ b/lib/vapi/phone_numbers/types/phone_numbers_list_response_item.rb @@ -9,60 +9,45 @@ module Vapi class PhoneNumbers class PhoneNumbersListResponseItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::PhoneNumbers::PhoneNumbersListResponseItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of PhoneNumbersListResponseItem # # @param json_object [String] # @return [Vapi::PhoneNumbers::PhoneNumbersListResponseItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "byo-phone-number" - Vapi::ByoPhoneNumber.from_json(json_object: json_object) - when "twilio" - Vapi::TwilioPhoneNumber.from_json(json_object: json_object) - when "vonage" - Vapi::VonagePhoneNumber.from_json(json_object: json_object) - when "vapi" - Vapi::VapiPhoneNumber.from_json(json_object: json_object) - else - Vapi::ByoPhoneNumber.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end + begin + Vapi::ByoPhoneNumber.validate_raw(obj: struct) + return Vapi::ByoPhoneNumber.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "byo-phone-number" - { **@member.to_json, provider: @discriminant }.to_json - when "twilio" - { **@member.to_json, provider: @discriminant }.to_json - when "vonage" - { **@member.to_json, provider: @discriminant }.to_json - when "vapi" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::TwilioPhoneNumber.validate_raw(obj: struct) + return Vapi::TwilioPhoneNumber.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::VonagePhoneNumber.validate_raw(obj: struct) + return Vapi::VonagePhoneNumber.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::VapiPhoneNumber.validate_raw(obj: struct) + return Vapi::VapiPhoneNumber.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -72,50 +57,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.provider - when "byo-phone-number" - Vapi::ByoPhoneNumber.validate_raw(obj: obj) - when "twilio" - Vapi::TwilioPhoneNumber.validate_raw(obj: obj) - when "vonage" - Vapi::VonagePhoneNumber.validate_raw(obj: obj) - when "vapi" - Vapi::VapiPhoneNumber.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ByoPhoneNumber.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ByoPhoneNumber] - # @return [Vapi::PhoneNumbers::PhoneNumbersListResponseItem] - def self.byo_phone_number(member:) - new(member: member, discriminant: "byo-phone-number") - end - - # @param member [Vapi::TwilioPhoneNumber] - # @return [Vapi::PhoneNumbers::PhoneNumbersListResponseItem] - def self.twilio(member:) - new(member: member, discriminant: "twilio") - end - - # @param member [Vapi::VonagePhoneNumber] - # @return [Vapi::PhoneNumbers::PhoneNumbersListResponseItem] - def self.vonage(member:) - new(member: member, discriminant: "vonage") - end - - # @param member [Vapi::VapiPhoneNumber] - # @return [Vapi::PhoneNumbers::PhoneNumbersListResponseItem] - def self.vapi(member:) - new(member: member, discriminant: "vapi") + begin + return Vapi::TwilioPhoneNumber.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::VonagePhoneNumber.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::VapiPhoneNumber.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/phone_numbers/types/phone_numbers_update_response.rb b/lib/vapi/phone_numbers/types/phone_numbers_update_response.rb index ea0df6c..4c41a14 100644 --- a/lib/vapi/phone_numbers/types/phone_numbers_update_response.rb +++ b/lib/vapi/phone_numbers/types/phone_numbers_update_response.rb @@ -9,60 +9,45 @@ module Vapi class PhoneNumbers class PhoneNumbersUpdateResponse - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::PhoneNumbers::PhoneNumbersUpdateResponse] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of PhoneNumbersUpdateResponse # # @param json_object [String] # @return [Vapi::PhoneNumbers::PhoneNumbersUpdateResponse] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "byo-phone-number" - Vapi::ByoPhoneNumber.from_json(json_object: json_object) - when "twilio" - Vapi::TwilioPhoneNumber.from_json(json_object: json_object) - when "vonage" - Vapi::VonagePhoneNumber.from_json(json_object: json_object) - when "vapi" - Vapi::VapiPhoneNumber.from_json(json_object: json_object) - else - Vapi::ByoPhoneNumber.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end + begin + Vapi::ByoPhoneNumber.validate_raw(obj: struct) + return Vapi::ByoPhoneNumber.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "byo-phone-number" - { **@member.to_json, provider: @discriminant }.to_json - when "twilio" - { **@member.to_json, provider: @discriminant }.to_json - when "vonage" - { **@member.to_json, provider: @discriminant }.to_json - when "vapi" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::TwilioPhoneNumber.validate_raw(obj: struct) + return Vapi::TwilioPhoneNumber.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::VonagePhoneNumber.validate_raw(obj: struct) + return Vapi::VonagePhoneNumber.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::VapiPhoneNumber.validate_raw(obj: struct) + return Vapi::VapiPhoneNumber.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -72,50 +57,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.provider - when "byo-phone-number" - Vapi::ByoPhoneNumber.validate_raw(obj: obj) - when "twilio" - Vapi::TwilioPhoneNumber.validate_raw(obj: obj) - when "vonage" - Vapi::VonagePhoneNumber.validate_raw(obj: obj) - when "vapi" - Vapi::VapiPhoneNumber.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ByoPhoneNumber.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ByoPhoneNumber] - # @return [Vapi::PhoneNumbers::PhoneNumbersUpdateResponse] - def self.byo_phone_number(member:) - new(member: member, discriminant: "byo-phone-number") - end - - # @param member [Vapi::TwilioPhoneNumber] - # @return [Vapi::PhoneNumbers::PhoneNumbersUpdateResponse] - def self.twilio(member:) - new(member: member, discriminant: "twilio") - end - - # @param member [Vapi::VonagePhoneNumber] - # @return [Vapi::PhoneNumbers::PhoneNumbersUpdateResponse] - def self.vonage(member:) - new(member: member, discriminant: "vonage") - end - - # @param member [Vapi::VapiPhoneNumber] - # @return [Vapi::PhoneNumbers::PhoneNumbersUpdateResponse] - def self.vapi(member:) - new(member: member, discriminant: "vapi") + begin + return Vapi::TwilioPhoneNumber.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::VonagePhoneNumber.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::VapiPhoneNumber.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/phone_numbers/types/update_phone_number_dto_fallback_destination.rb b/lib/vapi/phone_numbers/types/update_phone_number_dto_fallback_destination.rb index 5187287..8517b6b 100644 --- a/lib/vapi/phone_numbers/types/update_phone_number_dto_fallback_destination.rb +++ b/lib/vapi/phone_numbers/types/update_phone_number_dto_fallback_destination.rb @@ -13,22 +13,6 @@ class PhoneNumbers # If this is not set and above conditions are met, the inbound call is hung up # with an error message. class UpdatePhoneNumberDtoFallbackDestination - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::PhoneNumbers::UpdatePhoneNumberDtoFallbackDestination] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of # UpdatePhoneNumberDtoFallbackDestination # @@ -36,30 +20,23 @@ def initialize(member:, discriminant:) # @return [Vapi::PhoneNumbers::UpdatePhoneNumberDtoFallbackDestination] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "number" - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - when "sip" - Vapi::TransferDestinationSip.from_json(json_object: json_object) - else - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::TransferDestinationNumber.validate_raw(obj: struct) + return Vapi::TransferDestinationNumber.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "number" - { **@member.to_json, type: @discriminant }.to_json - when "sip" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::TransferDestinationSip.validate_raw(obj: struct) + return Vapi::TransferDestinationSip.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -69,34 +46,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "number" - Vapi::TransferDestinationNumber.validate_raw(obj: obj) - when "sip" - Vapi::TransferDestinationSip.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::TransferDestinationNumber.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::TransferDestinationNumber] - # @return [Vapi::PhoneNumbers::UpdatePhoneNumberDtoFallbackDestination] - def self.number(member:) - new(member: member, discriminant: "number") - end - - # @param member [Vapi::TransferDestinationSip] - # @return [Vapi::PhoneNumbers::UpdatePhoneNumberDtoFallbackDestination] - def self.sip(member:) - new(member: member, discriminant: "sip") + begin + return Vapi::TransferDestinationSip.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/tools/client.rb b/lib/vapi/tools/client.rb index 7a98e72..59344d9 100644 --- a/lib/vapi/tools/client.rb +++ b/lib/vapi/tools/client.rb @@ -81,16 +81,16 @@ def list(limit: nil, created_at_gt: nil, created_at_lt: nil, created_at_ge: nil, end end - # @param request [Vapi::Tools::ToolsCreateRequest] + # @param request [Vapi::CreateDtmfToolDto, Vapi::CreateEndCallToolDto, Vapi::CreateFunctionToolDto, Vapi::CreateGhlToolDto, Vapi::CreateMakeToolDto, Vapi::CreateTransferCallToolDto, Vapi::CreateOutputToolDto] # @param request_options [Vapi::RequestOptions] - # @return [Vapi::Tools::ToolsCreateResponse] + # @return [Vapi::DtmfTool, Vapi::EndCallTool, Vapi::FunctionTool, Vapi::GhlTool, Vapi::MakeTool, Vapi::TransferCallTool, Vapi::OutputTool] # @example # api = Vapi::Client.new( # base_url: "https://api.example.com", # environment: Vapi::Environment::DEFAULT, # token: "YOUR_AUTH_TOKEN" # ) - # api.tools.create + # api.tools.create(request: { type: "dtmf" }) def create(request:, request_options: nil) response = @request_client.conn.post do |req| req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil? @@ -111,7 +111,7 @@ def create(request:, request_options: nil) # @param id [String] # @param request_options [Vapi::RequestOptions] - # @return [Vapi::Tools::ToolsGetResponse] + # @return [Vapi::DtmfTool, Vapi::EndCallTool, Vapi::FunctionTool, Vapi::GhlTool, Vapi::MakeTool, Vapi::TransferCallTool, Vapi::OutputTool] # @example # api = Vapi::Client.new( # base_url: "https://api.example.com", @@ -141,7 +141,7 @@ def get(id:, request_options: nil) # @param id [String] # @param request_options [Vapi::RequestOptions] - # @return [Vapi::Tools::ToolsDeleteResponse] + # @return [Vapi::DtmfTool, Vapi::EndCallTool, Vapi::FunctionTool, Vapi::GhlTool, Vapi::MakeTool, Vapi::TransferCallTool, Vapi::OutputTool] # @example # api = Vapi::Client.new( # base_url: "https://api.example.com", @@ -205,7 +205,7 @@ def delete(id:, request_options: nil) # * :url (String) # * :secret (String) # @param request_options [Vapi::RequestOptions] - # @return [Vapi::Tools::ToolsUpdateResponse] + # @return [Vapi::DtmfTool, Vapi::EndCallTool, Vapi::FunctionTool, Vapi::GhlTool, Vapi::MakeTool, Vapi::TransferCallTool, Vapi::OutputTool] # @example # api = Vapi::Client.new( # base_url: "https://api.example.com", @@ -306,16 +306,16 @@ def list(limit: nil, created_at_gt: nil, created_at_lt: nil, created_at_ge: nil, end end - # @param request [Vapi::Tools::ToolsCreateRequest] + # @param request [Vapi::CreateDtmfToolDto, Vapi::CreateEndCallToolDto, Vapi::CreateFunctionToolDto, Vapi::CreateGhlToolDto, Vapi::CreateMakeToolDto, Vapi::CreateTransferCallToolDto, Vapi::CreateOutputToolDto] # @param request_options [Vapi::RequestOptions] - # @return [Vapi::Tools::ToolsCreateResponse] + # @return [Vapi::DtmfTool, Vapi::EndCallTool, Vapi::FunctionTool, Vapi::GhlTool, Vapi::MakeTool, Vapi::TransferCallTool, Vapi::OutputTool] # @example # api = Vapi::Client.new( # base_url: "https://api.example.com", # environment: Vapi::Environment::DEFAULT, # token: "YOUR_AUTH_TOKEN" # ) - # api.tools.create + # api.tools.create(request: { type: "dtmf" }) def create(request:, request_options: nil) Async do response = @request_client.conn.post do |req| @@ -338,7 +338,7 @@ def create(request:, request_options: nil) # @param id [String] # @param request_options [Vapi::RequestOptions] - # @return [Vapi::Tools::ToolsGetResponse] + # @return [Vapi::DtmfTool, Vapi::EndCallTool, Vapi::FunctionTool, Vapi::GhlTool, Vapi::MakeTool, Vapi::TransferCallTool, Vapi::OutputTool] # @example # api = Vapi::Client.new( # base_url: "https://api.example.com", @@ -370,7 +370,7 @@ def get(id:, request_options: nil) # @param id [String] # @param request_options [Vapi::RequestOptions] - # @return [Vapi::Tools::ToolsDeleteResponse] + # @return [Vapi::DtmfTool, Vapi::EndCallTool, Vapi::FunctionTool, Vapi::GhlTool, Vapi::MakeTool, Vapi::TransferCallTool, Vapi::OutputTool] # @example # api = Vapi::Client.new( # base_url: "https://api.example.com", @@ -436,7 +436,7 @@ def delete(id:, request_options: nil) # * :url (String) # * :secret (String) # @param request_options [Vapi::RequestOptions] - # @return [Vapi::Tools::ToolsUpdateResponse] + # @return [Vapi::DtmfTool, Vapi::EndCallTool, Vapi::FunctionTool, Vapi::GhlTool, Vapi::MakeTool, Vapi::TransferCallTool, Vapi::OutputTool] # @example # api = Vapi::Client.new( # base_url: "https://api.example.com", diff --git a/lib/vapi/tools/types/tools_create_request.rb b/lib/vapi/tools/types/tools_create_request.rb index 35b1643..e5ebcaf 100644 --- a/lib/vapi/tools/types/tools_create_request.rb +++ b/lib/vapi/tools/types/tools_create_request.rb @@ -12,72 +12,69 @@ module Vapi class Tools class ToolsCreateRequest - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::Tools::ToolsCreateRequest] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of ToolsCreateRequest # # @param json_object [String] # @return [Vapi::Tools::ToolsCreateRequest] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "dtmf" - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - when "endCall" - Vapi::CreateEndCallToolDto.from_json(json_object: json_object) - when "function" - Vapi::CreateFunctionToolDto.from_json(json_object: json_object) - when "ghl" - Vapi::CreateGhlToolDto.from_json(json_object: json_object) - when "make" - Vapi::CreateMakeToolDto.from_json(json_object: json_object) - when "transferCall" - Vapi::CreateTransferCallToolDto.from_json(json_object: json_object) - when "output" - Vapi::CreateOutputToolDto.from_json(json_object: json_object) - else - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::CreateDtmfToolDto.validate_raw(obj: struct) + return Vapi::CreateDtmfToolDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "dtmf" - { **@member.to_json, type: @discriminant }.to_json - when "endCall" - { **@member.to_json, type: @discriminant }.to_json - when "function" - { **@member.to_json, type: @discriminant }.to_json - when "ghl" - { **@member.to_json, type: @discriminant }.to_json - when "make" - { **@member.to_json, type: @discriminant }.to_json - when "transferCall" - { **@member.to_json, type: @discriminant }.to_json - when "output" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateEndCallToolDto.validate_raw(obj: struct) + return Vapi::CreateEndCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateFunctionToolDto.validate_raw(obj: struct) + return Vapi::CreateFunctionToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateGhlToolDto.validate_raw(obj: struct) + return Vapi::CreateGhlToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::CreateMakeToolDto.validate_raw(obj: struct) + return Vapi::CreateMakeToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTransferCallToolDto.validate_raw(obj: struct) + return Vapi::CreateTransferCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateOutputToolDto.validate_raw(obj: struct) + return Vapi::CreateOutputToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -87,74 +84,42 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "dtmf" - Vapi::CreateDtmfToolDto.validate_raw(obj: obj) - when "endCall" - Vapi::CreateEndCallToolDto.validate_raw(obj: obj) - when "function" - Vapi::CreateFunctionToolDto.validate_raw(obj: obj) - when "ghl" - Vapi::CreateGhlToolDto.validate_raw(obj: obj) - when "make" - Vapi::CreateMakeToolDto.validate_raw(obj: obj) - when "transferCall" - Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) - when "output" - Vapi::CreateOutputToolDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateDtmfToolDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateDtmfToolDto] - # @return [Vapi::Tools::ToolsCreateRequest] - def self.dtmf(member:) - new(member: member, discriminant: "dtmf") - end - - # @param member [Vapi::CreateEndCallToolDto] - # @return [Vapi::Tools::ToolsCreateRequest] - def self.end_call(member:) - new(member: member, discriminant: "endCall") - end - - # @param member [Vapi::CreateFunctionToolDto] - # @return [Vapi::Tools::ToolsCreateRequest] - def self.function(member:) - new(member: member, discriminant: "function") - end - - # @param member [Vapi::CreateGhlToolDto] - # @return [Vapi::Tools::ToolsCreateRequest] - def self.ghl(member:) - new(member: member, discriminant: "ghl") - end - - # @param member [Vapi::CreateMakeToolDto] - # @return [Vapi::Tools::ToolsCreateRequest] - def self.make(member:) - new(member: member, discriminant: "make") - end - - # @param member [Vapi::CreateTransferCallToolDto] - # @return [Vapi::Tools::ToolsCreateRequest] - def self.transfer_call(member:) - new(member: member, discriminant: "transferCall") - end - - # @param member [Vapi::CreateOutputToolDto] - # @return [Vapi::Tools::ToolsCreateRequest] - def self.output(member:) - new(member: member, discriminant: "output") + begin + return Vapi::CreateEndCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateFunctionToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateGhlToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateMakeToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateOutputToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/tools/types/tools_create_response.rb b/lib/vapi/tools/types/tools_create_response.rb index 9d66cd5..91c29a4 100644 --- a/lib/vapi/tools/types/tools_create_response.rb +++ b/lib/vapi/tools/types/tools_create_response.rb @@ -12,72 +12,69 @@ module Vapi class Tools class ToolsCreateResponse - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::Tools::ToolsCreateResponse] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of ToolsCreateResponse # # @param json_object [String] # @return [Vapi::Tools::ToolsCreateResponse] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "dtmf" - Vapi::DtmfTool.from_json(json_object: json_object) - when "endCall" - Vapi::EndCallTool.from_json(json_object: json_object) - when "function" - Vapi::FunctionTool.from_json(json_object: json_object) - when "ghl" - Vapi::GhlTool.from_json(json_object: json_object) - when "make" - Vapi::MakeTool.from_json(json_object: json_object) - when "transferCall" - Vapi::TransferCallTool.from_json(json_object: json_object) - when "output" - Vapi::OutputTool.from_json(json_object: json_object) - else - Vapi::DtmfTool.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::DtmfTool.validate_raw(obj: struct) + return Vapi::DtmfTool.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "dtmf" - { **@member.to_json, type: @discriminant }.to_json - when "endCall" - { **@member.to_json, type: @discriminant }.to_json - when "function" - { **@member.to_json, type: @discriminant }.to_json - when "ghl" - { **@member.to_json, type: @discriminant }.to_json - when "make" - { **@member.to_json, type: @discriminant }.to_json - when "transferCall" - { **@member.to_json, type: @discriminant }.to_json - when "output" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::EndCallTool.validate_raw(obj: struct) + return Vapi::EndCallTool.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::FunctionTool.validate_raw(obj: struct) + return Vapi::FunctionTool.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::GhlTool.validate_raw(obj: struct) + return Vapi::GhlTool.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::MakeTool.validate_raw(obj: struct) + return Vapi::MakeTool.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::TransferCallTool.validate_raw(obj: struct) + return Vapi::TransferCallTool.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::OutputTool.validate_raw(obj: struct) + return Vapi::OutputTool.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -87,74 +84,42 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "dtmf" - Vapi::DtmfTool.validate_raw(obj: obj) - when "endCall" - Vapi::EndCallTool.validate_raw(obj: obj) - when "function" - Vapi::FunctionTool.validate_raw(obj: obj) - when "ghl" - Vapi::GhlTool.validate_raw(obj: obj) - when "make" - Vapi::MakeTool.validate_raw(obj: obj) - when "transferCall" - Vapi::TransferCallTool.validate_raw(obj: obj) - when "output" - Vapi::OutputTool.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::DtmfTool.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::DtmfTool] - # @return [Vapi::Tools::ToolsCreateResponse] - def self.dtmf(member:) - new(member: member, discriminant: "dtmf") - end - - # @param member [Vapi::EndCallTool] - # @return [Vapi::Tools::ToolsCreateResponse] - def self.end_call(member:) - new(member: member, discriminant: "endCall") - end - - # @param member [Vapi::FunctionTool] - # @return [Vapi::Tools::ToolsCreateResponse] - def self.function(member:) - new(member: member, discriminant: "function") - end - - # @param member [Vapi::GhlTool] - # @return [Vapi::Tools::ToolsCreateResponse] - def self.ghl(member:) - new(member: member, discriminant: "ghl") - end - - # @param member [Vapi::MakeTool] - # @return [Vapi::Tools::ToolsCreateResponse] - def self.make(member:) - new(member: member, discriminant: "make") - end - - # @param member [Vapi::TransferCallTool] - # @return [Vapi::Tools::ToolsCreateResponse] - def self.transfer_call(member:) - new(member: member, discriminant: "transferCall") - end - - # @param member [Vapi::OutputTool] - # @return [Vapi::Tools::ToolsCreateResponse] - def self.output(member:) - new(member: member, discriminant: "output") + begin + return Vapi::EndCallTool.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::FunctionTool.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::GhlTool.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::MakeTool.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::TransferCallTool.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::OutputTool.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/tools/types/tools_delete_response.rb b/lib/vapi/tools/types/tools_delete_response.rb index 258e32e..7a3440a 100644 --- a/lib/vapi/tools/types/tools_delete_response.rb +++ b/lib/vapi/tools/types/tools_delete_response.rb @@ -12,72 +12,69 @@ module Vapi class Tools class ToolsDeleteResponse - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::Tools::ToolsDeleteResponse] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of ToolsDeleteResponse # # @param json_object [String] # @return [Vapi::Tools::ToolsDeleteResponse] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "dtmf" - Vapi::DtmfTool.from_json(json_object: json_object) - when "endCall" - Vapi::EndCallTool.from_json(json_object: json_object) - when "function" - Vapi::FunctionTool.from_json(json_object: json_object) - when "ghl" - Vapi::GhlTool.from_json(json_object: json_object) - when "make" - Vapi::MakeTool.from_json(json_object: json_object) - when "transferCall" - Vapi::TransferCallTool.from_json(json_object: json_object) - when "output" - Vapi::OutputTool.from_json(json_object: json_object) - else - Vapi::DtmfTool.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::DtmfTool.validate_raw(obj: struct) + return Vapi::DtmfTool.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "dtmf" - { **@member.to_json, type: @discriminant }.to_json - when "endCall" - { **@member.to_json, type: @discriminant }.to_json - when "function" - { **@member.to_json, type: @discriminant }.to_json - when "ghl" - { **@member.to_json, type: @discriminant }.to_json - when "make" - { **@member.to_json, type: @discriminant }.to_json - when "transferCall" - { **@member.to_json, type: @discriminant }.to_json - when "output" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::EndCallTool.validate_raw(obj: struct) + return Vapi::EndCallTool.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::FunctionTool.validate_raw(obj: struct) + return Vapi::FunctionTool.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::GhlTool.validate_raw(obj: struct) + return Vapi::GhlTool.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::MakeTool.validate_raw(obj: struct) + return Vapi::MakeTool.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::TransferCallTool.validate_raw(obj: struct) + return Vapi::TransferCallTool.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::OutputTool.validate_raw(obj: struct) + return Vapi::OutputTool.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -87,74 +84,42 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "dtmf" - Vapi::DtmfTool.validate_raw(obj: obj) - when "endCall" - Vapi::EndCallTool.validate_raw(obj: obj) - when "function" - Vapi::FunctionTool.validate_raw(obj: obj) - when "ghl" - Vapi::GhlTool.validate_raw(obj: obj) - when "make" - Vapi::MakeTool.validate_raw(obj: obj) - when "transferCall" - Vapi::TransferCallTool.validate_raw(obj: obj) - when "output" - Vapi::OutputTool.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::DtmfTool.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::DtmfTool] - # @return [Vapi::Tools::ToolsDeleteResponse] - def self.dtmf(member:) - new(member: member, discriminant: "dtmf") - end - - # @param member [Vapi::EndCallTool] - # @return [Vapi::Tools::ToolsDeleteResponse] - def self.end_call(member:) - new(member: member, discriminant: "endCall") - end - - # @param member [Vapi::FunctionTool] - # @return [Vapi::Tools::ToolsDeleteResponse] - def self.function(member:) - new(member: member, discriminant: "function") - end - - # @param member [Vapi::GhlTool] - # @return [Vapi::Tools::ToolsDeleteResponse] - def self.ghl(member:) - new(member: member, discriminant: "ghl") - end - - # @param member [Vapi::MakeTool] - # @return [Vapi::Tools::ToolsDeleteResponse] - def self.make(member:) - new(member: member, discriminant: "make") - end - - # @param member [Vapi::TransferCallTool] - # @return [Vapi::Tools::ToolsDeleteResponse] - def self.transfer_call(member:) - new(member: member, discriminant: "transferCall") - end - - # @param member [Vapi::OutputTool] - # @return [Vapi::Tools::ToolsDeleteResponse] - def self.output(member:) - new(member: member, discriminant: "output") + begin + return Vapi::EndCallTool.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::FunctionTool.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::GhlTool.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::MakeTool.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::TransferCallTool.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::OutputTool.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/tools/types/tools_get_response.rb b/lib/vapi/tools/types/tools_get_response.rb index 63e816e..a6581fd 100644 --- a/lib/vapi/tools/types/tools_get_response.rb +++ b/lib/vapi/tools/types/tools_get_response.rb @@ -12,72 +12,69 @@ module Vapi class Tools class ToolsGetResponse - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::Tools::ToolsGetResponse] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of ToolsGetResponse # # @param json_object [String] # @return [Vapi::Tools::ToolsGetResponse] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "dtmf" - Vapi::DtmfTool.from_json(json_object: json_object) - when "endCall" - Vapi::EndCallTool.from_json(json_object: json_object) - when "function" - Vapi::FunctionTool.from_json(json_object: json_object) - when "ghl" - Vapi::GhlTool.from_json(json_object: json_object) - when "make" - Vapi::MakeTool.from_json(json_object: json_object) - when "transferCall" - Vapi::TransferCallTool.from_json(json_object: json_object) - when "output" - Vapi::OutputTool.from_json(json_object: json_object) - else - Vapi::DtmfTool.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::DtmfTool.validate_raw(obj: struct) + return Vapi::DtmfTool.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "dtmf" - { **@member.to_json, type: @discriminant }.to_json - when "endCall" - { **@member.to_json, type: @discriminant }.to_json - when "function" - { **@member.to_json, type: @discriminant }.to_json - when "ghl" - { **@member.to_json, type: @discriminant }.to_json - when "make" - { **@member.to_json, type: @discriminant }.to_json - when "transferCall" - { **@member.to_json, type: @discriminant }.to_json - when "output" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::EndCallTool.validate_raw(obj: struct) + return Vapi::EndCallTool.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::FunctionTool.validate_raw(obj: struct) + return Vapi::FunctionTool.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::GhlTool.validate_raw(obj: struct) + return Vapi::GhlTool.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::MakeTool.validate_raw(obj: struct) + return Vapi::MakeTool.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::TransferCallTool.validate_raw(obj: struct) + return Vapi::TransferCallTool.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::OutputTool.validate_raw(obj: struct) + return Vapi::OutputTool.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -87,74 +84,42 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "dtmf" - Vapi::DtmfTool.validate_raw(obj: obj) - when "endCall" - Vapi::EndCallTool.validate_raw(obj: obj) - when "function" - Vapi::FunctionTool.validate_raw(obj: obj) - when "ghl" - Vapi::GhlTool.validate_raw(obj: obj) - when "make" - Vapi::MakeTool.validate_raw(obj: obj) - when "transferCall" - Vapi::TransferCallTool.validate_raw(obj: obj) - when "output" - Vapi::OutputTool.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::DtmfTool.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::DtmfTool] - # @return [Vapi::Tools::ToolsGetResponse] - def self.dtmf(member:) - new(member: member, discriminant: "dtmf") - end - - # @param member [Vapi::EndCallTool] - # @return [Vapi::Tools::ToolsGetResponse] - def self.end_call(member:) - new(member: member, discriminant: "endCall") - end - - # @param member [Vapi::FunctionTool] - # @return [Vapi::Tools::ToolsGetResponse] - def self.function(member:) - new(member: member, discriminant: "function") - end - - # @param member [Vapi::GhlTool] - # @return [Vapi::Tools::ToolsGetResponse] - def self.ghl(member:) - new(member: member, discriminant: "ghl") - end - - # @param member [Vapi::MakeTool] - # @return [Vapi::Tools::ToolsGetResponse] - def self.make(member:) - new(member: member, discriminant: "make") - end - - # @param member [Vapi::TransferCallTool] - # @return [Vapi::Tools::ToolsGetResponse] - def self.transfer_call(member:) - new(member: member, discriminant: "transferCall") - end - - # @param member [Vapi::OutputTool] - # @return [Vapi::Tools::ToolsGetResponse] - def self.output(member:) - new(member: member, discriminant: "output") + begin + return Vapi::EndCallTool.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::FunctionTool.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::GhlTool.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::MakeTool.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::TransferCallTool.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::OutputTool.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/tools/types/tools_list_response_item.rb b/lib/vapi/tools/types/tools_list_response_item.rb index c5dd1bb..7d3915b 100644 --- a/lib/vapi/tools/types/tools_list_response_item.rb +++ b/lib/vapi/tools/types/tools_list_response_item.rb @@ -12,72 +12,69 @@ module Vapi class Tools class ToolsListResponseItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::Tools::ToolsListResponseItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of ToolsListResponseItem # # @param json_object [String] # @return [Vapi::Tools::ToolsListResponseItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "dtmf" - Vapi::DtmfTool.from_json(json_object: json_object) - when "endCall" - Vapi::EndCallTool.from_json(json_object: json_object) - when "function" - Vapi::FunctionTool.from_json(json_object: json_object) - when "ghl" - Vapi::GhlTool.from_json(json_object: json_object) - when "make" - Vapi::MakeTool.from_json(json_object: json_object) - when "transferCall" - Vapi::TransferCallTool.from_json(json_object: json_object) - when "output" - Vapi::OutputTool.from_json(json_object: json_object) - else - Vapi::DtmfTool.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::DtmfTool.validate_raw(obj: struct) + return Vapi::DtmfTool.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "dtmf" - { **@member.to_json, type: @discriminant }.to_json - when "endCall" - { **@member.to_json, type: @discriminant }.to_json - when "function" - { **@member.to_json, type: @discriminant }.to_json - when "ghl" - { **@member.to_json, type: @discriminant }.to_json - when "make" - { **@member.to_json, type: @discriminant }.to_json - when "transferCall" - { **@member.to_json, type: @discriminant }.to_json - when "output" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::EndCallTool.validate_raw(obj: struct) + return Vapi::EndCallTool.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::FunctionTool.validate_raw(obj: struct) + return Vapi::FunctionTool.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::GhlTool.validate_raw(obj: struct) + return Vapi::GhlTool.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::MakeTool.validate_raw(obj: struct) + return Vapi::MakeTool.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::TransferCallTool.validate_raw(obj: struct) + return Vapi::TransferCallTool.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::OutputTool.validate_raw(obj: struct) + return Vapi::OutputTool.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -87,74 +84,42 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "dtmf" - Vapi::DtmfTool.validate_raw(obj: obj) - when "endCall" - Vapi::EndCallTool.validate_raw(obj: obj) - when "function" - Vapi::FunctionTool.validate_raw(obj: obj) - when "ghl" - Vapi::GhlTool.validate_raw(obj: obj) - when "make" - Vapi::MakeTool.validate_raw(obj: obj) - when "transferCall" - Vapi::TransferCallTool.validate_raw(obj: obj) - when "output" - Vapi::OutputTool.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::DtmfTool.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::DtmfTool] - # @return [Vapi::Tools::ToolsListResponseItem] - def self.dtmf(member:) - new(member: member, discriminant: "dtmf") - end - - # @param member [Vapi::EndCallTool] - # @return [Vapi::Tools::ToolsListResponseItem] - def self.end_call(member:) - new(member: member, discriminant: "endCall") - end - - # @param member [Vapi::FunctionTool] - # @return [Vapi::Tools::ToolsListResponseItem] - def self.function(member:) - new(member: member, discriminant: "function") - end - - # @param member [Vapi::GhlTool] - # @return [Vapi::Tools::ToolsListResponseItem] - def self.ghl(member:) - new(member: member, discriminant: "ghl") - end - - # @param member [Vapi::MakeTool] - # @return [Vapi::Tools::ToolsListResponseItem] - def self.make(member:) - new(member: member, discriminant: "make") - end - - # @param member [Vapi::TransferCallTool] - # @return [Vapi::Tools::ToolsListResponseItem] - def self.transfer_call(member:) - new(member: member, discriminant: "transferCall") - end - - # @param member [Vapi::OutputTool] - # @return [Vapi::Tools::ToolsListResponseItem] - def self.output(member:) - new(member: member, discriminant: "output") + begin + return Vapi::EndCallTool.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::FunctionTool.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::GhlTool.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::MakeTool.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::TransferCallTool.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::OutputTool.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/tools/types/tools_update_response.rb b/lib/vapi/tools/types/tools_update_response.rb index 44f6d03..21a5c93 100644 --- a/lib/vapi/tools/types/tools_update_response.rb +++ b/lib/vapi/tools/types/tools_update_response.rb @@ -12,72 +12,69 @@ module Vapi class Tools class ToolsUpdateResponse - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::Tools::ToolsUpdateResponse] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of ToolsUpdateResponse # # @param json_object [String] # @return [Vapi::Tools::ToolsUpdateResponse] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "dtmf" - Vapi::DtmfTool.from_json(json_object: json_object) - when "endCall" - Vapi::EndCallTool.from_json(json_object: json_object) - when "function" - Vapi::FunctionTool.from_json(json_object: json_object) - when "ghl" - Vapi::GhlTool.from_json(json_object: json_object) - when "make" - Vapi::MakeTool.from_json(json_object: json_object) - when "transferCall" - Vapi::TransferCallTool.from_json(json_object: json_object) - when "output" - Vapi::OutputTool.from_json(json_object: json_object) - else - Vapi::DtmfTool.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::DtmfTool.validate_raw(obj: struct) + return Vapi::DtmfTool.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "dtmf" - { **@member.to_json, type: @discriminant }.to_json - when "endCall" - { **@member.to_json, type: @discriminant }.to_json - when "function" - { **@member.to_json, type: @discriminant }.to_json - when "ghl" - { **@member.to_json, type: @discriminant }.to_json - when "make" - { **@member.to_json, type: @discriminant }.to_json - when "transferCall" - { **@member.to_json, type: @discriminant }.to_json - when "output" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::EndCallTool.validate_raw(obj: struct) + return Vapi::EndCallTool.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::FunctionTool.validate_raw(obj: struct) + return Vapi::FunctionTool.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::GhlTool.validate_raw(obj: struct) + return Vapi::GhlTool.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::MakeTool.validate_raw(obj: struct) + return Vapi::MakeTool.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::TransferCallTool.validate_raw(obj: struct) + return Vapi::TransferCallTool.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::OutputTool.validate_raw(obj: struct) + return Vapi::OutputTool.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -87,74 +84,42 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "dtmf" - Vapi::DtmfTool.validate_raw(obj: obj) - when "endCall" - Vapi::EndCallTool.validate_raw(obj: obj) - when "function" - Vapi::FunctionTool.validate_raw(obj: obj) - when "ghl" - Vapi::GhlTool.validate_raw(obj: obj) - when "make" - Vapi::MakeTool.validate_raw(obj: obj) - when "transferCall" - Vapi::TransferCallTool.validate_raw(obj: obj) - when "output" - Vapi::OutputTool.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::DtmfTool.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::DtmfTool] - # @return [Vapi::Tools::ToolsUpdateResponse] - def self.dtmf(member:) - new(member: member, discriminant: "dtmf") - end - - # @param member [Vapi::EndCallTool] - # @return [Vapi::Tools::ToolsUpdateResponse] - def self.end_call(member:) - new(member: member, discriminant: "endCall") - end - - # @param member [Vapi::FunctionTool] - # @return [Vapi::Tools::ToolsUpdateResponse] - def self.function(member:) - new(member: member, discriminant: "function") - end - - # @param member [Vapi::GhlTool] - # @return [Vapi::Tools::ToolsUpdateResponse] - def self.ghl(member:) - new(member: member, discriminant: "ghl") - end - - # @param member [Vapi::MakeTool] - # @return [Vapi::Tools::ToolsUpdateResponse] - def self.make(member:) - new(member: member, discriminant: "make") - end - - # @param member [Vapi::TransferCallTool] - # @return [Vapi::Tools::ToolsUpdateResponse] - def self.transfer_call(member:) - new(member: member, discriminant: "transferCall") - end - - # @param member [Vapi::OutputTool] - # @return [Vapi::Tools::ToolsUpdateResponse] - def self.output(member:) - new(member: member, discriminant: "output") + begin + return Vapi::EndCallTool.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::FunctionTool.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::GhlTool.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::MakeTool.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::TransferCallTool.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::OutputTool.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/tools/types/update_tool_dto_messages_item.rb b/lib/vapi/tools/types/update_tool_dto_messages_item.rb index 7581031..76c4b09 100644 --- a/lib/vapi/tools/types/update_tool_dto_messages_item.rb +++ b/lib/vapi/tools/types/update_tool_dto_messages_item.rb @@ -9,60 +9,45 @@ module Vapi class Tools class UpdateToolDtoMessagesItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::Tools::UpdateToolDtoMessagesItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of UpdateToolDtoMessagesItem # # @param json_object [String] # @return [Vapi::Tools::UpdateToolDtoMessagesItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "request-start" - Vapi::ToolMessageStart.from_json(json_object: json_object) - when "request-complete" - Vapi::ToolMessageComplete.from_json(json_object: json_object) - when "request-failed" - Vapi::ToolMessageFailed.from_json(json_object: json_object) - when "request-response-delayed" - Vapi::ToolMessageDelayed.from_json(json_object: json_object) - else - Vapi::ToolMessageStart.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ToolMessageStart.validate_raw(obj: struct) + return Vapi::ToolMessageStart.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "request-start" - { **@member.to_json, type: @discriminant }.to_json - when "request-complete" - { **@member.to_json, type: @discriminant }.to_json - when "request-failed" - { **@member.to_json, type: @discriminant }.to_json - when "request-response-delayed" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageComplete.validate_raw(obj: struct) + return Vapi::ToolMessageComplete.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageFailed.validate_raw(obj: struct) + return Vapi::ToolMessageFailed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageDelayed.validate_raw(obj: struct) + return Vapi::ToolMessageDelayed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -72,50 +57,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "request-start" - Vapi::ToolMessageStart.validate_raw(obj: obj) - when "request-complete" - Vapi::ToolMessageComplete.validate_raw(obj: obj) - when "request-failed" - Vapi::ToolMessageFailed.validate_raw(obj: obj) - when "request-response-delayed" - Vapi::ToolMessageDelayed.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ToolMessageStart.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ToolMessageStart] - # @return [Vapi::Tools::UpdateToolDtoMessagesItem] - def self.request_start(member:) - new(member: member, discriminant: "request-start") - end - - # @param member [Vapi::ToolMessageComplete] - # @return [Vapi::Tools::UpdateToolDtoMessagesItem] - def self.request_complete(member:) - new(member: member, discriminant: "request-complete") - end - - # @param member [Vapi::ToolMessageFailed] - # @return [Vapi::Tools::UpdateToolDtoMessagesItem] - def self.request_failed(member:) - new(member: member, discriminant: "request-failed") - end - - # @param member [Vapi::ToolMessageDelayed] - # @return [Vapi::Tools::UpdateToolDtoMessagesItem] - def self.request_response_delayed(member:) - new(member: member, discriminant: "request-response-delayed") + begin + return Vapi::ToolMessageComplete.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageFailed.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageDelayed.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/analysis_cost.rb b/lib/vapi/types/analysis_cost.rb index 25ecea4..a2d4175 100644 --- a/lib/vapi/types/analysis_cost.rb +++ b/lib/vapi/types/analysis_cost.rb @@ -6,6 +6,8 @@ module Vapi class AnalysisCost + # @return [String] This is the type of cost, always 'analysis' for this class. + attr_reader :type # @return [Vapi::AnalysisCostAnalysisType] This is the type of analysis performed. attr_reader :analysis_type # @return [Hash{String => Object}] This is the model that was used to perform the analysis. @@ -24,6 +26,7 @@ class AnalysisCost OMIT = Object.new + # @param type [String] This is the type of cost, always 'analysis' for this class. # @param analysis_type [Vapi::AnalysisCostAnalysisType] This is the type of analysis performed. # @param model [Hash{String => Object}] This is the model that was used to perform the analysis. # @param prompt_tokens [Float] This is the number of prompt tokens used in the analysis. @@ -31,7 +34,8 @@ class AnalysisCost # @param cost [Float] This is the cost of the component in USD. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::AnalysisCost] - def initialize(analysis_type:, model:, prompt_tokens:, completion_tokens:, cost:, additional_properties: nil) + def initialize(type:, analysis_type:, model:, prompt_tokens:, completion_tokens:, cost:, additional_properties: nil) + @type = type @analysis_type = analysis_type @model = model @prompt_tokens = prompt_tokens @@ -39,6 +43,7 @@ def initialize(analysis_type:, model:, prompt_tokens:, completion_tokens:, cost: @cost = cost @additional_properties = additional_properties @_field_set = { + "type": type, "analysisType": analysis_type, "model": model, "promptTokens": prompt_tokens, @@ -54,12 +59,14 @@ def initialize(analysis_type:, model:, prompt_tokens:, completion_tokens:, cost: def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + type = parsed_json["type"] analysis_type = parsed_json["analysisType"] model = parsed_json["model"] prompt_tokens = parsed_json["promptTokens"] completion_tokens = parsed_json["completionTokens"] cost = parsed_json["cost"] new( + type: type, analysis_type: analysis_type, model: model, prompt_tokens: prompt_tokens, @@ -83,6 +90,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.analysis_type.is_a?(Vapi::AnalysisCostAnalysisType) != false || raise("Passed value for field obj.analysis_type is not the expected type, validation failed.") obj.model.is_a?(Hash) != false || raise("Passed value for field obj.model is not the expected type, validation failed.") obj.prompt_tokens.is_a?(Float) != false || raise("Passed value for field obj.prompt_tokens is not the expected type, validation failed.") diff --git a/lib/vapi/types/anthropic_model.rb b/lib/vapi/types/anthropic_model.rb index 2ba0520..6bd8c95 100644 --- a/lib/vapi/types/anthropic_model.rb +++ b/lib/vapi/types/anthropic_model.rb @@ -21,6 +21,8 @@ class AnthropicModel attr_reader :tool_ids # @return [Vapi::AnthropicModelModel] This is the Anthropic/Claude models that will be used. attr_reader :model + # @return [String] + attr_reader :provider # @return [Float] This is the temperature that will be used for calls. Default is 0 to leverage # caching for lower latency. attr_reader :temperature @@ -57,6 +59,7 @@ class AnthropicModel # tools, use `tools`. # Both `tools` and `toolIds` can be used together. # @param model [Vapi::AnthropicModelModel] This is the Anthropic/Claude models that will be used. + # @param provider [String] # @param temperature [Float] This is the temperature that will be used for calls. Default is 0 to leverage # caching for lower latency. # @param knowledge_base [Vapi::KnowledgeBase] These are the options for the knowledge base. @@ -74,12 +77,13 @@ class AnthropicModel # @default 0 # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::AnthropicModel] - def initialize(model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, temperature: OMIT, knowledge_base: OMIT, - max_tokens: OMIT, emotion_recognition_enabled: OMIT, num_fast_turns: OMIT, additional_properties: nil) + def initialize(model:, provider:, messages: OMIT, tools: OMIT, tool_ids: OMIT, temperature: OMIT, + knowledge_base: OMIT, max_tokens: OMIT, emotion_recognition_enabled: OMIT, num_fast_turns: OMIT, additional_properties: nil) @messages = messages if messages != OMIT @tools = tools if tools != OMIT @tool_ids = tool_ids if tool_ids != OMIT @model = model + @provider = provider @temperature = temperature if temperature != OMIT @knowledge_base = knowledge_base if knowledge_base != OMIT @max_tokens = max_tokens if max_tokens != OMIT @@ -91,6 +95,7 @@ def initialize(model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, temperature: "tools": tools, "toolIds": tool_ids, "model": model, + "provider": provider, "temperature": temperature, "knowledgeBase": knowledge_base, "maxTokens": max_tokens, @@ -118,6 +123,7 @@ def self.from_json(json_object:) end tool_ids = parsed_json["toolIds"] model = parsed_json["model"] + provider = parsed_json["provider"] temperature = parsed_json["temperature"] if parsed_json["knowledgeBase"].nil? knowledge_base = nil @@ -133,6 +139,7 @@ def self.from_json(json_object:) tools: tools, tool_ids: tool_ids, model: model, + provider: provider, temperature: temperature, knowledge_base: knowledge_base, max_tokens: max_tokens, @@ -160,6 +167,7 @@ def self.validate_raw(obj:) obj.tools&.is_a?(Array) != false || raise("Passed value for field obj.tools is not the expected type, validation failed.") obj.tool_ids&.is_a?(Array) != false || raise("Passed value for field obj.tool_ids is not the expected type, validation failed.") obj.model.is_a?(Vapi::AnthropicModelModel) != false || raise("Passed value for field obj.model is not the expected type, validation failed.") + obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") obj.temperature&.is_a?(Float) != false || raise("Passed value for field obj.temperature is not the expected type, validation failed.") obj.knowledge_base.nil? || Vapi::KnowledgeBase.validate_raw(obj: obj.knowledge_base) obj.max_tokens&.is_a?(Float) != false || raise("Passed value for field obj.max_tokens is not the expected type, validation failed.") diff --git a/lib/vapi/types/anthropic_model_tools_item.rb b/lib/vapi/types/anthropic_model_tools_item.rb index 8bcf54f..f60d056 100644 --- a/lib/vapi/types/anthropic_model_tools_item.rb +++ b/lib/vapi/types/anthropic_model_tools_item.rb @@ -11,72 +11,69 @@ module Vapi class AnthropicModelToolsItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::AnthropicModelToolsItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of AnthropicModelToolsItem # # @param json_object [String] # @return [Vapi::AnthropicModelToolsItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "dtmf" - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - when "endCall" - Vapi::CreateEndCallToolDto.from_json(json_object: json_object) - when "voicemail" - Vapi::CreateVoicemailToolDto.from_json(json_object: json_object) - when "function" - Vapi::CreateFunctionToolDto.from_json(json_object: json_object) - when "ghl" - Vapi::CreateGhlToolDto.from_json(json_object: json_object) - when "make" - Vapi::CreateMakeToolDto.from_json(json_object: json_object) - when "transferCall" - Vapi::CreateTransferCallToolDto.from_json(json_object: json_object) - else - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::CreateDtmfToolDto.validate_raw(obj: struct) + return Vapi::CreateDtmfToolDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "dtmf" - { **@member.to_json, type: @discriminant }.to_json - when "endCall" - { **@member.to_json, type: @discriminant }.to_json - when "voicemail" - { **@member.to_json, type: @discriminant }.to_json - when "function" - { **@member.to_json, type: @discriminant }.to_json - when "ghl" - { **@member.to_json, type: @discriminant }.to_json - when "make" - { **@member.to_json, type: @discriminant }.to_json - when "transferCall" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateEndCallToolDto.validate_raw(obj: struct) + return Vapi::CreateEndCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVoicemailToolDto.validate_raw(obj: struct) + return Vapi::CreateVoicemailToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateFunctionToolDto.validate_raw(obj: struct) + return Vapi::CreateFunctionToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::CreateGhlToolDto.validate_raw(obj: struct) + return Vapi::CreateGhlToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateMakeToolDto.validate_raw(obj: struct) + return Vapi::CreateMakeToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTransferCallToolDto.validate_raw(obj: struct) + return Vapi::CreateTransferCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -86,74 +83,42 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "dtmf" - Vapi::CreateDtmfToolDto.validate_raw(obj: obj) - when "endCall" - Vapi::CreateEndCallToolDto.validate_raw(obj: obj) - when "voicemail" - Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) - when "function" - Vapi::CreateFunctionToolDto.validate_raw(obj: obj) - when "ghl" - Vapi::CreateGhlToolDto.validate_raw(obj: obj) - when "make" - Vapi::CreateMakeToolDto.validate_raw(obj: obj) - when "transferCall" - Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateDtmfToolDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateDtmfToolDto] - # @return [Vapi::AnthropicModelToolsItem] - def self.dtmf(member:) - new(member: member, discriminant: "dtmf") - end - - # @param member [Vapi::CreateEndCallToolDto] - # @return [Vapi::AnthropicModelToolsItem] - def self.end_call(member:) - new(member: member, discriminant: "endCall") - end - - # @param member [Vapi::CreateVoicemailToolDto] - # @return [Vapi::AnthropicModelToolsItem] - def self.voicemail(member:) - new(member: member, discriminant: "voicemail") - end - - # @param member [Vapi::CreateFunctionToolDto] - # @return [Vapi::AnthropicModelToolsItem] - def self.function(member:) - new(member: member, discriminant: "function") - end - - # @param member [Vapi::CreateGhlToolDto] - # @return [Vapi::AnthropicModelToolsItem] - def self.ghl(member:) - new(member: member, discriminant: "ghl") - end - - # @param member [Vapi::CreateMakeToolDto] - # @return [Vapi::AnthropicModelToolsItem] - def self.make(member:) - new(member: member, discriminant: "make") - end - - # @param member [Vapi::CreateTransferCallToolDto] - # @return [Vapi::AnthropicModelToolsItem] - def self.transfer_call(member:) - new(member: member, discriminant: "transferCall") + begin + return Vapi::CreateEndCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateFunctionToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateGhlToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateMakeToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/anyscale_model.rb b/lib/vapi/types/anyscale_model.rb index 13828c9..ea91136 100644 --- a/lib/vapi/types/anyscale_model.rb +++ b/lib/vapi/types/anyscale_model.rb @@ -18,6 +18,8 @@ class AnyscaleModel # tools, use `tools`. # Both `tools` and `toolIds` can be used together. attr_reader :tool_ids + # @return [String] + attr_reader :provider # @return [String] This is the name of the model. Ex. cognitivecomputations/dolphin-mixtral-8x7b attr_reader :model # @return [Float] This is the temperature that will be used for calls. Default is 0 to leverage @@ -55,6 +57,7 @@ class AnyscaleModel # @param tool_ids [Array] These are the tools that the assistant can use during the call. To use transient # tools, use `tools`. # Both `tools` and `toolIds` can be used together. + # @param provider [String] # @param model [String] This is the name of the model. Ex. cognitivecomputations/dolphin-mixtral-8x7b # @param temperature [Float] This is the temperature that will be used for calls. Default is 0 to leverage # caching for lower latency. @@ -73,11 +76,12 @@ class AnyscaleModel # @default 0 # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::AnyscaleModel] - def initialize(model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, temperature: OMIT, knowledge_base: OMIT, - max_tokens: OMIT, emotion_recognition_enabled: OMIT, num_fast_turns: OMIT, additional_properties: nil) + def initialize(provider:, model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, temperature: OMIT, + knowledge_base: OMIT, max_tokens: OMIT, emotion_recognition_enabled: OMIT, num_fast_turns: OMIT, additional_properties: nil) @messages = messages if messages != OMIT @tools = tools if tools != OMIT @tool_ids = tool_ids if tool_ids != OMIT + @provider = provider @model = model @temperature = temperature if temperature != OMIT @knowledge_base = knowledge_base if knowledge_base != OMIT @@ -89,6 +93,7 @@ def initialize(model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, temperature: "messages": messages, "tools": tools, "toolIds": tool_ids, + "provider": provider, "model": model, "temperature": temperature, "knowledgeBase": knowledge_base, @@ -116,6 +121,7 @@ def self.from_json(json_object:) Vapi::AnyscaleModelToolsItem.from_json(json_object: item) end tool_ids = parsed_json["toolIds"] + provider = parsed_json["provider"] model = parsed_json["model"] temperature = parsed_json["temperature"] if parsed_json["knowledgeBase"].nil? @@ -131,6 +137,7 @@ def self.from_json(json_object:) messages: messages, tools: tools, tool_ids: tool_ids, + provider: provider, model: model, temperature: temperature, knowledge_base: knowledge_base, @@ -158,6 +165,7 @@ 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.tools&.is_a?(Array) != false || raise("Passed value for field obj.tools is not the expected type, validation failed.") obj.tool_ids&.is_a?(Array) != false || raise("Passed value for field obj.tool_ids is not the expected type, validation failed.") + obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") obj.model.is_a?(String) != false || raise("Passed value for field obj.model is not the expected type, validation failed.") obj.temperature&.is_a?(Float) != false || raise("Passed value for field obj.temperature is not the expected type, validation failed.") obj.knowledge_base.nil? || Vapi::KnowledgeBase.validate_raw(obj: obj.knowledge_base) diff --git a/lib/vapi/types/anyscale_model_tools_item.rb b/lib/vapi/types/anyscale_model_tools_item.rb index 48df935..d68d1cf 100644 --- a/lib/vapi/types/anyscale_model_tools_item.rb +++ b/lib/vapi/types/anyscale_model_tools_item.rb @@ -11,72 +11,69 @@ module Vapi class AnyscaleModelToolsItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::AnyscaleModelToolsItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of AnyscaleModelToolsItem # # @param json_object [String] # @return [Vapi::AnyscaleModelToolsItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "dtmf" - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - when "endCall" - Vapi::CreateEndCallToolDto.from_json(json_object: json_object) - when "voicemail" - Vapi::CreateVoicemailToolDto.from_json(json_object: json_object) - when "function" - Vapi::CreateFunctionToolDto.from_json(json_object: json_object) - when "ghl" - Vapi::CreateGhlToolDto.from_json(json_object: json_object) - when "make" - Vapi::CreateMakeToolDto.from_json(json_object: json_object) - when "transferCall" - Vapi::CreateTransferCallToolDto.from_json(json_object: json_object) - else - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::CreateDtmfToolDto.validate_raw(obj: struct) + return Vapi::CreateDtmfToolDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "dtmf" - { **@member.to_json, type: @discriminant }.to_json - when "endCall" - { **@member.to_json, type: @discriminant }.to_json - when "voicemail" - { **@member.to_json, type: @discriminant }.to_json - when "function" - { **@member.to_json, type: @discriminant }.to_json - when "ghl" - { **@member.to_json, type: @discriminant }.to_json - when "make" - { **@member.to_json, type: @discriminant }.to_json - when "transferCall" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateEndCallToolDto.validate_raw(obj: struct) + return Vapi::CreateEndCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVoicemailToolDto.validate_raw(obj: struct) + return Vapi::CreateVoicemailToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateFunctionToolDto.validate_raw(obj: struct) + return Vapi::CreateFunctionToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::CreateGhlToolDto.validate_raw(obj: struct) + return Vapi::CreateGhlToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateMakeToolDto.validate_raw(obj: struct) + return Vapi::CreateMakeToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTransferCallToolDto.validate_raw(obj: struct) + return Vapi::CreateTransferCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -86,74 +83,42 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "dtmf" - Vapi::CreateDtmfToolDto.validate_raw(obj: obj) - when "endCall" - Vapi::CreateEndCallToolDto.validate_raw(obj: obj) - when "voicemail" - Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) - when "function" - Vapi::CreateFunctionToolDto.validate_raw(obj: obj) - when "ghl" - Vapi::CreateGhlToolDto.validate_raw(obj: obj) - when "make" - Vapi::CreateMakeToolDto.validate_raw(obj: obj) - when "transferCall" - Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateDtmfToolDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateDtmfToolDto] - # @return [Vapi::AnyscaleModelToolsItem] - def self.dtmf(member:) - new(member: member, discriminant: "dtmf") - end - - # @param member [Vapi::CreateEndCallToolDto] - # @return [Vapi::AnyscaleModelToolsItem] - def self.end_call(member:) - new(member: member, discriminant: "endCall") - end - - # @param member [Vapi::CreateVoicemailToolDto] - # @return [Vapi::AnyscaleModelToolsItem] - def self.voicemail(member:) - new(member: member, discriminant: "voicemail") - end - - # @param member [Vapi::CreateFunctionToolDto] - # @return [Vapi::AnyscaleModelToolsItem] - def self.function(member:) - new(member: member, discriminant: "function") - end - - # @param member [Vapi::CreateGhlToolDto] - # @return [Vapi::AnyscaleModelToolsItem] - def self.ghl(member:) - new(member: member, discriminant: "ghl") - end - - # @param member [Vapi::CreateMakeToolDto] - # @return [Vapi::AnyscaleModelToolsItem] - def self.make(member:) - new(member: member, discriminant: "make") - end - - # @param member [Vapi::CreateTransferCallToolDto] - # @return [Vapi::AnyscaleModelToolsItem] - def self.transfer_call(member:) - new(member: member, discriminant: "transferCall") + begin + return Vapi::CreateEndCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateFunctionToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateGhlToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateMakeToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/assignment_mutation_conditions_item.rb b/lib/vapi/types/assignment_mutation_conditions_item.rb index 7e8fd53..766441a 100644 --- a/lib/vapi/types/assignment_mutation_conditions_item.rb +++ b/lib/vapi/types/assignment_mutation_conditions_item.rb @@ -6,52 +6,29 @@ module Vapi class AssignmentMutationConditionsItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::AssignmentMutationConditionsItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of AssignmentMutationConditionsItem # # @param json_object [String] # @return [Vapi::AssignmentMutationConditionsItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "model-based" - Vapi::ModelBasedCondition.from_json(json_object: json_object) - when "rule-based" - Vapi::RuleBasedCondition.from_json(json_object: json_object) - else - Vapi::ModelBasedCondition.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ModelBasedCondition.validate_raw(obj: struct) + return Vapi::ModelBasedCondition.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "model-based" - { **@member.to_json, type: @discriminant }.to_json - when "rule-based" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::RuleBasedCondition.validate_raw(obj: struct) + return Vapi::RuleBasedCondition.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -61,34 +38,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "model-based" - Vapi::ModelBasedCondition.validate_raw(obj: obj) - when "rule-based" - Vapi::RuleBasedCondition.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ModelBasedCondition.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ModelBasedCondition] - # @return [Vapi::AssignmentMutationConditionsItem] - def self.model_based(member:) - new(member: member, discriminant: "model-based") - end - - # @param member [Vapi::RuleBasedCondition] - # @return [Vapi::AssignmentMutationConditionsItem] - def self.rule_based(member:) - new(member: member, discriminant: "rule-based") + begin + return Vapi::RuleBasedCondition.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/assistant_model.rb b/lib/vapi/types/assistant_model.rb index 88a3053..faa82a6 100644 --- a/lib/vapi/types/assistant_model.rb +++ b/lib/vapi/types/assistant_model.rb @@ -15,185 +15,153 @@ module Vapi # These are the options for the assistant's LLM. class AssistantModel - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::AssistantModel] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of AssistantModel # # @param json_object [String] # @return [Vapi::AssistantModel] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "anyscale" - Vapi::AnyscaleModel.from_json(json_object: json_object) - when "anthropic" - Vapi::AnthropicModel.from_json(json_object: json_object) - when "custom-llm" - Vapi::CustomLlmModel.from_json(json_object: json_object) - when "deepinfra" - Vapi::DeepInfraModel.from_json(json_object: json_object) - when "groq" - Vapi::GroqModel.from_json(json_object: json_object) - when "openai" - Vapi::OpenAiModel.from_json(json_object: json_object) - when "openrouter" - Vapi::OpenRouterModel.from_json(json_object: json_object) - when "perplexity-ai" - Vapi::PerplexityAiModel.from_json(json_object: json_object) - when "together-ai" - Vapi::TogetherAiModel.from_json(json_object: json_object) - when "vapi" - Vapi::VapiModel.from_json(json_object: json_object) - else - Vapi::AnyscaleModel.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end - - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "anyscale" - { **@member.to_json, provider: @discriminant }.to_json - when "anthropic" - { **@member.to_json, provider: @discriminant }.to_json - when "custom-llm" - { **@member.to_json, provider: @discriminant }.to_json - when "deepinfra" - { **@member.to_json, provider: @discriminant }.to_json - when "groq" - { **@member.to_json, provider: @discriminant }.to_json - when "openai" - { **@member.to_json, provider: @discriminant }.to_json - when "openrouter" - { **@member.to_json, provider: @discriminant }.to_json - when "perplexity-ai" - { **@member.to_json, provider: @discriminant }.to_json - when "together-ai" - { **@member.to_json, provider: @discriminant }.to_json - when "vapi" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json - end - @member.to_json - end + begin + Vapi::AnyscaleModel.validate_raw(obj: struct) + return Vapi::AnyscaleModel.from_json(json_object: struct) unless struct.nil? - # 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. - # - # @param obj [Object] - # @return [Void] - def self.validate_raw(obj:) - case obj.provider - when "anyscale" - Vapi::AnyscaleModel.validate_raw(obj: obj) - when "anthropic" - Vapi::AnthropicModel.validate_raw(obj: obj) - when "custom-llm" - Vapi::CustomLlmModel.validate_raw(obj: obj) - when "deepinfra" - Vapi::DeepInfraModel.validate_raw(obj: obj) - when "groq" - Vapi::GroqModel.validate_raw(obj: obj) - when "openai" - Vapi::OpenAiModel.validate_raw(obj: obj) - when "openrouter" - Vapi::OpenRouterModel.validate_raw(obj: obj) - when "perplexity-ai" - Vapi::PerplexityAiModel.validate_raw(obj: obj) - when "together-ai" - Vapi::TogetherAiModel.validate_raw(obj: obj) - when "vapi" - Vapi::VapiModel.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + return nil + rescue StandardError + # noop end - end + begin + Vapi::AnthropicModel.validate_raw(obj: struct) + return Vapi::AnthropicModel.from_json(json_object: struct) unless struct.nil? - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::AnyscaleModel] - # @return [Vapi::AssistantModel] - def self.anyscale(member:) - new(member: member, discriminant: "anyscale") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::CustomLlmModel.validate_raw(obj: struct) + return Vapi::CustomLlmModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::AnthropicModel] - # @return [Vapi::AssistantModel] - def self.anthropic(member:) - new(member: member, discriminant: "anthropic") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::DeepInfraModel.validate_raw(obj: struct) + return Vapi::DeepInfraModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::CustomLlmModel] - # @return [Vapi::AssistantModel] - def self.custom_llm(member:) - new(member: member, discriminant: "custom-llm") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::GroqModel.validate_raw(obj: struct) + return Vapi::GroqModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::DeepInfraModel] - # @return [Vapi::AssistantModel] - def self.deepinfra(member:) - new(member: member, discriminant: "deepinfra") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::OpenAiModel.validate_raw(obj: struct) + return Vapi::OpenAiModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::GroqModel] - # @return [Vapi::AssistantModel] - def self.groq(member:) - new(member: member, discriminant: "groq") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::OpenRouterModel.validate_raw(obj: struct) + return Vapi::OpenRouterModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::OpenAiModel] - # @return [Vapi::AssistantModel] - def self.openai(member:) - new(member: member, discriminant: "openai") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::PerplexityAiModel.validate_raw(obj: struct) + return Vapi::PerplexityAiModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::OpenRouterModel] - # @return [Vapi::AssistantModel] - def self.openrouter(member:) - new(member: member, discriminant: "openrouter") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::TogetherAiModel.validate_raw(obj: struct) + return Vapi::TogetherAiModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::PerplexityAiModel] - # @return [Vapi::AssistantModel] - def self.perplexity_ai(member:) - new(member: member, discriminant: "perplexity-ai") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::VapiModel.validate_raw(obj: struct) + return Vapi::VapiModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::TogetherAiModel] - # @return [Vapi::AssistantModel] - def self.together_ai(member:) - new(member: member, discriminant: "together-ai") + return nil + rescue StandardError + # noop + end + struct end - # @param member [Vapi::VapiModel] - # @return [Vapi::AssistantModel] - def self.vapi(member:) - new(member: member, discriminant: "vapi") + # 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. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return Vapi::AnyscaleModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::AnthropicModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CustomLlmModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::DeepInfraModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::GroqModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::OpenAiModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::OpenRouterModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::PerplexityAiModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::TogetherAiModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::VapiModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/assistant_overrides_model.rb b/lib/vapi/types/assistant_overrides_model.rb index 5d2e64f..2a184ea 100644 --- a/lib/vapi/types/assistant_overrides_model.rb +++ b/lib/vapi/types/assistant_overrides_model.rb @@ -15,185 +15,153 @@ module Vapi # These are the options for the assistant's LLM. class AssistantOverridesModel - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::AssistantOverridesModel] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of AssistantOverridesModel # # @param json_object [String] # @return [Vapi::AssistantOverridesModel] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "anyscale" - Vapi::AnyscaleModel.from_json(json_object: json_object) - when "anthropic" - Vapi::AnthropicModel.from_json(json_object: json_object) - when "custom-llm" - Vapi::CustomLlmModel.from_json(json_object: json_object) - when "deepinfra" - Vapi::DeepInfraModel.from_json(json_object: json_object) - when "groq" - Vapi::GroqModel.from_json(json_object: json_object) - when "openai" - Vapi::OpenAiModel.from_json(json_object: json_object) - when "openrouter" - Vapi::OpenRouterModel.from_json(json_object: json_object) - when "perplexity-ai" - Vapi::PerplexityAiModel.from_json(json_object: json_object) - when "together-ai" - Vapi::TogetherAiModel.from_json(json_object: json_object) - when "vapi" - Vapi::VapiModel.from_json(json_object: json_object) - else - Vapi::AnyscaleModel.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end - - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "anyscale" - { **@member.to_json, provider: @discriminant }.to_json - when "anthropic" - { **@member.to_json, provider: @discriminant }.to_json - when "custom-llm" - { **@member.to_json, provider: @discriminant }.to_json - when "deepinfra" - { **@member.to_json, provider: @discriminant }.to_json - when "groq" - { **@member.to_json, provider: @discriminant }.to_json - when "openai" - { **@member.to_json, provider: @discriminant }.to_json - when "openrouter" - { **@member.to_json, provider: @discriminant }.to_json - when "perplexity-ai" - { **@member.to_json, provider: @discriminant }.to_json - when "together-ai" - { **@member.to_json, provider: @discriminant }.to_json - when "vapi" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json - end - @member.to_json - end + begin + Vapi::AnyscaleModel.validate_raw(obj: struct) + return Vapi::AnyscaleModel.from_json(json_object: struct) unless struct.nil? - # 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. - # - # @param obj [Object] - # @return [Void] - def self.validate_raw(obj:) - case obj.provider - when "anyscale" - Vapi::AnyscaleModel.validate_raw(obj: obj) - when "anthropic" - Vapi::AnthropicModel.validate_raw(obj: obj) - when "custom-llm" - Vapi::CustomLlmModel.validate_raw(obj: obj) - when "deepinfra" - Vapi::DeepInfraModel.validate_raw(obj: obj) - when "groq" - Vapi::GroqModel.validate_raw(obj: obj) - when "openai" - Vapi::OpenAiModel.validate_raw(obj: obj) - when "openrouter" - Vapi::OpenRouterModel.validate_raw(obj: obj) - when "perplexity-ai" - Vapi::PerplexityAiModel.validate_raw(obj: obj) - when "together-ai" - Vapi::TogetherAiModel.validate_raw(obj: obj) - when "vapi" - Vapi::VapiModel.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + return nil + rescue StandardError + # noop end - end + begin + Vapi::AnthropicModel.validate_raw(obj: struct) + return Vapi::AnthropicModel.from_json(json_object: struct) unless struct.nil? - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::AnyscaleModel] - # @return [Vapi::AssistantOverridesModel] - def self.anyscale(member:) - new(member: member, discriminant: "anyscale") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::CustomLlmModel.validate_raw(obj: struct) + return Vapi::CustomLlmModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::AnthropicModel] - # @return [Vapi::AssistantOverridesModel] - def self.anthropic(member:) - new(member: member, discriminant: "anthropic") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::DeepInfraModel.validate_raw(obj: struct) + return Vapi::DeepInfraModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::CustomLlmModel] - # @return [Vapi::AssistantOverridesModel] - def self.custom_llm(member:) - new(member: member, discriminant: "custom-llm") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::GroqModel.validate_raw(obj: struct) + return Vapi::GroqModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::DeepInfraModel] - # @return [Vapi::AssistantOverridesModel] - def self.deepinfra(member:) - new(member: member, discriminant: "deepinfra") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::OpenAiModel.validate_raw(obj: struct) + return Vapi::OpenAiModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::GroqModel] - # @return [Vapi::AssistantOverridesModel] - def self.groq(member:) - new(member: member, discriminant: "groq") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::OpenRouterModel.validate_raw(obj: struct) + return Vapi::OpenRouterModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::OpenAiModel] - # @return [Vapi::AssistantOverridesModel] - def self.openai(member:) - new(member: member, discriminant: "openai") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::PerplexityAiModel.validate_raw(obj: struct) + return Vapi::PerplexityAiModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::OpenRouterModel] - # @return [Vapi::AssistantOverridesModel] - def self.openrouter(member:) - new(member: member, discriminant: "openrouter") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::TogetherAiModel.validate_raw(obj: struct) + return Vapi::TogetherAiModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::PerplexityAiModel] - # @return [Vapi::AssistantOverridesModel] - def self.perplexity_ai(member:) - new(member: member, discriminant: "perplexity-ai") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::VapiModel.validate_raw(obj: struct) + return Vapi::VapiModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::TogetherAiModel] - # @return [Vapi::AssistantOverridesModel] - def self.together_ai(member:) - new(member: member, discriminant: "together-ai") + return nil + rescue StandardError + # noop + end + struct end - # @param member [Vapi::VapiModel] - # @return [Vapi::AssistantOverridesModel] - def self.vapi(member:) - new(member: member, discriminant: "vapi") + # 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. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return Vapi::AnyscaleModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::AnthropicModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CustomLlmModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::DeepInfraModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::GroqModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::OpenAiModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::OpenRouterModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::PerplexityAiModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::TogetherAiModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::VapiModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/assistant_overrides_transcriber.rb b/lib/vapi/types/assistant_overrides_transcriber.rb index 3955819..1896b6a 100644 --- a/lib/vapi/types/assistant_overrides_transcriber.rb +++ b/lib/vapi/types/assistant_overrides_transcriber.rb @@ -8,56 +8,37 @@ module Vapi # These are the options for the assistant's transcriber. class AssistantOverridesTranscriber - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::AssistantOverridesTranscriber] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of AssistantOverridesTranscriber # # @param json_object [String] # @return [Vapi::AssistantOverridesTranscriber] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "deepgram" - Vapi::DeepgramTranscriber.from_json(json_object: json_object) - when "gladia" - Vapi::GladiaTranscriber.from_json(json_object: json_object) - when "talkscriber" - Vapi::TalkscriberTranscriber.from_json(json_object: json_object) - else - Vapi::DeepgramTranscriber.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end + begin + Vapi::DeepgramTranscriber.validate_raw(obj: struct) + return Vapi::DeepgramTranscriber.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "deepgram" - { **@member.to_json, provider: @discriminant }.to_json - when "gladia" - { **@member.to_json, provider: @discriminant }.to_json - when "talkscriber" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::GladiaTranscriber.validate_raw(obj: struct) + return Vapi::GladiaTranscriber.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::TalkscriberTranscriber.validate_raw(obj: struct) + return Vapi::TalkscriberTranscriber.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -67,42 +48,22 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.provider - when "deepgram" - Vapi::DeepgramTranscriber.validate_raw(obj: obj) - when "gladia" - Vapi::GladiaTranscriber.validate_raw(obj: obj) - when "talkscriber" - Vapi::TalkscriberTranscriber.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::DeepgramTranscriber.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::DeepgramTranscriber] - # @return [Vapi::AssistantOverridesTranscriber] - def self.deepgram(member:) - new(member: member, discriminant: "deepgram") - end - - # @param member [Vapi::GladiaTranscriber] - # @return [Vapi::AssistantOverridesTranscriber] - def self.gladia(member:) - new(member: member, discriminant: "gladia") - end - - # @param member [Vapi::TalkscriberTranscriber] - # @return [Vapi::AssistantOverridesTranscriber] - def self.talkscriber(member:) - new(member: member, discriminant: "talkscriber") + begin + return Vapi::GladiaTranscriber.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::TalkscriberTranscriber.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/assistant_overrides_voice.rb b/lib/vapi/types/assistant_overrides_voice.rb index e63c558..48225cd 100644 --- a/lib/vapi/types/assistant_overrides_voice.rb +++ b/lib/vapi/types/assistant_overrides_voice.rb @@ -14,173 +14,140 @@ module Vapi # These are the options for the assistant's voice. class AssistantOverridesVoice - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::AssistantOverridesVoice] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of AssistantOverridesVoice # # @param json_object [String] # @return [Vapi::AssistantOverridesVoice] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "azure" - Vapi::AzureVoice.from_json(json_object: json_object) - when "cartesia" - Vapi::CartesiaVoice.from_json(json_object: json_object) - when "deepgram" - Vapi::DeepgramVoice.from_json(json_object: json_object) - when "11labs" - Vapi::ElevenLabsVoice.from_json(json_object: json_object) - when "lmnt" - Vapi::LmntVoice.from_json(json_object: json_object) - when "neets" - Vapi::NeetsVoice.from_json(json_object: json_object) - when "openai" - Vapi::OpenAiVoice.from_json(json_object: json_object) - when "playht" - Vapi::PlayHtVoice.from_json(json_object: json_object) - when "rime-ai" - Vapi::RimeAiVoice.from_json(json_object: json_object) - else - Vapi::AzureVoice.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end - - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "azure" - { **@member.to_json, provider: @discriminant }.to_json - when "cartesia" - { **@member.to_json, provider: @discriminant }.to_json - when "deepgram" - { **@member.to_json, provider: @discriminant }.to_json - when "11labs" - { **@member.to_json, provider: @discriminant }.to_json - when "lmnt" - { **@member.to_json, provider: @discriminant }.to_json - when "neets" - { **@member.to_json, provider: @discriminant }.to_json - when "openai" - { **@member.to_json, provider: @discriminant }.to_json - when "playht" - { **@member.to_json, provider: @discriminant }.to_json - when "rime-ai" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json - end - @member.to_json - end + begin + Vapi::AzureVoice.validate_raw(obj: struct) + return Vapi::AzureVoice.from_json(json_object: struct) unless struct.nil? - # 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. - # - # @param obj [Object] - # @return [Void] - def self.validate_raw(obj:) - case obj.provider - when "azure" - Vapi::AzureVoice.validate_raw(obj: obj) - when "cartesia" - Vapi::CartesiaVoice.validate_raw(obj: obj) - when "deepgram" - Vapi::DeepgramVoice.validate_raw(obj: obj) - when "11labs" - Vapi::ElevenLabsVoice.validate_raw(obj: obj) - when "lmnt" - Vapi::LmntVoice.validate_raw(obj: obj) - when "neets" - Vapi::NeetsVoice.validate_raw(obj: obj) - when "openai" - Vapi::OpenAiVoice.validate_raw(obj: obj) - when "playht" - Vapi::PlayHtVoice.validate_raw(obj: obj) - when "rime-ai" - Vapi::RimeAiVoice.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + return nil + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end + begin + Vapi::CartesiaVoice.validate_raw(obj: struct) + return Vapi::CartesiaVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::AzureVoice] - # @return [Vapi::AssistantOverridesVoice] - def self.azure(member:) - new(member: member, discriminant: "azure") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::DeepgramVoice.validate_raw(obj: struct) + return Vapi::DeepgramVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::CartesiaVoice] - # @return [Vapi::AssistantOverridesVoice] - def self.cartesia(member:) - new(member: member, discriminant: "cartesia") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::ElevenLabsVoice.validate_raw(obj: struct) + return Vapi::ElevenLabsVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::DeepgramVoice] - # @return [Vapi::AssistantOverridesVoice] - def self.deepgram(member:) - new(member: member, discriminant: "deepgram") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::LmntVoice.validate_raw(obj: struct) + return Vapi::LmntVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::ElevenLabsVoice] - # @return [Vapi::AssistantOverridesVoice] - def self._11_labs(member:) - new(member: member, discriminant: "11labs") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::NeetsVoice.validate_raw(obj: struct) + return Vapi::NeetsVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::LmntVoice] - # @return [Vapi::AssistantOverridesVoice] - def self.lmnt(member:) - new(member: member, discriminant: "lmnt") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::OpenAiVoice.validate_raw(obj: struct) + return Vapi::OpenAiVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::NeetsVoice] - # @return [Vapi::AssistantOverridesVoice] - def self.neets(member:) - new(member: member, discriminant: "neets") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::PlayHtVoice.validate_raw(obj: struct) + return Vapi::PlayHtVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::OpenAiVoice] - # @return [Vapi::AssistantOverridesVoice] - def self.openai(member:) - new(member: member, discriminant: "openai") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::RimeAiVoice.validate_raw(obj: struct) + return Vapi::RimeAiVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::PlayHtVoice] - # @return [Vapi::AssistantOverridesVoice] - def self.playht(member:) - new(member: member, discriminant: "playht") + return nil + rescue StandardError + # noop + end + struct end - # @param member [Vapi::RimeAiVoice] - # @return [Vapi::AssistantOverridesVoice] - def self.rime_ai(member:) - new(member: member, discriminant: "rime-ai") + # 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. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return Vapi::AzureVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CartesiaVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::DeepgramVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ElevenLabsVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::LmntVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::NeetsVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::OpenAiVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::PlayHtVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::RimeAiVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/assistant_transcriber.rb b/lib/vapi/types/assistant_transcriber.rb index 2ff78fc..19695a2 100644 --- a/lib/vapi/types/assistant_transcriber.rb +++ b/lib/vapi/types/assistant_transcriber.rb @@ -8,56 +8,37 @@ module Vapi # These are the options for the assistant's transcriber. class AssistantTranscriber - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::AssistantTranscriber] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of AssistantTranscriber # # @param json_object [String] # @return [Vapi::AssistantTranscriber] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "deepgram" - Vapi::DeepgramTranscriber.from_json(json_object: json_object) - when "gladia" - Vapi::GladiaTranscriber.from_json(json_object: json_object) - when "talkscriber" - Vapi::TalkscriberTranscriber.from_json(json_object: json_object) - else - Vapi::DeepgramTranscriber.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end + begin + Vapi::DeepgramTranscriber.validate_raw(obj: struct) + return Vapi::DeepgramTranscriber.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "deepgram" - { **@member.to_json, provider: @discriminant }.to_json - when "gladia" - { **@member.to_json, provider: @discriminant }.to_json - when "talkscriber" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::GladiaTranscriber.validate_raw(obj: struct) + return Vapi::GladiaTranscriber.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::TalkscriberTranscriber.validate_raw(obj: struct) + return Vapi::TalkscriberTranscriber.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -67,42 +48,22 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.provider - when "deepgram" - Vapi::DeepgramTranscriber.validate_raw(obj: obj) - when "gladia" - Vapi::GladiaTranscriber.validate_raw(obj: obj) - when "talkscriber" - Vapi::TalkscriberTranscriber.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::DeepgramTranscriber.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::DeepgramTranscriber] - # @return [Vapi::AssistantTranscriber] - def self.deepgram(member:) - new(member: member, discriminant: "deepgram") - end - - # @param member [Vapi::GladiaTranscriber] - # @return [Vapi::AssistantTranscriber] - def self.gladia(member:) - new(member: member, discriminant: "gladia") - end - - # @param member [Vapi::TalkscriberTranscriber] - # @return [Vapi::AssistantTranscriber] - def self.talkscriber(member:) - new(member: member, discriminant: "talkscriber") + begin + return Vapi::GladiaTranscriber.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::TalkscriberTranscriber.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/assistant_voice.rb b/lib/vapi/types/assistant_voice.rb index 4df4885..f3280ff 100644 --- a/lib/vapi/types/assistant_voice.rb +++ b/lib/vapi/types/assistant_voice.rb @@ -14,173 +14,140 @@ module Vapi # These are the options for the assistant's voice. class AssistantVoice - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::AssistantVoice] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of AssistantVoice # # @param json_object [String] # @return [Vapi::AssistantVoice] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "azure" - Vapi::AzureVoice.from_json(json_object: json_object) - when "cartesia" - Vapi::CartesiaVoice.from_json(json_object: json_object) - when "deepgram" - Vapi::DeepgramVoice.from_json(json_object: json_object) - when "11labs" - Vapi::ElevenLabsVoice.from_json(json_object: json_object) - when "lmnt" - Vapi::LmntVoice.from_json(json_object: json_object) - when "neets" - Vapi::NeetsVoice.from_json(json_object: json_object) - when "openai" - Vapi::OpenAiVoice.from_json(json_object: json_object) - when "playht" - Vapi::PlayHtVoice.from_json(json_object: json_object) - when "rime-ai" - Vapi::RimeAiVoice.from_json(json_object: json_object) - else - Vapi::AzureVoice.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end - - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "azure" - { **@member.to_json, provider: @discriminant }.to_json - when "cartesia" - { **@member.to_json, provider: @discriminant }.to_json - when "deepgram" - { **@member.to_json, provider: @discriminant }.to_json - when "11labs" - { **@member.to_json, provider: @discriminant }.to_json - when "lmnt" - { **@member.to_json, provider: @discriminant }.to_json - when "neets" - { **@member.to_json, provider: @discriminant }.to_json - when "openai" - { **@member.to_json, provider: @discriminant }.to_json - when "playht" - { **@member.to_json, provider: @discriminant }.to_json - when "rime-ai" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json - end - @member.to_json - end + begin + Vapi::AzureVoice.validate_raw(obj: struct) + return Vapi::AzureVoice.from_json(json_object: struct) unless struct.nil? - # 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. - # - # @param obj [Object] - # @return [Void] - def self.validate_raw(obj:) - case obj.provider - when "azure" - Vapi::AzureVoice.validate_raw(obj: obj) - when "cartesia" - Vapi::CartesiaVoice.validate_raw(obj: obj) - when "deepgram" - Vapi::DeepgramVoice.validate_raw(obj: obj) - when "11labs" - Vapi::ElevenLabsVoice.validate_raw(obj: obj) - when "lmnt" - Vapi::LmntVoice.validate_raw(obj: obj) - when "neets" - Vapi::NeetsVoice.validate_raw(obj: obj) - when "openai" - Vapi::OpenAiVoice.validate_raw(obj: obj) - when "playht" - Vapi::PlayHtVoice.validate_raw(obj: obj) - when "rime-ai" - Vapi::RimeAiVoice.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + return nil + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end + begin + Vapi::CartesiaVoice.validate_raw(obj: struct) + return Vapi::CartesiaVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::AzureVoice] - # @return [Vapi::AssistantVoice] - def self.azure(member:) - new(member: member, discriminant: "azure") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::DeepgramVoice.validate_raw(obj: struct) + return Vapi::DeepgramVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::CartesiaVoice] - # @return [Vapi::AssistantVoice] - def self.cartesia(member:) - new(member: member, discriminant: "cartesia") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::ElevenLabsVoice.validate_raw(obj: struct) + return Vapi::ElevenLabsVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::DeepgramVoice] - # @return [Vapi::AssistantVoice] - def self.deepgram(member:) - new(member: member, discriminant: "deepgram") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::LmntVoice.validate_raw(obj: struct) + return Vapi::LmntVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::ElevenLabsVoice] - # @return [Vapi::AssistantVoice] - def self._11_labs(member:) - new(member: member, discriminant: "11labs") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::NeetsVoice.validate_raw(obj: struct) + return Vapi::NeetsVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::LmntVoice] - # @return [Vapi::AssistantVoice] - def self.lmnt(member:) - new(member: member, discriminant: "lmnt") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::OpenAiVoice.validate_raw(obj: struct) + return Vapi::OpenAiVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::NeetsVoice] - # @return [Vapi::AssistantVoice] - def self.neets(member:) - new(member: member, discriminant: "neets") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::PlayHtVoice.validate_raw(obj: struct) + return Vapi::PlayHtVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::OpenAiVoice] - # @return [Vapi::AssistantVoice] - def self.openai(member:) - new(member: member, discriminant: "openai") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::RimeAiVoice.validate_raw(obj: struct) + return Vapi::RimeAiVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::PlayHtVoice] - # @return [Vapi::AssistantVoice] - def self.playht(member:) - new(member: member, discriminant: "playht") + return nil + rescue StandardError + # noop + end + struct end - # @param member [Vapi::RimeAiVoice] - # @return [Vapi::AssistantVoice] - def self.rime_ai(member:) - new(member: member, discriminant: "rime-ai") + # 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. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return Vapi::AzureVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CartesiaVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::DeepgramVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ElevenLabsVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::LmntVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::NeetsVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::OpenAiVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::PlayHtVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::RimeAiVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/azure_voice.rb b/lib/vapi/types/azure_voice.rb index 16a3078..5f70f16 100644 --- a/lib/vapi/types/azure_voice.rb +++ b/lib/vapi/types/azure_voice.rb @@ -11,6 +11,8 @@ class AzureVoice # inputting it into the voice provider. # Default `false` because you can achieve better results with prompting the model. attr_reader :filler_injection_enabled + # @return [String] This is the voice provider that will be used. + attr_reader :provider # @return [Vapi::AzureVoiceVoiceId] This is the provider-specific ID that will be used. attr_reader :voice_id # @return [Float] This is the speed multiplier that will be used. @@ -29,20 +31,24 @@ class AzureVoice # @param filler_injection_enabled [Boolean] This determines whether fillers are injected into the model output before # inputting it into the voice provider. # Default `false` because you can achieve better results with prompting the model. + # @param provider [String] This is the voice provider that will be used. # @param voice_id [Vapi::AzureVoiceVoiceId] This is the provider-specific ID that will be used. # @param speed [Float] This is the speed multiplier that will be used. # @param chunk_plan [Vapi::ChunkPlan] This is the plan for chunking the model output before it is sent to the voice # provider. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::AzureVoice] - def initialize(voice_id:, filler_injection_enabled: OMIT, speed: OMIT, chunk_plan: OMIT, additional_properties: nil) + def initialize(provider:, voice_id:, filler_injection_enabled: OMIT, speed: OMIT, chunk_plan: OMIT, + additional_properties: nil) @filler_injection_enabled = filler_injection_enabled if filler_injection_enabled != OMIT + @provider = provider @voice_id = voice_id @speed = speed if speed != OMIT @chunk_plan = chunk_plan if chunk_plan != OMIT @additional_properties = additional_properties @_field_set = { "fillerInjectionEnabled": filler_injection_enabled, + "provider": provider, "voiceId": voice_id, "speed": speed, "chunkPlan": chunk_plan @@ -59,6 +65,7 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) filler_injection_enabled = parsed_json["fillerInjectionEnabled"] + provider = parsed_json["provider"] if parsed_json["voiceId"].nil? voice_id = nil else @@ -74,6 +81,7 @@ def self.from_json(json_object:) end new( filler_injection_enabled: filler_injection_enabled, + provider: provider, voice_id: voice_id, speed: speed, chunk_plan: chunk_plan, @@ -96,6 +104,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.filler_injection_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.filler_injection_enabled is not the expected type, validation failed.") + obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") Vapi::AzureVoiceVoiceId.validate_raw(obj: obj.voice_id) obj.speed&.is_a?(Float) != false || raise("Passed value for field obj.speed is not the expected type, validation failed.") obj.chunk_plan.nil? || Vapi::ChunkPlan.validate_raw(obj: obj.chunk_plan) diff --git a/lib/vapi/types/block_complete_message.rb b/lib/vapi/types/block_complete_message.rb index ab45626..1a648dc 100644 --- a/lib/vapi/types/block_complete_message.rb +++ b/lib/vapi/types/block_complete_message.rb @@ -9,6 +9,8 @@ class BlockCompleteMessage # @return [Array] This is an optional array of conditions that must be met for this message to be # triggered. attr_reader :conditions + # @return [String] This is the message type that is triggered when the block completes. + attr_reader :type # @return [String] This is the content that the assistant will say when this message is triggered. attr_reader :content # @return [OpenStruct] Additional properties unmapped to the current class definition @@ -21,14 +23,16 @@ class BlockCompleteMessage # @param conditions [Array] This is an optional array of conditions that must be met for this message to be # triggered. + # @param type [String] This is the message type that is triggered when the block completes. # @param content [String] This is the content that the assistant will say when this message is triggered. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::BlockCompleteMessage] - def initialize(content:, conditions: OMIT, additional_properties: nil) + def initialize(type:, content:, conditions: OMIT, additional_properties: nil) @conditions = conditions if conditions != OMIT + @type = type @content = content @additional_properties = additional_properties - @_field_set = { "conditions": conditions, "content": content }.reject do |_k, v| + @_field_set = { "conditions": conditions, "type": type, "content": content }.reject do |_k, v| v == OMIT end end @@ -44,9 +48,11 @@ def self.from_json(json_object:) item = item.to_json Vapi::BlockCompleteMessageConditionsItem.from_json(json_object: item) end + type = parsed_json["type"] content = parsed_json["content"] new( conditions: conditions, + type: type, content: content, additional_properties: struct ) @@ -67,6 +73,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.conditions&.is_a?(Array) != false || raise("Passed value for field obj.conditions is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.content.is_a?(String) != false || raise("Passed value for field obj.content is not the expected type, validation failed.") end end diff --git a/lib/vapi/types/block_complete_message_conditions_item.rb b/lib/vapi/types/block_complete_message_conditions_item.rb index cfb73b1..7a9e1f9 100644 --- a/lib/vapi/types/block_complete_message_conditions_item.rb +++ b/lib/vapi/types/block_complete_message_conditions_item.rb @@ -6,52 +6,29 @@ module Vapi class BlockCompleteMessageConditionsItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::BlockCompleteMessageConditionsItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of BlockCompleteMessageConditionsItem # # @param json_object [String] # @return [Vapi::BlockCompleteMessageConditionsItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "model-based" - Vapi::ModelBasedCondition.from_json(json_object: json_object) - when "rule-based" - Vapi::RuleBasedCondition.from_json(json_object: json_object) - else - Vapi::ModelBasedCondition.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ModelBasedCondition.validate_raw(obj: struct) + return Vapi::ModelBasedCondition.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "model-based" - { **@member.to_json, type: @discriminant }.to_json - when "rule-based" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::RuleBasedCondition.validate_raw(obj: struct) + return Vapi::RuleBasedCondition.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -61,34 +38,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "model-based" - Vapi::ModelBasedCondition.validate_raw(obj: obj) - when "rule-based" - Vapi::RuleBasedCondition.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ModelBasedCondition.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ModelBasedCondition] - # @return [Vapi::BlockCompleteMessageConditionsItem] - def self.model_based(member:) - new(member: member, discriminant: "model-based") - end - - # @param member [Vapi::RuleBasedCondition] - # @return [Vapi::BlockCompleteMessageConditionsItem] - def self.rule_based(member:) - new(member: member, discriminant: "rule-based") + begin + return Vapi::RuleBasedCondition.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/block_start_message.rb b/lib/vapi/types/block_start_message.rb index 33b4223..efe2f10 100644 --- a/lib/vapi/types/block_start_message.rb +++ b/lib/vapi/types/block_start_message.rb @@ -9,6 +9,8 @@ class BlockStartMessage # @return [Array] This is an optional array of conditions that must be met for this message to be # triggered. attr_reader :conditions + # @return [String] This is the message type that is triggered when the block starts. + attr_reader :type # @return [String] This is the content that the assistant will say when this message is triggered. attr_reader :content # @return [OpenStruct] Additional properties unmapped to the current class definition @@ -21,14 +23,16 @@ class BlockStartMessage # @param conditions [Array] This is an optional array of conditions that must be met for this message to be # triggered. + # @param type [String] This is the message type that is triggered when the block starts. # @param content [String] This is the content that the assistant will say when this message is triggered. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::BlockStartMessage] - def initialize(content:, conditions: OMIT, additional_properties: nil) + def initialize(type:, content:, conditions: OMIT, additional_properties: nil) @conditions = conditions if conditions != OMIT + @type = type @content = content @additional_properties = additional_properties - @_field_set = { "conditions": conditions, "content": content }.reject do |_k, v| + @_field_set = { "conditions": conditions, "type": type, "content": content }.reject do |_k, v| v == OMIT end end @@ -44,9 +48,11 @@ def self.from_json(json_object:) item = item.to_json Vapi::BlockStartMessageConditionsItem.from_json(json_object: item) end + type = parsed_json["type"] content = parsed_json["content"] new( conditions: conditions, + type: type, content: content, additional_properties: struct ) @@ -67,6 +73,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.conditions&.is_a?(Array) != false || raise("Passed value for field obj.conditions is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.content.is_a?(String) != false || raise("Passed value for field obj.content is not the expected type, validation failed.") end end diff --git a/lib/vapi/types/block_start_message_conditions_item.rb b/lib/vapi/types/block_start_message_conditions_item.rb index 64fdd3b..5682542 100644 --- a/lib/vapi/types/block_start_message_conditions_item.rb +++ b/lib/vapi/types/block_start_message_conditions_item.rb @@ -6,52 +6,29 @@ module Vapi class BlockStartMessageConditionsItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::BlockStartMessageConditionsItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of BlockStartMessageConditionsItem # # @param json_object [String] # @return [Vapi::BlockStartMessageConditionsItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "model-based" - Vapi::ModelBasedCondition.from_json(json_object: json_object) - when "rule-based" - Vapi::RuleBasedCondition.from_json(json_object: json_object) - else - Vapi::ModelBasedCondition.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ModelBasedCondition.validate_raw(obj: struct) + return Vapi::ModelBasedCondition.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "model-based" - { **@member.to_json, type: @discriminant }.to_json - when "rule-based" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::RuleBasedCondition.validate_raw(obj: struct) + return Vapi::RuleBasedCondition.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -61,34 +38,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "model-based" - Vapi::ModelBasedCondition.validate_raw(obj: obj) - when "rule-based" - Vapi::RuleBasedCondition.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ModelBasedCondition.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ModelBasedCondition] - # @return [Vapi::BlockStartMessageConditionsItem] - def self.model_based(member:) - new(member: member, discriminant: "model-based") - end - - # @param member [Vapi::RuleBasedCondition] - # @return [Vapi::BlockStartMessageConditionsItem] - def self.rule_based(member:) - new(member: member, discriminant: "rule-based") + begin + return Vapi::RuleBasedCondition.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/buy_phone_number_dto_fallback_destination.rb b/lib/vapi/types/buy_phone_number_dto_fallback_destination.rb index 0a27386..4f43175 100644 --- a/lib/vapi/types/buy_phone_number_dto_fallback_destination.rb +++ b/lib/vapi/types/buy_phone_number_dto_fallback_destination.rb @@ -12,52 +12,29 @@ module Vapi # If this is not set and above conditions are met, the inbound call is hung up # with an error message. class BuyPhoneNumberDtoFallbackDestination - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::BuyPhoneNumberDtoFallbackDestination] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of BuyPhoneNumberDtoFallbackDestination # # @param json_object [String] # @return [Vapi::BuyPhoneNumberDtoFallbackDestination] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "number" - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - when "sip" - Vapi::TransferDestinationSip.from_json(json_object: json_object) - else - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::TransferDestinationNumber.validate_raw(obj: struct) + return Vapi::TransferDestinationNumber.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "number" - { **@member.to_json, type: @discriminant }.to_json - when "sip" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::TransferDestinationSip.validate_raw(obj: struct) + return Vapi::TransferDestinationSip.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -67,34 +44,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "number" - Vapi::TransferDestinationNumber.validate_raw(obj: obj) - when "sip" - Vapi::TransferDestinationSip.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::TransferDestinationNumber.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::TransferDestinationNumber] - # @return [Vapi::BuyPhoneNumberDtoFallbackDestination] - def self.number(member:) - new(member: member, discriminant: "number") - end - - # @param member [Vapi::TransferDestinationSip] - # @return [Vapi::BuyPhoneNumberDtoFallbackDestination] - def self.sip(member:) - new(member: member, discriminant: "sip") + begin + return Vapi::TransferDestinationSip.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/byo_phone_number.rb b/lib/vapi/types/byo_phone_number.rb index a1192db..73e254e 100644 --- a/lib/vapi/types/byo_phone_number.rb +++ b/lib/vapi/types/byo_phone_number.rb @@ -14,6 +14,8 @@ class ByoPhoneNumber # If this is not set and above conditions are met, the inbound call is hung up # with an error message. attr_reader :fallback_destination + # @return [String] + attr_reader :provider # @return [Boolean] This is the flag to toggle the E164 check for the `number` field. This is an # advanced property which should be used if you know your use case requires it. # Use cases: @@ -76,6 +78,7 @@ class ByoPhoneNumber # 3. and, `assistant-request` message to the `serverUrl` fails # If this is not set and above conditions are met, the inbound call is hung up # with an error message. + # @param provider [String] # @param number_e_164_check_enabled [Boolean] This is the flag to toggle the E164 check for the `number` field. This is an # advanced property which should be used if you know your use case requires it. # Use cases: @@ -114,9 +117,10 @@ class ByoPhoneNumber # on the Dashboard to get the credentialId. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ByoPhoneNumber] - def initialize(id:, org_id:, created_at:, updated_at:, credential_id:, fallback_destination: OMIT, + def initialize(provider:, id:, org_id:, created_at:, updated_at:, credential_id:, fallback_destination: OMIT, number_e_164_check_enabled: OMIT, name: OMIT, assistant_id: OMIT, squad_id: OMIT, server_url: OMIT, server_url_secret: OMIT, number: OMIT, additional_properties: nil) @fallback_destination = fallback_destination if fallback_destination != OMIT + @provider = provider @number_e_164_check_enabled = number_e_164_check_enabled if number_e_164_check_enabled != OMIT @id = id @org_id = org_id @@ -132,6 +136,7 @@ def initialize(id:, org_id:, created_at:, updated_at:, credential_id:, fallback_ @additional_properties = additional_properties @_field_set = { "fallbackDestination": fallback_destination, + "provider": provider, "numberE164CheckEnabled": number_e_164_check_enabled, "id": id, "orgId": org_id, @@ -162,6 +167,7 @@ def self.from_json(json_object:) fallback_destination = parsed_json["fallbackDestination"].to_json fallback_destination = Vapi::ByoPhoneNumberFallbackDestination.from_json(json_object: fallback_destination) end + provider = parsed_json["provider"] number_e_164_check_enabled = parsed_json["numberE164CheckEnabled"] id = parsed_json["id"] org_id = parsed_json["orgId"] @@ -176,6 +182,7 @@ def self.from_json(json_object:) credential_id = parsed_json["credentialId"] new( fallback_destination: fallback_destination, + provider: provider, number_e_164_check_enabled: number_e_164_check_enabled, id: id, org_id: org_id, @@ -207,6 +214,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.fallback_destination.nil? || Vapi::ByoPhoneNumberFallbackDestination.validate_raw(obj: obj.fallback_destination) + obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") obj.number_e_164_check_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.number_e_164_check_enabled 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.") diff --git a/lib/vapi/types/byo_phone_number_fallback_destination.rb b/lib/vapi/types/byo_phone_number_fallback_destination.rb index 66d2973..39fdfa4 100644 --- a/lib/vapi/types/byo_phone_number_fallback_destination.rb +++ b/lib/vapi/types/byo_phone_number_fallback_destination.rb @@ -12,52 +12,29 @@ module Vapi # If this is not set and above conditions are met, the inbound call is hung up # with an error message. class ByoPhoneNumberFallbackDestination - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ByoPhoneNumberFallbackDestination] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of ByoPhoneNumberFallbackDestination # # @param json_object [String] # @return [Vapi::ByoPhoneNumberFallbackDestination] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "number" - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - when "sip" - Vapi::TransferDestinationSip.from_json(json_object: json_object) - else - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::TransferDestinationNumber.validate_raw(obj: struct) + return Vapi::TransferDestinationNumber.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "number" - { **@member.to_json, type: @discriminant }.to_json - when "sip" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::TransferDestinationSip.validate_raw(obj: struct) + return Vapi::TransferDestinationSip.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -67,34 +44,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "number" - Vapi::TransferDestinationNumber.validate_raw(obj: obj) - when "sip" - Vapi::TransferDestinationSip.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::TransferDestinationNumber.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::TransferDestinationNumber] - # @return [Vapi::ByoPhoneNumberFallbackDestination] - def self.number(member:) - new(member: member, discriminant: "number") - end - - # @param member [Vapi::TransferDestinationSip] - # @return [Vapi::ByoPhoneNumberFallbackDestination] - def self.sip(member:) - new(member: member, discriminant: "sip") + begin + return Vapi::TransferDestinationSip.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/call_costs_item.rb b/lib/vapi/types/call_costs_item.rb index f529659..1ba2268 100644 --- a/lib/vapi/types/call_costs_item.rb +++ b/lib/vapi/types/call_costs_item.rb @@ -10,68 +10,61 @@ module Vapi class CallCostsItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::CallCostsItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of CallCostsItem # # @param json_object [String] # @return [Vapi::CallCostsItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "transport" - Vapi::TransportCost.from_json(json_object: json_object) - when "transcriber" - Vapi::TranscriberCost.from_json(json_object: json_object) - when "model" - Vapi::ModelCost.from_json(json_object: json_object) - when "voice" - Vapi::VoiceCost.from_json(json_object: json_object) - when "vapi" - Vapi::VapiCost.from_json(json_object: json_object) - when "analysis" - Vapi::AnalysisCost.from_json(json_object: json_object) - else - Vapi::TransportCost.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::TransportCost.validate_raw(obj: struct) + return Vapi::TransportCost.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "transport" - { **@member.to_json, type: @discriminant }.to_json - when "transcriber" - { **@member.to_json, type: @discriminant }.to_json - when "model" - { **@member.to_json, type: @discriminant }.to_json - when "voice" - { **@member.to_json, type: @discriminant }.to_json - when "vapi" - { **@member.to_json, type: @discriminant }.to_json - when "analysis" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::TranscriberCost.validate_raw(obj: struct) + return Vapi::TranscriberCost.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ModelCost.validate_raw(obj: struct) + return Vapi::ModelCost.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::VoiceCost.validate_raw(obj: struct) + return Vapi::VoiceCost.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::VapiCost.validate_raw(obj: struct) + return Vapi::VapiCost.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::AnalysisCost.validate_raw(obj: struct) + return Vapi::AnalysisCost.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -81,66 +74,37 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "transport" - Vapi::TransportCost.validate_raw(obj: obj) - when "transcriber" - Vapi::TranscriberCost.validate_raw(obj: obj) - when "model" - Vapi::ModelCost.validate_raw(obj: obj) - when "voice" - Vapi::VoiceCost.validate_raw(obj: obj) - when "vapi" - Vapi::VapiCost.validate_raw(obj: obj) - when "analysis" - Vapi::AnalysisCost.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::TransportCost.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::TransportCost] - # @return [Vapi::CallCostsItem] - def self.transport(member:) - new(member: member, discriminant: "transport") - end - - # @param member [Vapi::TranscriberCost] - # @return [Vapi::CallCostsItem] - def self.transcriber(member:) - new(member: member, discriminant: "transcriber") - end - - # @param member [Vapi::ModelCost] - # @return [Vapi::CallCostsItem] - def self.model(member:) - new(member: member, discriminant: "model") - end - - # @param member [Vapi::VoiceCost] - # @return [Vapi::CallCostsItem] - def self.voice(member:) - new(member: member, discriminant: "voice") - end - - # @param member [Vapi::VapiCost] - # @return [Vapi::CallCostsItem] - def self.vapi(member:) - new(member: member, discriminant: "vapi") - end - - # @param member [Vapi::AnalysisCost] - # @return [Vapi::CallCostsItem] - def self.analysis(member:) - new(member: member, discriminant: "analysis") + begin + return Vapi::TranscriberCost.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ModelCost.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::VoiceCost.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::VapiCost.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::AnalysisCost.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/call_destination.rb b/lib/vapi/types/call_destination.rb index 1fdcb2b..af1be78 100644 --- a/lib/vapi/types/call_destination.rb +++ b/lib/vapi/types/call_destination.rb @@ -8,52 +8,29 @@ module Vapi # This is the destination where the call ended up being transferred to. If the # call was not transferred, this will be empty. class CallDestination - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::CallDestination] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of CallDestination # # @param json_object [String] # @return [Vapi::CallDestination] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "number" - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - when "sip" - Vapi::TransferDestinationSip.from_json(json_object: json_object) - else - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::TransferDestinationNumber.validate_raw(obj: struct) + return Vapi::TransferDestinationNumber.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "number" - { **@member.to_json, type: @discriminant }.to_json - when "sip" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::TransferDestinationSip.validate_raw(obj: struct) + return Vapi::TransferDestinationSip.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -63,34 +40,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "number" - Vapi::TransferDestinationNumber.validate_raw(obj: obj) - when "sip" - Vapi::TransferDestinationSip.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::TransferDestinationNumber.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::TransferDestinationNumber] - # @return [Vapi::CallDestination] - def self.number(member:) - new(member: member, discriminant: "number") - end - - # @param member [Vapi::TransferDestinationSip] - # @return [Vapi::CallDestination] - def self.sip(member:) - new(member: member, discriminant: "sip") + begin + return Vapi::TransferDestinationSip.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/callback_step.rb b/lib/vapi/types/callback_step.rb index 573ddf6..76ed8c8 100644 --- a/lib/vapi/types/callback_step.rb +++ b/lib/vapi/types/callback_step.rb @@ -9,6 +9,14 @@ module Vapi class CallbackStep # @return [Vapi::CallbackStepBlock] This is the block to use. To use an existing block, use `blockId`. attr_reader :block + # @return [String] This is a step that calls back to the previous step after it's done. This + # effectively means we're spawning a new conversation thread. The previous + # conversation thread will resume where it left off once this step is done. + # Use case: + # - You are collecting a customer's order and while they were on one item, they + # start a new item or try to modify a previous one. You would make a OrderUpdate + # block which calls the same block repeatedly when a new update starts. + attr_reader :type # @return [Array] This is the mutations to apply to the context after the step is done. attr_reader :mutations # @return [String] This is the name of the step. @@ -76,6 +84,13 @@ class CallbackStep OMIT = Object.new # @param block [Vapi::CallbackStepBlock] This is the block to use. To use an existing block, use `blockId`. + # @param type [String] This is a step that calls back to the previous step after it's done. This + # effectively means we're spawning a new conversation thread. The previous + # conversation thread will resume where it left off once this step is done. + # Use case: + # - You are collecting a customer's order and while they were on one item, they + # start a new item or try to modify a previous one. You would make a OrderUpdate + # block which calls the same block repeatedly when a new update starts. # @param mutations [Array] This is the mutations to apply to the context after the step is done. # @param name [String] This is the name of the step. # @param block_id [String] This is the id of the block to use. To use a transient block, use `block`. @@ -132,8 +147,9 @@ class CallbackStep # blocks outside of a workflow. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::CallbackStep] - def initialize(name:, block: OMIT, mutations: OMIT, block_id: OMIT, input: OMIT, additional_properties: nil) + def initialize(type:, name:, block: OMIT, mutations: OMIT, block_id: OMIT, input: OMIT, additional_properties: nil) @block = block if block != OMIT + @type = type @mutations = mutations if mutations != OMIT @name = name @block_id = block_id if block_id != OMIT @@ -141,6 +157,7 @@ def initialize(name:, block: OMIT, mutations: OMIT, block_id: OMIT, input: OMIT, @additional_properties = additional_properties @_field_set = { "block": block, + "type": type, "mutations": mutations, "name": name, "blockId": block_id, @@ -163,6 +180,7 @@ def self.from_json(json_object:) block = parsed_json["block"].to_json block = Vapi::CallbackStepBlock.from_json(json_object: block) end + type = parsed_json["type"] mutations = parsed_json["mutations"]&.map do |item| item = item.to_json Vapi::AssignmentMutation.from_json(json_object: item) @@ -172,6 +190,7 @@ def self.from_json(json_object:) input = parsed_json["input"] new( block: block, + type: type, mutations: mutations, name: name, block_id: block_id, @@ -195,6 +214,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.block.nil? || Vapi::CallbackStepBlock.validate_raw(obj: obj.block) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.mutations&.is_a?(Array) != false || raise("Passed value for field obj.mutations is not the expected type, validation failed.") obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") obj.block_id&.is_a?(String) != false || raise("Passed value for field obj.block_id is not the expected type, validation failed.") diff --git a/lib/vapi/types/callback_step_block.rb b/lib/vapi/types/callback_step_block.rb index 30dc2db..508c438 100644 --- a/lib/vapi/types/callback_step_block.rb +++ b/lib/vapi/types/callback_step_block.rb @@ -8,56 +8,37 @@ module Vapi # This is the block to use. To use an existing block, use `blockId`. class CallbackStepBlock - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::CallbackStepBlock] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of CallbackStepBlock # # @param json_object [String] # @return [Vapi::CallbackStepBlock] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "conversation" - Vapi::CreateConversationBlockDto.from_json(json_object: json_object) - when "tool-call" - Vapi::CreateToolCallBlockDto.from_json(json_object: json_object) - when "workflow" - Vapi::CreateWorkflowBlockDto.from_json(json_object: json_object) - else - Vapi::CreateConversationBlockDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::CreateConversationBlockDto.validate_raw(obj: struct) + return Vapi::CreateConversationBlockDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "conversation" - { **@member.to_json, type: @discriminant }.to_json - when "tool-call" - { **@member.to_json, type: @discriminant }.to_json - when "workflow" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::CreateToolCallBlockDto.validate_raw(obj: struct) + return Vapi::CreateToolCallBlockDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateWorkflowBlockDto.validate_raw(obj: struct) + return Vapi::CreateWorkflowBlockDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -67,42 +48,22 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "conversation" - Vapi::CreateConversationBlockDto.validate_raw(obj: obj) - when "tool-call" - Vapi::CreateToolCallBlockDto.validate_raw(obj: obj) - when "workflow" - Vapi::CreateWorkflowBlockDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateConversationBlockDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateConversationBlockDto] - # @return [Vapi::CallbackStepBlock] - def self.conversation(member:) - new(member: member, discriminant: "conversation") - end - - # @param member [Vapi::CreateToolCallBlockDto] - # @return [Vapi::CallbackStepBlock] - def self.tool_call(member:) - new(member: member, discriminant: "tool-call") - end - - # @param member [Vapi::CreateWorkflowBlockDto] - # @return [Vapi::CallbackStepBlock] - def self.workflow(member:) - new(member: member, discriminant: "workflow") + begin + return Vapi::CreateToolCallBlockDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateWorkflowBlockDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/cartesia_voice.rb b/lib/vapi/types/cartesia_voice.rb index 79f0917..bb0c53d 100644 --- a/lib/vapi/types/cartesia_voice.rb +++ b/lib/vapi/types/cartesia_voice.rb @@ -12,6 +12,8 @@ class CartesiaVoice # inputting it into the voice provider. # Default `false` because you can achieve better results with prompting the model. attr_reader :filler_injection_enabled + # @return [String] This is the voice provider that will be used. + attr_reader :provider # @return [Vapi::CartesiaVoiceModel] This is the model that will be used. This is optional and will default to the # correct model for the voiceId. attr_reader :model @@ -34,6 +36,7 @@ class CartesiaVoice # @param filler_injection_enabled [Boolean] This determines whether fillers are injected into the model output before # inputting it into the voice provider. # Default `false` because you can achieve better results with prompting the model. + # @param provider [String] This is the voice provider that will be used. # @param model [Vapi::CartesiaVoiceModel] This is the model that will be used. This is optional and will default to the # correct model for the voiceId. # @param language [Vapi::CartesiaVoiceLanguage] This is the language that will be used. This is optional and will default to the @@ -43,9 +46,10 @@ class CartesiaVoice # provider. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::CartesiaVoice] - def initialize(voice_id:, filler_injection_enabled: OMIT, model: OMIT, language: OMIT, chunk_plan: OMIT, + def initialize(provider:, voice_id:, filler_injection_enabled: OMIT, model: OMIT, language: OMIT, chunk_plan: OMIT, additional_properties: nil) @filler_injection_enabled = filler_injection_enabled if filler_injection_enabled != OMIT + @provider = provider @model = model if model != OMIT @language = language if language != OMIT @voice_id = voice_id @@ -53,6 +57,7 @@ def initialize(voice_id:, filler_injection_enabled: OMIT, model: OMIT, language: @additional_properties = additional_properties @_field_set = { "fillerInjectionEnabled": filler_injection_enabled, + "provider": provider, "model": model, "language": language, "voiceId": voice_id, @@ -70,6 +75,7 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) filler_injection_enabled = parsed_json["fillerInjectionEnabled"] + provider = parsed_json["provider"] model = parsed_json["model"] language = parsed_json["language"] voice_id = parsed_json["voiceId"] @@ -81,6 +87,7 @@ def self.from_json(json_object:) end new( filler_injection_enabled: filler_injection_enabled, + provider: provider, model: model, language: language, voice_id: voice_id, @@ -104,6 +111,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.filler_injection_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.filler_injection_enabled is not the expected type, validation failed.") + obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") obj.model&.is_a?(Vapi::CartesiaVoiceModel) != false || raise("Passed value for field obj.model is not the expected type, validation failed.") obj.language&.is_a?(Vapi::CartesiaVoiceLanguage) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") obj.voice_id.is_a?(String) != false || raise("Passed value for field obj.voice_id is not the expected type, validation failed.") diff --git a/lib/vapi/types/chunk_plan.rb b/lib/vapi/types/chunk_plan.rb index 0e97c8b..d401dcf 100644 --- a/lib/vapi/types/chunk_plan.rb +++ b/lib/vapi/types/chunk_plan.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative "chunk_plan_punctuation_boundaries_item" +require_relative "punctuation_boundary" require_relative "format_plan" require "ostruct" require "json" @@ -21,7 +21,7 @@ class ChunkPlan # - To decrease latency, set this to a lower value. # @default 30 attr_reader :min_characters - # @return [Array] These are the punctuations that are considered valid boundaries for a chunk to + # @return [Array] These are the punctuations that are considered valid boundaries for a chunk to # be created. # Usage: # - To increase quality, constrain to fewer boundaries. @@ -52,7 +52,7 @@ class ChunkPlan # - To increase quality, set this to a higher value. # - To decrease latency, set this to a lower value. # @default 30 - # @param punctuation_boundaries [Array] These are the punctuations that are considered valid boundaries for a chunk to + # @param punctuation_boundaries [Array] These are the punctuations that are considered valid boundaries for a chunk to # be created. # Usage: # - To increase quality, constrain to fewer boundaries. diff --git a/lib/vapi/types/client_inbound_message_add_message.rb b/lib/vapi/types/client_inbound_message_add_message.rb index b0fd931..8a4b4db 100644 --- a/lib/vapi/types/client_inbound_message_add_message.rb +++ b/lib/vapi/types/client_inbound_message_add_message.rb @@ -6,6 +6,9 @@ module Vapi class ClientInboundMessageAddMessage + # @return [String] This is the type of the message. Send "add-message" message to add a message to + # the conversation history. + attr_reader :type # @return [Vapi::OpenAiMessage] This is the message to add to the conversation. attr_reader :message # @return [OpenStruct] Additional properties unmapped to the current class definition @@ -16,13 +19,16 @@ class ClientInboundMessageAddMessage OMIT = Object.new + # @param type [String] This is the type of the message. Send "add-message" message to add a message to + # the conversation history. # @param message [Vapi::OpenAiMessage] This is the message to add to the conversation. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ClientInboundMessageAddMessage] - def initialize(message:, additional_properties: nil) + def initialize(type:, message:, additional_properties: nil) + @type = type @message = message @additional_properties = additional_properties - @_field_set = { "message": message } + @_field_set = { "type": type, "message": message } end # Deserialize a JSON object to an instance of ClientInboundMessageAddMessage @@ -32,13 +38,18 @@ def initialize(message:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + type = parsed_json["type"] if parsed_json["message"].nil? message = nil else message = parsed_json["message"].to_json message = Vapi::OpenAiMessage.from_json(json_object: message) end - new(message: message, additional_properties: struct) + new( + type: type, + message: message, + additional_properties: struct + ) end # Serialize an instance of ClientInboundMessageAddMessage to a JSON object @@ -55,6 +66,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") Vapi::OpenAiMessage.validate_raw(obj: obj.message) end end diff --git a/lib/vapi/types/client_inbound_message_control.rb b/lib/vapi/types/client_inbound_message_control.rb index 0c5bb24..570bc7c 100644 --- a/lib/vapi/types/client_inbound_message_control.rb +++ b/lib/vapi/types/client_inbound_message_control.rb @@ -6,6 +6,14 @@ module Vapi class ClientInboundMessageControl + # @return [String] This is the type of the message. Send "control" message to control the + # assistant. `control` options are: + # - "mute-assistant" - mute the assistant + # - "unmute-assistant" - unmute the assistant + # - "say-first-message" - say the first message (this is used when video recording + # is enabled and the conversation is only started once the client side kicks off + # the recording) + attr_reader :type # @return [Vapi::ClientInboundMessageControlControl] This is the control action attr_reader :control # @return [OpenStruct] Additional properties unmapped to the current class definition @@ -16,13 +24,21 @@ class ClientInboundMessageControl OMIT = Object.new + # @param type [String] This is the type of the message. Send "control" message to control the + # assistant. `control` options are: + # - "mute-assistant" - mute the assistant + # - "unmute-assistant" - unmute the assistant + # - "say-first-message" - say the first message (this is used when video recording + # is enabled and the conversation is only started once the client side kicks off + # the recording) # @param control [Vapi::ClientInboundMessageControlControl] This is the control action # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ClientInboundMessageControl] - def initialize(control:, additional_properties: nil) + def initialize(type:, control:, additional_properties: nil) + @type = type @control = control @additional_properties = additional_properties - @_field_set = { "control": control } + @_field_set = { "type": type, "control": control } end # Deserialize a JSON object to an instance of ClientInboundMessageControl @@ -32,8 +48,13 @@ def initialize(control:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + type = parsed_json["type"] control = parsed_json["control"] - new(control: control, additional_properties: struct) + new( + type: type, + control: control, + additional_properties: struct + ) end # Serialize an instance of ClientInboundMessageControl to a JSON object @@ -50,6 +71,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.control.is_a?(Vapi::ClientInboundMessageControlControl) != false || raise("Passed value for field obj.control is not the expected type, validation failed.") end end diff --git a/lib/vapi/types/client_inbound_message_message.rb b/lib/vapi/types/client_inbound_message_message.rb index e699148..a04813d 100644 --- a/lib/vapi/types/client_inbound_message_message.rb +++ b/lib/vapi/types/client_inbound_message_message.rb @@ -9,56 +9,37 @@ module Vapi # These are the messages that can be sent from client-side SDKs to control the # call. class ClientInboundMessageMessage - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ClientInboundMessageMessage] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of ClientInboundMessageMessage # # @param json_object [String] # @return [Vapi::ClientInboundMessageMessage] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "add-message" - Vapi::ClientInboundMessageAddMessage.from_json(json_object: json_object) - when "control" - Vapi::ClientInboundMessageControl.from_json(json_object: json_object) - when "say" - Vapi::ClientInboundMessageSay.from_json(json_object: json_object) - else - Vapi::ClientInboundMessageAddMessage.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ClientInboundMessageAddMessage.validate_raw(obj: struct) + return Vapi::ClientInboundMessageAddMessage.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "add-message" - { **@member.to_json, type: @discriminant }.to_json - when "control" - { **@member.to_json, type: @discriminant }.to_json - when "say" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::ClientInboundMessageControl.validate_raw(obj: struct) + return Vapi::ClientInboundMessageControl.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ClientInboundMessageSay.validate_raw(obj: struct) + return Vapi::ClientInboundMessageSay.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -68,42 +49,22 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "add-message" - Vapi::ClientInboundMessageAddMessage.validate_raw(obj: obj) - when "control" - Vapi::ClientInboundMessageControl.validate_raw(obj: obj) - when "say" - Vapi::ClientInboundMessageSay.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ClientInboundMessageAddMessage.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ClientInboundMessageAddMessage] - # @return [Vapi::ClientInboundMessageMessage] - def self.add_message(member:) - new(member: member, discriminant: "add-message") - end - - # @param member [Vapi::ClientInboundMessageControl] - # @return [Vapi::ClientInboundMessageMessage] - def self.control(member:) - new(member: member, discriminant: "control") - end - - # @param member [Vapi::ClientInboundMessageSay] - # @return [Vapi::ClientInboundMessageMessage] - def self.say(member:) - new(member: member, discriminant: "say") + begin + return Vapi::ClientInboundMessageControl.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ClientInboundMessageSay.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/client_inbound_message_say.rb b/lib/vapi/types/client_inbound_message_say.rb index 300c70f..0722401 100644 --- a/lib/vapi/types/client_inbound_message_say.rb +++ b/lib/vapi/types/client_inbound_message_say.rb @@ -5,6 +5,9 @@ module Vapi class ClientInboundMessageSay + # @return [String] This is the type of the message. Send "say" message to make the assistant say + # something. + attr_reader :type # @return [String] This is the content to say. attr_reader :content # @return [Boolean] This is the flag to end call after content is spoken. @@ -17,15 +20,22 @@ class ClientInboundMessageSay OMIT = Object.new + # @param type [String] This is the type of the message. Send "say" message to make the assistant say + # something. # @param content [String] This is the content to say. # @param end_call_after_spoken [Boolean] This is the flag to end call after content is spoken. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ClientInboundMessageSay] - def initialize(content: OMIT, end_call_after_spoken: OMIT, additional_properties: nil) + def initialize(type: OMIT, content: OMIT, end_call_after_spoken: OMIT, additional_properties: nil) + @type = type if type != OMIT @content = content if content != OMIT @end_call_after_spoken = end_call_after_spoken if end_call_after_spoken != OMIT @additional_properties = additional_properties - @_field_set = { "content": content, "endCallAfterSpoken": end_call_after_spoken }.reject do |_k, v| + @_field_set = { + "type": type, + "content": content, + "endCallAfterSpoken": end_call_after_spoken + }.reject do |_k, v| v == OMIT end end @@ -37,9 +47,11 @@ def initialize(content: OMIT, end_call_after_spoken: OMIT, additional_properties def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + type = parsed_json["type"] content = parsed_json["content"] end_call_after_spoken = parsed_json["endCallAfterSpoken"] new( + type: type, content: content, end_call_after_spoken: end_call_after_spoken, additional_properties: struct @@ -60,6 +72,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.type&.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.content&.is_a?(String) != false || raise("Passed value for field obj.content is not the expected type, validation failed.") obj.end_call_after_spoken&.is_a?(Boolean) != false || raise("Passed value for field obj.end_call_after_spoken is not the expected type, validation failed.") end diff --git a/lib/vapi/types/client_message_conversation_update.rb b/lib/vapi/types/client_message_conversation_update.rb index 1e47c0e..14169da 100644 --- a/lib/vapi/types/client_message_conversation_update.rb +++ b/lib/vapi/types/client_message_conversation_update.rb @@ -7,6 +7,9 @@ module Vapi class ClientMessageConversationUpdate + # @return [String] This is the type of the message. "conversation-update" is sent when an update is + # committed to the conversation history. + attr_reader :type # @return [Array] This is the most up-to-date conversation history at the time the message is # sent. attr_reader :messages @@ -21,17 +24,24 @@ class ClientMessageConversationUpdate OMIT = Object.new + # @param type [String] This is the type of the message. "conversation-update" is sent when an update is + # committed to the conversation history. # @param messages [Array] This is the most up-to-date conversation history at the time the message is # sent. # @param messages_open_ai_formatted [Array] This is the most up-to-date conversation history at the time the message is # sent, formatted for OpenAI. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ClientMessageConversationUpdate] - def initialize(messages_open_ai_formatted:, messages: OMIT, additional_properties: nil) + def initialize(type:, messages_open_ai_formatted:, messages: OMIT, additional_properties: nil) + @type = type @messages = messages if messages != OMIT @messages_open_ai_formatted = messages_open_ai_formatted @additional_properties = additional_properties - @_field_set = { "messages": messages, "messagesOpenAIFormatted": messages_open_ai_formatted }.reject do |_k, v| + @_field_set = { + "type": type, + "messages": messages, + "messagesOpenAIFormatted": messages_open_ai_formatted + }.reject do |_k, v| v == OMIT end end @@ -43,6 +53,7 @@ def initialize(messages_open_ai_formatted:, messages: OMIT, additional_propertie def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + type = parsed_json["type"] messages = parsed_json["messages"]&.map do |item| item = item.to_json Vapi::ClientMessageConversationUpdateMessagesItem.from_json(json_object: item) @@ -52,6 +63,7 @@ def self.from_json(json_object:) Vapi::OpenAiMessage.from_json(json_object: item) end new( + type: type, messages: messages, messages_open_ai_formatted: messages_open_ai_formatted, additional_properties: struct @@ -72,6 +84,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.messages&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.") obj.messages_open_ai_formatted.is_a?(Array) != false || raise("Passed value for field obj.messages_open_ai_formatted is not the expected type, validation failed.") end diff --git a/lib/vapi/types/client_message_hang.rb b/lib/vapi/types/client_message_hang.rb index a1ac8dd..3afe48e 100644 --- a/lib/vapi/types/client_message_hang.rb +++ b/lib/vapi/types/client_message_hang.rb @@ -5,6 +5,13 @@ module Vapi class ClientMessageHang + # @return [String] This is the type of the message. "hang" is sent when the assistant is hanging + # due to a delay. The delay can be caused by many factors, such as: + # - the model is too slow to respond + # - the voice is too slow to respond + # - the tool call is still waiting for a response from your server + # - etc. + attr_reader :type # @return [OpenStruct] Additional properties unmapped to the current class definition attr_reader :additional_properties # @return [Object] @@ -13,11 +20,18 @@ class ClientMessageHang OMIT = Object.new + # @param type [String] This is the type of the message. "hang" is sent when the assistant is hanging + # due to a delay. The delay can be caused by many factors, such as: + # - the model is too slow to respond + # - the voice is too slow to respond + # - the tool call is still waiting for a response from your server + # - etc. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ClientMessageHang] - def initialize(additional_properties: nil) + def initialize(type:, additional_properties: nil) + @type = type @additional_properties = additional_properties - @_field_set = {} + @_field_set = { "type": type } end # Deserialize a JSON object to an instance of ClientMessageHang @@ -26,7 +40,9 @@ def initialize(additional_properties: nil) # @return [Vapi::ClientMessageHang] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - new(additional_properties: struct) + parsed_json = JSON.parse(json_object) + type = parsed_json["type"] + new(type: type, additional_properties: struct) end # Serialize an instance of ClientMessageHang to a JSON object @@ -42,6 +58,8 @@ def to_json(*_args) # # @param obj [Object] # @return [Void] - def self.validate_raw(obj:); end + def self.validate_raw(obj:) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + end end end diff --git a/lib/vapi/types/client_message_language_changed.rb b/lib/vapi/types/client_message_language_changed.rb index 00ee71c..39dc8a1 100644 --- a/lib/vapi/types/client_message_language_changed.rb +++ b/lib/vapi/types/client_message_language_changed.rb @@ -5,6 +5,9 @@ module Vapi class ClientMessageLanguageChanged + # @return [String] This is the type of the message. "language-switched" is sent when the + # transcriber is automatically switched based on the detected language. + attr_reader :type # @return [String] This is the language the transcriber is switched to. attr_reader :language # @return [OpenStruct] Additional properties unmapped to the current class definition @@ -15,13 +18,16 @@ class ClientMessageLanguageChanged OMIT = Object.new + # @param type [String] This is the type of the message. "language-switched" is sent when the + # transcriber is automatically switched based on the detected language. # @param language [String] This is the language the transcriber is switched to. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ClientMessageLanguageChanged] - def initialize(language:, additional_properties: nil) + def initialize(type:, language:, additional_properties: nil) + @type = type @language = language @additional_properties = additional_properties - @_field_set = { "language": language } + @_field_set = { "type": type, "language": language } end # Deserialize a JSON object to an instance of ClientMessageLanguageChanged @@ -31,8 +37,13 @@ def initialize(language:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + type = parsed_json["type"] language = parsed_json["language"] - new(language: language, additional_properties: struct) + new( + type: type, + language: language, + additional_properties: struct + ) end # Serialize an instance of ClientMessageLanguageChanged to a JSON object @@ -49,6 +60,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.language.is_a?(String) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") end end diff --git a/lib/vapi/types/client_message_message.rb b/lib/vapi/types/client_message_message.rb index 25a2010..788c4d6 100644 --- a/lib/vapi/types/client_message_message.rb +++ b/lib/vapi/types/client_message_message.rb @@ -18,197 +18,166 @@ module Vapi # call. Configure the messages you'd like to receive in # `assistant.clientMessages`. class ClientMessageMessage - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ClientMessageMessage] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of ClientMessageMessage # # @param json_object [String] # @return [Vapi::ClientMessageMessage] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "conversation-update" - Vapi::ClientMessageConversationUpdate.from_json(json_object: json_object) - when "hang" - Vapi::ClientMessageHang.from_json(json_object: json_object) - when "metadata" - Vapi::ClientMessageMetadata.from_json(json_object: json_object) - when "model-output" - Vapi::ClientMessageModelOutput.from_json(json_object: json_object) - when "speech-update" - Vapi::ClientMessageSpeechUpdate.from_json(json_object: json_object) - when "transcript" - Vapi::ClientMessageTranscript.from_json(json_object: json_object) - when "tool-calls" - Vapi::ClientMessageToolCalls.from_json(json_object: json_object) - when "tool-calls-result" - Vapi::ClientMessageToolCallsResult.from_json(json_object: json_object) - when "user-interrupted" - Vapi::ClientMessageUserInterrupted.from_json(json_object: json_object) - when "language-changed" - Vapi::ClientMessageLanguageChanged.from_json(json_object: json_object) - when "voice-input" - Vapi::ClientMessageVoiceInput.from_json(json_object: json_object) - else - Vapi::ClientMessageConversationUpdate.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end - - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "conversation-update" - { **@member.to_json, type: @discriminant }.to_json - when "hang" - { **@member.to_json, type: @discriminant }.to_json - when "metadata" - { **@member.to_json, type: @discriminant }.to_json - when "model-output" - { **@member.to_json, type: @discriminant }.to_json - when "speech-update" - { **@member.to_json, type: @discriminant }.to_json - when "transcript" - { **@member.to_json, type: @discriminant }.to_json - when "tool-calls" - { **@member.to_json, type: @discriminant }.to_json - when "tool-calls-result" - { **@member.to_json, type: @discriminant }.to_json - when "user-interrupted" - { **@member.to_json, type: @discriminant }.to_json - when "language-changed" - { **@member.to_json, type: @discriminant }.to_json - when "voice-input" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json - end - @member.to_json - end + begin + Vapi::ClientMessageConversationUpdate.validate_raw(obj: struct) + return Vapi::ClientMessageConversationUpdate.from_json(json_object: struct) unless struct.nil? - # 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. - # - # @param obj [Object] - # @return [Void] - def self.validate_raw(obj:) - case obj.type - when "conversation-update" - Vapi::ClientMessageConversationUpdate.validate_raw(obj: obj) - when "hang" - Vapi::ClientMessageHang.validate_raw(obj: obj) - when "metadata" - Vapi::ClientMessageMetadata.validate_raw(obj: obj) - when "model-output" - Vapi::ClientMessageModelOutput.validate_raw(obj: obj) - when "speech-update" - Vapi::ClientMessageSpeechUpdate.validate_raw(obj: obj) - when "transcript" - Vapi::ClientMessageTranscript.validate_raw(obj: obj) - when "tool-calls" - Vapi::ClientMessageToolCalls.validate_raw(obj: obj) - when "tool-calls-result" - Vapi::ClientMessageToolCallsResult.validate_raw(obj: obj) - when "user-interrupted" - Vapi::ClientMessageUserInterrupted.validate_raw(obj: obj) - when "language-changed" - Vapi::ClientMessageLanguageChanged.validate_raw(obj: obj) - when "voice-input" - Vapi::ClientMessageVoiceInput.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + return nil + rescue StandardError + # noop end - end + begin + Vapi::ClientMessageHang.validate_raw(obj: struct) + return Vapi::ClientMessageHang.from_json(json_object: struct) unless struct.nil? - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ClientMessageConversationUpdate] - # @return [Vapi::ClientMessageMessage] - def self.conversation_update(member:) - new(member: member, discriminant: "conversation-update") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::ClientMessageMetadata.validate_raw(obj: struct) + return Vapi::ClientMessageMetadata.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::ClientMessageHang] - # @return [Vapi::ClientMessageMessage] - def self.hang(member:) - new(member: member, discriminant: "hang") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::ClientMessageModelOutput.validate_raw(obj: struct) + return Vapi::ClientMessageModelOutput.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::ClientMessageMetadata] - # @return [Vapi::ClientMessageMessage] - def self.metadata(member:) - new(member: member, discriminant: "metadata") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::ClientMessageSpeechUpdate.validate_raw(obj: struct) + return Vapi::ClientMessageSpeechUpdate.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::ClientMessageModelOutput] - # @return [Vapi::ClientMessageMessage] - def self.model_output(member:) - new(member: member, discriminant: "model-output") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::ClientMessageTranscript.validate_raw(obj: struct) + return Vapi::ClientMessageTranscript.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::ClientMessageSpeechUpdate] - # @return [Vapi::ClientMessageMessage] - def self.speech_update(member:) - new(member: member, discriminant: "speech-update") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::ClientMessageToolCalls.validate_raw(obj: struct) + return Vapi::ClientMessageToolCalls.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::ClientMessageTranscript] - # @return [Vapi::ClientMessageMessage] - def self.transcript(member:) - new(member: member, discriminant: "transcript") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::ClientMessageToolCallsResult.validate_raw(obj: struct) + return Vapi::ClientMessageToolCallsResult.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::ClientMessageToolCalls] - # @return [Vapi::ClientMessageMessage] - def self.tool_calls(member:) - new(member: member, discriminant: "tool-calls") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::ClientMessageUserInterrupted.validate_raw(obj: struct) + return Vapi::ClientMessageUserInterrupted.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::ClientMessageToolCallsResult] - # @return [Vapi::ClientMessageMessage] - def self.tool_calls_result(member:) - new(member: member, discriminant: "tool-calls-result") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::ClientMessageLanguageChanged.validate_raw(obj: struct) + return Vapi::ClientMessageLanguageChanged.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::ClientMessageUserInterrupted] - # @return [Vapi::ClientMessageMessage] - def self.user_interrupted(member:) - new(member: member, discriminant: "user-interrupted") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::ClientMessageVoiceInput.validate_raw(obj: struct) + return Vapi::ClientMessageVoiceInput.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::ClientMessageLanguageChanged] - # @return [Vapi::ClientMessageMessage] - def self.language_changed(member:) - new(member: member, discriminant: "language-changed") + return nil + rescue StandardError + # noop + end + struct end - # @param member [Vapi::ClientMessageVoiceInput] - # @return [Vapi::ClientMessageMessage] - def self.voice_input(member:) - new(member: member, discriminant: "voice-input") + # 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. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return Vapi::ClientMessageConversationUpdate.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ClientMessageHang.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ClientMessageMetadata.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ClientMessageModelOutput.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ClientMessageSpeechUpdate.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ClientMessageTranscript.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ClientMessageToolCalls.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ClientMessageToolCallsResult.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ClientMessageUserInterrupted.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ClientMessageLanguageChanged.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ClientMessageVoiceInput.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/client_message_metadata.rb b/lib/vapi/types/client_message_metadata.rb index 60bd42e..1e70f7c 100644 --- a/lib/vapi/types/client_message_metadata.rb +++ b/lib/vapi/types/client_message_metadata.rb @@ -5,6 +5,9 @@ module Vapi class ClientMessageMetadata + # @return [String] This is the type of the message. "metadata" is sent to forward metadata to the + # client. + attr_reader :type # @return [String] This is the metadata content attr_reader :metadata # @return [OpenStruct] Additional properties unmapped to the current class definition @@ -15,13 +18,16 @@ class ClientMessageMetadata OMIT = Object.new + # @param type [String] This is the type of the message. "metadata" is sent to forward metadata to the + # client. # @param metadata [String] This is the metadata content # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ClientMessageMetadata] - def initialize(metadata:, additional_properties: nil) + def initialize(type:, metadata:, additional_properties: nil) + @type = type @metadata = metadata @additional_properties = additional_properties - @_field_set = { "metadata": metadata } + @_field_set = { "type": type, "metadata": metadata } end # Deserialize a JSON object to an instance of ClientMessageMetadata @@ -31,8 +37,13 @@ def initialize(metadata:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + type = parsed_json["type"] metadata = parsed_json["metadata"] - new(metadata: metadata, additional_properties: struct) + new( + type: type, + metadata: metadata, + additional_properties: struct + ) end # Serialize an instance of ClientMessageMetadata to a JSON object @@ -49,6 +60,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.metadata.is_a?(String) != false || raise("Passed value for field obj.metadata is not the expected type, validation failed.") end end diff --git a/lib/vapi/types/client_message_model_output.rb b/lib/vapi/types/client_message_model_output.rb index aa68fa9..7aec3a1 100644 --- a/lib/vapi/types/client_message_model_output.rb +++ b/lib/vapi/types/client_message_model_output.rb @@ -5,6 +5,9 @@ module Vapi class ClientMessageModelOutput + # @return [String] This is the type of the message. "model-output" is sent as the model outputs + # tokens. + attr_reader :type # @return [Hash{String => Object}] This is the output of the model. It can be a token or tool call. attr_reader :output # @return [OpenStruct] Additional properties unmapped to the current class definition @@ -15,13 +18,16 @@ class ClientMessageModelOutput OMIT = Object.new + # @param type [String] This is the type of the message. "model-output" is sent as the model outputs + # tokens. # @param output [Hash{String => Object}] This is the output of the model. It can be a token or tool call. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ClientMessageModelOutput] - def initialize(output:, additional_properties: nil) + def initialize(type:, output:, additional_properties: nil) + @type = type @output = output @additional_properties = additional_properties - @_field_set = { "output": output } + @_field_set = { "type": type, "output": output } end # Deserialize a JSON object to an instance of ClientMessageModelOutput @@ -31,8 +37,13 @@ def initialize(output:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + type = parsed_json["type"] output = parsed_json["output"] - new(output: output, additional_properties: struct) + new( + type: type, + output: output, + additional_properties: struct + ) end # Serialize an instance of ClientMessageModelOutput to a JSON object @@ -49,6 +60,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.output.is_a?(Hash) != false || raise("Passed value for field obj.output is not the expected type, validation failed.") end end diff --git a/lib/vapi/types/client_message_speech_update.rb b/lib/vapi/types/client_message_speech_update.rb index b61303e..33b88f9 100644 --- a/lib/vapi/types/client_message_speech_update.rb +++ b/lib/vapi/types/client_message_speech_update.rb @@ -7,6 +7,9 @@ module Vapi class ClientMessageSpeechUpdate + # @return [String] This is the type of the message. "speech-update" is sent whenever assistant or + # user start or stop speaking. + attr_reader :type # @return [Vapi::ClientMessageSpeechUpdateStatus] This is the status of the speech update. attr_reader :status # @return [Vapi::ClientMessageSpeechUpdateRole] This is the role which the speech update is for. @@ -19,15 +22,18 @@ class ClientMessageSpeechUpdate OMIT = Object.new + # @param type [String] This is the type of the message. "speech-update" is sent whenever assistant or + # user start or stop speaking. # @param status [Vapi::ClientMessageSpeechUpdateStatus] This is the status of the speech update. # @param role [Vapi::ClientMessageSpeechUpdateRole] This is the role which the speech update is for. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ClientMessageSpeechUpdate] - def initialize(status:, role:, additional_properties: nil) + def initialize(type:, status:, role:, additional_properties: nil) + @type = type @status = status @role = role @additional_properties = additional_properties - @_field_set = { "status": status, "role": role } + @_field_set = { "type": type, "status": status, "role": role } end # Deserialize a JSON object to an instance of ClientMessageSpeechUpdate @@ -37,9 +43,11 @@ def initialize(status:, role:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + type = parsed_json["type"] status = parsed_json["status"] role = parsed_json["role"] new( + type: type, status: status, role: role, additional_properties: struct @@ -60,6 +68,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.status.is_a?(Vapi::ClientMessageSpeechUpdateStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") obj.role.is_a?(Vapi::ClientMessageSpeechUpdateRole) != false || raise("Passed value for field obj.role is not the expected type, validation failed.") end diff --git a/lib/vapi/types/client_message_tool_calls.rb b/lib/vapi/types/client_message_tool_calls.rb index e6abc6d..0b13f91 100644 --- a/lib/vapi/types/client_message_tool_calls.rb +++ b/lib/vapi/types/client_message_tool_calls.rb @@ -7,6 +7,8 @@ module Vapi class ClientMessageToolCalls + # @return [String] This is the type of the message. "tool-calls" is sent to call a tool. + attr_reader :type # @return [Array] This is the list of tools calls that the model is requesting along with the # original tool configuration. attr_reader :tool_with_tool_call_list @@ -20,16 +22,24 @@ class ClientMessageToolCalls OMIT = Object.new + # @param type [String] This is the type of the message. "tool-calls" is sent to call a tool. # @param tool_with_tool_call_list [Array] This is the list of tools calls that the model is requesting along with the # original tool configuration. # @param tool_call_list [Array] This is the list of tool calls that the model is requesting. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ClientMessageToolCalls] - def initialize(tool_with_tool_call_list:, tool_call_list:, additional_properties: nil) + def initialize(tool_with_tool_call_list:, tool_call_list:, type: OMIT, additional_properties: nil) + @type = type if type != OMIT @tool_with_tool_call_list = tool_with_tool_call_list @tool_call_list = tool_call_list @additional_properties = additional_properties - @_field_set = { "toolWithToolCallList": tool_with_tool_call_list, "toolCallList": tool_call_list } + @_field_set = { + "type": type, + "toolWithToolCallList": tool_with_tool_call_list, + "toolCallList": tool_call_list + }.reject do |_k, v| + v == OMIT + end end # Deserialize a JSON object to an instance of ClientMessageToolCalls @@ -39,6 +49,7 @@ def initialize(tool_with_tool_call_list:, tool_call_list:, additional_properties def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + type = parsed_json["type"] tool_with_tool_call_list = parsed_json["toolWithToolCallList"]&.map do |item| item = item.to_json Vapi::ClientMessageToolCallsToolWithToolCallListItem.from_json(json_object: item) @@ -48,6 +59,7 @@ def self.from_json(json_object:) Vapi::ToolCall.from_json(json_object: item) end new( + type: type, tool_with_tool_call_list: tool_with_tool_call_list, tool_call_list: tool_call_list, additional_properties: struct @@ -68,6 +80,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.type&.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.tool_with_tool_call_list.is_a?(Array) != false || raise("Passed value for field obj.tool_with_tool_call_list is not the expected type, validation failed.") obj.tool_call_list.is_a?(Array) != false || raise("Passed value for field obj.tool_call_list is not the expected type, validation failed.") end diff --git a/lib/vapi/types/client_message_tool_calls_result.rb b/lib/vapi/types/client_message_tool_calls_result.rb index 820eecd..6285e4e 100644 --- a/lib/vapi/types/client_message_tool_calls_result.rb +++ b/lib/vapi/types/client_message_tool_calls_result.rb @@ -5,6 +5,9 @@ module Vapi class ClientMessageToolCallsResult + # @return [String] This is the type of the message. "tool-calls-result" is sent to forward the + # result of a tool call to the client. + attr_reader :type # @return [Hash{String => Object}] This is the result of the tool call. attr_reader :tool_call_result # @return [OpenStruct] Additional properties unmapped to the current class definition @@ -15,13 +18,16 @@ class ClientMessageToolCallsResult OMIT = Object.new + # @param type [String] This is the type of the message. "tool-calls-result" is sent to forward the + # result of a tool call to the client. # @param tool_call_result [Hash{String => Object}] This is the result of the tool call. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ClientMessageToolCallsResult] - def initialize(tool_call_result:, additional_properties: nil) + def initialize(type:, tool_call_result:, additional_properties: nil) + @type = type @tool_call_result = tool_call_result @additional_properties = additional_properties - @_field_set = { "toolCallResult": tool_call_result } + @_field_set = { "type": type, "toolCallResult": tool_call_result } end # Deserialize a JSON object to an instance of ClientMessageToolCallsResult @@ -31,8 +37,13 @@ def initialize(tool_call_result:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + type = parsed_json["type"] tool_call_result = parsed_json["toolCallResult"] - new(tool_call_result: tool_call_result, additional_properties: struct) + new( + type: type, + tool_call_result: tool_call_result, + additional_properties: struct + ) end # Serialize an instance of ClientMessageToolCallsResult to a JSON object @@ -49,6 +60,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.tool_call_result.is_a?(Hash) != false || raise("Passed value for field obj.tool_call_result is not the expected type, validation failed.") end end diff --git a/lib/vapi/types/client_message_tool_calls_tool_with_tool_call_list_item.rb b/lib/vapi/types/client_message_tool_calls_tool_with_tool_call_list_item.rb index 10e3cf6..987fecf 100644 --- a/lib/vapi/types/client_message_tool_calls_tool_with_tool_call_list_item.rb +++ b/lib/vapi/types/client_message_tool_calls_tool_with_tool_call_list_item.rb @@ -7,22 +7,6 @@ module Vapi class ClientMessageToolCallsToolWithToolCallListItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ClientMessageToolCallsToolWithToolCallListItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of # ClientMessageToolCallsToolWithToolCallListItem # @@ -30,34 +14,31 @@ def initialize(member:, discriminant:) # @return [Vapi::ClientMessageToolCallsToolWithToolCallListItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "function" - Vapi::FunctionToolWithToolCall.from_json(json_object: json_object) - when "ghl" - Vapi::GhlToolWithToolCall.from_json(json_object: json_object) - when "make" - Vapi::MakeToolWithToolCall.from_json(json_object: json_object) - else - Vapi::FunctionToolWithToolCall.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::FunctionToolWithToolCall.validate_raw(obj: struct) + return Vapi::FunctionToolWithToolCall.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "function" - { **@member.to_json, type: @discriminant }.to_json - when "ghl" - { **@member.to_json, type: @discriminant }.to_json - when "make" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::GhlToolWithToolCall.validate_raw(obj: struct) + return Vapi::GhlToolWithToolCall.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::MakeToolWithToolCall.validate_raw(obj: struct) + return Vapi::MakeToolWithToolCall.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -67,42 +48,22 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "function" - Vapi::FunctionToolWithToolCall.validate_raw(obj: obj) - when "ghl" - Vapi::GhlToolWithToolCall.validate_raw(obj: obj) - when "make" - Vapi::MakeToolWithToolCall.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::FunctionToolWithToolCall.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::FunctionToolWithToolCall] - # @return [Vapi::ClientMessageToolCallsToolWithToolCallListItem] - def self.function(member:) - new(member: member, discriminant: "function") - end - - # @param member [Vapi::GhlToolWithToolCall] - # @return [Vapi::ClientMessageToolCallsToolWithToolCallListItem] - def self.ghl(member:) - new(member: member, discriminant: "ghl") - end - - # @param member [Vapi::MakeToolWithToolCall] - # @return [Vapi::ClientMessageToolCallsToolWithToolCallListItem] - def self.make(member:) - new(member: member, discriminant: "make") + begin + return Vapi::GhlToolWithToolCall.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::MakeToolWithToolCall.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/client_message_transcript.rb b/lib/vapi/types/client_message_transcript.rb index 7ec0e2a..84bd8b0 100644 --- a/lib/vapi/types/client_message_transcript.rb +++ b/lib/vapi/types/client_message_transcript.rb @@ -7,6 +7,9 @@ module Vapi class ClientMessageTranscript + # @return [String] This is the type of the message. "transcript" is sent as transcriber outputs + # partial or final transcript. + attr_reader :type # @return [Vapi::ClientMessageTranscriptRole] This is the role for which the transcript is for. attr_reader :role # @return [Vapi::ClientMessageTranscriptTranscriptType] This is the type of the transcript. @@ -21,17 +24,20 @@ class ClientMessageTranscript OMIT = Object.new + # @param type [String] This is the type of the message. "transcript" is sent as transcriber outputs + # partial or final transcript. # @param role [Vapi::ClientMessageTranscriptRole] This is the role for which the transcript is for. # @param transcript_type [Vapi::ClientMessageTranscriptTranscriptType] This is the type of the transcript. # @param transcript [String] This is the transcript content. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ClientMessageTranscript] - def initialize(role:, transcript_type:, transcript:, additional_properties: nil) + def initialize(type:, role:, transcript_type:, transcript:, additional_properties: nil) + @type = type @role = role @transcript_type = transcript_type @transcript = transcript @additional_properties = additional_properties - @_field_set = { "role": role, "transcriptType": transcript_type, "transcript": transcript } + @_field_set = { "type": type, "role": role, "transcriptType": transcript_type, "transcript": transcript } end # Deserialize a JSON object to an instance of ClientMessageTranscript @@ -41,10 +47,12 @@ def initialize(role:, transcript_type:, transcript:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + type = parsed_json["type"] role = parsed_json["role"] transcript_type = parsed_json["transcriptType"] transcript = parsed_json["transcript"] new( + type: type, role: role, transcript_type: transcript_type, transcript: transcript, @@ -66,6 +74,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.role.is_a?(Vapi::ClientMessageTranscriptRole) != false || raise("Passed value for field obj.role is not the expected type, validation failed.") obj.transcript_type.is_a?(Vapi::ClientMessageTranscriptTranscriptType) != false || raise("Passed value for field obj.transcript_type is not the expected type, validation failed.") obj.transcript.is_a?(String) != false || raise("Passed value for field obj.transcript is not the expected type, validation failed.") diff --git a/lib/vapi/types/client_message_user_interrupted.rb b/lib/vapi/types/client_message_user_interrupted.rb index b6f6c26..5808ec5 100644 --- a/lib/vapi/types/client_message_user_interrupted.rb +++ b/lib/vapi/types/client_message_user_interrupted.rb @@ -5,6 +5,9 @@ module Vapi class ClientMessageUserInterrupted + # @return [String] This is the type of the message. "user-interrupted" is sent when the user + # interrupts the assistant. + attr_reader :type # @return [OpenStruct] Additional properties unmapped to the current class definition attr_reader :additional_properties # @return [Object] @@ -13,11 +16,14 @@ class ClientMessageUserInterrupted OMIT = Object.new + # @param type [String] This is the type of the message. "user-interrupted" is sent when the user + # interrupts the assistant. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ClientMessageUserInterrupted] - def initialize(additional_properties: nil) + def initialize(type:, additional_properties: nil) + @type = type @additional_properties = additional_properties - @_field_set = {} + @_field_set = { "type": type } end # Deserialize a JSON object to an instance of ClientMessageUserInterrupted @@ -26,7 +32,9 @@ def initialize(additional_properties: nil) # @return [Vapi::ClientMessageUserInterrupted] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - new(additional_properties: struct) + parsed_json = JSON.parse(json_object) + type = parsed_json["type"] + new(type: type, additional_properties: struct) end # Serialize an instance of ClientMessageUserInterrupted to a JSON object @@ -42,6 +50,8 @@ def to_json(*_args) # # @param obj [Object] # @return [Void] - def self.validate_raw(obj:); end + def self.validate_raw(obj:) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + end end end diff --git a/lib/vapi/types/client_message_voice_input.rb b/lib/vapi/types/client_message_voice_input.rb index 8363b56..63da49d 100644 --- a/lib/vapi/types/client_message_voice_input.rb +++ b/lib/vapi/types/client_message_voice_input.rb @@ -5,6 +5,9 @@ module Vapi class ClientMessageVoiceInput + # @return [String] This is the type of the message. "voice-input" is sent when a generation is + # requested from voice provider. + attr_reader :type # @return [String] This is the voice input content attr_reader :input # @return [OpenStruct] Additional properties unmapped to the current class definition @@ -15,13 +18,16 @@ class ClientMessageVoiceInput OMIT = Object.new + # @param type [String] This is the type of the message. "voice-input" is sent when a generation is + # requested from voice provider. # @param input [String] This is the voice input content # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ClientMessageVoiceInput] - def initialize(input:, additional_properties: nil) + def initialize(type:, input:, additional_properties: nil) + @type = type @input = input @additional_properties = additional_properties - @_field_set = { "input": input } + @_field_set = { "type": type, "input": input } end # Deserialize a JSON object to an instance of ClientMessageVoiceInput @@ -31,8 +37,13 @@ def initialize(input:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + type = parsed_json["type"] input = parsed_json["input"] - new(input: input, additional_properties: struct) + new( + type: type, + input: input, + additional_properties: struct + ) end # Serialize an instance of ClientMessageVoiceInput to a JSON object @@ -49,6 +60,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.input.is_a?(String) != false || raise("Passed value for field obj.input is not the expected type, validation failed.") end end diff --git a/lib/vapi/types/conversation_block.rb b/lib/vapi/types/conversation_block.rb index 1d814dd..790d1d7 100644 --- a/lib/vapi/types/conversation_block.rb +++ b/lib/vapi/types/conversation_block.rb @@ -34,6 +34,8 @@ class ConversationBlock # this liquid variable is just provided for convenience when creating blocks # outside of a workflow with steps. attr_reader :output_schema + # @return [String] + attr_reader :type # @return [String] This is the unique identifier for the block. attr_reader :id # @return [String] This is the unique identifier for the organization that this block belongs to. @@ -105,6 +107,7 @@ class ConversationBlock # {{blockName.output.propertyName}} will reference the latest usage of the block. # this liquid variable is just provided for convenience when creating blocks # outside of a workflow with steps. + # @param type [String] # @param id [String] This is the unique identifier for the block. # @param org_id [String] This is the unique identifier for the organization that this block belongs to. # @param created_at [DateTime] This is the ISO 8601 date-time string of when the block was created. @@ -141,11 +144,12 @@ class ConversationBlock # blocks outside of a workflow with steps. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ConversationBlock] - def initialize(id:, org_id:, created_at:, updated_at:, instruction:, messages: OMIT, input_schema: OMIT, output_schema: OMIT, - name: OMIT, additional_properties: nil) + def initialize(type:, id:, org_id:, created_at:, updated_at:, instruction:, messages: OMIT, input_schema: OMIT, + output_schema: OMIT, name: OMIT, additional_properties: nil) @messages = messages if messages != OMIT @input_schema = input_schema if input_schema != OMIT @output_schema = output_schema if output_schema != OMIT + @type = type @id = id @org_id = org_id @created_at = created_at @@ -157,6 +161,7 @@ def initialize(id:, org_id:, created_at:, updated_at:, instruction:, messages: O "messages": messages, "inputSchema": input_schema, "outputSchema": output_schema, + "type": type, "id": id, "orgId": org_id, "createdAt": created_at, @@ -191,6 +196,7 @@ def self.from_json(json_object:) output_schema = parsed_json["outputSchema"].to_json output_schema = Vapi::JsonSchema.from_json(json_object: output_schema) end + type = parsed_json["type"] id = parsed_json["id"] org_id = parsed_json["orgId"] created_at = (DateTime.parse(parsed_json["createdAt"]) unless parsed_json["createdAt"].nil?) @@ -201,6 +207,7 @@ def self.from_json(json_object:) messages: messages, input_schema: input_schema, output_schema: output_schema, + type: type, id: id, org_id: org_id, created_at: created_at, @@ -228,6 +235,7 @@ 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.input_schema.nil? || Vapi::JsonSchema.validate_raw(obj: obj.input_schema) obj.output_schema.nil? || Vapi::JsonSchema.validate_raw(obj: obj.output_schema) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type 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.") diff --git a/lib/vapi/types/conversation_block_messages_item.rb b/lib/vapi/types/conversation_block_messages_item.rb index c5e8d07..fc60571 100644 --- a/lib/vapi/types/conversation_block_messages_item.rb +++ b/lib/vapi/types/conversation_block_messages_item.rb @@ -6,52 +6,29 @@ module Vapi class ConversationBlockMessagesItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ConversationBlockMessagesItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of ConversationBlockMessagesItem # # @param json_object [String] # @return [Vapi::ConversationBlockMessagesItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "block-start" - Vapi::BlockStartMessage.from_json(json_object: json_object) - when "block-complete" - Vapi::BlockCompleteMessage.from_json(json_object: json_object) - else - Vapi::BlockStartMessage.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::BlockStartMessage.validate_raw(obj: struct) + return Vapi::BlockStartMessage.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "block-start" - { **@member.to_json, type: @discriminant }.to_json - when "block-complete" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::BlockCompleteMessage.validate_raw(obj: struct) + return Vapi::BlockCompleteMessage.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -61,34 +38,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "block-start" - Vapi::BlockStartMessage.validate_raw(obj: obj) - when "block-complete" - Vapi::BlockCompleteMessage.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::BlockStartMessage.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::BlockStartMessage] - # @return [Vapi::ConversationBlockMessagesItem] - def self.block_start(member:) - new(member: member, discriminant: "block-start") - end - - # @param member [Vapi::BlockCompleteMessage] - # @return [Vapi::ConversationBlockMessagesItem] - def self.block_complete(member:) - new(member: member, discriminant: "block-complete") + begin + return Vapi::BlockCompleteMessage.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/create_assistant_dto_model.rb b/lib/vapi/types/create_assistant_dto_model.rb index 701bbdb..4da63b9 100644 --- a/lib/vapi/types/create_assistant_dto_model.rb +++ b/lib/vapi/types/create_assistant_dto_model.rb @@ -15,185 +15,153 @@ module Vapi # These are the options for the assistant's LLM. class CreateAssistantDtoModel - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::CreateAssistantDtoModel] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of CreateAssistantDtoModel # # @param json_object [String] # @return [Vapi::CreateAssistantDtoModel] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "anyscale" - Vapi::AnyscaleModel.from_json(json_object: json_object) - when "anthropic" - Vapi::AnthropicModel.from_json(json_object: json_object) - when "custom-llm" - Vapi::CustomLlmModel.from_json(json_object: json_object) - when "deepinfra" - Vapi::DeepInfraModel.from_json(json_object: json_object) - when "groq" - Vapi::GroqModel.from_json(json_object: json_object) - when "openai" - Vapi::OpenAiModel.from_json(json_object: json_object) - when "openrouter" - Vapi::OpenRouterModel.from_json(json_object: json_object) - when "perplexity-ai" - Vapi::PerplexityAiModel.from_json(json_object: json_object) - when "together-ai" - Vapi::TogetherAiModel.from_json(json_object: json_object) - when "vapi" - Vapi::VapiModel.from_json(json_object: json_object) - else - Vapi::AnyscaleModel.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end - - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "anyscale" - { **@member.to_json, provider: @discriminant }.to_json - when "anthropic" - { **@member.to_json, provider: @discriminant }.to_json - when "custom-llm" - { **@member.to_json, provider: @discriminant }.to_json - when "deepinfra" - { **@member.to_json, provider: @discriminant }.to_json - when "groq" - { **@member.to_json, provider: @discriminant }.to_json - when "openai" - { **@member.to_json, provider: @discriminant }.to_json - when "openrouter" - { **@member.to_json, provider: @discriminant }.to_json - when "perplexity-ai" - { **@member.to_json, provider: @discriminant }.to_json - when "together-ai" - { **@member.to_json, provider: @discriminant }.to_json - when "vapi" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json - end - @member.to_json - end + begin + Vapi::AnyscaleModel.validate_raw(obj: struct) + return Vapi::AnyscaleModel.from_json(json_object: struct) unless struct.nil? - # 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. - # - # @param obj [Object] - # @return [Void] - def self.validate_raw(obj:) - case obj.provider - when "anyscale" - Vapi::AnyscaleModel.validate_raw(obj: obj) - when "anthropic" - Vapi::AnthropicModel.validate_raw(obj: obj) - when "custom-llm" - Vapi::CustomLlmModel.validate_raw(obj: obj) - when "deepinfra" - Vapi::DeepInfraModel.validate_raw(obj: obj) - when "groq" - Vapi::GroqModel.validate_raw(obj: obj) - when "openai" - Vapi::OpenAiModel.validate_raw(obj: obj) - when "openrouter" - Vapi::OpenRouterModel.validate_raw(obj: obj) - when "perplexity-ai" - Vapi::PerplexityAiModel.validate_raw(obj: obj) - when "together-ai" - Vapi::TogetherAiModel.validate_raw(obj: obj) - when "vapi" - Vapi::VapiModel.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + return nil + rescue StandardError + # noop end - end + begin + Vapi::AnthropicModel.validate_raw(obj: struct) + return Vapi::AnthropicModel.from_json(json_object: struct) unless struct.nil? - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::AnyscaleModel] - # @return [Vapi::CreateAssistantDtoModel] - def self.anyscale(member:) - new(member: member, discriminant: "anyscale") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::CustomLlmModel.validate_raw(obj: struct) + return Vapi::CustomLlmModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::AnthropicModel] - # @return [Vapi::CreateAssistantDtoModel] - def self.anthropic(member:) - new(member: member, discriminant: "anthropic") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::DeepInfraModel.validate_raw(obj: struct) + return Vapi::DeepInfraModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::CustomLlmModel] - # @return [Vapi::CreateAssistantDtoModel] - def self.custom_llm(member:) - new(member: member, discriminant: "custom-llm") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::GroqModel.validate_raw(obj: struct) + return Vapi::GroqModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::DeepInfraModel] - # @return [Vapi::CreateAssistantDtoModel] - def self.deepinfra(member:) - new(member: member, discriminant: "deepinfra") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::OpenAiModel.validate_raw(obj: struct) + return Vapi::OpenAiModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::GroqModel] - # @return [Vapi::CreateAssistantDtoModel] - def self.groq(member:) - new(member: member, discriminant: "groq") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::OpenRouterModel.validate_raw(obj: struct) + return Vapi::OpenRouterModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::OpenAiModel] - # @return [Vapi::CreateAssistantDtoModel] - def self.openai(member:) - new(member: member, discriminant: "openai") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::PerplexityAiModel.validate_raw(obj: struct) + return Vapi::PerplexityAiModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::OpenRouterModel] - # @return [Vapi::CreateAssistantDtoModel] - def self.openrouter(member:) - new(member: member, discriminant: "openrouter") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::TogetherAiModel.validate_raw(obj: struct) + return Vapi::TogetherAiModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::PerplexityAiModel] - # @return [Vapi::CreateAssistantDtoModel] - def self.perplexity_ai(member:) - new(member: member, discriminant: "perplexity-ai") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::VapiModel.validate_raw(obj: struct) + return Vapi::VapiModel.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::TogetherAiModel] - # @return [Vapi::CreateAssistantDtoModel] - def self.together_ai(member:) - new(member: member, discriminant: "together-ai") + return nil + rescue StandardError + # noop + end + struct end - # @param member [Vapi::VapiModel] - # @return [Vapi::CreateAssistantDtoModel] - def self.vapi(member:) - new(member: member, discriminant: "vapi") + # 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. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return Vapi::AnyscaleModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::AnthropicModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CustomLlmModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::DeepInfraModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::GroqModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::OpenAiModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::OpenRouterModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::PerplexityAiModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::TogetherAiModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::VapiModel.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/create_assistant_dto_transcriber.rb b/lib/vapi/types/create_assistant_dto_transcriber.rb index 9988744..6e4d6af 100644 --- a/lib/vapi/types/create_assistant_dto_transcriber.rb +++ b/lib/vapi/types/create_assistant_dto_transcriber.rb @@ -8,56 +8,37 @@ module Vapi # These are the options for the assistant's transcriber. class CreateAssistantDtoTranscriber - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::CreateAssistantDtoTranscriber] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of CreateAssistantDtoTranscriber # # @param json_object [String] # @return [Vapi::CreateAssistantDtoTranscriber] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "deepgram" - Vapi::DeepgramTranscriber.from_json(json_object: json_object) - when "gladia" - Vapi::GladiaTranscriber.from_json(json_object: json_object) - when "talkscriber" - Vapi::TalkscriberTranscriber.from_json(json_object: json_object) - else - Vapi::DeepgramTranscriber.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end + begin + Vapi::DeepgramTranscriber.validate_raw(obj: struct) + return Vapi::DeepgramTranscriber.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "deepgram" - { **@member.to_json, provider: @discriminant }.to_json - when "gladia" - { **@member.to_json, provider: @discriminant }.to_json - when "talkscriber" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::GladiaTranscriber.validate_raw(obj: struct) + return Vapi::GladiaTranscriber.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::TalkscriberTranscriber.validate_raw(obj: struct) + return Vapi::TalkscriberTranscriber.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -67,42 +48,22 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.provider - when "deepgram" - Vapi::DeepgramTranscriber.validate_raw(obj: obj) - when "gladia" - Vapi::GladiaTranscriber.validate_raw(obj: obj) - when "talkscriber" - Vapi::TalkscriberTranscriber.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::DeepgramTranscriber.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::DeepgramTranscriber] - # @return [Vapi::CreateAssistantDtoTranscriber] - def self.deepgram(member:) - new(member: member, discriminant: "deepgram") - end - - # @param member [Vapi::GladiaTranscriber] - # @return [Vapi::CreateAssistantDtoTranscriber] - def self.gladia(member:) - new(member: member, discriminant: "gladia") - end - - # @param member [Vapi::TalkscriberTranscriber] - # @return [Vapi::CreateAssistantDtoTranscriber] - def self.talkscriber(member:) - new(member: member, discriminant: "talkscriber") + begin + return Vapi::GladiaTranscriber.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::TalkscriberTranscriber.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/create_assistant_dto_voice.rb b/lib/vapi/types/create_assistant_dto_voice.rb index 11db546..593d7a1 100644 --- a/lib/vapi/types/create_assistant_dto_voice.rb +++ b/lib/vapi/types/create_assistant_dto_voice.rb @@ -14,173 +14,140 @@ module Vapi # These are the options for the assistant's voice. class CreateAssistantDtoVoice - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::CreateAssistantDtoVoice] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of CreateAssistantDtoVoice # # @param json_object [String] # @return [Vapi::CreateAssistantDtoVoice] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "azure" - Vapi::AzureVoice.from_json(json_object: json_object) - when "cartesia" - Vapi::CartesiaVoice.from_json(json_object: json_object) - when "deepgram" - Vapi::DeepgramVoice.from_json(json_object: json_object) - when "11labs" - Vapi::ElevenLabsVoice.from_json(json_object: json_object) - when "lmnt" - Vapi::LmntVoice.from_json(json_object: json_object) - when "neets" - Vapi::NeetsVoice.from_json(json_object: json_object) - when "openai" - Vapi::OpenAiVoice.from_json(json_object: json_object) - when "playht" - Vapi::PlayHtVoice.from_json(json_object: json_object) - when "rime-ai" - Vapi::RimeAiVoice.from_json(json_object: json_object) - else - Vapi::AzureVoice.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end - - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "azure" - { **@member.to_json, provider: @discriminant }.to_json - when "cartesia" - { **@member.to_json, provider: @discriminant }.to_json - when "deepgram" - { **@member.to_json, provider: @discriminant }.to_json - when "11labs" - { **@member.to_json, provider: @discriminant }.to_json - when "lmnt" - { **@member.to_json, provider: @discriminant }.to_json - when "neets" - { **@member.to_json, provider: @discriminant }.to_json - when "openai" - { **@member.to_json, provider: @discriminant }.to_json - when "playht" - { **@member.to_json, provider: @discriminant }.to_json - when "rime-ai" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json - end - @member.to_json - end + begin + Vapi::AzureVoice.validate_raw(obj: struct) + return Vapi::AzureVoice.from_json(json_object: struct) unless struct.nil? - # 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. - # - # @param obj [Object] - # @return [Void] - def self.validate_raw(obj:) - case obj.provider - when "azure" - Vapi::AzureVoice.validate_raw(obj: obj) - when "cartesia" - Vapi::CartesiaVoice.validate_raw(obj: obj) - when "deepgram" - Vapi::DeepgramVoice.validate_raw(obj: obj) - when "11labs" - Vapi::ElevenLabsVoice.validate_raw(obj: obj) - when "lmnt" - Vapi::LmntVoice.validate_raw(obj: obj) - when "neets" - Vapi::NeetsVoice.validate_raw(obj: obj) - when "openai" - Vapi::OpenAiVoice.validate_raw(obj: obj) - when "playht" - Vapi::PlayHtVoice.validate_raw(obj: obj) - when "rime-ai" - Vapi::RimeAiVoice.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + return nil + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end + begin + Vapi::CartesiaVoice.validate_raw(obj: struct) + return Vapi::CartesiaVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::AzureVoice] - # @return [Vapi::CreateAssistantDtoVoice] - def self.azure(member:) - new(member: member, discriminant: "azure") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::DeepgramVoice.validate_raw(obj: struct) + return Vapi::DeepgramVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::CartesiaVoice] - # @return [Vapi::CreateAssistantDtoVoice] - def self.cartesia(member:) - new(member: member, discriminant: "cartesia") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::ElevenLabsVoice.validate_raw(obj: struct) + return Vapi::ElevenLabsVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::DeepgramVoice] - # @return [Vapi::CreateAssistantDtoVoice] - def self.deepgram(member:) - new(member: member, discriminant: "deepgram") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::LmntVoice.validate_raw(obj: struct) + return Vapi::LmntVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::ElevenLabsVoice] - # @return [Vapi::CreateAssistantDtoVoice] - def self._11_labs(member:) - new(member: member, discriminant: "11labs") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::NeetsVoice.validate_raw(obj: struct) + return Vapi::NeetsVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::LmntVoice] - # @return [Vapi::CreateAssistantDtoVoice] - def self.lmnt(member:) - new(member: member, discriminant: "lmnt") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::OpenAiVoice.validate_raw(obj: struct) + return Vapi::OpenAiVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::NeetsVoice] - # @return [Vapi::CreateAssistantDtoVoice] - def self.neets(member:) - new(member: member, discriminant: "neets") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::PlayHtVoice.validate_raw(obj: struct) + return Vapi::PlayHtVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::OpenAiVoice] - # @return [Vapi::CreateAssistantDtoVoice] - def self.openai(member:) - new(member: member, discriminant: "openai") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::RimeAiVoice.validate_raw(obj: struct) + return Vapi::RimeAiVoice.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::PlayHtVoice] - # @return [Vapi::CreateAssistantDtoVoice] - def self.playht(member:) - new(member: member, discriminant: "playht") + return nil + rescue StandardError + # noop + end + struct end - # @param member [Vapi::RimeAiVoice] - # @return [Vapi::CreateAssistantDtoVoice] - def self.rime_ai(member:) - new(member: member, discriminant: "rime-ai") + # 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. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return Vapi::AzureVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CartesiaVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::DeepgramVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ElevenLabsVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::LmntVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::NeetsVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::OpenAiVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::PlayHtVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::RimeAiVoice.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/create_byo_phone_number_dto.rb b/lib/vapi/types/create_byo_phone_number_dto.rb index 0bf3306..c026444 100644 --- a/lib/vapi/types/create_byo_phone_number_dto.rb +++ b/lib/vapi/types/create_byo_phone_number_dto.rb @@ -13,6 +13,8 @@ class CreateByoPhoneNumberDto # If this is not set and above conditions are met, the inbound call is hung up # with an error message. attr_reader :fallback_destination + # @return [String] + attr_reader :provider # @return [Boolean] This is the flag to toggle the E164 check for the `number` field. This is an # advanced property which should be used if you know your use case requires it. # Use cases: @@ -67,6 +69,7 @@ class CreateByoPhoneNumberDto # 3. and, `assistant-request` message to the `serverUrl` fails # If this is not set and above conditions are met, the inbound call is hung up # with an error message. + # @param provider [String] # @param number_e_164_check_enabled [Boolean] This is the flag to toggle the E164 check for the `number` field. This is an # advanced property which should be used if you know your use case requires it. # Use cases: @@ -101,9 +104,10 @@ class CreateByoPhoneNumberDto # Same precedence logic as serverUrl. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::CreateByoPhoneNumberDto] - def initialize(credential_id:, fallback_destination: OMIT, number_e_164_check_enabled: OMIT, number: OMIT, - name: OMIT, assistant_id: OMIT, squad_id: OMIT, server_url: OMIT, server_url_secret: OMIT, additional_properties: nil) + def initialize(provider:, credential_id:, fallback_destination: OMIT, number_e_164_check_enabled: OMIT, + number: OMIT, name: OMIT, assistant_id: OMIT, squad_id: OMIT, server_url: OMIT, server_url_secret: OMIT, additional_properties: nil) @fallback_destination = fallback_destination if fallback_destination != OMIT + @provider = provider @number_e_164_check_enabled = number_e_164_check_enabled if number_e_164_check_enabled != OMIT @number = number if number != OMIT @credential_id = credential_id @@ -115,6 +119,7 @@ def initialize(credential_id:, fallback_destination: OMIT, number_e_164_check_en @additional_properties = additional_properties @_field_set = { "fallbackDestination": fallback_destination, + "provider": provider, "numberE164CheckEnabled": number_e_164_check_enabled, "number": number, "credentialId": credential_id, @@ -141,6 +146,7 @@ def self.from_json(json_object:) fallback_destination = parsed_json["fallbackDestination"].to_json fallback_destination = Vapi::CreateByoPhoneNumberDtoFallbackDestination.from_json(json_object: fallback_destination) end + provider = parsed_json["provider"] number_e_164_check_enabled = parsed_json["numberE164CheckEnabled"] number = parsed_json["number"] credential_id = parsed_json["credentialId"] @@ -151,6 +157,7 @@ def self.from_json(json_object:) server_url_secret = parsed_json["serverUrlSecret"] new( fallback_destination: fallback_destination, + provider: provider, number_e_164_check_enabled: number_e_164_check_enabled, number: number, credential_id: credential_id, @@ -178,6 +185,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.fallback_destination.nil? || Vapi::CreateByoPhoneNumberDtoFallbackDestination.validate_raw(obj: obj.fallback_destination) + obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") obj.number_e_164_check_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.number_e_164_check_enabled is not the expected type, validation failed.") obj.number&.is_a?(String) != false || raise("Passed value for field obj.number is not the expected type, validation failed.") obj.credential_id.is_a?(String) != false || raise("Passed value for field obj.credential_id is not the expected type, validation failed.") diff --git a/lib/vapi/types/create_byo_phone_number_dto_fallback_destination.rb b/lib/vapi/types/create_byo_phone_number_dto_fallback_destination.rb index dd5d7df..384105c 100644 --- a/lib/vapi/types/create_byo_phone_number_dto_fallback_destination.rb +++ b/lib/vapi/types/create_byo_phone_number_dto_fallback_destination.rb @@ -12,22 +12,6 @@ module Vapi # If this is not set and above conditions are met, the inbound call is hung up # with an error message. class CreateByoPhoneNumberDtoFallbackDestination - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::CreateByoPhoneNumberDtoFallbackDestination] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of # CreateByoPhoneNumberDtoFallbackDestination # @@ -35,30 +19,23 @@ def initialize(member:, discriminant:) # @return [Vapi::CreateByoPhoneNumberDtoFallbackDestination] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "number" - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - when "sip" - Vapi::TransferDestinationSip.from_json(json_object: json_object) - else - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::TransferDestinationNumber.validate_raw(obj: struct) + return Vapi::TransferDestinationNumber.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "number" - { **@member.to_json, type: @discriminant }.to_json - when "sip" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::TransferDestinationSip.validate_raw(obj: struct) + return Vapi::TransferDestinationSip.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -68,34 +45,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "number" - Vapi::TransferDestinationNumber.validate_raw(obj: obj) - when "sip" - Vapi::TransferDestinationSip.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::TransferDestinationNumber.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::TransferDestinationNumber] - # @return [Vapi::CreateByoPhoneNumberDtoFallbackDestination] - def self.number(member:) - new(member: member, discriminant: "number") - end - - # @param member [Vapi::TransferDestinationSip] - # @return [Vapi::CreateByoPhoneNumberDtoFallbackDestination] - def self.sip(member:) - new(member: member, discriminant: "sip") + begin + return Vapi::TransferDestinationSip.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/create_conversation_block_dto.rb b/lib/vapi/types/create_conversation_block_dto.rb index 838bbaf..f7913f4 100644 --- a/lib/vapi/types/create_conversation_block_dto.rb +++ b/lib/vapi/types/create_conversation_block_dto.rb @@ -33,6 +33,8 @@ class CreateConversationBlockDto # this liquid variable is just provided for convenience when creating blocks # outside of a workflow with steps. attr_reader :output_schema + # @return [String] + attr_reader :type # @return [String] This is the instruction to the model. # You can reference any variable in the context of the current block execution # (step): @@ -96,6 +98,7 @@ class CreateConversationBlockDto # {{blockName.output.propertyName}} will reference the latest usage of the block. # this liquid variable is just provided for convenience when creating blocks # outside of a workflow with steps. + # @param type [String] # @param instruction [String] This is the instruction to the model. # You can reference any variable in the context of the current block execution # (step): @@ -128,11 +131,12 @@ class CreateConversationBlockDto # @param name [String] This is the name of the block. This is just for your reference. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::CreateConversationBlockDto] - def initialize(instruction:, messages: OMIT, input_schema: OMIT, output_schema: OMIT, name: OMIT, + def initialize(type:, instruction:, messages: OMIT, input_schema: OMIT, output_schema: OMIT, name: OMIT, additional_properties: nil) @messages = messages if messages != OMIT @input_schema = input_schema if input_schema != OMIT @output_schema = output_schema if output_schema != OMIT + @type = type @instruction = instruction @name = name if name != OMIT @additional_properties = additional_properties @@ -140,6 +144,7 @@ def initialize(instruction:, messages: OMIT, input_schema: OMIT, output_schema: "messages": messages, "inputSchema": input_schema, "outputSchema": output_schema, + "type": type, "instruction": instruction, "name": name }.reject do |_k, v| @@ -170,12 +175,14 @@ def self.from_json(json_object:) output_schema = parsed_json["outputSchema"].to_json output_schema = Vapi::JsonSchema.from_json(json_object: output_schema) end + type = parsed_json["type"] instruction = parsed_json["instruction"] name = parsed_json["name"] new( messages: messages, input_schema: input_schema, output_schema: output_schema, + type: type, instruction: instruction, name: name, additional_properties: struct @@ -199,6 +206,7 @@ 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.input_schema.nil? || Vapi::JsonSchema.validate_raw(obj: obj.input_schema) obj.output_schema.nil? || Vapi::JsonSchema.validate_raw(obj: obj.output_schema) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.instruction.is_a?(String) != false || raise("Passed value for field obj.instruction is not the expected type, validation failed.") obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") end diff --git a/lib/vapi/types/create_conversation_block_dto_messages_item.rb b/lib/vapi/types/create_conversation_block_dto_messages_item.rb index 43bff35..35f2d4f 100644 --- a/lib/vapi/types/create_conversation_block_dto_messages_item.rb +++ b/lib/vapi/types/create_conversation_block_dto_messages_item.rb @@ -6,22 +6,6 @@ module Vapi class CreateConversationBlockDtoMessagesItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::CreateConversationBlockDtoMessagesItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of # CreateConversationBlockDtoMessagesItem # @@ -29,30 +13,23 @@ def initialize(member:, discriminant:) # @return [Vapi::CreateConversationBlockDtoMessagesItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "block-start" - Vapi::BlockStartMessage.from_json(json_object: json_object) - when "block-complete" - Vapi::BlockCompleteMessage.from_json(json_object: json_object) - else - Vapi::BlockStartMessage.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::BlockStartMessage.validate_raw(obj: struct) + return Vapi::BlockStartMessage.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "block-start" - { **@member.to_json, type: @discriminant }.to_json - when "block-complete" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::BlockCompleteMessage.validate_raw(obj: struct) + return Vapi::BlockCompleteMessage.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -62,34 +39,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "block-start" - Vapi::BlockStartMessage.validate_raw(obj: obj) - when "block-complete" - Vapi::BlockCompleteMessage.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::BlockStartMessage.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::BlockStartMessage] - # @return [Vapi::CreateConversationBlockDtoMessagesItem] - def self.block_start(member:) - new(member: member, discriminant: "block-start") - end - - # @param member [Vapi::BlockCompleteMessage] - # @return [Vapi::CreateConversationBlockDtoMessagesItem] - def self.block_complete(member:) - new(member: member, discriminant: "block-complete") + begin + return Vapi::BlockCompleteMessage.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/create_dtmf_tool_dto.rb b/lib/vapi/types/create_dtmf_tool_dto.rb index 6428b31..fd35470 100644 --- a/lib/vapi/types/create_dtmf_tool_dto.rb +++ b/lib/vapi/types/create_dtmf_tool_dto.rb @@ -20,6 +20,8 @@ class CreateDtmfToolDto # `tool.destinations`. For others like the function tool, these can be custom # configured. attr_reader :messages + # @return [String] + attr_reader :type # @return [Vapi::OpenAiFunction] This is the function definition of the tool. # For `endCall`, `transferCall`, and `dtmf` tools, this is auto-filled based on # tool-specific fields like `tool.destinations`. But, even in those cases, you can @@ -55,6 +57,7 @@ class CreateDtmfToolDto # For some tools, this is auto-filled based on special fields like # `tool.destinations`. For others like the function tool, these can be custom # configured. + # @param type [String] # @param function [Vapi::OpenAiFunction] This is the function definition of the tool. # For `endCall`, `transferCall`, and `dtmf` tools, this is auto-filled based on # tool-specific fields like `tool.destinations`. But, even in those cases, you can @@ -72,13 +75,20 @@ class CreateDtmfToolDto # phoneNumber.serverUrl, then org.serverUrl. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::CreateDtmfToolDto] - def initialize(async: OMIT, messages: OMIT, function: OMIT, server: OMIT, additional_properties: nil) + def initialize(type:, async: OMIT, messages: OMIT, function: OMIT, server: OMIT, additional_properties: nil) @async = async if async != OMIT @messages = messages if messages != OMIT + @type = type @function = function if function != OMIT @server = server if server != OMIT @additional_properties = additional_properties - @_field_set = { "async": async, "messages": messages, "function": function, "server": server }.reject do |_k, v| + @_field_set = { + "async": async, + "messages": messages, + "type": type, + "function": function, + "server": server + }.reject do |_k, v| v == OMIT end end @@ -95,6 +105,7 @@ def self.from_json(json_object:) item = item.to_json Vapi::CreateDtmfToolDtoMessagesItem.from_json(json_object: item) end + type = parsed_json["type"] if parsed_json["function"].nil? function = nil else @@ -110,6 +121,7 @@ def self.from_json(json_object:) new( async: async, messages: messages, + type: type, function: function, server: server, additional_properties: struct @@ -132,6 +144,7 @@ def to_json(*_args) def self.validate_raw(obj:) obj.async&.is_a?(Boolean) != false || raise("Passed value for field obj.async is not the expected type, validation failed.") obj.messages&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.function.nil? || Vapi::OpenAiFunction.validate_raw(obj: obj.function) obj.server.nil? || Vapi::Server.validate_raw(obj: obj.server) end diff --git a/lib/vapi/types/create_dtmf_tool_dto_messages_item.rb b/lib/vapi/types/create_dtmf_tool_dto_messages_item.rb index a6ba7f8..6b118d4 100644 --- a/lib/vapi/types/create_dtmf_tool_dto_messages_item.rb +++ b/lib/vapi/types/create_dtmf_tool_dto_messages_item.rb @@ -8,60 +8,45 @@ module Vapi class CreateDtmfToolDtoMessagesItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::CreateDtmfToolDtoMessagesItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of CreateDtmfToolDtoMessagesItem # # @param json_object [String] # @return [Vapi::CreateDtmfToolDtoMessagesItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "request-start" - Vapi::ToolMessageStart.from_json(json_object: json_object) - when "request-complete" - Vapi::ToolMessageComplete.from_json(json_object: json_object) - when "request-failed" - Vapi::ToolMessageFailed.from_json(json_object: json_object) - when "request-response-delayed" - Vapi::ToolMessageDelayed.from_json(json_object: json_object) - else - Vapi::ToolMessageStart.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ToolMessageStart.validate_raw(obj: struct) + return Vapi::ToolMessageStart.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "request-start" - { **@member.to_json, type: @discriminant }.to_json - when "request-complete" - { **@member.to_json, type: @discriminant }.to_json - when "request-failed" - { **@member.to_json, type: @discriminant }.to_json - when "request-response-delayed" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageComplete.validate_raw(obj: struct) + return Vapi::ToolMessageComplete.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageFailed.validate_raw(obj: struct) + return Vapi::ToolMessageFailed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageDelayed.validate_raw(obj: struct) + return Vapi::ToolMessageDelayed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -71,50 +56,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "request-start" - Vapi::ToolMessageStart.validate_raw(obj: obj) - when "request-complete" - Vapi::ToolMessageComplete.validate_raw(obj: obj) - when "request-failed" - Vapi::ToolMessageFailed.validate_raw(obj: obj) - when "request-response-delayed" - Vapi::ToolMessageDelayed.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ToolMessageStart.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ToolMessageStart] - # @return [Vapi::CreateDtmfToolDtoMessagesItem] - def self.request_start(member:) - new(member: member, discriminant: "request-start") - end - - # @param member [Vapi::ToolMessageComplete] - # @return [Vapi::CreateDtmfToolDtoMessagesItem] - def self.request_complete(member:) - new(member: member, discriminant: "request-complete") - end - - # @param member [Vapi::ToolMessageFailed] - # @return [Vapi::CreateDtmfToolDtoMessagesItem] - def self.request_failed(member:) - new(member: member, discriminant: "request-failed") - end - - # @param member [Vapi::ToolMessageDelayed] - # @return [Vapi::CreateDtmfToolDtoMessagesItem] - def self.request_response_delayed(member:) - new(member: member, discriminant: "request-response-delayed") + begin + return Vapi::ToolMessageComplete.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageFailed.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageDelayed.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/create_end_call_tool_dto.rb b/lib/vapi/types/create_end_call_tool_dto.rb index 18cdb2a..4197aa2 100644 --- a/lib/vapi/types/create_end_call_tool_dto.rb +++ b/lib/vapi/types/create_end_call_tool_dto.rb @@ -20,6 +20,8 @@ class CreateEndCallToolDto # `tool.destinations`. For others like the function tool, these can be custom # configured. attr_reader :messages + # @return [String] + attr_reader :type # @return [Vapi::OpenAiFunction] This is the function definition of the tool. # For `endCall`, `transferCall`, and `dtmf` tools, this is auto-filled based on # tool-specific fields like `tool.destinations`. But, even in those cases, you can @@ -55,6 +57,7 @@ class CreateEndCallToolDto # For some tools, this is auto-filled based on special fields like # `tool.destinations`. For others like the function tool, these can be custom # configured. + # @param type [String] # @param function [Vapi::OpenAiFunction] This is the function definition of the tool. # For `endCall`, `transferCall`, and `dtmf` tools, this is auto-filled based on # tool-specific fields like `tool.destinations`. But, even in those cases, you can @@ -72,13 +75,20 @@ class CreateEndCallToolDto # phoneNumber.serverUrl, then org.serverUrl. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::CreateEndCallToolDto] - def initialize(async: OMIT, messages: OMIT, function: OMIT, server: OMIT, additional_properties: nil) + def initialize(type:, async: OMIT, messages: OMIT, function: OMIT, server: OMIT, additional_properties: nil) @async = async if async != OMIT @messages = messages if messages != OMIT + @type = type @function = function if function != OMIT @server = server if server != OMIT @additional_properties = additional_properties - @_field_set = { "async": async, "messages": messages, "function": function, "server": server }.reject do |_k, v| + @_field_set = { + "async": async, + "messages": messages, + "type": type, + "function": function, + "server": server + }.reject do |_k, v| v == OMIT end end @@ -95,6 +105,7 @@ def self.from_json(json_object:) item = item.to_json Vapi::CreateEndCallToolDtoMessagesItem.from_json(json_object: item) end + type = parsed_json["type"] if parsed_json["function"].nil? function = nil else @@ -110,6 +121,7 @@ def self.from_json(json_object:) new( async: async, messages: messages, + type: type, function: function, server: server, additional_properties: struct @@ -132,6 +144,7 @@ def to_json(*_args) def self.validate_raw(obj:) obj.async&.is_a?(Boolean) != false || raise("Passed value for field obj.async is not the expected type, validation failed.") obj.messages&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.function.nil? || Vapi::OpenAiFunction.validate_raw(obj: obj.function) obj.server.nil? || Vapi::Server.validate_raw(obj: obj.server) end diff --git a/lib/vapi/types/create_end_call_tool_dto_messages_item.rb b/lib/vapi/types/create_end_call_tool_dto_messages_item.rb index ab13ab5..000553d 100644 --- a/lib/vapi/types/create_end_call_tool_dto_messages_item.rb +++ b/lib/vapi/types/create_end_call_tool_dto_messages_item.rb @@ -8,60 +8,45 @@ module Vapi class CreateEndCallToolDtoMessagesItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::CreateEndCallToolDtoMessagesItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of CreateEndCallToolDtoMessagesItem # # @param json_object [String] # @return [Vapi::CreateEndCallToolDtoMessagesItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "request-start" - Vapi::ToolMessageStart.from_json(json_object: json_object) - when "request-complete" - Vapi::ToolMessageComplete.from_json(json_object: json_object) - when "request-failed" - Vapi::ToolMessageFailed.from_json(json_object: json_object) - when "request-response-delayed" - Vapi::ToolMessageDelayed.from_json(json_object: json_object) - else - Vapi::ToolMessageStart.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ToolMessageStart.validate_raw(obj: struct) + return Vapi::ToolMessageStart.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "request-start" - { **@member.to_json, type: @discriminant }.to_json - when "request-complete" - { **@member.to_json, type: @discriminant }.to_json - when "request-failed" - { **@member.to_json, type: @discriminant }.to_json - when "request-response-delayed" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageComplete.validate_raw(obj: struct) + return Vapi::ToolMessageComplete.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageFailed.validate_raw(obj: struct) + return Vapi::ToolMessageFailed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageDelayed.validate_raw(obj: struct) + return Vapi::ToolMessageDelayed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -71,50 +56,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "request-start" - Vapi::ToolMessageStart.validate_raw(obj: obj) - when "request-complete" - Vapi::ToolMessageComplete.validate_raw(obj: obj) - when "request-failed" - Vapi::ToolMessageFailed.validate_raw(obj: obj) - when "request-response-delayed" - Vapi::ToolMessageDelayed.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ToolMessageStart.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ToolMessageStart] - # @return [Vapi::CreateEndCallToolDtoMessagesItem] - def self.request_start(member:) - new(member: member, discriminant: "request-start") - end - - # @param member [Vapi::ToolMessageComplete] - # @return [Vapi::CreateEndCallToolDtoMessagesItem] - def self.request_complete(member:) - new(member: member, discriminant: "request-complete") - end - - # @param member [Vapi::ToolMessageFailed] - # @return [Vapi::CreateEndCallToolDtoMessagesItem] - def self.request_failed(member:) - new(member: member, discriminant: "request-failed") - end - - # @param member [Vapi::ToolMessageDelayed] - # @return [Vapi::CreateEndCallToolDtoMessagesItem] - def self.request_response_delayed(member:) - new(member: member, discriminant: "request-response-delayed") + begin + return Vapi::ToolMessageComplete.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageFailed.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageDelayed.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/create_function_tool_dto.rb b/lib/vapi/types/create_function_tool_dto.rb index b59dc10..d205714 100644 --- a/lib/vapi/types/create_function_tool_dto.rb +++ b/lib/vapi/types/create_function_tool_dto.rb @@ -20,6 +20,8 @@ class CreateFunctionToolDto # `tool.destinations`. For others like the function tool, these can be custom # configured. attr_reader :messages + # @return [String] + attr_reader :type # @return [Vapi::OpenAiFunction] This is the function definition of the tool. # For `endCall`, `transferCall`, and `dtmf` tools, this is auto-filled based on # tool-specific fields like `tool.destinations`. But, even in those cases, you can @@ -55,6 +57,7 @@ class CreateFunctionToolDto # For some tools, this is auto-filled based on special fields like # `tool.destinations`. For others like the function tool, these can be custom # configured. + # @param type [String] # @param function [Vapi::OpenAiFunction] This is the function definition of the tool. # For `endCall`, `transferCall`, and `dtmf` tools, this is auto-filled based on # tool-specific fields like `tool.destinations`. But, even in those cases, you can @@ -72,13 +75,20 @@ class CreateFunctionToolDto # phoneNumber.serverUrl, then org.serverUrl. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::CreateFunctionToolDto] - def initialize(async: OMIT, messages: OMIT, function: OMIT, server: OMIT, additional_properties: nil) + def initialize(type:, async: OMIT, messages: OMIT, function: OMIT, server: OMIT, additional_properties: nil) @async = async if async != OMIT @messages = messages if messages != OMIT + @type = type @function = function if function != OMIT @server = server if server != OMIT @additional_properties = additional_properties - @_field_set = { "async": async, "messages": messages, "function": function, "server": server }.reject do |_k, v| + @_field_set = { + "async": async, + "messages": messages, + "type": type, + "function": function, + "server": server + }.reject do |_k, v| v == OMIT end end @@ -95,6 +105,7 @@ def self.from_json(json_object:) item = item.to_json Vapi::CreateFunctionToolDtoMessagesItem.from_json(json_object: item) end + type = parsed_json["type"] if parsed_json["function"].nil? function = nil else @@ -110,6 +121,7 @@ def self.from_json(json_object:) new( async: async, messages: messages, + type: type, function: function, server: server, additional_properties: struct @@ -132,6 +144,7 @@ def to_json(*_args) def self.validate_raw(obj:) obj.async&.is_a?(Boolean) != false || raise("Passed value for field obj.async is not the expected type, validation failed.") obj.messages&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.function.nil? || Vapi::OpenAiFunction.validate_raw(obj: obj.function) obj.server.nil? || Vapi::Server.validate_raw(obj: obj.server) end diff --git a/lib/vapi/types/create_function_tool_dto_messages_item.rb b/lib/vapi/types/create_function_tool_dto_messages_item.rb index 45f446e..8206817 100644 --- a/lib/vapi/types/create_function_tool_dto_messages_item.rb +++ b/lib/vapi/types/create_function_tool_dto_messages_item.rb @@ -8,60 +8,45 @@ module Vapi class CreateFunctionToolDtoMessagesItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::CreateFunctionToolDtoMessagesItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of CreateFunctionToolDtoMessagesItem # # @param json_object [String] # @return [Vapi::CreateFunctionToolDtoMessagesItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "request-start" - Vapi::ToolMessageStart.from_json(json_object: json_object) - when "request-complete" - Vapi::ToolMessageComplete.from_json(json_object: json_object) - when "request-failed" - Vapi::ToolMessageFailed.from_json(json_object: json_object) - when "request-response-delayed" - Vapi::ToolMessageDelayed.from_json(json_object: json_object) - else - Vapi::ToolMessageStart.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ToolMessageStart.validate_raw(obj: struct) + return Vapi::ToolMessageStart.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "request-start" - { **@member.to_json, type: @discriminant }.to_json - when "request-complete" - { **@member.to_json, type: @discriminant }.to_json - when "request-failed" - { **@member.to_json, type: @discriminant }.to_json - when "request-response-delayed" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageComplete.validate_raw(obj: struct) + return Vapi::ToolMessageComplete.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageFailed.validate_raw(obj: struct) + return Vapi::ToolMessageFailed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageDelayed.validate_raw(obj: struct) + return Vapi::ToolMessageDelayed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -71,50 +56,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "request-start" - Vapi::ToolMessageStart.validate_raw(obj: obj) - when "request-complete" - Vapi::ToolMessageComplete.validate_raw(obj: obj) - when "request-failed" - Vapi::ToolMessageFailed.validate_raw(obj: obj) - when "request-response-delayed" - Vapi::ToolMessageDelayed.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ToolMessageStart.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ToolMessageStart] - # @return [Vapi::CreateFunctionToolDtoMessagesItem] - def self.request_start(member:) - new(member: member, discriminant: "request-start") - end - - # @param member [Vapi::ToolMessageComplete] - # @return [Vapi::CreateFunctionToolDtoMessagesItem] - def self.request_complete(member:) - new(member: member, discriminant: "request-complete") - end - - # @param member [Vapi::ToolMessageFailed] - # @return [Vapi::CreateFunctionToolDtoMessagesItem] - def self.request_failed(member:) - new(member: member, discriminant: "request-failed") - end - - # @param member [Vapi::ToolMessageDelayed] - # @return [Vapi::CreateFunctionToolDtoMessagesItem] - def self.request_response_delayed(member:) - new(member: member, discriminant: "request-response-delayed") + begin + return Vapi::ToolMessageComplete.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageFailed.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageDelayed.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/create_ghl_tool_dto.rb b/lib/vapi/types/create_ghl_tool_dto.rb index 6047741..19a3bc4 100644 --- a/lib/vapi/types/create_ghl_tool_dto.rb +++ b/lib/vapi/types/create_ghl_tool_dto.rb @@ -21,6 +21,8 @@ class CreateGhlToolDto # `tool.destinations`. For others like the function tool, these can be custom # configured. attr_reader :messages + # @return [String] + attr_reader :type # @return [Vapi::GhlToolMetadata] attr_reader :metadata # @return [Vapi::OpenAiFunction] This is the function definition of the tool. @@ -58,6 +60,7 @@ class CreateGhlToolDto # For some tools, this is auto-filled based on special fields like # `tool.destinations`. For others like the function tool, these can be custom # configured. + # @param type [String] # @param metadata [Vapi::GhlToolMetadata] # @param function [Vapi::OpenAiFunction] This is the function definition of the tool. # For `endCall`, `transferCall`, and `dtmf` tools, this is auto-filled based on @@ -76,9 +79,11 @@ class CreateGhlToolDto # phoneNumber.serverUrl, then org.serverUrl. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::CreateGhlToolDto] - def initialize(metadata:, async: OMIT, messages: OMIT, function: OMIT, server: OMIT, additional_properties: nil) + def initialize(type:, metadata:, async: OMIT, messages: OMIT, function: OMIT, server: OMIT, + additional_properties: nil) @async = async if async != OMIT @messages = messages if messages != OMIT + @type = type @metadata = metadata @function = function if function != OMIT @server = server if server != OMIT @@ -86,6 +91,7 @@ def initialize(metadata:, async: OMIT, messages: OMIT, function: OMIT, server: O @_field_set = { "async": async, "messages": messages, + "type": type, "metadata": metadata, "function": function, "server": server @@ -106,6 +112,7 @@ def self.from_json(json_object:) item = item.to_json Vapi::CreateGhlToolDtoMessagesItem.from_json(json_object: item) end + type = parsed_json["type"] if parsed_json["metadata"].nil? metadata = nil else @@ -127,6 +134,7 @@ def self.from_json(json_object:) new( async: async, messages: messages, + type: type, metadata: metadata, function: function, server: server, @@ -150,6 +158,7 @@ def to_json(*_args) def self.validate_raw(obj:) obj.async&.is_a?(Boolean) != false || raise("Passed value for field obj.async is not the expected type, validation failed.") obj.messages&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") Vapi::GhlToolMetadata.validate_raw(obj: obj.metadata) obj.function.nil? || Vapi::OpenAiFunction.validate_raw(obj: obj.function) obj.server.nil? || Vapi::Server.validate_raw(obj: obj.server) diff --git a/lib/vapi/types/create_ghl_tool_dto_messages_item.rb b/lib/vapi/types/create_ghl_tool_dto_messages_item.rb index c60a13b..31a74b6 100644 --- a/lib/vapi/types/create_ghl_tool_dto_messages_item.rb +++ b/lib/vapi/types/create_ghl_tool_dto_messages_item.rb @@ -8,60 +8,45 @@ module Vapi class CreateGhlToolDtoMessagesItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::CreateGhlToolDtoMessagesItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of CreateGhlToolDtoMessagesItem # # @param json_object [String] # @return [Vapi::CreateGhlToolDtoMessagesItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "request-start" - Vapi::ToolMessageStart.from_json(json_object: json_object) - when "request-complete" - Vapi::ToolMessageComplete.from_json(json_object: json_object) - when "request-failed" - Vapi::ToolMessageFailed.from_json(json_object: json_object) - when "request-response-delayed" - Vapi::ToolMessageDelayed.from_json(json_object: json_object) - else - Vapi::ToolMessageStart.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ToolMessageStart.validate_raw(obj: struct) + return Vapi::ToolMessageStart.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "request-start" - { **@member.to_json, type: @discriminant }.to_json - when "request-complete" - { **@member.to_json, type: @discriminant }.to_json - when "request-failed" - { **@member.to_json, type: @discriminant }.to_json - when "request-response-delayed" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageComplete.validate_raw(obj: struct) + return Vapi::ToolMessageComplete.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageFailed.validate_raw(obj: struct) + return Vapi::ToolMessageFailed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageDelayed.validate_raw(obj: struct) + return Vapi::ToolMessageDelayed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -71,50 +56,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "request-start" - Vapi::ToolMessageStart.validate_raw(obj: obj) - when "request-complete" - Vapi::ToolMessageComplete.validate_raw(obj: obj) - when "request-failed" - Vapi::ToolMessageFailed.validate_raw(obj: obj) - when "request-response-delayed" - Vapi::ToolMessageDelayed.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ToolMessageStart.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ToolMessageStart] - # @return [Vapi::CreateGhlToolDtoMessagesItem] - def self.request_start(member:) - new(member: member, discriminant: "request-start") - end - - # @param member [Vapi::ToolMessageComplete] - # @return [Vapi::CreateGhlToolDtoMessagesItem] - def self.request_complete(member:) - new(member: member, discriminant: "request-complete") - end - - # @param member [Vapi::ToolMessageFailed] - # @return [Vapi::CreateGhlToolDtoMessagesItem] - def self.request_failed(member:) - new(member: member, discriminant: "request-failed") - end - - # @param member [Vapi::ToolMessageDelayed] - # @return [Vapi::CreateGhlToolDtoMessagesItem] - def self.request_response_delayed(member:) - new(member: member, discriminant: "request-response-delayed") + begin + return Vapi::ToolMessageComplete.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageFailed.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageDelayed.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/create_make_tool_dto.rb b/lib/vapi/types/create_make_tool_dto.rb index 3236518..37bc7cd 100644 --- a/lib/vapi/types/create_make_tool_dto.rb +++ b/lib/vapi/types/create_make_tool_dto.rb @@ -21,6 +21,8 @@ class CreateMakeToolDto # `tool.destinations`. For others like the function tool, these can be custom # configured. attr_reader :messages + # @return [String] + attr_reader :type # @return [Vapi::MakeToolMetadata] attr_reader :metadata # @return [Vapi::OpenAiFunction] This is the function definition of the tool. @@ -58,6 +60,7 @@ class CreateMakeToolDto # For some tools, this is auto-filled based on special fields like # `tool.destinations`. For others like the function tool, these can be custom # configured. + # @param type [String] # @param metadata [Vapi::MakeToolMetadata] # @param function [Vapi::OpenAiFunction] This is the function definition of the tool. # For `endCall`, `transferCall`, and `dtmf` tools, this is auto-filled based on @@ -76,9 +79,11 @@ class CreateMakeToolDto # phoneNumber.serverUrl, then org.serverUrl. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::CreateMakeToolDto] - def initialize(metadata:, async: OMIT, messages: OMIT, function: OMIT, server: OMIT, additional_properties: nil) + def initialize(type:, metadata:, async: OMIT, messages: OMIT, function: OMIT, server: OMIT, + additional_properties: nil) @async = async if async != OMIT @messages = messages if messages != OMIT + @type = type @metadata = metadata @function = function if function != OMIT @server = server if server != OMIT @@ -86,6 +91,7 @@ def initialize(metadata:, async: OMIT, messages: OMIT, function: OMIT, server: O @_field_set = { "async": async, "messages": messages, + "type": type, "metadata": metadata, "function": function, "server": server @@ -106,6 +112,7 @@ def self.from_json(json_object:) item = item.to_json Vapi::CreateMakeToolDtoMessagesItem.from_json(json_object: item) end + type = parsed_json["type"] if parsed_json["metadata"].nil? metadata = nil else @@ -127,6 +134,7 @@ def self.from_json(json_object:) new( async: async, messages: messages, + type: type, metadata: metadata, function: function, server: server, @@ -150,6 +158,7 @@ def to_json(*_args) def self.validate_raw(obj:) obj.async&.is_a?(Boolean) != false || raise("Passed value for field obj.async is not the expected type, validation failed.") obj.messages&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") Vapi::MakeToolMetadata.validate_raw(obj: obj.metadata) obj.function.nil? || Vapi::OpenAiFunction.validate_raw(obj: obj.function) obj.server.nil? || Vapi::Server.validate_raw(obj: obj.server) diff --git a/lib/vapi/types/create_make_tool_dto_messages_item.rb b/lib/vapi/types/create_make_tool_dto_messages_item.rb index e50c03d..8e29886 100644 --- a/lib/vapi/types/create_make_tool_dto_messages_item.rb +++ b/lib/vapi/types/create_make_tool_dto_messages_item.rb @@ -8,60 +8,45 @@ module Vapi class CreateMakeToolDtoMessagesItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::CreateMakeToolDtoMessagesItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of CreateMakeToolDtoMessagesItem # # @param json_object [String] # @return [Vapi::CreateMakeToolDtoMessagesItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "request-start" - Vapi::ToolMessageStart.from_json(json_object: json_object) - when "request-complete" - Vapi::ToolMessageComplete.from_json(json_object: json_object) - when "request-failed" - Vapi::ToolMessageFailed.from_json(json_object: json_object) - when "request-response-delayed" - Vapi::ToolMessageDelayed.from_json(json_object: json_object) - else - Vapi::ToolMessageStart.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ToolMessageStart.validate_raw(obj: struct) + return Vapi::ToolMessageStart.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "request-start" - { **@member.to_json, type: @discriminant }.to_json - when "request-complete" - { **@member.to_json, type: @discriminant }.to_json - when "request-failed" - { **@member.to_json, type: @discriminant }.to_json - when "request-response-delayed" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageComplete.validate_raw(obj: struct) + return Vapi::ToolMessageComplete.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageFailed.validate_raw(obj: struct) + return Vapi::ToolMessageFailed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageDelayed.validate_raw(obj: struct) + return Vapi::ToolMessageDelayed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -71,50 +56,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "request-start" - Vapi::ToolMessageStart.validate_raw(obj: obj) - when "request-complete" - Vapi::ToolMessageComplete.validate_raw(obj: obj) - when "request-failed" - Vapi::ToolMessageFailed.validate_raw(obj: obj) - when "request-response-delayed" - Vapi::ToolMessageDelayed.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ToolMessageStart.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ToolMessageStart] - # @return [Vapi::CreateMakeToolDtoMessagesItem] - def self.request_start(member:) - new(member: member, discriminant: "request-start") - end - - # @param member [Vapi::ToolMessageComplete] - # @return [Vapi::CreateMakeToolDtoMessagesItem] - def self.request_complete(member:) - new(member: member, discriminant: "request-complete") - end - - # @param member [Vapi::ToolMessageFailed] - # @return [Vapi::CreateMakeToolDtoMessagesItem] - def self.request_failed(member:) - new(member: member, discriminant: "request-failed") - end - - # @param member [Vapi::ToolMessageDelayed] - # @return [Vapi::CreateMakeToolDtoMessagesItem] - def self.request_response_delayed(member:) - new(member: member, discriminant: "request-response-delayed") + begin + return Vapi::ToolMessageComplete.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageFailed.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageDelayed.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/create_output_tool_dto.rb b/lib/vapi/types/create_output_tool_dto.rb index c2bc1a7..9c993b1 100644 --- a/lib/vapi/types/create_output_tool_dto.rb +++ b/lib/vapi/types/create_output_tool_dto.rb @@ -20,6 +20,8 @@ class CreateOutputToolDto # `tool.destinations`. For others like the function tool, these can be custom # configured. attr_reader :messages + # @return [String] + attr_reader :type # @return [Vapi::OpenAiFunction] This is the function definition of the tool. # For `endCall`, `transferCall`, and `dtmf` tools, this is auto-filled based on # tool-specific fields like `tool.destinations`. But, even in those cases, you can @@ -55,6 +57,7 @@ class CreateOutputToolDto # For some tools, this is auto-filled based on special fields like # `tool.destinations`. For others like the function tool, these can be custom # configured. + # @param type [String] # @param function [Vapi::OpenAiFunction] This is the function definition of the tool. # For `endCall`, `transferCall`, and `dtmf` tools, this is auto-filled based on # tool-specific fields like `tool.destinations`. But, even in those cases, you can @@ -72,13 +75,20 @@ class CreateOutputToolDto # phoneNumber.serverUrl, then org.serverUrl. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::CreateOutputToolDto] - def initialize(async: OMIT, messages: OMIT, function: OMIT, server: OMIT, additional_properties: nil) + def initialize(type:, async: OMIT, messages: OMIT, function: OMIT, server: OMIT, additional_properties: nil) @async = async if async != OMIT @messages = messages if messages != OMIT + @type = type @function = function if function != OMIT @server = server if server != OMIT @additional_properties = additional_properties - @_field_set = { "async": async, "messages": messages, "function": function, "server": server }.reject do |_k, v| + @_field_set = { + "async": async, + "messages": messages, + "type": type, + "function": function, + "server": server + }.reject do |_k, v| v == OMIT end end @@ -95,6 +105,7 @@ def self.from_json(json_object:) item = item.to_json Vapi::CreateOutputToolDtoMessagesItem.from_json(json_object: item) end + type = parsed_json["type"] if parsed_json["function"].nil? function = nil else @@ -110,6 +121,7 @@ def self.from_json(json_object:) new( async: async, messages: messages, + type: type, function: function, server: server, additional_properties: struct @@ -132,6 +144,7 @@ def to_json(*_args) def self.validate_raw(obj:) obj.async&.is_a?(Boolean) != false || raise("Passed value for field obj.async is not the expected type, validation failed.") obj.messages&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.function.nil? || Vapi::OpenAiFunction.validate_raw(obj: obj.function) obj.server.nil? || Vapi::Server.validate_raw(obj: obj.server) end diff --git a/lib/vapi/types/create_output_tool_dto_messages_item.rb b/lib/vapi/types/create_output_tool_dto_messages_item.rb index 03afd4f..69d2a30 100644 --- a/lib/vapi/types/create_output_tool_dto_messages_item.rb +++ b/lib/vapi/types/create_output_tool_dto_messages_item.rb @@ -8,60 +8,45 @@ module Vapi class CreateOutputToolDtoMessagesItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::CreateOutputToolDtoMessagesItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of CreateOutputToolDtoMessagesItem # # @param json_object [String] # @return [Vapi::CreateOutputToolDtoMessagesItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "request-start" - Vapi::ToolMessageStart.from_json(json_object: json_object) - when "request-complete" - Vapi::ToolMessageComplete.from_json(json_object: json_object) - when "request-failed" - Vapi::ToolMessageFailed.from_json(json_object: json_object) - when "request-response-delayed" - Vapi::ToolMessageDelayed.from_json(json_object: json_object) - else - Vapi::ToolMessageStart.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ToolMessageStart.validate_raw(obj: struct) + return Vapi::ToolMessageStart.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "request-start" - { **@member.to_json, type: @discriminant }.to_json - when "request-complete" - { **@member.to_json, type: @discriminant }.to_json - when "request-failed" - { **@member.to_json, type: @discriminant }.to_json - when "request-response-delayed" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageComplete.validate_raw(obj: struct) + return Vapi::ToolMessageComplete.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageFailed.validate_raw(obj: struct) + return Vapi::ToolMessageFailed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageDelayed.validate_raw(obj: struct) + return Vapi::ToolMessageDelayed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -71,50 +56,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "request-start" - Vapi::ToolMessageStart.validate_raw(obj: obj) - when "request-complete" - Vapi::ToolMessageComplete.validate_raw(obj: obj) - when "request-failed" - Vapi::ToolMessageFailed.validate_raw(obj: obj) - when "request-response-delayed" - Vapi::ToolMessageDelayed.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ToolMessageStart.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ToolMessageStart] - # @return [Vapi::CreateOutputToolDtoMessagesItem] - def self.request_start(member:) - new(member: member, discriminant: "request-start") - end - - # @param member [Vapi::ToolMessageComplete] - # @return [Vapi::CreateOutputToolDtoMessagesItem] - def self.request_complete(member:) - new(member: member, discriminant: "request-complete") - end - - # @param member [Vapi::ToolMessageFailed] - # @return [Vapi::CreateOutputToolDtoMessagesItem] - def self.request_failed(member:) - new(member: member, discriminant: "request-failed") - end - - # @param member [Vapi::ToolMessageDelayed] - # @return [Vapi::CreateOutputToolDtoMessagesItem] - def self.request_response_delayed(member:) - new(member: member, discriminant: "request-response-delayed") + begin + return Vapi::ToolMessageComplete.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageFailed.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageDelayed.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/create_tool_call_block_dto.rb b/lib/vapi/types/create_tool_call_block_dto.rb index 7732f7c..eb8cd8f 100644 --- a/lib/vapi/types/create_tool_call_block_dto.rb +++ b/lib/vapi/types/create_tool_call_block_dto.rb @@ -34,6 +34,8 @@ class CreateToolCallBlockDto # this liquid variable is just provided for convenience when creating blocks # outside of a workflow with steps. attr_reader :output_schema + # @return [String] + attr_reader :type # @return [Vapi::CreateToolCallBlockDtoTool] This is the tool that the block will call. To use an existing tool, use # `toolId`. attr_reader :tool @@ -73,6 +75,7 @@ class CreateToolCallBlockDto # {{blockName.output.propertyName}} will reference the latest usage of the block. # this liquid variable is just provided for convenience when creating blocks # outside of a workflow with steps. + # @param type [String] # @param tool [Vapi::CreateToolCallBlockDtoTool] This is the tool that the block will call. To use an existing tool, use # `toolId`. # @param tool_id [String] This is the id of the tool that the block will call. To use a transient tool, @@ -80,11 +83,12 @@ class CreateToolCallBlockDto # @param name [String] This is the name of the block. This is just for your reference. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::CreateToolCallBlockDto] - def initialize(messages: OMIT, input_schema: OMIT, output_schema: OMIT, tool: OMIT, tool_id: OMIT, name: OMIT, - additional_properties: nil) + def initialize(type:, messages: OMIT, input_schema: OMIT, output_schema: OMIT, tool: OMIT, tool_id: OMIT, + name: OMIT, additional_properties: nil) @messages = messages if messages != OMIT @input_schema = input_schema if input_schema != OMIT @output_schema = output_schema if output_schema != OMIT + @type = type @tool = tool if tool != OMIT @tool_id = tool_id if tool_id != OMIT @name = name if name != OMIT @@ -93,6 +97,7 @@ def initialize(messages: OMIT, input_schema: OMIT, output_schema: OMIT, tool: OM "messages": messages, "inputSchema": input_schema, "outputSchema": output_schema, + "type": type, "tool": tool, "toolId": tool_id, "name": name @@ -124,6 +129,7 @@ def self.from_json(json_object:) output_schema = parsed_json["outputSchema"].to_json output_schema = Vapi::JsonSchema.from_json(json_object: output_schema) end + type = parsed_json["type"] if parsed_json["tool"].nil? tool = nil else @@ -136,6 +142,7 @@ def self.from_json(json_object:) messages: messages, input_schema: input_schema, output_schema: output_schema, + type: type, tool: tool, tool_id: tool_id, name: name, @@ -160,6 +167,7 @@ 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.input_schema.nil? || Vapi::JsonSchema.validate_raw(obj: obj.input_schema) obj.output_schema.nil? || Vapi::JsonSchema.validate_raw(obj: obj.output_schema) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.tool.nil? || Vapi::CreateToolCallBlockDtoTool.validate_raw(obj: obj.tool) obj.tool_id&.is_a?(String) != false || raise("Passed value for field obj.tool_id is not the expected type, validation failed.") obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") diff --git a/lib/vapi/types/create_tool_call_block_dto_messages_item.rb b/lib/vapi/types/create_tool_call_block_dto_messages_item.rb index 4bc4f52..981d2b2 100644 --- a/lib/vapi/types/create_tool_call_block_dto_messages_item.rb +++ b/lib/vapi/types/create_tool_call_block_dto_messages_item.rb @@ -6,52 +6,29 @@ module Vapi class CreateToolCallBlockDtoMessagesItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::CreateToolCallBlockDtoMessagesItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of CreateToolCallBlockDtoMessagesItem # # @param json_object [String] # @return [Vapi::CreateToolCallBlockDtoMessagesItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "block-start" - Vapi::BlockStartMessage.from_json(json_object: json_object) - when "block-complete" - Vapi::BlockCompleteMessage.from_json(json_object: json_object) - else - Vapi::BlockStartMessage.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::BlockStartMessage.validate_raw(obj: struct) + return Vapi::BlockStartMessage.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "block-start" - { **@member.to_json, type: @discriminant }.to_json - when "block-complete" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::BlockCompleteMessage.validate_raw(obj: struct) + return Vapi::BlockCompleteMessage.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -61,34 +38,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "block-start" - Vapi::BlockStartMessage.validate_raw(obj: obj) - when "block-complete" - Vapi::BlockCompleteMessage.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::BlockStartMessage.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::BlockStartMessage] - # @return [Vapi::CreateToolCallBlockDtoMessagesItem] - def self.block_start(member:) - new(member: member, discriminant: "block-start") - end - - # @param member [Vapi::BlockCompleteMessage] - # @return [Vapi::CreateToolCallBlockDtoMessagesItem] - def self.block_complete(member:) - new(member: member, discriminant: "block-complete") + begin + return Vapi::BlockCompleteMessage.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/create_tool_call_block_dto_tool.rb b/lib/vapi/types/create_tool_call_block_dto_tool.rb index ffa6839..4ada74c 100644 --- a/lib/vapi/types/create_tool_call_block_dto_tool.rb +++ b/lib/vapi/types/create_tool_call_block_dto_tool.rb @@ -13,72 +13,69 @@ module Vapi # This is the tool that the block will call. To use an existing tool, use # `toolId`. class CreateToolCallBlockDtoTool - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::CreateToolCallBlockDtoTool] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of CreateToolCallBlockDtoTool # # @param json_object [String] # @return [Vapi::CreateToolCallBlockDtoTool] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "dtmf" - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - when "endCall" - Vapi::CreateEndCallToolDto.from_json(json_object: json_object) - when "voicemail" - Vapi::CreateVoicemailToolDto.from_json(json_object: json_object) - when "function" - Vapi::CreateFunctionToolDto.from_json(json_object: json_object) - when "ghl" - Vapi::CreateGhlToolDto.from_json(json_object: json_object) - when "make" - Vapi::CreateMakeToolDto.from_json(json_object: json_object) - when "transferCall" - Vapi::CreateTransferCallToolDto.from_json(json_object: json_object) - else - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::CreateDtmfToolDto.validate_raw(obj: struct) + return Vapi::CreateDtmfToolDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "dtmf" - { **@member.to_json, type: @discriminant }.to_json - when "endCall" - { **@member.to_json, type: @discriminant }.to_json - when "voicemail" - { **@member.to_json, type: @discriminant }.to_json - when "function" - { **@member.to_json, type: @discriminant }.to_json - when "ghl" - { **@member.to_json, type: @discriminant }.to_json - when "make" - { **@member.to_json, type: @discriminant }.to_json - when "transferCall" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateEndCallToolDto.validate_raw(obj: struct) + return Vapi::CreateEndCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVoicemailToolDto.validate_raw(obj: struct) + return Vapi::CreateVoicemailToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateFunctionToolDto.validate_raw(obj: struct) + return Vapi::CreateFunctionToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::CreateGhlToolDto.validate_raw(obj: struct) + return Vapi::CreateGhlToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateMakeToolDto.validate_raw(obj: struct) + return Vapi::CreateMakeToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTransferCallToolDto.validate_raw(obj: struct) + return Vapi::CreateTransferCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -88,74 +85,42 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "dtmf" - Vapi::CreateDtmfToolDto.validate_raw(obj: obj) - when "endCall" - Vapi::CreateEndCallToolDto.validate_raw(obj: obj) - when "voicemail" - Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) - when "function" - Vapi::CreateFunctionToolDto.validate_raw(obj: obj) - when "ghl" - Vapi::CreateGhlToolDto.validate_raw(obj: obj) - when "make" - Vapi::CreateMakeToolDto.validate_raw(obj: obj) - when "transferCall" - Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateDtmfToolDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateDtmfToolDto] - # @return [Vapi::CreateToolCallBlockDtoTool] - def self.dtmf(member:) - new(member: member, discriminant: "dtmf") - end - - # @param member [Vapi::CreateEndCallToolDto] - # @return [Vapi::CreateToolCallBlockDtoTool] - def self.end_call(member:) - new(member: member, discriminant: "endCall") - end - - # @param member [Vapi::CreateVoicemailToolDto] - # @return [Vapi::CreateToolCallBlockDtoTool] - def self.voicemail(member:) - new(member: member, discriminant: "voicemail") - end - - # @param member [Vapi::CreateFunctionToolDto] - # @return [Vapi::CreateToolCallBlockDtoTool] - def self.function(member:) - new(member: member, discriminant: "function") - end - - # @param member [Vapi::CreateGhlToolDto] - # @return [Vapi::CreateToolCallBlockDtoTool] - def self.ghl(member:) - new(member: member, discriminant: "ghl") - end - - # @param member [Vapi::CreateMakeToolDto] - # @return [Vapi::CreateToolCallBlockDtoTool] - def self.make(member:) - new(member: member, discriminant: "make") - end - - # @param member [Vapi::CreateTransferCallToolDto] - # @return [Vapi::CreateToolCallBlockDtoTool] - def self.transfer_call(member:) - new(member: member, discriminant: "transferCall") + begin + return Vapi::CreateEndCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateFunctionToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateGhlToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateMakeToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/create_tool_template_dto_details.rb b/lib/vapi/types/create_tool_template_dto_details.rb index 8e5d50a..253d4da 100644 --- a/lib/vapi/types/create_tool_template_dto_details.rb +++ b/lib/vapi/types/create_tool_template_dto_details.rb @@ -11,72 +11,69 @@ module Vapi class CreateToolTemplateDtoDetails - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::CreateToolTemplateDtoDetails] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of CreateToolTemplateDtoDetails # # @param json_object [String] # @return [Vapi::CreateToolTemplateDtoDetails] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "dtmf" - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - when "endCall" - Vapi::CreateEndCallToolDto.from_json(json_object: json_object) - when "voicemail" - Vapi::CreateVoicemailToolDto.from_json(json_object: json_object) - when "function" - Vapi::CreateFunctionToolDto.from_json(json_object: json_object) - when "ghl" - Vapi::CreateGhlToolDto.from_json(json_object: json_object) - when "make" - Vapi::CreateMakeToolDto.from_json(json_object: json_object) - when "transferCall" - Vapi::CreateTransferCallToolDto.from_json(json_object: json_object) - else - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::CreateDtmfToolDto.validate_raw(obj: struct) + return Vapi::CreateDtmfToolDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "dtmf" - { **@member.to_json, type: @discriminant }.to_json - when "endCall" - { **@member.to_json, type: @discriminant }.to_json - when "voicemail" - { **@member.to_json, type: @discriminant }.to_json - when "function" - { **@member.to_json, type: @discriminant }.to_json - when "ghl" - { **@member.to_json, type: @discriminant }.to_json - when "make" - { **@member.to_json, type: @discriminant }.to_json - when "transferCall" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateEndCallToolDto.validate_raw(obj: struct) + return Vapi::CreateEndCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVoicemailToolDto.validate_raw(obj: struct) + return Vapi::CreateVoicemailToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateFunctionToolDto.validate_raw(obj: struct) + return Vapi::CreateFunctionToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::CreateGhlToolDto.validate_raw(obj: struct) + return Vapi::CreateGhlToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateMakeToolDto.validate_raw(obj: struct) + return Vapi::CreateMakeToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTransferCallToolDto.validate_raw(obj: struct) + return Vapi::CreateTransferCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -86,74 +83,42 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "dtmf" - Vapi::CreateDtmfToolDto.validate_raw(obj: obj) - when "endCall" - Vapi::CreateEndCallToolDto.validate_raw(obj: obj) - when "voicemail" - Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) - when "function" - Vapi::CreateFunctionToolDto.validate_raw(obj: obj) - when "ghl" - Vapi::CreateGhlToolDto.validate_raw(obj: obj) - when "make" - Vapi::CreateMakeToolDto.validate_raw(obj: obj) - when "transferCall" - Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateDtmfToolDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateDtmfToolDto] - # @return [Vapi::CreateToolTemplateDtoDetails] - def self.dtmf(member:) - new(member: member, discriminant: "dtmf") - end - - # @param member [Vapi::CreateEndCallToolDto] - # @return [Vapi::CreateToolTemplateDtoDetails] - def self.end_call(member:) - new(member: member, discriminant: "endCall") - end - - # @param member [Vapi::CreateVoicemailToolDto] - # @return [Vapi::CreateToolTemplateDtoDetails] - def self.voicemail(member:) - new(member: member, discriminant: "voicemail") - end - - # @param member [Vapi::CreateFunctionToolDto] - # @return [Vapi::CreateToolTemplateDtoDetails] - def self.function(member:) - new(member: member, discriminant: "function") - end - - # @param member [Vapi::CreateGhlToolDto] - # @return [Vapi::CreateToolTemplateDtoDetails] - def self.ghl(member:) - new(member: member, discriminant: "ghl") - end - - # @param member [Vapi::CreateMakeToolDto] - # @return [Vapi::CreateToolTemplateDtoDetails] - def self.make(member:) - new(member: member, discriminant: "make") - end - - # @param member [Vapi::CreateTransferCallToolDto] - # @return [Vapi::CreateToolTemplateDtoDetails] - def self.transfer_call(member:) - new(member: member, discriminant: "transferCall") + begin + return Vapi::CreateEndCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateFunctionToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateGhlToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateMakeToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/create_tool_template_dto_provider_details.rb b/lib/vapi/types/create_tool_template_dto_provider_details.rb index 139e998..356847c 100644 --- a/lib/vapi/types/create_tool_template_dto_provider_details.rb +++ b/lib/vapi/types/create_tool_template_dto_provider_details.rb @@ -7,56 +7,37 @@ module Vapi class CreateToolTemplateDtoProviderDetails - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::CreateToolTemplateDtoProviderDetails] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of CreateToolTemplateDtoProviderDetails # # @param json_object [String] # @return [Vapi::CreateToolTemplateDtoProviderDetails] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "make" - Vapi::MakeToolProviderDetails.from_json(json_object: json_object) - when "ghl" - Vapi::GhlToolProviderDetails.from_json(json_object: json_object) - when "function" - Vapi::FunctionToolProviderDetails.from_json(json_object: json_object) - else - Vapi::MakeToolProviderDetails.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::MakeToolProviderDetails.validate_raw(obj: struct) + return Vapi::MakeToolProviderDetails.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "make" - { **@member.to_json, type: @discriminant }.to_json - when "ghl" - { **@member.to_json, type: @discriminant }.to_json - when "function" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::GhlToolProviderDetails.validate_raw(obj: struct) + return Vapi::GhlToolProviderDetails.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::FunctionToolProviderDetails.validate_raw(obj: struct) + return Vapi::FunctionToolProviderDetails.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -66,42 +47,22 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "make" - Vapi::MakeToolProviderDetails.validate_raw(obj: obj) - when "ghl" - Vapi::GhlToolProviderDetails.validate_raw(obj: obj) - when "function" - Vapi::FunctionToolProviderDetails.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::MakeToolProviderDetails.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::MakeToolProviderDetails] - # @return [Vapi::CreateToolTemplateDtoProviderDetails] - def self.make(member:) - new(member: member, discriminant: "make") - end - - # @param member [Vapi::GhlToolProviderDetails] - # @return [Vapi::CreateToolTemplateDtoProviderDetails] - def self.ghl(member:) - new(member: member, discriminant: "ghl") - end - - # @param member [Vapi::FunctionToolProviderDetails] - # @return [Vapi::CreateToolTemplateDtoProviderDetails] - def self.function(member:) - new(member: member, discriminant: "function") + begin + return Vapi::GhlToolProviderDetails.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::FunctionToolProviderDetails.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/create_transfer_call_tool_dto.rb b/lib/vapi/types/create_transfer_call_tool_dto.rb index d338cd8..7b79082 100644 --- a/lib/vapi/types/create_transfer_call_tool_dto.rb +++ b/lib/vapi/types/create_transfer_call_tool_dto.rb @@ -21,6 +21,8 @@ class CreateTransferCallToolDto # `tool.destinations`. For others like the function tool, these can be custom # configured. attr_reader :messages + # @return [String] + attr_reader :type # @return [Array] These are the destinations that the call can be transferred to. If no # destinations are provided, server.url will be used to get the transfer # destination once the tool is called. @@ -60,6 +62,7 @@ class CreateTransferCallToolDto # For some tools, this is auto-filled based on special fields like # `tool.destinations`. For others like the function tool, these can be custom # configured. + # @param type [String] # @param destinations [Array] These are the destinations that the call can be transferred to. If no # destinations are provided, server.url will be used to get the transfer # destination once the tool is called. @@ -80,10 +83,11 @@ class CreateTransferCallToolDto # phoneNumber.serverUrl, then org.serverUrl. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::CreateTransferCallToolDto] - def initialize(async: OMIT, messages: OMIT, destinations: OMIT, function: OMIT, server: OMIT, + def initialize(type:, async: OMIT, messages: OMIT, destinations: OMIT, function: OMIT, server: OMIT, additional_properties: nil) @async = async if async != OMIT @messages = messages if messages != OMIT + @type = type @destinations = destinations if destinations != OMIT @function = function if function != OMIT @server = server if server != OMIT @@ -91,6 +95,7 @@ def initialize(async: OMIT, messages: OMIT, destinations: OMIT, function: OMIT, @_field_set = { "async": async, "messages": messages, + "type": type, "destinations": destinations, "function": function, "server": server @@ -111,6 +116,7 @@ def self.from_json(json_object:) item = item.to_json Vapi::CreateTransferCallToolDtoMessagesItem.from_json(json_object: item) end + type = parsed_json["type"] destinations = parsed_json["destinations"]&.map do |item| item = item.to_json Vapi::CreateTransferCallToolDtoDestinationsItem.from_json(json_object: item) @@ -130,6 +136,7 @@ def self.from_json(json_object:) new( async: async, messages: messages, + type: type, destinations: destinations, function: function, server: server, @@ -153,6 +160,7 @@ def to_json(*_args) def self.validate_raw(obj:) obj.async&.is_a?(Boolean) != false || raise("Passed value for field obj.async is not the expected type, validation failed.") obj.messages&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.destinations&.is_a?(Array) != false || raise("Passed value for field obj.destinations is not the expected type, validation failed.") obj.function.nil? || Vapi::OpenAiFunction.validate_raw(obj: obj.function) obj.server.nil? || Vapi::Server.validate_raw(obj: obj.server) diff --git a/lib/vapi/types/create_transfer_call_tool_dto_destinations_item.rb b/lib/vapi/types/create_transfer_call_tool_dto_destinations_item.rb index 44bc477..a0483b5 100644 --- a/lib/vapi/types/create_transfer_call_tool_dto_destinations_item.rb +++ b/lib/vapi/types/create_transfer_call_tool_dto_destinations_item.rb @@ -8,22 +8,6 @@ module Vapi class CreateTransferCallToolDtoDestinationsItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::CreateTransferCallToolDtoDestinationsItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of # CreateTransferCallToolDtoDestinationsItem # @@ -31,38 +15,39 @@ def initialize(member:, discriminant:) # @return [Vapi::CreateTransferCallToolDtoDestinationsItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "assistant" - Vapi::TransferDestinationAssistant.from_json(json_object: json_object) - when "step" - Vapi::TransferDestinationStep.from_json(json_object: json_object) - when "number" - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - when "sip" - Vapi::TransferDestinationSip.from_json(json_object: json_object) - else - Vapi::TransferDestinationAssistant.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::TransferDestinationAssistant.validate_raw(obj: struct) + return Vapi::TransferDestinationAssistant.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "assistant" - { **@member.to_json, type: @discriminant }.to_json - when "step" - { **@member.to_json, type: @discriminant }.to_json - when "number" - { **@member.to_json, type: @discriminant }.to_json - when "sip" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::TransferDestinationStep.validate_raw(obj: struct) + return Vapi::TransferDestinationStep.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::TransferDestinationNumber.validate_raw(obj: struct) + return Vapi::TransferDestinationNumber.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::TransferDestinationSip.validate_raw(obj: struct) + return Vapi::TransferDestinationSip.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -72,50 +57,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "assistant" - Vapi::TransferDestinationAssistant.validate_raw(obj: obj) - when "step" - Vapi::TransferDestinationStep.validate_raw(obj: obj) - when "number" - Vapi::TransferDestinationNumber.validate_raw(obj: obj) - when "sip" - Vapi::TransferDestinationSip.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::TransferDestinationAssistant.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::TransferDestinationAssistant] - # @return [Vapi::CreateTransferCallToolDtoDestinationsItem] - def self.assistant(member:) - new(member: member, discriminant: "assistant") - end - - # @param member [Vapi::TransferDestinationStep] - # @return [Vapi::CreateTransferCallToolDtoDestinationsItem] - def self.step(member:) - new(member: member, discriminant: "step") - end - - # @param member [Vapi::TransferDestinationNumber] - # @return [Vapi::CreateTransferCallToolDtoDestinationsItem] - def self.number(member:) - new(member: member, discriminant: "number") - end - - # @param member [Vapi::TransferDestinationSip] - # @return [Vapi::CreateTransferCallToolDtoDestinationsItem] - def self.sip(member:) - new(member: member, discriminant: "sip") + begin + return Vapi::TransferDestinationStep.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::TransferDestinationNumber.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::TransferDestinationSip.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/create_transfer_call_tool_dto_messages_item.rb b/lib/vapi/types/create_transfer_call_tool_dto_messages_item.rb index 1d0b5db..e338a6e 100644 --- a/lib/vapi/types/create_transfer_call_tool_dto_messages_item.rb +++ b/lib/vapi/types/create_transfer_call_tool_dto_messages_item.rb @@ -8,22 +8,6 @@ module Vapi class CreateTransferCallToolDtoMessagesItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::CreateTransferCallToolDtoMessagesItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of # CreateTransferCallToolDtoMessagesItem # @@ -31,38 +15,39 @@ def initialize(member:, discriminant:) # @return [Vapi::CreateTransferCallToolDtoMessagesItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "request-start" - Vapi::ToolMessageStart.from_json(json_object: json_object) - when "request-complete" - Vapi::ToolMessageComplete.from_json(json_object: json_object) - when "request-failed" - Vapi::ToolMessageFailed.from_json(json_object: json_object) - when "request-response-delayed" - Vapi::ToolMessageDelayed.from_json(json_object: json_object) - else - Vapi::ToolMessageStart.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ToolMessageStart.validate_raw(obj: struct) + return Vapi::ToolMessageStart.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "request-start" - { **@member.to_json, type: @discriminant }.to_json - when "request-complete" - { **@member.to_json, type: @discriminant }.to_json - when "request-failed" - { **@member.to_json, type: @discriminant }.to_json - when "request-response-delayed" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageComplete.validate_raw(obj: struct) + return Vapi::ToolMessageComplete.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageFailed.validate_raw(obj: struct) + return Vapi::ToolMessageFailed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageDelayed.validate_raw(obj: struct) + return Vapi::ToolMessageDelayed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -72,50 +57,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "request-start" - Vapi::ToolMessageStart.validate_raw(obj: obj) - when "request-complete" - Vapi::ToolMessageComplete.validate_raw(obj: obj) - when "request-failed" - Vapi::ToolMessageFailed.validate_raw(obj: obj) - when "request-response-delayed" - Vapi::ToolMessageDelayed.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ToolMessageStart.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ToolMessageStart] - # @return [Vapi::CreateTransferCallToolDtoMessagesItem] - def self.request_start(member:) - new(member: member, discriminant: "request-start") - end - - # @param member [Vapi::ToolMessageComplete] - # @return [Vapi::CreateTransferCallToolDtoMessagesItem] - def self.request_complete(member:) - new(member: member, discriminant: "request-complete") - end - - # @param member [Vapi::ToolMessageFailed] - # @return [Vapi::CreateTransferCallToolDtoMessagesItem] - def self.request_failed(member:) - new(member: member, discriminant: "request-failed") - end - - # @param member [Vapi::ToolMessageDelayed] - # @return [Vapi::CreateTransferCallToolDtoMessagesItem] - def self.request_response_delayed(member:) - new(member: member, discriminant: "request-response-delayed") + begin + return Vapi::ToolMessageComplete.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageFailed.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageDelayed.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/create_twilio_phone_number_dto.rb b/lib/vapi/types/create_twilio_phone_number_dto.rb index 5a36610..cfed656 100644 --- a/lib/vapi/types/create_twilio_phone_number_dto.rb +++ b/lib/vapi/types/create_twilio_phone_number_dto.rb @@ -13,6 +13,8 @@ class CreateTwilioPhoneNumberDto # If this is not set and above conditions are met, the inbound call is hung up # with an error message. attr_reader :fallback_destination + # @return [String] + attr_reader :provider # @return [String] These are the digits of the phone number you own on your Twilio. attr_reader :number # @return [String] This is the Twilio Account SID for the phone number. @@ -55,6 +57,7 @@ class CreateTwilioPhoneNumberDto # 3. and, `assistant-request` message to the `serverUrl` fails # If this is not set and above conditions are met, the inbound call is hung up # with an error message. + # @param provider [String] # @param number [String] These are the digits of the phone number you own on your Twilio. # @param twilio_account_sid [String] This is the Twilio Account SID for the phone number. # @param twilio_auth_token [String] This is the Twilio Auth Token for the phone number. @@ -77,9 +80,10 @@ class CreateTwilioPhoneNumberDto # Same precedence logic as serverUrl. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::CreateTwilioPhoneNumberDto] - def initialize(number:, twilio_account_sid:, twilio_auth_token:, fallback_destination: OMIT, name: OMIT, + def initialize(provider:, number:, twilio_account_sid:, twilio_auth_token:, fallback_destination: OMIT, name: OMIT, assistant_id: OMIT, squad_id: OMIT, server_url: OMIT, server_url_secret: OMIT, additional_properties: nil) @fallback_destination = fallback_destination if fallback_destination != OMIT + @provider = provider @number = number @twilio_account_sid = twilio_account_sid @twilio_auth_token = twilio_auth_token @@ -91,6 +95,7 @@ def initialize(number:, twilio_account_sid:, twilio_auth_token:, fallback_destin @additional_properties = additional_properties @_field_set = { "fallbackDestination": fallback_destination, + "provider": provider, "number": number, "twilioAccountSid": twilio_account_sid, "twilioAuthToken": twilio_auth_token, @@ -117,6 +122,7 @@ def self.from_json(json_object:) fallback_destination = parsed_json["fallbackDestination"].to_json fallback_destination = Vapi::CreateTwilioPhoneNumberDtoFallbackDestination.from_json(json_object: fallback_destination) end + provider = parsed_json["provider"] number = parsed_json["number"] twilio_account_sid = parsed_json["twilioAccountSid"] twilio_auth_token = parsed_json["twilioAuthToken"] @@ -127,6 +133,7 @@ def self.from_json(json_object:) server_url_secret = parsed_json["serverUrlSecret"] new( fallback_destination: fallback_destination, + provider: provider, number: number, twilio_account_sid: twilio_account_sid, twilio_auth_token: twilio_auth_token, @@ -154,6 +161,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.fallback_destination.nil? || Vapi::CreateTwilioPhoneNumberDtoFallbackDestination.validate_raw(obj: obj.fallback_destination) + obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") obj.number.is_a?(String) != false || raise("Passed value for field obj.number is not the expected type, validation failed.") obj.twilio_account_sid.is_a?(String) != false || raise("Passed value for field obj.twilio_account_sid is not the expected type, validation failed.") obj.twilio_auth_token.is_a?(String) != false || raise("Passed value for field obj.twilio_auth_token is not the expected type, validation failed.") diff --git a/lib/vapi/types/create_twilio_phone_number_dto_fallback_destination.rb b/lib/vapi/types/create_twilio_phone_number_dto_fallback_destination.rb index cba4cf0..84b54a5 100644 --- a/lib/vapi/types/create_twilio_phone_number_dto_fallback_destination.rb +++ b/lib/vapi/types/create_twilio_phone_number_dto_fallback_destination.rb @@ -12,22 +12,6 @@ module Vapi # If this is not set and above conditions are met, the inbound call is hung up # with an error message. class CreateTwilioPhoneNumberDtoFallbackDestination - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::CreateTwilioPhoneNumberDtoFallbackDestination] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of # CreateTwilioPhoneNumberDtoFallbackDestination # @@ -35,30 +19,23 @@ def initialize(member:, discriminant:) # @return [Vapi::CreateTwilioPhoneNumberDtoFallbackDestination] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "number" - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - when "sip" - Vapi::TransferDestinationSip.from_json(json_object: json_object) - else - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::TransferDestinationNumber.validate_raw(obj: struct) + return Vapi::TransferDestinationNumber.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "number" - { **@member.to_json, type: @discriminant }.to_json - when "sip" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::TransferDestinationSip.validate_raw(obj: struct) + return Vapi::TransferDestinationSip.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -68,34 +45,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "number" - Vapi::TransferDestinationNumber.validate_raw(obj: obj) - when "sip" - Vapi::TransferDestinationSip.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::TransferDestinationNumber.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::TransferDestinationNumber] - # @return [Vapi::CreateTwilioPhoneNumberDtoFallbackDestination] - def self.number(member:) - new(member: member, discriminant: "number") - end - - # @param member [Vapi::TransferDestinationSip] - # @return [Vapi::CreateTwilioPhoneNumberDtoFallbackDestination] - def self.sip(member:) - new(member: member, discriminant: "sip") + begin + return Vapi::TransferDestinationSip.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/create_vapi_phone_number_dto.rb b/lib/vapi/types/create_vapi_phone_number_dto.rb index bdcd9a2..bdc118c 100644 --- a/lib/vapi/types/create_vapi_phone_number_dto.rb +++ b/lib/vapi/types/create_vapi_phone_number_dto.rb @@ -13,6 +13,8 @@ class CreateVapiPhoneNumberDto # If this is not set and above conditions are met, the inbound call is hung up # with an error message. attr_reader :fallback_destination + # @return [String] + attr_reader :provider # @return [String] This is the SIP URI of the phone number. You can SIP INVITE this. The assistant # attached to this number will answer. # This is case-insensitive. @@ -53,6 +55,7 @@ class CreateVapiPhoneNumberDto # 3. and, `assistant-request` message to the `serverUrl` fails # If this is not set and above conditions are met, the inbound call is hung up # with an error message. + # @param provider [String] # @param sip_uri [String] This is the SIP URI of the phone number. You can SIP INVITE this. The assistant # attached to this number will answer. # This is case-insensitive. @@ -75,9 +78,10 @@ class CreateVapiPhoneNumberDto # Same precedence logic as serverUrl. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::CreateVapiPhoneNumberDto] - def initialize(sip_uri:, fallback_destination: OMIT, name: OMIT, assistant_id: OMIT, squad_id: OMIT, + def initialize(provider:, sip_uri:, fallback_destination: OMIT, name: OMIT, assistant_id: OMIT, squad_id: OMIT, server_url: OMIT, server_url_secret: OMIT, additional_properties: nil) @fallback_destination = fallback_destination if fallback_destination != OMIT + @provider = provider @sip_uri = sip_uri @name = name if name != OMIT @assistant_id = assistant_id if assistant_id != OMIT @@ -87,6 +91,7 @@ def initialize(sip_uri:, fallback_destination: OMIT, name: OMIT, assistant_id: O @additional_properties = additional_properties @_field_set = { "fallbackDestination": fallback_destination, + "provider": provider, "sipUri": sip_uri, "name": name, "assistantId": assistant_id, @@ -111,6 +116,7 @@ def self.from_json(json_object:) fallback_destination = parsed_json["fallbackDestination"].to_json fallback_destination = Vapi::CreateVapiPhoneNumberDtoFallbackDestination.from_json(json_object: fallback_destination) end + provider = parsed_json["provider"] sip_uri = parsed_json["sipUri"] name = parsed_json["name"] assistant_id = parsed_json["assistantId"] @@ -119,6 +125,7 @@ def self.from_json(json_object:) server_url_secret = parsed_json["serverUrlSecret"] new( fallback_destination: fallback_destination, + provider: provider, sip_uri: sip_uri, name: name, assistant_id: assistant_id, @@ -144,6 +151,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.fallback_destination.nil? || Vapi::CreateVapiPhoneNumberDtoFallbackDestination.validate_raw(obj: obj.fallback_destination) + obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") obj.sip_uri.is_a?(String) != false || raise("Passed value for field obj.sip_uri is not the expected type, validation failed.") obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") obj.assistant_id&.is_a?(String) != false || raise("Passed value for field obj.assistant_id is not the expected type, validation failed.") diff --git a/lib/vapi/types/create_vapi_phone_number_dto_fallback_destination.rb b/lib/vapi/types/create_vapi_phone_number_dto_fallback_destination.rb index 98b9959..fb653b6 100644 --- a/lib/vapi/types/create_vapi_phone_number_dto_fallback_destination.rb +++ b/lib/vapi/types/create_vapi_phone_number_dto_fallback_destination.rb @@ -12,22 +12,6 @@ module Vapi # If this is not set and above conditions are met, the inbound call is hung up # with an error message. class CreateVapiPhoneNumberDtoFallbackDestination - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::CreateVapiPhoneNumberDtoFallbackDestination] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of # CreateVapiPhoneNumberDtoFallbackDestination # @@ -35,30 +19,23 @@ def initialize(member:, discriminant:) # @return [Vapi::CreateVapiPhoneNumberDtoFallbackDestination] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "number" - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - when "sip" - Vapi::TransferDestinationSip.from_json(json_object: json_object) - else - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::TransferDestinationNumber.validate_raw(obj: struct) + return Vapi::TransferDestinationNumber.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "number" - { **@member.to_json, type: @discriminant }.to_json - when "sip" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::TransferDestinationSip.validate_raw(obj: struct) + return Vapi::TransferDestinationSip.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -68,34 +45,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "number" - Vapi::TransferDestinationNumber.validate_raw(obj: obj) - when "sip" - Vapi::TransferDestinationSip.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::TransferDestinationNumber.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::TransferDestinationNumber] - # @return [Vapi::CreateVapiPhoneNumberDtoFallbackDestination] - def self.number(member:) - new(member: member, discriminant: "number") - end - - # @param member [Vapi::TransferDestinationSip] - # @return [Vapi::CreateVapiPhoneNumberDtoFallbackDestination] - def self.sip(member:) - new(member: member, discriminant: "sip") + begin + return Vapi::TransferDestinationSip.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/create_voicemail_tool_dto.rb b/lib/vapi/types/create_voicemail_tool_dto.rb index c8fefde..d4dfc13 100644 --- a/lib/vapi/types/create_voicemail_tool_dto.rb +++ b/lib/vapi/types/create_voicemail_tool_dto.rb @@ -20,6 +20,10 @@ class CreateVoicemailToolDto # `tool.destinations`. For others like the function tool, these can be custom # configured. attr_reader :messages + # @return [String] The type of tool. "voicemail". This uses the model itself to determine if a + # voicemil was reached. Can be used alternatively/alongside with + # TwilioVoicemailDetection + attr_reader :type # @return [Vapi::OpenAiFunction] This is the function definition of the tool. # For `endCall`, `transferCall`, and `dtmf` tools, this is auto-filled based on # tool-specific fields like `tool.destinations`. But, even in those cases, you can @@ -55,6 +59,9 @@ class CreateVoicemailToolDto # For some tools, this is auto-filled based on special fields like # `tool.destinations`. For others like the function tool, these can be custom # configured. + # @param type [String] The type of tool. "voicemail". This uses the model itself to determine if a + # voicemil was reached. Can be used alternatively/alongside with + # TwilioVoicemailDetection # @param function [Vapi::OpenAiFunction] This is the function definition of the tool. # For `endCall`, `transferCall`, and `dtmf` tools, this is auto-filled based on # tool-specific fields like `tool.destinations`. But, even in those cases, you can @@ -72,13 +79,20 @@ class CreateVoicemailToolDto # phoneNumber.serverUrl, then org.serverUrl. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::CreateVoicemailToolDto] - def initialize(async: OMIT, messages: OMIT, function: OMIT, server: OMIT, additional_properties: nil) + def initialize(type:, async: OMIT, messages: OMIT, function: OMIT, server: OMIT, additional_properties: nil) @async = async if async != OMIT @messages = messages if messages != OMIT + @type = type @function = function if function != OMIT @server = server if server != OMIT @additional_properties = additional_properties - @_field_set = { "async": async, "messages": messages, "function": function, "server": server }.reject do |_k, v| + @_field_set = { + "async": async, + "messages": messages, + "type": type, + "function": function, + "server": server + }.reject do |_k, v| v == OMIT end end @@ -95,6 +109,7 @@ def self.from_json(json_object:) item = item.to_json Vapi::CreateVoicemailToolDtoMessagesItem.from_json(json_object: item) end + type = parsed_json["type"] if parsed_json["function"].nil? function = nil else @@ -110,6 +125,7 @@ def self.from_json(json_object:) new( async: async, messages: messages, + type: type, function: function, server: server, additional_properties: struct @@ -132,6 +148,7 @@ def to_json(*_args) def self.validate_raw(obj:) obj.async&.is_a?(Boolean) != false || raise("Passed value for field obj.async is not the expected type, validation failed.") obj.messages&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.function.nil? || Vapi::OpenAiFunction.validate_raw(obj: obj.function) obj.server.nil? || Vapi::Server.validate_raw(obj: obj.server) end diff --git a/lib/vapi/types/create_voicemail_tool_dto_messages_item.rb b/lib/vapi/types/create_voicemail_tool_dto_messages_item.rb index f1ec613..f56371e 100644 --- a/lib/vapi/types/create_voicemail_tool_dto_messages_item.rb +++ b/lib/vapi/types/create_voicemail_tool_dto_messages_item.rb @@ -8,60 +8,45 @@ module Vapi class CreateVoicemailToolDtoMessagesItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::CreateVoicemailToolDtoMessagesItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of CreateVoicemailToolDtoMessagesItem # # @param json_object [String] # @return [Vapi::CreateVoicemailToolDtoMessagesItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "request-start" - Vapi::ToolMessageStart.from_json(json_object: json_object) - when "request-complete" - Vapi::ToolMessageComplete.from_json(json_object: json_object) - when "request-failed" - Vapi::ToolMessageFailed.from_json(json_object: json_object) - when "request-response-delayed" - Vapi::ToolMessageDelayed.from_json(json_object: json_object) - else - Vapi::ToolMessageStart.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ToolMessageStart.validate_raw(obj: struct) + return Vapi::ToolMessageStart.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "request-start" - { **@member.to_json, type: @discriminant }.to_json - when "request-complete" - { **@member.to_json, type: @discriminant }.to_json - when "request-failed" - { **@member.to_json, type: @discriminant }.to_json - when "request-response-delayed" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageComplete.validate_raw(obj: struct) + return Vapi::ToolMessageComplete.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageFailed.validate_raw(obj: struct) + return Vapi::ToolMessageFailed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageDelayed.validate_raw(obj: struct) + return Vapi::ToolMessageDelayed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -71,50 +56,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "request-start" - Vapi::ToolMessageStart.validate_raw(obj: obj) - when "request-complete" - Vapi::ToolMessageComplete.validate_raw(obj: obj) - when "request-failed" - Vapi::ToolMessageFailed.validate_raw(obj: obj) - when "request-response-delayed" - Vapi::ToolMessageDelayed.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ToolMessageStart.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ToolMessageStart] - # @return [Vapi::CreateVoicemailToolDtoMessagesItem] - def self.request_start(member:) - new(member: member, discriminant: "request-start") - end - - # @param member [Vapi::ToolMessageComplete] - # @return [Vapi::CreateVoicemailToolDtoMessagesItem] - def self.request_complete(member:) - new(member: member, discriminant: "request-complete") - end - - # @param member [Vapi::ToolMessageFailed] - # @return [Vapi::CreateVoicemailToolDtoMessagesItem] - def self.request_failed(member:) - new(member: member, discriminant: "request-failed") - end - - # @param member [Vapi::ToolMessageDelayed] - # @return [Vapi::CreateVoicemailToolDtoMessagesItem] - def self.request_response_delayed(member:) - new(member: member, discriminant: "request-response-delayed") + begin + return Vapi::ToolMessageComplete.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageFailed.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageDelayed.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/create_vonage_phone_number_dto.rb b/lib/vapi/types/create_vonage_phone_number_dto.rb index 75f437f..8528521 100644 --- a/lib/vapi/types/create_vonage_phone_number_dto.rb +++ b/lib/vapi/types/create_vonage_phone_number_dto.rb @@ -13,6 +13,8 @@ class CreateVonagePhoneNumberDto # If this is not set and above conditions are met, the inbound call is hung up # with an error message. attr_reader :fallback_destination + # @return [String] + attr_reader :provider # @return [String] These are the digits of the phone number you own on your Vonage. attr_reader :number # @return [String] This is the credential that is used to make outgoing calls, and do operations @@ -54,6 +56,7 @@ class CreateVonagePhoneNumberDto # 3. and, `assistant-request` message to the `serverUrl` fails # If this is not set and above conditions are met, the inbound call is hung up # with an error message. + # @param provider [String] # @param number [String] These are the digits of the phone number you own on your Vonage. # @param credential_id [String] This is the credential that is used to make outgoing calls, and do operations # like call transfer and hang up. @@ -76,9 +79,10 @@ class CreateVonagePhoneNumberDto # Same precedence logic as serverUrl. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::CreateVonagePhoneNumberDto] - def initialize(number:, credential_id:, fallback_destination: OMIT, name: OMIT, assistant_id: OMIT, squad_id: OMIT, - server_url: OMIT, server_url_secret: OMIT, additional_properties: nil) + def initialize(provider:, number:, credential_id:, fallback_destination: OMIT, name: OMIT, assistant_id: OMIT, + squad_id: OMIT, server_url: OMIT, server_url_secret: OMIT, additional_properties: nil) @fallback_destination = fallback_destination if fallback_destination != OMIT + @provider = provider @number = number @credential_id = credential_id @name = name if name != OMIT @@ -89,6 +93,7 @@ def initialize(number:, credential_id:, fallback_destination: OMIT, name: OMIT, @additional_properties = additional_properties @_field_set = { "fallbackDestination": fallback_destination, + "provider": provider, "number": number, "credentialId": credential_id, "name": name, @@ -114,6 +119,7 @@ def self.from_json(json_object:) fallback_destination = parsed_json["fallbackDestination"].to_json fallback_destination = Vapi::CreateVonagePhoneNumberDtoFallbackDestination.from_json(json_object: fallback_destination) end + provider = parsed_json["provider"] number = parsed_json["number"] credential_id = parsed_json["credentialId"] name = parsed_json["name"] @@ -123,6 +129,7 @@ def self.from_json(json_object:) server_url_secret = parsed_json["serverUrlSecret"] new( fallback_destination: fallback_destination, + provider: provider, number: number, credential_id: credential_id, name: name, @@ -149,6 +156,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.fallback_destination.nil? || Vapi::CreateVonagePhoneNumberDtoFallbackDestination.validate_raw(obj: obj.fallback_destination) + obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") obj.number.is_a?(String) != false || raise("Passed value for field obj.number is not the expected type, validation failed.") obj.credential_id.is_a?(String) != false || raise("Passed value for field obj.credential_id is not the expected type, validation failed.") obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") diff --git a/lib/vapi/types/create_vonage_phone_number_dto_fallback_destination.rb b/lib/vapi/types/create_vonage_phone_number_dto_fallback_destination.rb index da94eb6..00748f7 100644 --- a/lib/vapi/types/create_vonage_phone_number_dto_fallback_destination.rb +++ b/lib/vapi/types/create_vonage_phone_number_dto_fallback_destination.rb @@ -12,22 +12,6 @@ module Vapi # If this is not set and above conditions are met, the inbound call is hung up # with an error message. class CreateVonagePhoneNumberDtoFallbackDestination - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::CreateVonagePhoneNumberDtoFallbackDestination] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of # CreateVonagePhoneNumberDtoFallbackDestination # @@ -35,30 +19,23 @@ def initialize(member:, discriminant:) # @return [Vapi::CreateVonagePhoneNumberDtoFallbackDestination] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "number" - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - when "sip" - Vapi::TransferDestinationSip.from_json(json_object: json_object) - else - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::TransferDestinationNumber.validate_raw(obj: struct) + return Vapi::TransferDestinationNumber.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "number" - { **@member.to_json, type: @discriminant }.to_json - when "sip" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::TransferDestinationSip.validate_raw(obj: struct) + return Vapi::TransferDestinationSip.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -68,34 +45,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "number" - Vapi::TransferDestinationNumber.validate_raw(obj: obj) - when "sip" - Vapi::TransferDestinationSip.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::TransferDestinationNumber.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::TransferDestinationNumber] - # @return [Vapi::CreateVonagePhoneNumberDtoFallbackDestination] - def self.number(member:) - new(member: member, discriminant: "number") - end - - # @param member [Vapi::TransferDestinationSip] - # @return [Vapi::CreateVonagePhoneNumberDtoFallbackDestination] - def self.sip(member:) - new(member: member, discriminant: "sip") + begin + return Vapi::TransferDestinationSip.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/create_workflow_block_dto.rb b/lib/vapi/types/create_workflow_block_dto.rb index b951d75..eea2c21 100644 --- a/lib/vapi/types/create_workflow_block_dto.rb +++ b/lib/vapi/types/create_workflow_block_dto.rb @@ -34,6 +34,8 @@ class CreateWorkflowBlockDto # this liquid variable is just provided for convenience when creating blocks # outside of a workflow with steps. attr_reader :output_schema + # @return [String] + attr_reader :type # @return [Array] These are the steps in the workflow. attr_reader :steps # @return [String] This is the name of the block. This is just for your reference. @@ -69,15 +71,17 @@ class CreateWorkflowBlockDto # {{blockName.output.propertyName}} will reference the latest usage of the block. # this liquid variable is just provided for convenience when creating blocks # outside of a workflow with steps. + # @param type [String] # @param steps [Array] These are the steps in the workflow. # @param name [String] This is the name of the block. This is just for your reference. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::CreateWorkflowBlockDto] - def initialize(messages: OMIT, input_schema: OMIT, output_schema: OMIT, steps: OMIT, name: OMIT, + def initialize(type:, messages: OMIT, input_schema: OMIT, output_schema: OMIT, steps: OMIT, name: OMIT, additional_properties: nil) @messages = messages if messages != OMIT @input_schema = input_schema if input_schema != OMIT @output_schema = output_schema if output_schema != OMIT + @type = type @steps = steps if steps != OMIT @name = name if name != OMIT @additional_properties = additional_properties @@ -85,6 +89,7 @@ def initialize(messages: OMIT, input_schema: OMIT, output_schema: OMIT, steps: O "messages": messages, "inputSchema": input_schema, "outputSchema": output_schema, + "type": type, "steps": steps, "name": name }.reject do |_k, v| @@ -115,6 +120,7 @@ def self.from_json(json_object:) output_schema = parsed_json["outputSchema"].to_json output_schema = Vapi::JsonSchema.from_json(json_object: output_schema) end + type = parsed_json["type"] steps = parsed_json["steps"]&.map do |item| item = item.to_json Vapi::CreateWorkflowBlockDtoStepsItem.from_json(json_object: item) @@ -124,6 +130,7 @@ def self.from_json(json_object:) messages: messages, input_schema: input_schema, output_schema: output_schema, + type: type, steps: steps, name: name, additional_properties: struct @@ -147,6 +154,7 @@ 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.input_schema.nil? || Vapi::JsonSchema.validate_raw(obj: obj.input_schema) obj.output_schema.nil? || Vapi::JsonSchema.validate_raw(obj: obj.output_schema) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.steps&.is_a?(Array) != false || raise("Passed value for field obj.steps is not the expected type, validation failed.") obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") end diff --git a/lib/vapi/types/create_workflow_block_dto_messages_item.rb b/lib/vapi/types/create_workflow_block_dto_messages_item.rb index 8d6d959..7f0d967 100644 --- a/lib/vapi/types/create_workflow_block_dto_messages_item.rb +++ b/lib/vapi/types/create_workflow_block_dto_messages_item.rb @@ -6,52 +6,29 @@ module Vapi class CreateWorkflowBlockDtoMessagesItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::CreateWorkflowBlockDtoMessagesItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of CreateWorkflowBlockDtoMessagesItem # # @param json_object [String] # @return [Vapi::CreateWorkflowBlockDtoMessagesItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "block-start" - Vapi::BlockStartMessage.from_json(json_object: json_object) - when "block-complete" - Vapi::BlockCompleteMessage.from_json(json_object: json_object) - else - Vapi::BlockStartMessage.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::BlockStartMessage.validate_raw(obj: struct) + return Vapi::BlockStartMessage.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "block-start" - { **@member.to_json, type: @discriminant }.to_json - when "block-complete" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::BlockCompleteMessage.validate_raw(obj: struct) + return Vapi::BlockCompleteMessage.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -61,34 +38,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "block-start" - Vapi::BlockStartMessage.validate_raw(obj: obj) - when "block-complete" - Vapi::BlockCompleteMessage.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::BlockStartMessage.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::BlockStartMessage] - # @return [Vapi::CreateWorkflowBlockDtoMessagesItem] - def self.block_start(member:) - new(member: member, discriminant: "block-start") - end - - # @param member [Vapi::BlockCompleteMessage] - # @return [Vapi::CreateWorkflowBlockDtoMessagesItem] - def self.block_complete(member:) - new(member: member, discriminant: "block-complete") + begin + return Vapi::BlockCompleteMessage.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/create_workflow_block_dto_steps_item.rb b/lib/vapi/types/create_workflow_block_dto_steps_item.rb index cd4bddf..12f9dcc 100644 --- a/lib/vapi/types/create_workflow_block_dto_steps_item.rb +++ b/lib/vapi/types/create_workflow_block_dto_steps_item.rb @@ -6,52 +6,29 @@ module Vapi class CreateWorkflowBlockDtoStepsItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::CreateWorkflowBlockDtoStepsItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of CreateWorkflowBlockDtoStepsItem # # @param json_object [String] # @return [Vapi::CreateWorkflowBlockDtoStepsItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "handoff" - Vapi::HandoffStep.from_json(json_object: json_object) - when "callback" - Vapi::CallbackStep.from_json(json_object: json_object) - else - Vapi::HandoffStep.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::HandoffStep.validate_raw(obj: struct) + return Vapi::HandoffStep.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "handoff" - { **@member.to_json, type: @discriminant }.to_json - when "callback" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::CallbackStep.validate_raw(obj: struct) + return Vapi::CallbackStep.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -61,34 +38,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "handoff" - Vapi::HandoffStep.validate_raw(obj: obj) - when "callback" - Vapi::CallbackStep.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::HandoffStep.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::HandoffStep] - # @return [Vapi::CreateWorkflowBlockDtoStepsItem] - def self.handoff(member:) - new(member: member, discriminant: "handoff") - end - - # @param member [Vapi::CallbackStep] - # @return [Vapi::CreateWorkflowBlockDtoStepsItem] - def self.callback(member:) - new(member: member, discriminant: "callback") + begin + return Vapi::CallbackStep.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/custom_llm_model.rb b/lib/vapi/types/custom_llm_model.rb index a331f48..9c79160 100644 --- a/lib/vapi/types/custom_llm_model.rb +++ b/lib/vapi/types/custom_llm_model.rb @@ -19,6 +19,9 @@ class CustomLlmModel # tools, use `tools`. # Both `tools` and `toolIds` can be used together. attr_reader :tool_ids + # @return [String] This is the provider that will be used for the model. Any service, including + # your own server, that is compatible with the OpenAI API can be used. + attr_reader :provider # @return [Vapi::CustomLlmModelMetadataSendMode] This determines whether metadata is sent in requests to the custom provider. # - `off` will not send any metadata. payload will look like `{ messages }` # - `variable` will send `assistant.metadata` as a variable on the payload. @@ -69,6 +72,8 @@ class CustomLlmModel # @param tool_ids [Array] These are the tools that the assistant can use during the call. To use transient # tools, use `tools`. # Both `tools` and `toolIds` can be used together. + # @param provider [String] This is the provider that will be used for the model. Any service, including + # your own server, that is compatible with the OpenAI API can be used. # @param metadata_send_mode [Vapi::CustomLlmModelMetadataSendMode] This determines whether metadata is sent in requests to the custom provider. # - `off` will not send any metadata. payload will look like `{ messages }` # - `variable` will send `assistant.metadata` as a variable on the payload. @@ -98,11 +103,12 @@ class CustomLlmModel # @default 0 # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::CustomLlmModel] - def initialize(url:, model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, metadata_send_mode: OMIT, + def initialize(provider:, url:, model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, metadata_send_mode: OMIT, temperature: OMIT, knowledge_base: OMIT, max_tokens: OMIT, emotion_recognition_enabled: OMIT, num_fast_turns: OMIT, additional_properties: nil) @messages = messages if messages != OMIT @tools = tools if tools != OMIT @tool_ids = tool_ids if tool_ids != OMIT + @provider = provider @metadata_send_mode = metadata_send_mode if metadata_send_mode != OMIT @url = url @model = model @@ -116,6 +122,7 @@ def initialize(url:, model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, metada "messages": messages, "tools": tools, "toolIds": tool_ids, + "provider": provider, "metadataSendMode": metadata_send_mode, "url": url, "model": model, @@ -145,6 +152,7 @@ def self.from_json(json_object:) Vapi::CustomLlmModelToolsItem.from_json(json_object: item) end tool_ids = parsed_json["toolIds"] + provider = parsed_json["provider"] metadata_send_mode = parsed_json["metadataSendMode"] url = parsed_json["url"] model = parsed_json["model"] @@ -162,6 +170,7 @@ def self.from_json(json_object:) messages: messages, tools: tools, tool_ids: tool_ids, + provider: provider, metadata_send_mode: metadata_send_mode, url: url, model: model, @@ -191,6 +200,7 @@ 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.tools&.is_a?(Array) != false || raise("Passed value for field obj.tools is not the expected type, validation failed.") obj.tool_ids&.is_a?(Array) != false || raise("Passed value for field obj.tool_ids is not the expected type, validation failed.") + obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") obj.metadata_send_mode&.is_a?(Vapi::CustomLlmModelMetadataSendMode) != false || raise("Passed value for field obj.metadata_send_mode 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.model.is_a?(String) != false || raise("Passed value for field obj.model is not the expected type, validation failed.") diff --git a/lib/vapi/types/custom_llm_model_tools_item.rb b/lib/vapi/types/custom_llm_model_tools_item.rb index cc31a61..440c51b 100644 --- a/lib/vapi/types/custom_llm_model_tools_item.rb +++ b/lib/vapi/types/custom_llm_model_tools_item.rb @@ -11,72 +11,69 @@ module Vapi class CustomLlmModelToolsItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::CustomLlmModelToolsItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of CustomLlmModelToolsItem # # @param json_object [String] # @return [Vapi::CustomLlmModelToolsItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "dtmf" - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - when "endCall" - Vapi::CreateEndCallToolDto.from_json(json_object: json_object) - when "voicemail" - Vapi::CreateVoicemailToolDto.from_json(json_object: json_object) - when "function" - Vapi::CreateFunctionToolDto.from_json(json_object: json_object) - when "ghl" - Vapi::CreateGhlToolDto.from_json(json_object: json_object) - when "make" - Vapi::CreateMakeToolDto.from_json(json_object: json_object) - when "transferCall" - Vapi::CreateTransferCallToolDto.from_json(json_object: json_object) - else - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::CreateDtmfToolDto.validate_raw(obj: struct) + return Vapi::CreateDtmfToolDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "dtmf" - { **@member.to_json, type: @discriminant }.to_json - when "endCall" - { **@member.to_json, type: @discriminant }.to_json - when "voicemail" - { **@member.to_json, type: @discriminant }.to_json - when "function" - { **@member.to_json, type: @discriminant }.to_json - when "ghl" - { **@member.to_json, type: @discriminant }.to_json - when "make" - { **@member.to_json, type: @discriminant }.to_json - when "transferCall" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateEndCallToolDto.validate_raw(obj: struct) + return Vapi::CreateEndCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVoicemailToolDto.validate_raw(obj: struct) + return Vapi::CreateVoicemailToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateFunctionToolDto.validate_raw(obj: struct) + return Vapi::CreateFunctionToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::CreateGhlToolDto.validate_raw(obj: struct) + return Vapi::CreateGhlToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateMakeToolDto.validate_raw(obj: struct) + return Vapi::CreateMakeToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTransferCallToolDto.validate_raw(obj: struct) + return Vapi::CreateTransferCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -86,74 +83,42 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "dtmf" - Vapi::CreateDtmfToolDto.validate_raw(obj: obj) - when "endCall" - Vapi::CreateEndCallToolDto.validate_raw(obj: obj) - when "voicemail" - Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) - when "function" - Vapi::CreateFunctionToolDto.validate_raw(obj: obj) - when "ghl" - Vapi::CreateGhlToolDto.validate_raw(obj: obj) - when "make" - Vapi::CreateMakeToolDto.validate_raw(obj: obj) - when "transferCall" - Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateDtmfToolDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateDtmfToolDto] - # @return [Vapi::CustomLlmModelToolsItem] - def self.dtmf(member:) - new(member: member, discriminant: "dtmf") - end - - # @param member [Vapi::CreateEndCallToolDto] - # @return [Vapi::CustomLlmModelToolsItem] - def self.end_call(member:) - new(member: member, discriminant: "endCall") - end - - # @param member [Vapi::CreateVoicemailToolDto] - # @return [Vapi::CustomLlmModelToolsItem] - def self.voicemail(member:) - new(member: member, discriminant: "voicemail") - end - - # @param member [Vapi::CreateFunctionToolDto] - # @return [Vapi::CustomLlmModelToolsItem] - def self.function(member:) - new(member: member, discriminant: "function") - end - - # @param member [Vapi::CreateGhlToolDto] - # @return [Vapi::CustomLlmModelToolsItem] - def self.ghl(member:) - new(member: member, discriminant: "ghl") - end - - # @param member [Vapi::CreateMakeToolDto] - # @return [Vapi::CustomLlmModelToolsItem] - def self.make(member:) - new(member: member, discriminant: "make") - end - - # @param member [Vapi::CreateTransferCallToolDto] - # @return [Vapi::CustomLlmModelToolsItem] - def self.transfer_call(member:) - new(member: member, discriminant: "transferCall") + begin + return Vapi::CreateEndCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateFunctionToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateGhlToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateMakeToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/deep_infra_model.rb b/lib/vapi/types/deep_infra_model.rb index 2c46554..07174b7 100644 --- a/lib/vapi/types/deep_infra_model.rb +++ b/lib/vapi/types/deep_infra_model.rb @@ -18,6 +18,8 @@ class DeepInfraModel # tools, use `tools`. # Both `tools` and `toolIds` can be used together. attr_reader :tool_ids + # @return [String] + attr_reader :provider # @return [String] This is the name of the model. Ex. cognitivecomputations/dolphin-mixtral-8x7b attr_reader :model # @return [Float] This is the temperature that will be used for calls. Default is 0 to leverage @@ -55,6 +57,7 @@ class DeepInfraModel # @param tool_ids [Array] These are the tools that the assistant can use during the call. To use transient # tools, use `tools`. # Both `tools` and `toolIds` can be used together. + # @param provider [String] # @param model [String] This is the name of the model. Ex. cognitivecomputations/dolphin-mixtral-8x7b # @param temperature [Float] This is the temperature that will be used for calls. Default is 0 to leverage # caching for lower latency. @@ -73,11 +76,12 @@ class DeepInfraModel # @default 0 # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::DeepInfraModel] - def initialize(model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, temperature: OMIT, knowledge_base: OMIT, - max_tokens: OMIT, emotion_recognition_enabled: OMIT, num_fast_turns: OMIT, additional_properties: nil) + def initialize(provider:, model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, temperature: OMIT, + knowledge_base: OMIT, max_tokens: OMIT, emotion_recognition_enabled: OMIT, num_fast_turns: OMIT, additional_properties: nil) @messages = messages if messages != OMIT @tools = tools if tools != OMIT @tool_ids = tool_ids if tool_ids != OMIT + @provider = provider @model = model @temperature = temperature if temperature != OMIT @knowledge_base = knowledge_base if knowledge_base != OMIT @@ -89,6 +93,7 @@ def initialize(model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, temperature: "messages": messages, "tools": tools, "toolIds": tool_ids, + "provider": provider, "model": model, "temperature": temperature, "knowledgeBase": knowledge_base, @@ -116,6 +121,7 @@ def self.from_json(json_object:) Vapi::DeepInfraModelToolsItem.from_json(json_object: item) end tool_ids = parsed_json["toolIds"] + provider = parsed_json["provider"] model = parsed_json["model"] temperature = parsed_json["temperature"] if parsed_json["knowledgeBase"].nil? @@ -131,6 +137,7 @@ def self.from_json(json_object:) messages: messages, tools: tools, tool_ids: tool_ids, + provider: provider, model: model, temperature: temperature, knowledge_base: knowledge_base, @@ -158,6 +165,7 @@ 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.tools&.is_a?(Array) != false || raise("Passed value for field obj.tools is not the expected type, validation failed.") obj.tool_ids&.is_a?(Array) != false || raise("Passed value for field obj.tool_ids is not the expected type, validation failed.") + obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") obj.model.is_a?(String) != false || raise("Passed value for field obj.model is not the expected type, validation failed.") obj.temperature&.is_a?(Float) != false || raise("Passed value for field obj.temperature is not the expected type, validation failed.") obj.knowledge_base.nil? || Vapi::KnowledgeBase.validate_raw(obj: obj.knowledge_base) diff --git a/lib/vapi/types/deep_infra_model_tools_item.rb b/lib/vapi/types/deep_infra_model_tools_item.rb index d62056f..eb9f726 100644 --- a/lib/vapi/types/deep_infra_model_tools_item.rb +++ b/lib/vapi/types/deep_infra_model_tools_item.rb @@ -11,72 +11,69 @@ module Vapi class DeepInfraModelToolsItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::DeepInfraModelToolsItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of DeepInfraModelToolsItem # # @param json_object [String] # @return [Vapi::DeepInfraModelToolsItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "dtmf" - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - when "endCall" - Vapi::CreateEndCallToolDto.from_json(json_object: json_object) - when "voicemail" - Vapi::CreateVoicemailToolDto.from_json(json_object: json_object) - when "function" - Vapi::CreateFunctionToolDto.from_json(json_object: json_object) - when "ghl" - Vapi::CreateGhlToolDto.from_json(json_object: json_object) - when "make" - Vapi::CreateMakeToolDto.from_json(json_object: json_object) - when "transferCall" - Vapi::CreateTransferCallToolDto.from_json(json_object: json_object) - else - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::CreateDtmfToolDto.validate_raw(obj: struct) + return Vapi::CreateDtmfToolDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "dtmf" - { **@member.to_json, type: @discriminant }.to_json - when "endCall" - { **@member.to_json, type: @discriminant }.to_json - when "voicemail" - { **@member.to_json, type: @discriminant }.to_json - when "function" - { **@member.to_json, type: @discriminant }.to_json - when "ghl" - { **@member.to_json, type: @discriminant }.to_json - when "make" - { **@member.to_json, type: @discriminant }.to_json - when "transferCall" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateEndCallToolDto.validate_raw(obj: struct) + return Vapi::CreateEndCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVoicemailToolDto.validate_raw(obj: struct) + return Vapi::CreateVoicemailToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateFunctionToolDto.validate_raw(obj: struct) + return Vapi::CreateFunctionToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::CreateGhlToolDto.validate_raw(obj: struct) + return Vapi::CreateGhlToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateMakeToolDto.validate_raw(obj: struct) + return Vapi::CreateMakeToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTransferCallToolDto.validate_raw(obj: struct) + return Vapi::CreateTransferCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -86,74 +83,42 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "dtmf" - Vapi::CreateDtmfToolDto.validate_raw(obj: obj) - when "endCall" - Vapi::CreateEndCallToolDto.validate_raw(obj: obj) - when "voicemail" - Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) - when "function" - Vapi::CreateFunctionToolDto.validate_raw(obj: obj) - when "ghl" - Vapi::CreateGhlToolDto.validate_raw(obj: obj) - when "make" - Vapi::CreateMakeToolDto.validate_raw(obj: obj) - when "transferCall" - Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateDtmfToolDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateDtmfToolDto] - # @return [Vapi::DeepInfraModelToolsItem] - def self.dtmf(member:) - new(member: member, discriminant: "dtmf") - end - - # @param member [Vapi::CreateEndCallToolDto] - # @return [Vapi::DeepInfraModelToolsItem] - def self.end_call(member:) - new(member: member, discriminant: "endCall") - end - - # @param member [Vapi::CreateVoicemailToolDto] - # @return [Vapi::DeepInfraModelToolsItem] - def self.voicemail(member:) - new(member: member, discriminant: "voicemail") - end - - # @param member [Vapi::CreateFunctionToolDto] - # @return [Vapi::DeepInfraModelToolsItem] - def self.function(member:) - new(member: member, discriminant: "function") - end - - # @param member [Vapi::CreateGhlToolDto] - # @return [Vapi::DeepInfraModelToolsItem] - def self.ghl(member:) - new(member: member, discriminant: "ghl") - end - - # @param member [Vapi::CreateMakeToolDto] - # @return [Vapi::DeepInfraModelToolsItem] - def self.make(member:) - new(member: member, discriminant: "make") - end - - # @param member [Vapi::CreateTransferCallToolDto] - # @return [Vapi::DeepInfraModelToolsItem] - def self.transfer_call(member:) - new(member: member, discriminant: "transferCall") + begin + return Vapi::CreateEndCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateFunctionToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateGhlToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateMakeToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/deepgram_transcriber.rb b/lib/vapi/types/deepgram_transcriber.rb index d13f979..ef64e2d 100644 --- a/lib/vapi/types/deepgram_transcriber.rb +++ b/lib/vapi/types/deepgram_transcriber.rb @@ -7,6 +7,8 @@ module Vapi class DeepgramTranscriber + # @return [String] This is the transcription provider that will be used. + attr_reader :provider # @return [Vapi::DeepgramTranscriberModel] This is the Deepgram model that will be used. A list of models can be found # here: https://developers.deepgram.com/docs/models-languages-overview attr_reader :model @@ -46,6 +48,7 @@ class DeepgramTranscriber OMIT = Object.new + # @param provider [String] This is the transcription provider that will be used. # @param model [Vapi::DeepgramTranscriberModel] This is the Deepgram model that will be used. A list of models can be found # here: https://developers.deepgram.com/docs/models-languages-overview # @param language [Vapi::DeepgramTranscriberLanguage] This is the language that will be set for the transcription. The list of @@ -73,8 +76,9 @@ class DeepgramTranscriber # @default 10 # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::DeepgramTranscriber] - def initialize(model: OMIT, language: OMIT, smart_format: OMIT, language_detection_enabled: OMIT, keywords: OMIT, - endpointing: OMIT, additional_properties: nil) + def initialize(provider:, model: OMIT, language: OMIT, smart_format: OMIT, language_detection_enabled: OMIT, + keywords: OMIT, endpointing: OMIT, additional_properties: nil) + @provider = provider @model = model if model != OMIT @language = language if language != OMIT @smart_format = smart_format if smart_format != OMIT @@ -83,6 +87,7 @@ def initialize(model: OMIT, language: OMIT, smart_format: OMIT, language_detecti @endpointing = endpointing if endpointing != OMIT @additional_properties = additional_properties @_field_set = { + "provider": provider, "model": model, "language": language, "smartFormat": smart_format, @@ -101,18 +106,15 @@ def initialize(model: OMIT, language: OMIT, smart_format: OMIT, language_detecti def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) - if parsed_json["model"].nil? - model = nil - else - model = parsed_json["model"].to_json - model = Vapi::DeepgramTranscriberModel.from_json(json_object: model) - end + provider = parsed_json["provider"] + model = parsed_json["model"] language = parsed_json["language"] smart_format = parsed_json["smartFormat"] language_detection_enabled = parsed_json["languageDetectionEnabled"] keywords = parsed_json["keywords"] endpointing = parsed_json["endpointing"] new( + provider: provider, model: model, language: language, smart_format: smart_format, @@ -137,7 +139,8 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - obj.model.nil? || Vapi::DeepgramTranscriberModel.validate_raw(obj: obj.model) + obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") + obj.model&.is_a?(Vapi::DeepgramTranscriberModel) != false || raise("Passed value for field obj.model is not the expected type, validation failed.") obj.language&.is_a?(Vapi::DeepgramTranscriberLanguage) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") obj.smart_format&.is_a?(Boolean) != false || raise("Passed value for field obj.smart_format is not the expected type, validation failed.") obj.language_detection_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.language_detection_enabled is not the expected type, validation failed.") diff --git a/lib/vapi/types/deepgram_transcriber_language.rb b/lib/vapi/types/deepgram_transcriber_language.rb index 3bad43f..2cc7793 100644 --- a/lib/vapi/types/deepgram_transcriber_language.rb +++ b/lib/vapi/types/deepgram_transcriber_language.rb @@ -1,9 +1,6 @@ # frozen_string_literal: true module Vapi - # This is the language that will be set for the transcription. The list of - # languages Deepgram supports can be found here: - # https://developers.deepgram.com/docs/models-languages-overview class DeepgramTranscriberLanguage BG = "bg" CA = "ca" diff --git a/lib/vapi/types/deepgram_transcriber_model.rb b/lib/vapi/types/deepgram_transcriber_model.rb index 989ae37..f407edb 100644 --- a/lib/vapi/types/deepgram_transcriber_model.rb +++ b/lib/vapi/types/deepgram_transcriber_model.rb @@ -1,405 +1,34 @@ # frozen_string_literal: true -require "json" - module Vapi - # This is the Deepgram model that will be used. A list of models can be found - # here: https://developers.deepgram.com/docs/models-languages-overview class DeepgramTranscriberModel - # Deserialize a JSON object to an instance of DeepgramTranscriberModel - # - # @param json_object [String] - # @return [Vapi::DeepgramTranscriberModel] - def self.from_json(json_object:) - struct = JSON.parse(json_object, object_class: OpenStruct) - begin - struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") - return struct unless struct.nil? - - return nil - rescue StandardError - # noop - end - begin - struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") - return struct unless struct.nil? - - return nil - rescue StandardError - # noop - end - begin - struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") - return struct unless struct.nil? - - return nil - rescue StandardError - # noop - end - begin - struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") - return struct unless struct.nil? - - return nil - rescue StandardError - # noop - end - begin - struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") - return struct unless struct.nil? - - return nil - rescue StandardError - # noop - end - begin - struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") - return struct unless struct.nil? - - return nil - rescue StandardError - # noop - end - begin - struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") - return struct unless struct.nil? - - return nil - rescue StandardError - # noop - end - begin - struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") - return struct unless struct.nil? - - return nil - rescue StandardError - # noop - end - begin - struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") - return struct unless struct.nil? - - return nil - rescue StandardError - # noop - end - begin - struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") - return struct unless struct.nil? - - return nil - rescue StandardError - # noop - end - begin - struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") - return struct unless struct.nil? - - return nil - rescue StandardError - # noop - end - begin - struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") - return struct unless struct.nil? - - return nil - rescue StandardError - # noop - end - begin - struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") - return struct unless struct.nil? - - return nil - rescue StandardError - # noop - end - begin - struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") - return struct unless struct.nil? - - return nil - rescue StandardError - # noop - end - begin - struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") - return struct unless struct.nil? - - return nil - rescue StandardError - # noop - end - begin - struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") - return struct unless struct.nil? - - return nil - rescue StandardError - # noop - end - begin - struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") - return struct unless struct.nil? - - return nil - rescue StandardError - # noop - end - begin - struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") - return struct unless struct.nil? - - return nil - rescue StandardError - # noop - end - begin - struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") - return struct unless struct.nil? - - return nil - rescue StandardError - # noop - end - begin - struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") - return struct unless struct.nil? - - return nil - rescue StandardError - # noop - end - begin - struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") - return struct unless struct.nil? - - return nil - rescue StandardError - # noop - end - begin - struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") - return struct unless struct.nil? - - return nil - rescue StandardError - # noop - end - begin - struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") - return struct unless struct.nil? - - return nil - rescue StandardError - # noop - end - begin - struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") - return struct unless struct.nil? - - return nil - rescue StandardError - # noop - end - begin - struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") - return struct unless struct.nil? - - return nil - rescue StandardError - # noop - end - begin - struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") - return struct unless struct.nil? - - return nil - rescue StandardError - # noop - end - begin - struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") - return struct unless struct.nil? - - return nil - rescue StandardError - # noop - end - begin - struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") - return struct unless struct.nil? - - return nil - rescue StandardError - # noop - end - begin - struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") - return struct unless struct.nil? - - return nil - rescue StandardError - # noop - end - struct - end - - # 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. - # - # @param obj [Object] - # @return [Void] - def self.validate_raw(obj:) - begin - return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") - rescue StandardError - # noop - end - begin - return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") - rescue StandardError - # noop - end - begin - return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") - rescue StandardError - # noop - end - begin - return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") - rescue StandardError - # noop - end - begin - return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") - rescue StandardError - # noop - end - begin - return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") - rescue StandardError - # noop - end - begin - return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") - rescue StandardError - # noop - end - begin - return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") - rescue StandardError - # noop - end - begin - return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") - rescue StandardError - # noop - end - begin - return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") - rescue StandardError - # noop - end - begin - return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") - rescue StandardError - # noop - end - begin - return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") - rescue StandardError - # noop - end - begin - return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") - rescue StandardError - # noop - end - begin - return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") - rescue StandardError - # noop - end - begin - return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") - rescue StandardError - # noop - end - begin - return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") - rescue StandardError - # noop - end - begin - return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") - rescue StandardError - # noop - end - begin - return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") - rescue StandardError - # noop - end - begin - return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") - rescue StandardError - # noop - end - begin - return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") - rescue StandardError - # noop - end - begin - return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") - rescue StandardError - # noop - end - begin - return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") - rescue StandardError - # noop - end - begin - return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") - rescue StandardError - # noop - end - begin - return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") - rescue StandardError - # noop - end - begin - return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") - rescue StandardError - # noop - end - begin - return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") - rescue StandardError - # noop - end - begin - return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") - rescue StandardError - # noop - end - begin - return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") - rescue StandardError - # noop - end - begin - return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") - rescue StandardError - # noop - end - raise("Passed value matched no type within the union, validation failed.") - end + NOVA_2 = "nova-2" + NOVA_2_GENERAL = "nova-2-general" + NOVA_2_MEETING = "nova-2-meeting" + NOVA_2_PHONECALL = "nova-2-phonecall" + NOVA_2_FINANCE = "nova-2-finance" + NOVA_2_CONVERSATIONALAI = "nova-2-conversationalai" + NOVA_2_VOICEMAIL = "nova-2-voicemail" + NOVA_2_VIDEO = "nova-2-video" + NOVA_2_MEDICAL = "nova-2-medical" + NOVA_2_DRIVETHRU = "nova-2-drivethru" + NOVA_2_AUTOMOTIVE = "nova-2-automotive" + NOVA = "nova" + NOVA_GENERAL = "nova-general" + NOVA_PHONECALL = "nova-phonecall" + NOVA_MEDICAL = "nova-medical" + ENHANCED = "enhanced" + ENHANCED_GENERAL = "enhanced-general" + ENHANCED_MEETING = "enhanced-meeting" + ENHANCED_PHONECALL = "enhanced-phonecall" + ENHANCED_FINANCE = "enhanced-finance" + BASE = "base" + BASE_GENERAL = "base-general" + BASE_MEETING = "base-meeting" + BASE_PHONECALL = "base-phonecall" + BASE_FINANCE = "base-finance" + BASE_CONVERSATIONALAI = "base-conversationalai" + BASE_VOICEMAIL = "base-voicemail" + BASE_VIDEO = "base-video" end end diff --git a/lib/vapi/types/deepgram_voice.rb b/lib/vapi/types/deepgram_voice.rb index cb32457..dda6809 100644 --- a/lib/vapi/types/deepgram_voice.rb +++ b/lib/vapi/types/deepgram_voice.rb @@ -11,6 +11,8 @@ class DeepgramVoice # inputting it into the voice provider. # Default `false` because you can achieve better results with prompting the model. attr_reader :filler_injection_enabled + # @return [String] This is the voice provider that will be used. + attr_reader :provider # @return [Vapi::DeepgramVoiceVoiceId] This is the provider-specific ID that will be used. attr_reader :voice_id # @return [Vapi::ChunkPlan] This is the plan for chunking the model output before it is sent to the voice @@ -27,18 +29,21 @@ class DeepgramVoice # @param filler_injection_enabled [Boolean] This determines whether fillers are injected into the model output before # inputting it into the voice provider. # Default `false` because you can achieve better results with prompting the model. + # @param provider [String] This is the voice provider that will be used. # @param voice_id [Vapi::DeepgramVoiceVoiceId] This is the provider-specific ID that will be used. # @param chunk_plan [Vapi::ChunkPlan] This is the plan for chunking the model output before it is sent to the voice # provider. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::DeepgramVoice] - def initialize(voice_id:, filler_injection_enabled: OMIT, chunk_plan: OMIT, additional_properties: nil) + def initialize(provider:, voice_id:, filler_injection_enabled: OMIT, chunk_plan: OMIT, additional_properties: nil) @filler_injection_enabled = filler_injection_enabled if filler_injection_enabled != OMIT + @provider = provider @voice_id = voice_id @chunk_plan = chunk_plan if chunk_plan != OMIT @additional_properties = additional_properties @_field_set = { "fillerInjectionEnabled": filler_injection_enabled, + "provider": provider, "voiceId": voice_id, "chunkPlan": chunk_plan }.reject do |_k, v| @@ -54,6 +59,7 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) filler_injection_enabled = parsed_json["fillerInjectionEnabled"] + provider = parsed_json["provider"] if parsed_json["voiceId"].nil? voice_id = nil else @@ -68,6 +74,7 @@ def self.from_json(json_object:) end new( filler_injection_enabled: filler_injection_enabled, + provider: provider, voice_id: voice_id, chunk_plan: chunk_plan, additional_properties: struct @@ -89,6 +96,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.filler_injection_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.filler_injection_enabled is not the expected type, validation failed.") + obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") Vapi::DeepgramVoiceVoiceId.validate_raw(obj: obj.voice_id) obj.chunk_plan.nil? || Vapi::ChunkPlan.validate_raw(obj: obj.chunk_plan) end diff --git a/lib/vapi/types/dtmf_tool.rb b/lib/vapi/types/dtmf_tool.rb index 4eb80bc..4bac0bb 100644 --- a/lib/vapi/types/dtmf_tool.rb +++ b/lib/vapi/types/dtmf_tool.rb @@ -21,6 +21,8 @@ class DtmfTool # `tool.destinations`. For others like the function tool, these can be custom # configured. attr_reader :messages + # @return [String] + attr_reader :type # @return [String] This is the unique identifier for the tool. attr_reader :id # @return [String] This is the unique identifier for the organization that this tool belongs to. @@ -64,6 +66,7 @@ class DtmfTool # For some tools, this is auto-filled based on special fields like # `tool.destinations`. For others like the function tool, these can be custom # configured. + # @param type [String] # @param id [String] This is the unique identifier for the tool. # @param org_id [String] This is the unique identifier for the organization that this tool belongs to. # @param created_at [DateTime] This is the ISO 8601 date-time string of when the tool was created. @@ -85,10 +88,11 @@ class DtmfTool # phoneNumber.serverUrl, then org.serverUrl. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::DtmfTool] - def initialize(id:, org_id:, created_at:, updated_at:, async: OMIT, messages: OMIT, function: OMIT, server: OMIT, - additional_properties: nil) + def initialize(type:, id:, org_id:, created_at:, updated_at:, async: OMIT, messages: OMIT, function: OMIT, + server: OMIT, additional_properties: nil) @async = async if async != OMIT @messages = messages if messages != OMIT + @type = type @id = id @org_id = org_id @created_at = created_at @@ -99,6 +103,7 @@ def initialize(id:, org_id:, created_at:, updated_at:, async: OMIT, messages: OM @_field_set = { "async": async, "messages": messages, + "type": type, "id": id, "orgId": org_id, "createdAt": created_at, @@ -122,6 +127,7 @@ def self.from_json(json_object:) item = item.to_json Vapi::DtmfToolMessagesItem.from_json(json_object: item) end + type = parsed_json["type"] id = parsed_json["id"] org_id = parsed_json["orgId"] created_at = (DateTime.parse(parsed_json["createdAt"]) unless parsed_json["createdAt"].nil?) @@ -141,6 +147,7 @@ def self.from_json(json_object:) new( async: async, messages: messages, + type: type, id: id, org_id: org_id, created_at: created_at, @@ -167,6 +174,7 @@ def to_json(*_args) def self.validate_raw(obj:) obj.async&.is_a?(Boolean) != false || raise("Passed value for field obj.async is not the expected type, validation failed.") obj.messages&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type 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.") diff --git a/lib/vapi/types/dtmf_tool_messages_item.rb b/lib/vapi/types/dtmf_tool_messages_item.rb index 92a7ee2..6cd2942 100644 --- a/lib/vapi/types/dtmf_tool_messages_item.rb +++ b/lib/vapi/types/dtmf_tool_messages_item.rb @@ -8,60 +8,45 @@ module Vapi class DtmfToolMessagesItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::DtmfToolMessagesItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of DtmfToolMessagesItem # # @param json_object [String] # @return [Vapi::DtmfToolMessagesItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "request-start" - Vapi::ToolMessageStart.from_json(json_object: json_object) - when "request-complete" - Vapi::ToolMessageComplete.from_json(json_object: json_object) - when "request-failed" - Vapi::ToolMessageFailed.from_json(json_object: json_object) - when "request-response-delayed" - Vapi::ToolMessageDelayed.from_json(json_object: json_object) - else - Vapi::ToolMessageStart.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ToolMessageStart.validate_raw(obj: struct) + return Vapi::ToolMessageStart.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "request-start" - { **@member.to_json, type: @discriminant }.to_json - when "request-complete" - { **@member.to_json, type: @discriminant }.to_json - when "request-failed" - { **@member.to_json, type: @discriminant }.to_json - when "request-response-delayed" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageComplete.validate_raw(obj: struct) + return Vapi::ToolMessageComplete.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageFailed.validate_raw(obj: struct) + return Vapi::ToolMessageFailed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageDelayed.validate_raw(obj: struct) + return Vapi::ToolMessageDelayed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -71,50 +56,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "request-start" - Vapi::ToolMessageStart.validate_raw(obj: obj) - when "request-complete" - Vapi::ToolMessageComplete.validate_raw(obj: obj) - when "request-failed" - Vapi::ToolMessageFailed.validate_raw(obj: obj) - when "request-response-delayed" - Vapi::ToolMessageDelayed.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ToolMessageStart.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ToolMessageStart] - # @return [Vapi::DtmfToolMessagesItem] - def self.request_start(member:) - new(member: member, discriminant: "request-start") - end - - # @param member [Vapi::ToolMessageComplete] - # @return [Vapi::DtmfToolMessagesItem] - def self.request_complete(member:) - new(member: member, discriminant: "request-complete") - end - - # @param member [Vapi::ToolMessageFailed] - # @return [Vapi::DtmfToolMessagesItem] - def self.request_failed(member:) - new(member: member, discriminant: "request-failed") - end - - # @param member [Vapi::ToolMessageDelayed] - # @return [Vapi::DtmfToolMessagesItem] - def self.request_response_delayed(member:) - new(member: member, discriminant: "request-response-delayed") + begin + return Vapi::ToolMessageComplete.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageFailed.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageDelayed.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/eleven_labs_voice.rb b/lib/vapi/types/eleven_labs_voice.rb index 476921a..db73e09 100644 --- a/lib/vapi/types/eleven_labs_voice.rb +++ b/lib/vapi/types/eleven_labs_voice.rb @@ -12,6 +12,8 @@ class ElevenLabsVoice # inputting it into the voice provider. # Default `false` because you can achieve better results with prompting the model. attr_reader :filler_injection_enabled + # @return [String] This is the voice provider that will be used. + attr_reader :provider # @return [Vapi::ElevenLabsVoiceVoiceId] This is the provider-specific ID that will be used. Ensure the Voice is present # in your 11Labs Voice Library. attr_reader :voice_id @@ -51,6 +53,7 @@ class ElevenLabsVoice # @param filler_injection_enabled [Boolean] This determines whether fillers are injected into the model output before # inputting it into the voice provider. # Default `false` because you can achieve better results with prompting the model. + # @param provider [String] This is the voice provider that will be used. # @param voice_id [Vapi::ElevenLabsVoiceVoiceId] This is the provider-specific ID that will be used. Ensure the Voice is present # in your 11Labs Voice Library. # @param stability [Float] Defines the stability for voice settings. @@ -71,9 +74,10 @@ class ElevenLabsVoice # provider. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ElevenLabsVoice] - def initialize(voice_id:, filler_injection_enabled: OMIT, stability: OMIT, similarity_boost: OMIT, style: OMIT, - use_speaker_boost: OMIT, optimize_streaming_latency: OMIT, enable_ssml_parsing: OMIT, model: OMIT, language: OMIT, chunk_plan: OMIT, additional_properties: nil) + def initialize(provider:, voice_id:, filler_injection_enabled: OMIT, stability: OMIT, similarity_boost: OMIT, + style: OMIT, use_speaker_boost: OMIT, optimize_streaming_latency: OMIT, enable_ssml_parsing: OMIT, model: OMIT, language: OMIT, chunk_plan: OMIT, additional_properties: nil) @filler_injection_enabled = filler_injection_enabled if filler_injection_enabled != OMIT + @provider = provider @voice_id = voice_id @stability = stability if stability != OMIT @similarity_boost = similarity_boost if similarity_boost != OMIT @@ -87,6 +91,7 @@ def initialize(voice_id:, filler_injection_enabled: OMIT, stability: OMIT, simil @additional_properties = additional_properties @_field_set = { "fillerInjectionEnabled": filler_injection_enabled, + "provider": provider, "voiceId": voice_id, "stability": stability, "similarityBoost": similarity_boost, @@ -110,6 +115,7 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) filler_injection_enabled = parsed_json["fillerInjectionEnabled"] + provider = parsed_json["provider"] if parsed_json["voiceId"].nil? voice_id = nil else @@ -132,6 +138,7 @@ def self.from_json(json_object:) end new( filler_injection_enabled: filler_injection_enabled, + provider: provider, voice_id: voice_id, stability: stability, similarity_boost: similarity_boost, @@ -161,6 +168,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.filler_injection_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.filler_injection_enabled is not the expected type, validation failed.") + obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") Vapi::ElevenLabsVoiceVoiceId.validate_raw(obj: obj.voice_id) obj.stability&.is_a?(Float) != false || raise("Passed value for field obj.stability is not the expected type, validation failed.") obj.similarity_boost&.is_a?(Float) != false || raise("Passed value for field obj.similarity_boost is not the expected type, validation failed.") diff --git a/lib/vapi/types/end_call_tool.rb b/lib/vapi/types/end_call_tool.rb index 5d47820..e9e813e 100644 --- a/lib/vapi/types/end_call_tool.rb +++ b/lib/vapi/types/end_call_tool.rb @@ -21,6 +21,8 @@ class EndCallTool # `tool.destinations`. For others like the function tool, these can be custom # configured. attr_reader :messages + # @return [String] + attr_reader :type # @return [String] This is the unique identifier for the tool. attr_reader :id # @return [String] This is the unique identifier for the organization that this tool belongs to. @@ -64,6 +66,7 @@ class EndCallTool # For some tools, this is auto-filled based on special fields like # `tool.destinations`. For others like the function tool, these can be custom # configured. + # @param type [String] # @param id [String] This is the unique identifier for the tool. # @param org_id [String] This is the unique identifier for the organization that this tool belongs to. # @param created_at [DateTime] This is the ISO 8601 date-time string of when the tool was created. @@ -85,10 +88,11 @@ class EndCallTool # phoneNumber.serverUrl, then org.serverUrl. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::EndCallTool] - def initialize(id:, org_id:, created_at:, updated_at:, async: OMIT, messages: OMIT, function: OMIT, server: OMIT, - additional_properties: nil) + def initialize(type:, id:, org_id:, created_at:, updated_at:, async: OMIT, messages: OMIT, function: OMIT, + server: OMIT, additional_properties: nil) @async = async if async != OMIT @messages = messages if messages != OMIT + @type = type @id = id @org_id = org_id @created_at = created_at @@ -99,6 +103,7 @@ def initialize(id:, org_id:, created_at:, updated_at:, async: OMIT, messages: OM @_field_set = { "async": async, "messages": messages, + "type": type, "id": id, "orgId": org_id, "createdAt": created_at, @@ -122,6 +127,7 @@ def self.from_json(json_object:) item = item.to_json Vapi::EndCallToolMessagesItem.from_json(json_object: item) end + type = parsed_json["type"] id = parsed_json["id"] org_id = parsed_json["orgId"] created_at = (DateTime.parse(parsed_json["createdAt"]) unless parsed_json["createdAt"].nil?) @@ -141,6 +147,7 @@ def self.from_json(json_object:) new( async: async, messages: messages, + type: type, id: id, org_id: org_id, created_at: created_at, @@ -167,6 +174,7 @@ def to_json(*_args) def self.validate_raw(obj:) obj.async&.is_a?(Boolean) != false || raise("Passed value for field obj.async is not the expected type, validation failed.") obj.messages&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type 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.") diff --git a/lib/vapi/types/end_call_tool_messages_item.rb b/lib/vapi/types/end_call_tool_messages_item.rb index 853ad84..2685eb8 100644 --- a/lib/vapi/types/end_call_tool_messages_item.rb +++ b/lib/vapi/types/end_call_tool_messages_item.rb @@ -8,60 +8,45 @@ module Vapi class EndCallToolMessagesItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::EndCallToolMessagesItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of EndCallToolMessagesItem # # @param json_object [String] # @return [Vapi::EndCallToolMessagesItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "request-start" - Vapi::ToolMessageStart.from_json(json_object: json_object) - when "request-complete" - Vapi::ToolMessageComplete.from_json(json_object: json_object) - when "request-failed" - Vapi::ToolMessageFailed.from_json(json_object: json_object) - when "request-response-delayed" - Vapi::ToolMessageDelayed.from_json(json_object: json_object) - else - Vapi::ToolMessageStart.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ToolMessageStart.validate_raw(obj: struct) + return Vapi::ToolMessageStart.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "request-start" - { **@member.to_json, type: @discriminant }.to_json - when "request-complete" - { **@member.to_json, type: @discriminant }.to_json - when "request-failed" - { **@member.to_json, type: @discriminant }.to_json - when "request-response-delayed" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageComplete.validate_raw(obj: struct) + return Vapi::ToolMessageComplete.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageFailed.validate_raw(obj: struct) + return Vapi::ToolMessageFailed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageDelayed.validate_raw(obj: struct) + return Vapi::ToolMessageDelayed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -71,50 +56,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "request-start" - Vapi::ToolMessageStart.validate_raw(obj: obj) - when "request-complete" - Vapi::ToolMessageComplete.validate_raw(obj: obj) - when "request-failed" - Vapi::ToolMessageFailed.validate_raw(obj: obj) - when "request-response-delayed" - Vapi::ToolMessageDelayed.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ToolMessageStart.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ToolMessageStart] - # @return [Vapi::EndCallToolMessagesItem] - def self.request_start(member:) - new(member: member, discriminant: "request-start") - end - - # @param member [Vapi::ToolMessageComplete] - # @return [Vapi::EndCallToolMessagesItem] - def self.request_complete(member:) - new(member: member, discriminant: "request-complete") - end - - # @param member [Vapi::ToolMessageFailed] - # @return [Vapi::EndCallToolMessagesItem] - def self.request_failed(member:) - new(member: member, discriminant: "request-failed") - end - - # @param member [Vapi::ToolMessageDelayed] - # @return [Vapi::EndCallToolMessagesItem] - def self.request_response_delayed(member:) - new(member: member, discriminant: "request-response-delayed") + begin + return Vapi::ToolMessageComplete.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageFailed.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageDelayed.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/exact_replacement.rb b/lib/vapi/types/exact_replacement.rb index d54e059..48369c2 100644 --- a/lib/vapi/types/exact_replacement.rb +++ b/lib/vapi/types/exact_replacement.rb @@ -5,6 +5,19 @@ module Vapi class ExactReplacement + # @return [String] This is the exact replacement type. You can use this to replace a specific word + # or phrase with a different word or phrase. + # Usage: + # - Replace "hello" with "hi": { type: 'exact', key: 'hello', value: 'hi' } + # - Replace "good morning" with "good day": { type: 'exact', key: 'good morning', + # value: 'good day' } + # - Replace a specific name: { type: 'exact', key: 'John Doe', value: 'Jane Smith' + # } + # - Replace an acronym: { type: 'exact', key: 'AI', value: 'Artificial + # Intelligence' } + # - Replace a company name with its phonetic pronunciation: { type: 'exact', key: + # 'Vapi', value: 'Vappy' } + attr_reader :type # @return [String] This is the key to replace. attr_reader :key # @return [String] This is the value that will replace the match. @@ -17,15 +30,28 @@ class ExactReplacement OMIT = Object.new + # @param type [String] This is the exact replacement type. You can use this to replace a specific word + # or phrase with a different word or phrase. + # Usage: + # - Replace "hello" with "hi": { type: 'exact', key: 'hello', value: 'hi' } + # - Replace "good morning" with "good day": { type: 'exact', key: 'good morning', + # value: 'good day' } + # - Replace a specific name: { type: 'exact', key: 'John Doe', value: 'Jane Smith' + # } + # - Replace an acronym: { type: 'exact', key: 'AI', value: 'Artificial + # Intelligence' } + # - Replace a company name with its phonetic pronunciation: { type: 'exact', key: + # 'Vapi', value: 'Vappy' } # @param key [String] This is the key to replace. # @param value [String] This is the value that will replace the match. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ExactReplacement] - def initialize(key:, value:, additional_properties: nil) + def initialize(type:, key:, value:, additional_properties: nil) + @type = type @key = key @value = value @additional_properties = additional_properties - @_field_set = { "key": key, "value": value } + @_field_set = { "type": type, "key": key, "value": value } end # Deserialize a JSON object to an instance of ExactReplacement @@ -35,9 +61,11 @@ def initialize(key:, value:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + type = parsed_json["type"] key = parsed_json["key"] value = parsed_json["value"] new( + type: type, key: key, value: value, additional_properties: struct @@ -58,6 +86,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.key.is_a?(String) != false || raise("Passed value for field obj.key is not the expected type, validation failed.") obj.value.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.") end diff --git a/lib/vapi/types/format_plan_replacements_item.rb b/lib/vapi/types/format_plan_replacements_item.rb index d811b17..4075e89 100644 --- a/lib/vapi/types/format_plan_replacements_item.rb +++ b/lib/vapi/types/format_plan_replacements_item.rb @@ -6,52 +6,29 @@ module Vapi class FormatPlanReplacementsItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::FormatPlanReplacementsItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of FormatPlanReplacementsItem # # @param json_object [String] # @return [Vapi::FormatPlanReplacementsItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "exact" - Vapi::ExactReplacement.from_json(json_object: json_object) - when "regex" - Vapi::RegexReplacement.from_json(json_object: json_object) - else - Vapi::ExactReplacement.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ExactReplacement.validate_raw(obj: struct) + return Vapi::ExactReplacement.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "exact" - { **@member.to_json, type: @discriminant }.to_json - when "regex" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::RegexReplacement.validate_raw(obj: struct) + return Vapi::RegexReplacement.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -61,34 +38,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "exact" - Vapi::ExactReplacement.validate_raw(obj: obj) - when "regex" - Vapi::RegexReplacement.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ExactReplacement.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ExactReplacement] - # @return [Vapi::FormatPlanReplacementsItem] - def self.exact(member:) - new(member: member, discriminant: "exact") - end - - # @param member [Vapi::RegexReplacement] - # @return [Vapi::FormatPlanReplacementsItem] - def self.regex(member:) - new(member: member, discriminant: "regex") + begin + return Vapi::RegexReplacement.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/function_tool.rb b/lib/vapi/types/function_tool.rb index 6c7467c..d81be18 100644 --- a/lib/vapi/types/function_tool.rb +++ b/lib/vapi/types/function_tool.rb @@ -21,6 +21,8 @@ class FunctionTool # `tool.destinations`. For others like the function tool, these can be custom # configured. attr_reader :messages + # @return [String] + attr_reader :type # @return [String] This is the unique identifier for the tool. attr_reader :id # @return [String] This is the unique identifier for the organization that this tool belongs to. @@ -64,6 +66,7 @@ class FunctionTool # For some tools, this is auto-filled based on special fields like # `tool.destinations`. For others like the function tool, these can be custom # configured. + # @param type [String] # @param id [String] This is the unique identifier for the tool. # @param org_id [String] This is the unique identifier for the organization that this tool belongs to. # @param created_at [DateTime] This is the ISO 8601 date-time string of when the tool was created. @@ -85,10 +88,11 @@ class FunctionTool # phoneNumber.serverUrl, then org.serverUrl. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::FunctionTool] - def initialize(id:, org_id:, created_at:, updated_at:, async: OMIT, messages: OMIT, function: OMIT, server: OMIT, - additional_properties: nil) + def initialize(type:, id:, org_id:, created_at:, updated_at:, async: OMIT, messages: OMIT, function: OMIT, + server: OMIT, additional_properties: nil) @async = async if async != OMIT @messages = messages if messages != OMIT + @type = type @id = id @org_id = org_id @created_at = created_at @@ -99,6 +103,7 @@ def initialize(id:, org_id:, created_at:, updated_at:, async: OMIT, messages: OM @_field_set = { "async": async, "messages": messages, + "type": type, "id": id, "orgId": org_id, "createdAt": created_at, @@ -122,6 +127,7 @@ def self.from_json(json_object:) item = item.to_json Vapi::FunctionToolMessagesItem.from_json(json_object: item) end + type = parsed_json["type"] id = parsed_json["id"] org_id = parsed_json["orgId"] created_at = (DateTime.parse(parsed_json["createdAt"]) unless parsed_json["createdAt"].nil?) @@ -141,6 +147,7 @@ def self.from_json(json_object:) new( async: async, messages: messages, + type: type, id: id, org_id: org_id, created_at: created_at, @@ -167,6 +174,7 @@ def to_json(*_args) def self.validate_raw(obj:) obj.async&.is_a?(Boolean) != false || raise("Passed value for field obj.async is not the expected type, validation failed.") obj.messages&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type 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.") diff --git a/lib/vapi/types/function_tool_messages_item.rb b/lib/vapi/types/function_tool_messages_item.rb index 44850e9..797be2a 100644 --- a/lib/vapi/types/function_tool_messages_item.rb +++ b/lib/vapi/types/function_tool_messages_item.rb @@ -8,60 +8,45 @@ module Vapi class FunctionToolMessagesItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::FunctionToolMessagesItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of FunctionToolMessagesItem # # @param json_object [String] # @return [Vapi::FunctionToolMessagesItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "request-start" - Vapi::ToolMessageStart.from_json(json_object: json_object) - when "request-complete" - Vapi::ToolMessageComplete.from_json(json_object: json_object) - when "request-failed" - Vapi::ToolMessageFailed.from_json(json_object: json_object) - when "request-response-delayed" - Vapi::ToolMessageDelayed.from_json(json_object: json_object) - else - Vapi::ToolMessageStart.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ToolMessageStart.validate_raw(obj: struct) + return Vapi::ToolMessageStart.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "request-start" - { **@member.to_json, type: @discriminant }.to_json - when "request-complete" - { **@member.to_json, type: @discriminant }.to_json - when "request-failed" - { **@member.to_json, type: @discriminant }.to_json - when "request-response-delayed" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageComplete.validate_raw(obj: struct) + return Vapi::ToolMessageComplete.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageFailed.validate_raw(obj: struct) + return Vapi::ToolMessageFailed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageDelayed.validate_raw(obj: struct) + return Vapi::ToolMessageDelayed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -71,50 +56,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "request-start" - Vapi::ToolMessageStart.validate_raw(obj: obj) - when "request-complete" - Vapi::ToolMessageComplete.validate_raw(obj: obj) - when "request-failed" - Vapi::ToolMessageFailed.validate_raw(obj: obj) - when "request-response-delayed" - Vapi::ToolMessageDelayed.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ToolMessageStart.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ToolMessageStart] - # @return [Vapi::FunctionToolMessagesItem] - def self.request_start(member:) - new(member: member, discriminant: "request-start") - end - - # @param member [Vapi::ToolMessageComplete] - # @return [Vapi::FunctionToolMessagesItem] - def self.request_complete(member:) - new(member: member, discriminant: "request-complete") - end - - # @param member [Vapi::ToolMessageFailed] - # @return [Vapi::FunctionToolMessagesItem] - def self.request_failed(member:) - new(member: member, discriminant: "request-failed") - end - - # @param member [Vapi::ToolMessageDelayed] - # @return [Vapi::FunctionToolMessagesItem] - def self.request_response_delayed(member:) - new(member: member, discriminant: "request-response-delayed") + begin + return Vapi::ToolMessageComplete.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageFailed.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageDelayed.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/function_tool_provider_details.rb b/lib/vapi/types/function_tool_provider_details.rb index 89a267c..c0a84ae 100644 --- a/lib/vapi/types/function_tool_provider_details.rb +++ b/lib/vapi/types/function_tool_provider_details.rb @@ -10,6 +10,8 @@ class FunctionToolProviderDetails attr_reader :template_url # @return [Array] attr_reader :setup_instructions + # @return [String] The type of tool. "function" for Function tool. + attr_reader :type # @return [OpenStruct] Additional properties unmapped to the current class definition attr_reader :additional_properties # @return [Object] @@ -20,13 +22,19 @@ class FunctionToolProviderDetails # @param template_url [String] This is the Template URL or the Snapshot URL corresponding to the Template. # @param setup_instructions [Array] + # @param type [String] The type of tool. "function" for Function tool. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::FunctionToolProviderDetails] - def initialize(template_url: OMIT, setup_instructions: OMIT, additional_properties: nil) + def initialize(type:, template_url: OMIT, setup_instructions: OMIT, additional_properties: nil) @template_url = template_url if template_url != OMIT @setup_instructions = setup_instructions if setup_instructions != OMIT + @type = type @additional_properties = additional_properties - @_field_set = { "templateUrl": template_url, "setupInstructions": setup_instructions }.reject do |_k, v| + @_field_set = { + "templateUrl": template_url, + "setupInstructions": setup_instructions, + "type": type + }.reject do |_k, v| v == OMIT end end @@ -43,9 +51,11 @@ def self.from_json(json_object:) item = item.to_json Vapi::ToolTemplateSetup.from_json(json_object: item) end + type = parsed_json["type"] new( template_url: template_url, setup_instructions: setup_instructions, + type: type, additional_properties: struct ) end @@ -66,6 +76,7 @@ def to_json(*_args) def self.validate_raw(obj:) obj.template_url&.is_a?(String) != false || raise("Passed value for field obj.template_url is not the expected type, validation failed.") obj.setup_instructions&.is_a?(Array) != false || raise("Passed value for field obj.setup_instructions is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") end end end diff --git a/lib/vapi/types/function_tool_with_tool_call.rb b/lib/vapi/types/function_tool_with_tool_call.rb index e4043d1..046c2a2 100644 --- a/lib/vapi/types/function_tool_with_tool_call.rb +++ b/lib/vapi/types/function_tool_with_tool_call.rb @@ -21,6 +21,8 @@ class FunctionToolWithToolCall # `tool.destinations`. For others like the function tool, these can be custom # configured. attr_reader :messages + # @return [String] The type of tool. "function" for Function tool. + attr_reader :type # @return [Vapi::ToolCall] attr_reader :tool_call # @return [Vapi::OpenAiFunction] This is the function definition of the tool. @@ -58,6 +60,7 @@ class FunctionToolWithToolCall # For some tools, this is auto-filled based on special fields like # `tool.destinations`. For others like the function tool, these can be custom # configured. + # @param type [String] The type of tool. "function" for Function tool. # @param tool_call [Vapi::ToolCall] # @param function [Vapi::OpenAiFunction] This is the function definition of the tool. # For `endCall`, `transferCall`, and `dtmf` tools, this is auto-filled based on @@ -76,9 +79,11 @@ class FunctionToolWithToolCall # phoneNumber.serverUrl, then org.serverUrl. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::FunctionToolWithToolCall] - def initialize(tool_call:, async: OMIT, messages: OMIT, function: OMIT, server: OMIT, additional_properties: nil) + def initialize(type:, tool_call:, async: OMIT, messages: OMIT, function: OMIT, server: OMIT, + additional_properties: nil) @async = async if async != OMIT @messages = messages if messages != OMIT + @type = type @tool_call = tool_call @function = function if function != OMIT @server = server if server != OMIT @@ -86,6 +91,7 @@ def initialize(tool_call:, async: OMIT, messages: OMIT, function: OMIT, server: @_field_set = { "async": async, "messages": messages, + "type": type, "toolCall": tool_call, "function": function, "server": server @@ -106,6 +112,7 @@ def self.from_json(json_object:) item = item.to_json Vapi::FunctionToolWithToolCallMessagesItem.from_json(json_object: item) end + type = parsed_json["type"] if parsed_json["toolCall"].nil? tool_call = nil else @@ -127,6 +134,7 @@ def self.from_json(json_object:) new( async: async, messages: messages, + type: type, tool_call: tool_call, function: function, server: server, @@ -150,6 +158,7 @@ def to_json(*_args) def self.validate_raw(obj:) obj.async&.is_a?(Boolean) != false || raise("Passed value for field obj.async is not the expected type, validation failed.") obj.messages&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") Vapi::ToolCall.validate_raw(obj: obj.tool_call) obj.function.nil? || Vapi::OpenAiFunction.validate_raw(obj: obj.function) obj.server.nil? || Vapi::Server.validate_raw(obj: obj.server) diff --git a/lib/vapi/types/function_tool_with_tool_call_messages_item.rb b/lib/vapi/types/function_tool_with_tool_call_messages_item.rb index 0106279..83576c0 100644 --- a/lib/vapi/types/function_tool_with_tool_call_messages_item.rb +++ b/lib/vapi/types/function_tool_with_tool_call_messages_item.rb @@ -8,60 +8,45 @@ module Vapi class FunctionToolWithToolCallMessagesItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::FunctionToolWithToolCallMessagesItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of FunctionToolWithToolCallMessagesItem # # @param json_object [String] # @return [Vapi::FunctionToolWithToolCallMessagesItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "request-start" - Vapi::ToolMessageStart.from_json(json_object: json_object) - when "request-complete" - Vapi::ToolMessageComplete.from_json(json_object: json_object) - when "request-failed" - Vapi::ToolMessageFailed.from_json(json_object: json_object) - when "request-response-delayed" - Vapi::ToolMessageDelayed.from_json(json_object: json_object) - else - Vapi::ToolMessageStart.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ToolMessageStart.validate_raw(obj: struct) + return Vapi::ToolMessageStart.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "request-start" - { **@member.to_json, type: @discriminant }.to_json - when "request-complete" - { **@member.to_json, type: @discriminant }.to_json - when "request-failed" - { **@member.to_json, type: @discriminant }.to_json - when "request-response-delayed" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageComplete.validate_raw(obj: struct) + return Vapi::ToolMessageComplete.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageFailed.validate_raw(obj: struct) + return Vapi::ToolMessageFailed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageDelayed.validate_raw(obj: struct) + return Vapi::ToolMessageDelayed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -71,50 +56,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "request-start" - Vapi::ToolMessageStart.validate_raw(obj: obj) - when "request-complete" - Vapi::ToolMessageComplete.validate_raw(obj: obj) - when "request-failed" - Vapi::ToolMessageFailed.validate_raw(obj: obj) - when "request-response-delayed" - Vapi::ToolMessageDelayed.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ToolMessageStart.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ToolMessageStart] - # @return [Vapi::FunctionToolWithToolCallMessagesItem] - def self.request_start(member:) - new(member: member, discriminant: "request-start") - end - - # @param member [Vapi::ToolMessageComplete] - # @return [Vapi::FunctionToolWithToolCallMessagesItem] - def self.request_complete(member:) - new(member: member, discriminant: "request-complete") - end - - # @param member [Vapi::ToolMessageFailed] - # @return [Vapi::FunctionToolWithToolCallMessagesItem] - def self.request_failed(member:) - new(member: member, discriminant: "request-failed") - end - - # @param member [Vapi::ToolMessageDelayed] - # @return [Vapi::FunctionToolWithToolCallMessagesItem] - def self.request_response_delayed(member:) - new(member: member, discriminant: "request-response-delayed") + begin + return Vapi::ToolMessageComplete.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageFailed.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageDelayed.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/ghl_tool.rb b/lib/vapi/types/ghl_tool.rb index 333f5c3..35b7670 100644 --- a/lib/vapi/types/ghl_tool.rb +++ b/lib/vapi/types/ghl_tool.rb @@ -22,6 +22,8 @@ class GhlTool # `tool.destinations`. For others like the function tool, these can be custom # configured. attr_reader :messages + # @return [String] + attr_reader :type # @return [String] This is the unique identifier for the tool. attr_reader :id # @return [String] This is the unique identifier for the organization that this tool belongs to. @@ -67,6 +69,7 @@ class GhlTool # For some tools, this is auto-filled based on special fields like # `tool.destinations`. For others like the function tool, these can be custom # configured. + # @param type [String] # @param id [String] This is the unique identifier for the tool. # @param org_id [String] This is the unique identifier for the organization that this tool belongs to. # @param created_at [DateTime] This is the ISO 8601 date-time string of when the tool was created. @@ -89,10 +92,11 @@ class GhlTool # @param metadata [Vapi::GhlToolMetadata] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::GhlTool] - def initialize(id:, org_id:, created_at:, updated_at:, metadata:, async: OMIT, messages: OMIT, function: OMIT, + def initialize(type:, id:, org_id:, created_at:, updated_at:, metadata:, async: OMIT, messages: OMIT, function: OMIT, server: OMIT, additional_properties: nil) @async = async if async != OMIT @messages = messages if messages != OMIT + @type = type @id = id @org_id = org_id @created_at = created_at @@ -104,6 +108,7 @@ def initialize(id:, org_id:, created_at:, updated_at:, metadata:, async: OMIT, m @_field_set = { "async": async, "messages": messages, + "type": type, "id": id, "orgId": org_id, "createdAt": created_at, @@ -128,6 +133,7 @@ def self.from_json(json_object:) item = item.to_json Vapi::GhlToolMessagesItem.from_json(json_object: item) end + type = parsed_json["type"] id = parsed_json["id"] org_id = parsed_json["orgId"] created_at = (DateTime.parse(parsed_json["createdAt"]) unless parsed_json["createdAt"].nil?) @@ -153,6 +159,7 @@ def self.from_json(json_object:) new( async: async, messages: messages, + type: type, id: id, org_id: org_id, created_at: created_at, @@ -180,6 +187,7 @@ def to_json(*_args) def self.validate_raw(obj:) obj.async&.is_a?(Boolean) != false || raise("Passed value for field obj.async is not the expected type, validation failed.") obj.messages&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type 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.") diff --git a/lib/vapi/types/ghl_tool_messages_item.rb b/lib/vapi/types/ghl_tool_messages_item.rb index dc7531b..67cfa97 100644 --- a/lib/vapi/types/ghl_tool_messages_item.rb +++ b/lib/vapi/types/ghl_tool_messages_item.rb @@ -8,60 +8,45 @@ module Vapi class GhlToolMessagesItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::GhlToolMessagesItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of GhlToolMessagesItem # # @param json_object [String] # @return [Vapi::GhlToolMessagesItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "request-start" - Vapi::ToolMessageStart.from_json(json_object: json_object) - when "request-complete" - Vapi::ToolMessageComplete.from_json(json_object: json_object) - when "request-failed" - Vapi::ToolMessageFailed.from_json(json_object: json_object) - when "request-response-delayed" - Vapi::ToolMessageDelayed.from_json(json_object: json_object) - else - Vapi::ToolMessageStart.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ToolMessageStart.validate_raw(obj: struct) + return Vapi::ToolMessageStart.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "request-start" - { **@member.to_json, type: @discriminant }.to_json - when "request-complete" - { **@member.to_json, type: @discriminant }.to_json - when "request-failed" - { **@member.to_json, type: @discriminant }.to_json - when "request-response-delayed" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageComplete.validate_raw(obj: struct) + return Vapi::ToolMessageComplete.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageFailed.validate_raw(obj: struct) + return Vapi::ToolMessageFailed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageDelayed.validate_raw(obj: struct) + return Vapi::ToolMessageDelayed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -71,50 +56,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "request-start" - Vapi::ToolMessageStart.validate_raw(obj: obj) - when "request-complete" - Vapi::ToolMessageComplete.validate_raw(obj: obj) - when "request-failed" - Vapi::ToolMessageFailed.validate_raw(obj: obj) - when "request-response-delayed" - Vapi::ToolMessageDelayed.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ToolMessageStart.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ToolMessageStart] - # @return [Vapi::GhlToolMessagesItem] - def self.request_start(member:) - new(member: member, discriminant: "request-start") - end - - # @param member [Vapi::ToolMessageComplete] - # @return [Vapi::GhlToolMessagesItem] - def self.request_complete(member:) - new(member: member, discriminant: "request-complete") - end - - # @param member [Vapi::ToolMessageFailed] - # @return [Vapi::GhlToolMessagesItem] - def self.request_failed(member:) - new(member: member, discriminant: "request-failed") - end - - # @param member [Vapi::ToolMessageDelayed] - # @return [Vapi::GhlToolMessagesItem] - def self.request_response_delayed(member:) - new(member: member, discriminant: "request-response-delayed") + begin + return Vapi::ToolMessageComplete.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageFailed.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageDelayed.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/ghl_tool_provider_details.rb b/lib/vapi/types/ghl_tool_provider_details.rb index f734068..8b5d28e 100644 --- a/lib/vapi/types/ghl_tool_provider_details.rb +++ b/lib/vapi/types/ghl_tool_provider_details.rb @@ -10,6 +10,8 @@ class GhlToolProviderDetails attr_reader :template_url # @return [Array] attr_reader :setup_instructions + # @return [String] The type of tool. "ghl" for GHL tool. + attr_reader :type # @return [String] attr_reader :workflow_id # @return [String] @@ -30,6 +32,7 @@ class GhlToolProviderDetails # @param template_url [String] This is the Template URL or the Snapshot URL corresponding to the Template. # @param setup_instructions [Array] + # @param type [String] The type of tool. "ghl" for GHL tool. # @param workflow_id [String] # @param workflow_name [String] # @param webhook_hook_id [String] @@ -37,10 +40,11 @@ class GhlToolProviderDetails # @param location_id [String] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::GhlToolProviderDetails] - def initialize(template_url: OMIT, setup_instructions: OMIT, workflow_id: OMIT, workflow_name: OMIT, + def initialize(type:, template_url: OMIT, setup_instructions: OMIT, workflow_id: OMIT, workflow_name: OMIT, webhook_hook_id: OMIT, webhook_hook_name: OMIT, location_id: OMIT, additional_properties: nil) @template_url = template_url if template_url != OMIT @setup_instructions = setup_instructions if setup_instructions != OMIT + @type = type @workflow_id = workflow_id if workflow_id != OMIT @workflow_name = workflow_name if workflow_name != OMIT @webhook_hook_id = webhook_hook_id if webhook_hook_id != OMIT @@ -50,6 +54,7 @@ def initialize(template_url: OMIT, setup_instructions: OMIT, workflow_id: OMIT, @_field_set = { "templateUrl": template_url, "setupInstructions": setup_instructions, + "type": type, "workflowId": workflow_id, "workflowName": workflow_name, "webhookHookId": webhook_hook_id, @@ -72,6 +77,7 @@ def self.from_json(json_object:) item = item.to_json Vapi::ToolTemplateSetup.from_json(json_object: item) end + type = parsed_json["type"] workflow_id = parsed_json["workflowId"] workflow_name = parsed_json["workflowName"] webhook_hook_id = parsed_json["webhookHookId"] @@ -80,6 +86,7 @@ def self.from_json(json_object:) new( template_url: template_url, setup_instructions: setup_instructions, + type: type, workflow_id: workflow_id, workflow_name: workflow_name, webhook_hook_id: webhook_hook_id, @@ -105,6 +112,7 @@ def to_json(*_args) def self.validate_raw(obj:) obj.template_url&.is_a?(String) != false || raise("Passed value for field obj.template_url is not the expected type, validation failed.") obj.setup_instructions&.is_a?(Array) != false || raise("Passed value for field obj.setup_instructions is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.workflow_id&.is_a?(String) != false || raise("Passed value for field obj.workflow_id is not the expected type, validation failed.") obj.workflow_name&.is_a?(String) != false || raise("Passed value for field obj.workflow_name is not the expected type, validation failed.") obj.webhook_hook_id&.is_a?(String) != false || raise("Passed value for field obj.webhook_hook_id is not the expected type, validation failed.") diff --git a/lib/vapi/types/ghl_tool_with_tool_call.rb b/lib/vapi/types/ghl_tool_with_tool_call.rb index 0f56bd9..18e828a 100644 --- a/lib/vapi/types/ghl_tool_with_tool_call.rb +++ b/lib/vapi/types/ghl_tool_with_tool_call.rb @@ -22,6 +22,8 @@ class GhlToolWithToolCall # `tool.destinations`. For others like the function tool, these can be custom # configured. attr_reader :messages + # @return [String] The type of tool. "ghl" for GHL tool. + attr_reader :type # @return [Vapi::ToolCall] attr_reader :tool_call # @return [Vapi::GhlToolMetadata] @@ -61,6 +63,7 @@ class GhlToolWithToolCall # For some tools, this is auto-filled based on special fields like # `tool.destinations`. For others like the function tool, these can be custom # configured. + # @param type [String] The type of tool. "ghl" for GHL tool. # @param tool_call [Vapi::ToolCall] # @param metadata [Vapi::GhlToolMetadata] # @param function [Vapi::OpenAiFunction] This is the function definition of the tool. @@ -80,10 +83,11 @@ class GhlToolWithToolCall # phoneNumber.serverUrl, then org.serverUrl. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::GhlToolWithToolCall] - def initialize(tool_call:, metadata:, async: OMIT, messages: OMIT, function: OMIT, server: OMIT, + def initialize(type:, tool_call:, metadata:, async: OMIT, messages: OMIT, function: OMIT, server: OMIT, additional_properties: nil) @async = async if async != OMIT @messages = messages if messages != OMIT + @type = type @tool_call = tool_call @metadata = metadata @function = function if function != OMIT @@ -92,6 +96,7 @@ def initialize(tool_call:, metadata:, async: OMIT, messages: OMIT, function: OMI @_field_set = { "async": async, "messages": messages, + "type": type, "toolCall": tool_call, "metadata": metadata, "function": function, @@ -113,6 +118,7 @@ def self.from_json(json_object:) item = item.to_json Vapi::GhlToolWithToolCallMessagesItem.from_json(json_object: item) end + type = parsed_json["type"] if parsed_json["toolCall"].nil? tool_call = nil else @@ -140,6 +146,7 @@ def self.from_json(json_object:) new( async: async, messages: messages, + type: type, tool_call: tool_call, metadata: metadata, function: function, @@ -164,6 +171,7 @@ def to_json(*_args) def self.validate_raw(obj:) obj.async&.is_a?(Boolean) != false || raise("Passed value for field obj.async is not the expected type, validation failed.") obj.messages&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") Vapi::ToolCall.validate_raw(obj: obj.tool_call) Vapi::GhlToolMetadata.validate_raw(obj: obj.metadata) obj.function.nil? || Vapi::OpenAiFunction.validate_raw(obj: obj.function) diff --git a/lib/vapi/types/ghl_tool_with_tool_call_messages_item.rb b/lib/vapi/types/ghl_tool_with_tool_call_messages_item.rb index d8e9fee..1eaa73d 100644 --- a/lib/vapi/types/ghl_tool_with_tool_call_messages_item.rb +++ b/lib/vapi/types/ghl_tool_with_tool_call_messages_item.rb @@ -8,60 +8,45 @@ module Vapi class GhlToolWithToolCallMessagesItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::GhlToolWithToolCallMessagesItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of GhlToolWithToolCallMessagesItem # # @param json_object [String] # @return [Vapi::GhlToolWithToolCallMessagesItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "request-start" - Vapi::ToolMessageStart.from_json(json_object: json_object) - when "request-complete" - Vapi::ToolMessageComplete.from_json(json_object: json_object) - when "request-failed" - Vapi::ToolMessageFailed.from_json(json_object: json_object) - when "request-response-delayed" - Vapi::ToolMessageDelayed.from_json(json_object: json_object) - else - Vapi::ToolMessageStart.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ToolMessageStart.validate_raw(obj: struct) + return Vapi::ToolMessageStart.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "request-start" - { **@member.to_json, type: @discriminant }.to_json - when "request-complete" - { **@member.to_json, type: @discriminant }.to_json - when "request-failed" - { **@member.to_json, type: @discriminant }.to_json - when "request-response-delayed" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageComplete.validate_raw(obj: struct) + return Vapi::ToolMessageComplete.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageFailed.validate_raw(obj: struct) + return Vapi::ToolMessageFailed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageDelayed.validate_raw(obj: struct) + return Vapi::ToolMessageDelayed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -71,50 +56,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "request-start" - Vapi::ToolMessageStart.validate_raw(obj: obj) - when "request-complete" - Vapi::ToolMessageComplete.validate_raw(obj: obj) - when "request-failed" - Vapi::ToolMessageFailed.validate_raw(obj: obj) - when "request-response-delayed" - Vapi::ToolMessageDelayed.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ToolMessageStart.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ToolMessageStart] - # @return [Vapi::GhlToolWithToolCallMessagesItem] - def self.request_start(member:) - new(member: member, discriminant: "request-start") - end - - # @param member [Vapi::ToolMessageComplete] - # @return [Vapi::GhlToolWithToolCallMessagesItem] - def self.request_complete(member:) - new(member: member, discriminant: "request-complete") - end - - # @param member [Vapi::ToolMessageFailed] - # @return [Vapi::GhlToolWithToolCallMessagesItem] - def self.request_failed(member:) - new(member: member, discriminant: "request-failed") - end - - # @param member [Vapi::ToolMessageDelayed] - # @return [Vapi::GhlToolWithToolCallMessagesItem] - def self.request_response_delayed(member:) - new(member: member, discriminant: "request-response-delayed") + begin + return Vapi::ToolMessageComplete.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageFailed.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageDelayed.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/gladia_transcriber.rb b/lib/vapi/types/gladia_transcriber.rb index f8ff198..49c9956 100644 --- a/lib/vapi/types/gladia_transcriber.rb +++ b/lib/vapi/types/gladia_transcriber.rb @@ -8,6 +8,8 @@ module Vapi class GladiaTranscriber + # @return [String] This is the transcription provider that will be used. + attr_reader :provider # @return [Vapi::GladiaTranscriberModel] attr_reader :model # @return [Vapi::GladiaTranscriberLanguageBehaviour] @@ -36,6 +38,7 @@ class GladiaTranscriber OMIT = Object.new + # @param provider [String] This is the transcription provider that will be used. # @param model [Vapi::GladiaTranscriberModel] # @param language_behaviour [Vapi::GladiaTranscriberLanguageBehaviour] # @param language [Vapi::GladiaTranscriberLanguage] Defines the language to use for the transcription. Required when @@ -52,8 +55,9 @@ class GladiaTranscriber # increase. Default value is false. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::GladiaTranscriber] - def initialize(model: OMIT, language_behaviour: OMIT, language: OMIT, transcription_hint: OMIT, prosody: OMIT, - audio_enhancer: OMIT, additional_properties: nil) + def initialize(provider:, model: OMIT, language_behaviour: OMIT, language: OMIT, transcription_hint: OMIT, + prosody: OMIT, audio_enhancer: OMIT, additional_properties: nil) + @provider = provider @model = model if model != OMIT @language_behaviour = language_behaviour if language_behaviour != OMIT @language = language if language != OMIT @@ -62,6 +66,7 @@ def initialize(model: OMIT, language_behaviour: OMIT, language: OMIT, transcript @audio_enhancer = audio_enhancer if audio_enhancer != OMIT @additional_properties = additional_properties @_field_set = { + "provider": provider, "model": model, "languageBehaviour": language_behaviour, "language": language, @@ -80,6 +85,7 @@ def initialize(model: OMIT, language_behaviour: OMIT, language: OMIT, transcript def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + provider = parsed_json["provider"] model = parsed_json["model"] language_behaviour = parsed_json["languageBehaviour"] language = parsed_json["language"] @@ -87,6 +93,7 @@ def self.from_json(json_object:) prosody = parsed_json["prosody"] audio_enhancer = parsed_json["audioEnhancer"] new( + provider: provider, model: model, language_behaviour: language_behaviour, language: language, @@ -111,6 +118,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") obj.model&.is_a?(Vapi::GladiaTranscriberModel) != false || raise("Passed value for field obj.model is not the expected type, validation failed.") obj.language_behaviour&.is_a?(Vapi::GladiaTranscriberLanguageBehaviour) != false || raise("Passed value for field obj.language_behaviour is not the expected type, validation failed.") obj.language&.is_a?(Vapi::GladiaTranscriberLanguage) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") diff --git a/lib/vapi/types/groq_model.rb b/lib/vapi/types/groq_model.rb index ba1f91f..313a462 100644 --- a/lib/vapi/types/groq_model.rb +++ b/lib/vapi/types/groq_model.rb @@ -21,6 +21,8 @@ class GroqModel attr_reader :tool_ids # @return [Vapi::GroqModelModel] This is the name of the model. Ex. cognitivecomputations/dolphin-mixtral-8x7b attr_reader :model + # @return [String] + attr_reader :provider # @return [Float] This is the temperature that will be used for calls. Default is 0 to leverage # caching for lower latency. attr_reader :temperature @@ -57,6 +59,7 @@ class GroqModel # tools, use `tools`. # Both `tools` and `toolIds` can be used together. # @param model [Vapi::GroqModelModel] This is the name of the model. Ex. cognitivecomputations/dolphin-mixtral-8x7b + # @param provider [String] # @param temperature [Float] This is the temperature that will be used for calls. Default is 0 to leverage # caching for lower latency. # @param knowledge_base [Vapi::KnowledgeBase] These are the options for the knowledge base. @@ -74,12 +77,13 @@ class GroqModel # @default 0 # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::GroqModel] - def initialize(model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, temperature: OMIT, knowledge_base: OMIT, - max_tokens: OMIT, emotion_recognition_enabled: OMIT, num_fast_turns: OMIT, additional_properties: nil) + def initialize(model:, provider:, messages: OMIT, tools: OMIT, tool_ids: OMIT, temperature: OMIT, + knowledge_base: OMIT, max_tokens: OMIT, emotion_recognition_enabled: OMIT, num_fast_turns: OMIT, additional_properties: nil) @messages = messages if messages != OMIT @tools = tools if tools != OMIT @tool_ids = tool_ids if tool_ids != OMIT @model = model + @provider = provider @temperature = temperature if temperature != OMIT @knowledge_base = knowledge_base if knowledge_base != OMIT @max_tokens = max_tokens if max_tokens != OMIT @@ -91,6 +95,7 @@ def initialize(model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, temperature: "tools": tools, "toolIds": tool_ids, "model": model, + "provider": provider, "temperature": temperature, "knowledgeBase": knowledge_base, "maxTokens": max_tokens, @@ -118,6 +123,7 @@ def self.from_json(json_object:) end tool_ids = parsed_json["toolIds"] model = parsed_json["model"] + provider = parsed_json["provider"] temperature = parsed_json["temperature"] if parsed_json["knowledgeBase"].nil? knowledge_base = nil @@ -133,6 +139,7 @@ def self.from_json(json_object:) tools: tools, tool_ids: tool_ids, model: model, + provider: provider, temperature: temperature, knowledge_base: knowledge_base, max_tokens: max_tokens, @@ -160,6 +167,7 @@ def self.validate_raw(obj:) obj.tools&.is_a?(Array) != false || raise("Passed value for field obj.tools is not the expected type, validation failed.") obj.tool_ids&.is_a?(Array) != false || raise("Passed value for field obj.tool_ids is not the expected type, validation failed.") obj.model.is_a?(Vapi::GroqModelModel) != false || raise("Passed value for field obj.model is not the expected type, validation failed.") + obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") obj.temperature&.is_a?(Float) != false || raise("Passed value for field obj.temperature is not the expected type, validation failed.") obj.knowledge_base.nil? || Vapi::KnowledgeBase.validate_raw(obj: obj.knowledge_base) obj.max_tokens&.is_a?(Float) != false || raise("Passed value for field obj.max_tokens is not the expected type, validation failed.") diff --git a/lib/vapi/types/groq_model_tools_item.rb b/lib/vapi/types/groq_model_tools_item.rb index 417bbba..31f63d0 100644 --- a/lib/vapi/types/groq_model_tools_item.rb +++ b/lib/vapi/types/groq_model_tools_item.rb @@ -11,72 +11,69 @@ module Vapi class GroqModelToolsItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::GroqModelToolsItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of GroqModelToolsItem # # @param json_object [String] # @return [Vapi::GroqModelToolsItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "dtmf" - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - when "endCall" - Vapi::CreateEndCallToolDto.from_json(json_object: json_object) - when "voicemail" - Vapi::CreateVoicemailToolDto.from_json(json_object: json_object) - when "function" - Vapi::CreateFunctionToolDto.from_json(json_object: json_object) - when "ghl" - Vapi::CreateGhlToolDto.from_json(json_object: json_object) - when "make" - Vapi::CreateMakeToolDto.from_json(json_object: json_object) - when "transferCall" - Vapi::CreateTransferCallToolDto.from_json(json_object: json_object) - else - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::CreateDtmfToolDto.validate_raw(obj: struct) + return Vapi::CreateDtmfToolDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "dtmf" - { **@member.to_json, type: @discriminant }.to_json - when "endCall" - { **@member.to_json, type: @discriminant }.to_json - when "voicemail" - { **@member.to_json, type: @discriminant }.to_json - when "function" - { **@member.to_json, type: @discriminant }.to_json - when "ghl" - { **@member.to_json, type: @discriminant }.to_json - when "make" - { **@member.to_json, type: @discriminant }.to_json - when "transferCall" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateEndCallToolDto.validate_raw(obj: struct) + return Vapi::CreateEndCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVoicemailToolDto.validate_raw(obj: struct) + return Vapi::CreateVoicemailToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateFunctionToolDto.validate_raw(obj: struct) + return Vapi::CreateFunctionToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::CreateGhlToolDto.validate_raw(obj: struct) + return Vapi::CreateGhlToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateMakeToolDto.validate_raw(obj: struct) + return Vapi::CreateMakeToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTransferCallToolDto.validate_raw(obj: struct) + return Vapi::CreateTransferCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -86,74 +83,42 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "dtmf" - Vapi::CreateDtmfToolDto.validate_raw(obj: obj) - when "endCall" - Vapi::CreateEndCallToolDto.validate_raw(obj: obj) - when "voicemail" - Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) - when "function" - Vapi::CreateFunctionToolDto.validate_raw(obj: obj) - when "ghl" - Vapi::CreateGhlToolDto.validate_raw(obj: obj) - when "make" - Vapi::CreateMakeToolDto.validate_raw(obj: obj) - when "transferCall" - Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateDtmfToolDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateDtmfToolDto] - # @return [Vapi::GroqModelToolsItem] - def self.dtmf(member:) - new(member: member, discriminant: "dtmf") - end - - # @param member [Vapi::CreateEndCallToolDto] - # @return [Vapi::GroqModelToolsItem] - def self.end_call(member:) - new(member: member, discriminant: "endCall") - end - - # @param member [Vapi::CreateVoicemailToolDto] - # @return [Vapi::GroqModelToolsItem] - def self.voicemail(member:) - new(member: member, discriminant: "voicemail") - end - - # @param member [Vapi::CreateFunctionToolDto] - # @return [Vapi::GroqModelToolsItem] - def self.function(member:) - new(member: member, discriminant: "function") - end - - # @param member [Vapi::CreateGhlToolDto] - # @return [Vapi::GroqModelToolsItem] - def self.ghl(member:) - new(member: member, discriminant: "ghl") - end - - # @param member [Vapi::CreateMakeToolDto] - # @return [Vapi::GroqModelToolsItem] - def self.make(member:) - new(member: member, discriminant: "make") - end - - # @param member [Vapi::CreateTransferCallToolDto] - # @return [Vapi::GroqModelToolsItem] - def self.transfer_call(member:) - new(member: member, discriminant: "transferCall") + begin + return Vapi::CreateEndCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateFunctionToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateGhlToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateMakeToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/handoff_step.rb b/lib/vapi/types/handoff_step.rb index 031e3a2..f8723b7 100644 --- a/lib/vapi/types/handoff_step.rb +++ b/lib/vapi/types/handoff_step.rb @@ -9,6 +9,12 @@ module Vapi class HandoffStep # @return [Vapi::HandoffStepBlock] This is the block to use. To use an existing block, use `blockId`. attr_reader :block + # @return [String] This is a step that takes a handoff from the previous step. This means it won't + # return to the calling step. The workflow execution will continue linearly. + # Use case: + # - You want to collect information linearly (e.g. a form, provide information, + # etc). + attr_reader :type # @return [Array] These are the destinations that the step can go to after it's done. attr_reader :destinations # @return [String] This is the name of the step. @@ -76,6 +82,11 @@ class HandoffStep OMIT = Object.new # @param block [Vapi::HandoffStepBlock] This is the block to use. To use an existing block, use `blockId`. + # @param type [String] This is a step that takes a handoff from the previous step. This means it won't + # return to the calling step. The workflow execution will continue linearly. + # Use case: + # - You want to collect information linearly (e.g. a form, provide information, + # etc). # @param destinations [Array] These are the destinations that the step can go to after it's done. # @param name [String] This is the name of the step. # @param block_id [String] This is the id of the block to use. To use a transient block, use `block`. @@ -132,8 +143,10 @@ class HandoffStep # blocks outside of a workflow. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::HandoffStep] - def initialize(name:, block: OMIT, destinations: OMIT, block_id: OMIT, input: OMIT, additional_properties: nil) + def initialize(type:, name:, block: OMIT, destinations: OMIT, block_id: OMIT, input: OMIT, + additional_properties: nil) @block = block if block != OMIT + @type = type @destinations = destinations if destinations != OMIT @name = name @block_id = block_id if block_id != OMIT @@ -141,6 +154,7 @@ def initialize(name:, block: OMIT, destinations: OMIT, block_id: OMIT, input: OM @additional_properties = additional_properties @_field_set = { "block": block, + "type": type, "destinations": destinations, "name": name, "blockId": block_id, @@ -163,6 +177,7 @@ def self.from_json(json_object:) block = parsed_json["block"].to_json block = Vapi::HandoffStepBlock.from_json(json_object: block) end + type = parsed_json["type"] destinations = parsed_json["destinations"]&.map do |item| item = item.to_json Vapi::StepDestination.from_json(json_object: item) @@ -172,6 +187,7 @@ def self.from_json(json_object:) input = parsed_json["input"] new( block: block, + type: type, destinations: destinations, name: name, block_id: block_id, @@ -195,6 +211,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.block.nil? || Vapi::HandoffStepBlock.validate_raw(obj: obj.block) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.destinations&.is_a?(Array) != false || raise("Passed value for field obj.destinations is not the expected type, validation failed.") obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") obj.block_id&.is_a?(String) != false || raise("Passed value for field obj.block_id is not the expected type, validation failed.") diff --git a/lib/vapi/types/handoff_step_block.rb b/lib/vapi/types/handoff_step_block.rb index 0cd9476..f24dd6c 100644 --- a/lib/vapi/types/handoff_step_block.rb +++ b/lib/vapi/types/handoff_step_block.rb @@ -8,56 +8,37 @@ module Vapi # This is the block to use. To use an existing block, use `blockId`. class HandoffStepBlock - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::HandoffStepBlock] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of HandoffStepBlock # # @param json_object [String] # @return [Vapi::HandoffStepBlock] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "conversation" - Vapi::CreateConversationBlockDto.from_json(json_object: json_object) - when "tool-call" - Vapi::CreateToolCallBlockDto.from_json(json_object: json_object) - when "workflow" - Vapi::CreateWorkflowBlockDto.from_json(json_object: json_object) - else - Vapi::CreateConversationBlockDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::CreateConversationBlockDto.validate_raw(obj: struct) + return Vapi::CreateConversationBlockDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "conversation" - { **@member.to_json, type: @discriminant }.to_json - when "tool-call" - { **@member.to_json, type: @discriminant }.to_json - when "workflow" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::CreateToolCallBlockDto.validate_raw(obj: struct) + return Vapi::CreateToolCallBlockDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateWorkflowBlockDto.validate_raw(obj: struct) + return Vapi::CreateWorkflowBlockDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -67,42 +48,22 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "conversation" - Vapi::CreateConversationBlockDto.validate_raw(obj: obj) - when "tool-call" - Vapi::CreateToolCallBlockDto.validate_raw(obj: obj) - when "workflow" - Vapi::CreateWorkflowBlockDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateConversationBlockDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateConversationBlockDto] - # @return [Vapi::HandoffStepBlock] - def self.conversation(member:) - new(member: member, discriminant: "conversation") - end - - # @param member [Vapi::CreateToolCallBlockDto] - # @return [Vapi::HandoffStepBlock] - def self.tool_call(member:) - new(member: member, discriminant: "tool-call") - end - - # @param member [Vapi::CreateWorkflowBlockDto] - # @return [Vapi::HandoffStepBlock] - def self.workflow(member:) - new(member: member, discriminant: "workflow") + begin + return Vapi::CreateToolCallBlockDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateWorkflowBlockDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/import_twilio_phone_number_dto_fallback_destination.rb b/lib/vapi/types/import_twilio_phone_number_dto_fallback_destination.rb index 14b4b0f..230361c 100644 --- a/lib/vapi/types/import_twilio_phone_number_dto_fallback_destination.rb +++ b/lib/vapi/types/import_twilio_phone_number_dto_fallback_destination.rb @@ -12,22 +12,6 @@ module Vapi # If this is not set and above conditions are met, the inbound call is hung up # with an error message. class ImportTwilioPhoneNumberDtoFallbackDestination - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ImportTwilioPhoneNumberDtoFallbackDestination] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of # ImportTwilioPhoneNumberDtoFallbackDestination # @@ -35,30 +19,23 @@ def initialize(member:, discriminant:) # @return [Vapi::ImportTwilioPhoneNumberDtoFallbackDestination] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "number" - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - when "sip" - Vapi::TransferDestinationSip.from_json(json_object: json_object) - else - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::TransferDestinationNumber.validate_raw(obj: struct) + return Vapi::TransferDestinationNumber.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "number" - { **@member.to_json, type: @discriminant }.to_json - when "sip" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::TransferDestinationSip.validate_raw(obj: struct) + return Vapi::TransferDestinationSip.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -68,34 +45,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "number" - Vapi::TransferDestinationNumber.validate_raw(obj: obj) - when "sip" - Vapi::TransferDestinationSip.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::TransferDestinationNumber.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::TransferDestinationNumber] - # @return [Vapi::ImportTwilioPhoneNumberDtoFallbackDestination] - def self.number(member:) - new(member: member, discriminant: "number") - end - - # @param member [Vapi::TransferDestinationSip] - # @return [Vapi::ImportTwilioPhoneNumberDtoFallbackDestination] - def self.sip(member:) - new(member: member, discriminant: "sip") + begin + return Vapi::TransferDestinationSip.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/import_vonage_phone_number_dto_fallback_destination.rb b/lib/vapi/types/import_vonage_phone_number_dto_fallback_destination.rb index dc3d965..02a63a8 100644 --- a/lib/vapi/types/import_vonage_phone_number_dto_fallback_destination.rb +++ b/lib/vapi/types/import_vonage_phone_number_dto_fallback_destination.rb @@ -12,22 +12,6 @@ module Vapi # If this is not set and above conditions are met, the inbound call is hung up # with an error message. class ImportVonagePhoneNumberDtoFallbackDestination - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ImportVonagePhoneNumberDtoFallbackDestination] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of # ImportVonagePhoneNumberDtoFallbackDestination # @@ -35,30 +19,23 @@ def initialize(member:, discriminant:) # @return [Vapi::ImportVonagePhoneNumberDtoFallbackDestination] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "number" - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - when "sip" - Vapi::TransferDestinationSip.from_json(json_object: json_object) - else - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::TransferDestinationNumber.validate_raw(obj: struct) + return Vapi::TransferDestinationNumber.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "number" - { **@member.to_json, type: @discriminant }.to_json - when "sip" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::TransferDestinationSip.validate_raw(obj: struct) + return Vapi::TransferDestinationSip.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -68,34 +45,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "number" - Vapi::TransferDestinationNumber.validate_raw(obj: obj) - when "sip" - Vapi::TransferDestinationSip.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::TransferDestinationNumber.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::TransferDestinationNumber] - # @return [Vapi::ImportVonagePhoneNumberDtoFallbackDestination] - def self.number(member:) - new(member: member, discriminant: "number") - end - - # @param member [Vapi::TransferDestinationSip] - # @return [Vapi::ImportVonagePhoneNumberDtoFallbackDestination] - def self.sip(member:) - new(member: member, discriminant: "sip") + begin + return Vapi::TransferDestinationSip.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/lmnt_voice.rb b/lib/vapi/types/lmnt_voice.rb index 7660106..de5ddb9 100644 --- a/lib/vapi/types/lmnt_voice.rb +++ b/lib/vapi/types/lmnt_voice.rb @@ -11,6 +11,8 @@ class LmntVoice # inputting it into the voice provider. # Default `false` because you can achieve better results with prompting the model. attr_reader :filler_injection_enabled + # @return [String] This is the voice provider that will be used. + attr_reader :provider # @return [Vapi::LmntVoiceVoiceId] This is the provider-specific ID that will be used. attr_reader :voice_id # @return [Float] This is the speed multiplier that will be used. @@ -29,20 +31,24 @@ class LmntVoice # @param filler_injection_enabled [Boolean] This determines whether fillers are injected into the model output before # inputting it into the voice provider. # Default `false` because you can achieve better results with prompting the model. + # @param provider [String] This is the voice provider that will be used. # @param voice_id [Vapi::LmntVoiceVoiceId] This is the provider-specific ID that will be used. # @param speed [Float] This is the speed multiplier that will be used. # @param chunk_plan [Vapi::ChunkPlan] This is the plan for chunking the model output before it is sent to the voice # provider. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::LmntVoice] - def initialize(voice_id:, filler_injection_enabled: OMIT, speed: OMIT, chunk_plan: OMIT, additional_properties: nil) + def initialize(provider:, voice_id:, filler_injection_enabled: OMIT, speed: OMIT, chunk_plan: OMIT, + additional_properties: nil) @filler_injection_enabled = filler_injection_enabled if filler_injection_enabled != OMIT + @provider = provider @voice_id = voice_id @speed = speed if speed != OMIT @chunk_plan = chunk_plan if chunk_plan != OMIT @additional_properties = additional_properties @_field_set = { "fillerInjectionEnabled": filler_injection_enabled, + "provider": provider, "voiceId": voice_id, "speed": speed, "chunkPlan": chunk_plan @@ -59,6 +65,7 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) filler_injection_enabled = parsed_json["fillerInjectionEnabled"] + provider = parsed_json["provider"] if parsed_json["voiceId"].nil? voice_id = nil else @@ -74,6 +81,7 @@ def self.from_json(json_object:) end new( filler_injection_enabled: filler_injection_enabled, + provider: provider, voice_id: voice_id, speed: speed, chunk_plan: chunk_plan, @@ -96,6 +104,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.filler_injection_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.filler_injection_enabled is not the expected type, validation failed.") + obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") Vapi::LmntVoiceVoiceId.validate_raw(obj: obj.voice_id) obj.speed&.is_a?(Float) != false || raise("Passed value for field obj.speed is not the expected type, validation failed.") obj.chunk_plan.nil? || Vapi::ChunkPlan.validate_raw(obj: obj.chunk_plan) diff --git a/lib/vapi/types/make_tool.rb b/lib/vapi/types/make_tool.rb index 541de23..6646ef7 100644 --- a/lib/vapi/types/make_tool.rb +++ b/lib/vapi/types/make_tool.rb @@ -22,6 +22,8 @@ class MakeTool # `tool.destinations`. For others like the function tool, these can be custom # configured. attr_reader :messages + # @return [String] + attr_reader :type # @return [String] This is the unique identifier for the tool. attr_reader :id # @return [String] This is the unique identifier for the organization that this tool belongs to. @@ -67,6 +69,7 @@ class MakeTool # For some tools, this is auto-filled based on special fields like # `tool.destinations`. For others like the function tool, these can be custom # configured. + # @param type [String] # @param id [String] This is the unique identifier for the tool. # @param org_id [String] This is the unique identifier for the organization that this tool belongs to. # @param created_at [DateTime] This is the ISO 8601 date-time string of when the tool was created. @@ -89,10 +92,11 @@ class MakeTool # @param metadata [Vapi::MakeToolMetadata] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::MakeTool] - def initialize(id:, org_id:, created_at:, updated_at:, metadata:, async: OMIT, messages: OMIT, function: OMIT, + def initialize(type:, id:, org_id:, created_at:, updated_at:, metadata:, async: OMIT, messages: OMIT, function: OMIT, server: OMIT, additional_properties: nil) @async = async if async != OMIT @messages = messages if messages != OMIT + @type = type @id = id @org_id = org_id @created_at = created_at @@ -104,6 +108,7 @@ def initialize(id:, org_id:, created_at:, updated_at:, metadata:, async: OMIT, m @_field_set = { "async": async, "messages": messages, + "type": type, "id": id, "orgId": org_id, "createdAt": created_at, @@ -128,6 +133,7 @@ def self.from_json(json_object:) item = item.to_json Vapi::MakeToolMessagesItem.from_json(json_object: item) end + type = parsed_json["type"] id = parsed_json["id"] org_id = parsed_json["orgId"] created_at = (DateTime.parse(parsed_json["createdAt"]) unless parsed_json["createdAt"].nil?) @@ -153,6 +159,7 @@ def self.from_json(json_object:) new( async: async, messages: messages, + type: type, id: id, org_id: org_id, created_at: created_at, @@ -180,6 +187,7 @@ def to_json(*_args) def self.validate_raw(obj:) obj.async&.is_a?(Boolean) != false || raise("Passed value for field obj.async is not the expected type, validation failed.") obj.messages&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type 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.") diff --git a/lib/vapi/types/make_tool_messages_item.rb b/lib/vapi/types/make_tool_messages_item.rb index ccef717..6f7f34e 100644 --- a/lib/vapi/types/make_tool_messages_item.rb +++ b/lib/vapi/types/make_tool_messages_item.rb @@ -8,60 +8,45 @@ module Vapi class MakeToolMessagesItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::MakeToolMessagesItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of MakeToolMessagesItem # # @param json_object [String] # @return [Vapi::MakeToolMessagesItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "request-start" - Vapi::ToolMessageStart.from_json(json_object: json_object) - when "request-complete" - Vapi::ToolMessageComplete.from_json(json_object: json_object) - when "request-failed" - Vapi::ToolMessageFailed.from_json(json_object: json_object) - when "request-response-delayed" - Vapi::ToolMessageDelayed.from_json(json_object: json_object) - else - Vapi::ToolMessageStart.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ToolMessageStart.validate_raw(obj: struct) + return Vapi::ToolMessageStart.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "request-start" - { **@member.to_json, type: @discriminant }.to_json - when "request-complete" - { **@member.to_json, type: @discriminant }.to_json - when "request-failed" - { **@member.to_json, type: @discriminant }.to_json - when "request-response-delayed" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageComplete.validate_raw(obj: struct) + return Vapi::ToolMessageComplete.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageFailed.validate_raw(obj: struct) + return Vapi::ToolMessageFailed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageDelayed.validate_raw(obj: struct) + return Vapi::ToolMessageDelayed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -71,50 +56,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "request-start" - Vapi::ToolMessageStart.validate_raw(obj: obj) - when "request-complete" - Vapi::ToolMessageComplete.validate_raw(obj: obj) - when "request-failed" - Vapi::ToolMessageFailed.validate_raw(obj: obj) - when "request-response-delayed" - Vapi::ToolMessageDelayed.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ToolMessageStart.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ToolMessageStart] - # @return [Vapi::MakeToolMessagesItem] - def self.request_start(member:) - new(member: member, discriminant: "request-start") - end - - # @param member [Vapi::ToolMessageComplete] - # @return [Vapi::MakeToolMessagesItem] - def self.request_complete(member:) - new(member: member, discriminant: "request-complete") - end - - # @param member [Vapi::ToolMessageFailed] - # @return [Vapi::MakeToolMessagesItem] - def self.request_failed(member:) - new(member: member, discriminant: "request-failed") - end - - # @param member [Vapi::ToolMessageDelayed] - # @return [Vapi::MakeToolMessagesItem] - def self.request_response_delayed(member:) - new(member: member, discriminant: "request-response-delayed") + begin + return Vapi::ToolMessageComplete.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageFailed.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageDelayed.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/make_tool_provider_details.rb b/lib/vapi/types/make_tool_provider_details.rb index 5f04cb9..6918584 100644 --- a/lib/vapi/types/make_tool_provider_details.rb +++ b/lib/vapi/types/make_tool_provider_details.rb @@ -10,6 +10,8 @@ class MakeToolProviderDetails attr_reader :template_url # @return [Array] attr_reader :setup_instructions + # @return [String] The type of tool. "make" for Make tool. + attr_reader :type # @return [Float] attr_reader :scenario_id # @return [String] @@ -28,16 +30,18 @@ class MakeToolProviderDetails # @param template_url [String] This is the Template URL or the Snapshot URL corresponding to the Template. # @param setup_instructions [Array] + # @param type [String] The type of tool. "make" for Make tool. # @param scenario_id [Float] # @param scenario_name [String] # @param trigger_hook_id [Float] # @param trigger_hook_name [String] # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::MakeToolProviderDetails] - def initialize(template_url: OMIT, setup_instructions: OMIT, scenario_id: OMIT, scenario_name: OMIT, + def initialize(type:, template_url: OMIT, setup_instructions: OMIT, scenario_id: OMIT, scenario_name: OMIT, trigger_hook_id: OMIT, trigger_hook_name: OMIT, additional_properties: nil) @template_url = template_url if template_url != OMIT @setup_instructions = setup_instructions if setup_instructions != OMIT + @type = type @scenario_id = scenario_id if scenario_id != OMIT @scenario_name = scenario_name if scenario_name != OMIT @trigger_hook_id = trigger_hook_id if trigger_hook_id != OMIT @@ -46,6 +50,7 @@ def initialize(template_url: OMIT, setup_instructions: OMIT, scenario_id: OMIT, @_field_set = { "templateUrl": template_url, "setupInstructions": setup_instructions, + "type": type, "scenarioId": scenario_id, "scenarioName": scenario_name, "triggerHookId": trigger_hook_id, @@ -67,6 +72,7 @@ def self.from_json(json_object:) item = item.to_json Vapi::ToolTemplateSetup.from_json(json_object: item) end + type = parsed_json["type"] scenario_id = parsed_json["scenarioId"] scenario_name = parsed_json["scenarioName"] trigger_hook_id = parsed_json["triggerHookId"] @@ -74,6 +80,7 @@ def self.from_json(json_object:) new( template_url: template_url, setup_instructions: setup_instructions, + type: type, scenario_id: scenario_id, scenario_name: scenario_name, trigger_hook_id: trigger_hook_id, @@ -98,6 +105,7 @@ def to_json(*_args) def self.validate_raw(obj:) obj.template_url&.is_a?(String) != false || raise("Passed value for field obj.template_url is not the expected type, validation failed.") obj.setup_instructions&.is_a?(Array) != false || raise("Passed value for field obj.setup_instructions is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.scenario_id&.is_a?(Float) != false || raise("Passed value for field obj.scenario_id is not the expected type, validation failed.") obj.scenario_name&.is_a?(String) != false || raise("Passed value for field obj.scenario_name is not the expected type, validation failed.") obj.trigger_hook_id&.is_a?(Float) != false || raise("Passed value for field obj.trigger_hook_id is not the expected type, validation failed.") diff --git a/lib/vapi/types/make_tool_with_tool_call.rb b/lib/vapi/types/make_tool_with_tool_call.rb index 0bfb1e3..74d1c5b 100644 --- a/lib/vapi/types/make_tool_with_tool_call.rb +++ b/lib/vapi/types/make_tool_with_tool_call.rb @@ -22,6 +22,8 @@ class MakeToolWithToolCall # `tool.destinations`. For others like the function tool, these can be custom # configured. attr_reader :messages + # @return [String] The type of tool. "make" for Make tool. + attr_reader :type # @return [Vapi::ToolCall] attr_reader :tool_call # @return [Vapi::MakeToolMetadata] @@ -61,6 +63,7 @@ class MakeToolWithToolCall # For some tools, this is auto-filled based on special fields like # `tool.destinations`. For others like the function tool, these can be custom # configured. + # @param type [String] The type of tool. "make" for Make tool. # @param tool_call [Vapi::ToolCall] # @param metadata [Vapi::MakeToolMetadata] # @param function [Vapi::OpenAiFunction] This is the function definition of the tool. @@ -80,10 +83,11 @@ class MakeToolWithToolCall # phoneNumber.serverUrl, then org.serverUrl. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::MakeToolWithToolCall] - def initialize(tool_call:, metadata:, async: OMIT, messages: OMIT, function: OMIT, server: OMIT, + def initialize(type:, tool_call:, metadata:, async: OMIT, messages: OMIT, function: OMIT, server: OMIT, additional_properties: nil) @async = async if async != OMIT @messages = messages if messages != OMIT + @type = type @tool_call = tool_call @metadata = metadata @function = function if function != OMIT @@ -92,6 +96,7 @@ def initialize(tool_call:, metadata:, async: OMIT, messages: OMIT, function: OMI @_field_set = { "async": async, "messages": messages, + "type": type, "toolCall": tool_call, "metadata": metadata, "function": function, @@ -113,6 +118,7 @@ def self.from_json(json_object:) item = item.to_json Vapi::MakeToolWithToolCallMessagesItem.from_json(json_object: item) end + type = parsed_json["type"] if parsed_json["toolCall"].nil? tool_call = nil else @@ -140,6 +146,7 @@ def self.from_json(json_object:) new( async: async, messages: messages, + type: type, tool_call: tool_call, metadata: metadata, function: function, @@ -164,6 +171,7 @@ def to_json(*_args) def self.validate_raw(obj:) obj.async&.is_a?(Boolean) != false || raise("Passed value for field obj.async is not the expected type, validation failed.") obj.messages&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") Vapi::ToolCall.validate_raw(obj: obj.tool_call) Vapi::MakeToolMetadata.validate_raw(obj: obj.metadata) obj.function.nil? || Vapi::OpenAiFunction.validate_raw(obj: obj.function) diff --git a/lib/vapi/types/make_tool_with_tool_call_messages_item.rb b/lib/vapi/types/make_tool_with_tool_call_messages_item.rb index a0dbf38..6a3a643 100644 --- a/lib/vapi/types/make_tool_with_tool_call_messages_item.rb +++ b/lib/vapi/types/make_tool_with_tool_call_messages_item.rb @@ -8,60 +8,45 @@ module Vapi class MakeToolWithToolCallMessagesItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::MakeToolWithToolCallMessagesItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of MakeToolWithToolCallMessagesItem # # @param json_object [String] # @return [Vapi::MakeToolWithToolCallMessagesItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "request-start" - Vapi::ToolMessageStart.from_json(json_object: json_object) - when "request-complete" - Vapi::ToolMessageComplete.from_json(json_object: json_object) - when "request-failed" - Vapi::ToolMessageFailed.from_json(json_object: json_object) - when "request-response-delayed" - Vapi::ToolMessageDelayed.from_json(json_object: json_object) - else - Vapi::ToolMessageStart.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ToolMessageStart.validate_raw(obj: struct) + return Vapi::ToolMessageStart.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "request-start" - { **@member.to_json, type: @discriminant }.to_json - when "request-complete" - { **@member.to_json, type: @discriminant }.to_json - when "request-failed" - { **@member.to_json, type: @discriminant }.to_json - when "request-response-delayed" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageComplete.validate_raw(obj: struct) + return Vapi::ToolMessageComplete.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageFailed.validate_raw(obj: struct) + return Vapi::ToolMessageFailed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageDelayed.validate_raw(obj: struct) + return Vapi::ToolMessageDelayed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -71,50 +56,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "request-start" - Vapi::ToolMessageStart.validate_raw(obj: obj) - when "request-complete" - Vapi::ToolMessageComplete.validate_raw(obj: obj) - when "request-failed" - Vapi::ToolMessageFailed.validate_raw(obj: obj) - when "request-response-delayed" - Vapi::ToolMessageDelayed.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ToolMessageStart.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ToolMessageStart] - # @return [Vapi::MakeToolWithToolCallMessagesItem] - def self.request_start(member:) - new(member: member, discriminant: "request-start") - end - - # @param member [Vapi::ToolMessageComplete] - # @return [Vapi::MakeToolWithToolCallMessagesItem] - def self.request_complete(member:) - new(member: member, discriminant: "request-complete") - end - - # @param member [Vapi::ToolMessageFailed] - # @return [Vapi::MakeToolWithToolCallMessagesItem] - def self.request_failed(member:) - new(member: member, discriminant: "request-failed") - end - - # @param member [Vapi::ToolMessageDelayed] - # @return [Vapi::MakeToolWithToolCallMessagesItem] - def self.request_response_delayed(member:) - new(member: member, discriminant: "request-response-delayed") + begin + return Vapi::ToolMessageComplete.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageFailed.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageDelayed.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/model_based_condition.rb b/lib/vapi/types/model_based_condition.rb index 09f711d..618e820 100644 --- a/lib/vapi/types/model_based_condition.rb +++ b/lib/vapi/types/model_based_condition.rb @@ -5,6 +5,8 @@ module Vapi class ModelBasedCondition + # @return [String] This condition is based on a model. + attr_reader :type # @return [String] This is the instruction which should output a boolean value when passed to a # model. # You can reference any variable in the context of the current block execution @@ -46,6 +48,7 @@ class ModelBasedCondition OMIT = Object.new + # @param type [String] This condition is based on a model. # @param instruction [String] This is the instruction which should output a boolean value when passed to a # model. # You can reference any variable in the context of the current block execution @@ -80,10 +83,11 @@ class ModelBasedCondition # blocks outside of a workflow with steps. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ModelBasedCondition] - def initialize(instruction:, additional_properties: nil) + def initialize(type:, instruction:, additional_properties: nil) + @type = type @instruction = instruction @additional_properties = additional_properties - @_field_set = { "instruction": instruction } + @_field_set = { "type": type, "instruction": instruction } end # Deserialize a JSON object to an instance of ModelBasedCondition @@ -93,8 +97,13 @@ def initialize(instruction:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + type = parsed_json["type"] instruction = parsed_json["instruction"] - new(instruction: instruction, additional_properties: struct) + new( + type: type, + instruction: instruction, + additional_properties: struct + ) end # Serialize an instance of ModelBasedCondition to a JSON object @@ -111,6 +120,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.instruction.is_a?(String) != false || raise("Passed value for field obj.instruction is not the expected type, validation failed.") end end diff --git a/lib/vapi/types/model_cost.rb b/lib/vapi/types/model_cost.rb index 9e1fa28..c6d0710 100644 --- a/lib/vapi/types/model_cost.rb +++ b/lib/vapi/types/model_cost.rb @@ -5,6 +5,8 @@ module Vapi class ModelCost + # @return [String] This is the type of cost, always 'model' for this class. + attr_reader :type # @return [Hash{String => Object}] This is the model that was used during the call. # This matches one of the following: # - `call.assistant.model`, @@ -32,6 +34,7 @@ class ModelCost OMIT = Object.new + # @param type [String] This is the type of cost, always 'model' for this class. # @param model [Hash{String => Object}] This is the model that was used during the call. # This matches one of the following: # - `call.assistant.model`, @@ -49,13 +52,15 @@ class ModelCost # @param cost [Float] This is the cost of the component in USD. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ModelCost] - def initialize(model:, prompt_tokens:, completion_tokens:, cost:, additional_properties: nil) + def initialize(type:, model:, prompt_tokens:, completion_tokens:, cost:, additional_properties: nil) + @type = type @model = model @prompt_tokens = prompt_tokens @completion_tokens = completion_tokens @cost = cost @additional_properties = additional_properties @_field_set = { + "type": type, "model": model, "promptTokens": prompt_tokens, "completionTokens": completion_tokens, @@ -70,11 +75,13 @@ def initialize(model:, prompt_tokens:, completion_tokens:, cost:, additional_pro def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + type = parsed_json["type"] model = parsed_json["model"] prompt_tokens = parsed_json["promptTokens"] completion_tokens = parsed_json["completionTokens"] cost = parsed_json["cost"] new( + type: type, model: model, prompt_tokens: prompt_tokens, completion_tokens: completion_tokens, @@ -97,6 +104,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.model.is_a?(Hash) != false || raise("Passed value for field obj.model is not the expected type, validation failed.") obj.prompt_tokens.is_a?(Float) != false || raise("Passed value for field obj.prompt_tokens is not the expected type, validation failed.") obj.completion_tokens.is_a?(Float) != false || raise("Passed value for field obj.completion_tokens is not the expected type, validation failed.") diff --git a/lib/vapi/types/neets_voice.rb b/lib/vapi/types/neets_voice.rb index aed3e81..95fbe9e 100644 --- a/lib/vapi/types/neets_voice.rb +++ b/lib/vapi/types/neets_voice.rb @@ -11,6 +11,8 @@ class NeetsVoice # inputting it into the voice provider. # Default `false` because you can achieve better results with prompting the model. attr_reader :filler_injection_enabled + # @return [String] This is the voice provider that will be used. + attr_reader :provider # @return [Vapi::NeetsVoiceVoiceId] This is the provider-specific ID that will be used. attr_reader :voice_id # @return [Vapi::ChunkPlan] This is the plan for chunking the model output before it is sent to the voice @@ -27,18 +29,21 @@ class NeetsVoice # @param filler_injection_enabled [Boolean] This determines whether fillers are injected into the model output before # inputting it into the voice provider. # Default `false` because you can achieve better results with prompting the model. + # @param provider [String] This is the voice provider that will be used. # @param voice_id [Vapi::NeetsVoiceVoiceId] This is the provider-specific ID that will be used. # @param chunk_plan [Vapi::ChunkPlan] This is the plan for chunking the model output before it is sent to the voice # provider. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::NeetsVoice] - def initialize(voice_id:, filler_injection_enabled: OMIT, chunk_plan: OMIT, additional_properties: nil) + def initialize(provider:, voice_id:, filler_injection_enabled: OMIT, chunk_plan: OMIT, additional_properties: nil) @filler_injection_enabled = filler_injection_enabled if filler_injection_enabled != OMIT + @provider = provider @voice_id = voice_id @chunk_plan = chunk_plan if chunk_plan != OMIT @additional_properties = additional_properties @_field_set = { "fillerInjectionEnabled": filler_injection_enabled, + "provider": provider, "voiceId": voice_id, "chunkPlan": chunk_plan }.reject do |_k, v| @@ -54,6 +59,7 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) filler_injection_enabled = parsed_json["fillerInjectionEnabled"] + provider = parsed_json["provider"] if parsed_json["voiceId"].nil? voice_id = nil else @@ -68,6 +74,7 @@ def self.from_json(json_object:) end new( filler_injection_enabled: filler_injection_enabled, + provider: provider, voice_id: voice_id, chunk_plan: chunk_plan, additional_properties: struct @@ -89,6 +96,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.filler_injection_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.filler_injection_enabled is not the expected type, validation failed.") + obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") Vapi::NeetsVoiceVoiceId.validate_raw(obj: obj.voice_id) obj.chunk_plan.nil? || Vapi::ChunkPlan.validate_raw(obj: obj.chunk_plan) end diff --git a/lib/vapi/types/open_ai_model.rb b/lib/vapi/types/open_ai_model.rb index 71b3bbb..dda4040 100644 --- a/lib/vapi/types/open_ai_model.rb +++ b/lib/vapi/types/open_ai_model.rb @@ -20,6 +20,8 @@ class OpenAiModel # tools, use `tools`. # Both `tools` and `toolIds` can be used together. attr_reader :tool_ids + # @return [String] This is the provider that will be used for the model. + attr_reader :provider # @return [Vapi::OpenAiModelModel] This is the OpenAI model that will be used. attr_reader :model # @return [Array] These are the fallback models that will be used if the primary model fails. This @@ -63,6 +65,7 @@ class OpenAiModel # @param tool_ids [Array] These are the tools that the assistant can use during the call. To use transient # tools, use `tools`. # Both `tools` and `toolIds` can be used together. + # @param provider [String] This is the provider that will be used for the model. # @param model [Vapi::OpenAiModelModel] This is the OpenAI model that will be used. # @param fallback_models [Array] These are the fallback models that will be used if the primary model fails. This # shouldn't be specified unless you have a specific reason to do so. Vapi will @@ -85,11 +88,12 @@ class OpenAiModel # @default 0 # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::OpenAiModel] - def initialize(model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, fallback_models: OMIT, + def initialize(provider:, model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, fallback_models: OMIT, semantic_caching_enabled: OMIT, temperature: OMIT, knowledge_base: OMIT, max_tokens: OMIT, emotion_recognition_enabled: OMIT, num_fast_turns: OMIT, additional_properties: nil) @messages = messages if messages != OMIT @tools = tools if tools != OMIT @tool_ids = tool_ids if tool_ids != OMIT + @provider = provider @model = model @fallback_models = fallback_models if fallback_models != OMIT @semantic_caching_enabled = semantic_caching_enabled if semantic_caching_enabled != OMIT @@ -103,6 +107,7 @@ def initialize(model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, fallback_mod "messages": messages, "tools": tools, "toolIds": tool_ids, + "provider": provider, "model": model, "fallbackModels": fallback_models, "semanticCachingEnabled": semantic_caching_enabled, @@ -132,6 +137,7 @@ def self.from_json(json_object:) Vapi::OpenAiModelToolsItem.from_json(json_object: item) end tool_ids = parsed_json["toolIds"] + provider = parsed_json["provider"] model = parsed_json["model"] fallback_models = parsed_json["fallbackModels"] semantic_caching_enabled = parsed_json["semanticCachingEnabled"] @@ -149,6 +155,7 @@ def self.from_json(json_object:) messages: messages, tools: tools, tool_ids: tool_ids, + provider: provider, model: model, fallback_models: fallback_models, semantic_caching_enabled: semantic_caching_enabled, @@ -178,6 +185,7 @@ 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.tools&.is_a?(Array) != false || raise("Passed value for field obj.tools is not the expected type, validation failed.") obj.tool_ids&.is_a?(Array) != false || raise("Passed value for field obj.tool_ids is not the expected type, validation failed.") + obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") obj.model.is_a?(Vapi::OpenAiModelModel) != false || raise("Passed value for field obj.model is not the expected type, validation failed.") obj.fallback_models&.is_a?(Array) != false || raise("Passed value for field obj.fallback_models is not the expected type, validation failed.") obj.semantic_caching_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.semantic_caching_enabled is not the expected type, validation failed.") diff --git a/lib/vapi/types/open_ai_model_tools_item.rb b/lib/vapi/types/open_ai_model_tools_item.rb index 1444bbc..d801ff4 100644 --- a/lib/vapi/types/open_ai_model_tools_item.rb +++ b/lib/vapi/types/open_ai_model_tools_item.rb @@ -11,72 +11,69 @@ module Vapi class OpenAiModelToolsItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::OpenAiModelToolsItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of OpenAiModelToolsItem # # @param json_object [String] # @return [Vapi::OpenAiModelToolsItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "dtmf" - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - when "endCall" - Vapi::CreateEndCallToolDto.from_json(json_object: json_object) - when "voicemail" - Vapi::CreateVoicemailToolDto.from_json(json_object: json_object) - when "function" - Vapi::CreateFunctionToolDto.from_json(json_object: json_object) - when "ghl" - Vapi::CreateGhlToolDto.from_json(json_object: json_object) - when "make" - Vapi::CreateMakeToolDto.from_json(json_object: json_object) - when "transferCall" - Vapi::CreateTransferCallToolDto.from_json(json_object: json_object) - else - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::CreateDtmfToolDto.validate_raw(obj: struct) + return Vapi::CreateDtmfToolDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "dtmf" - { **@member.to_json, type: @discriminant }.to_json - when "endCall" - { **@member.to_json, type: @discriminant }.to_json - when "voicemail" - { **@member.to_json, type: @discriminant }.to_json - when "function" - { **@member.to_json, type: @discriminant }.to_json - when "ghl" - { **@member.to_json, type: @discriminant }.to_json - when "make" - { **@member.to_json, type: @discriminant }.to_json - when "transferCall" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateEndCallToolDto.validate_raw(obj: struct) + return Vapi::CreateEndCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVoicemailToolDto.validate_raw(obj: struct) + return Vapi::CreateVoicemailToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateFunctionToolDto.validate_raw(obj: struct) + return Vapi::CreateFunctionToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::CreateGhlToolDto.validate_raw(obj: struct) + return Vapi::CreateGhlToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateMakeToolDto.validate_raw(obj: struct) + return Vapi::CreateMakeToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTransferCallToolDto.validate_raw(obj: struct) + return Vapi::CreateTransferCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -86,74 +83,42 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "dtmf" - Vapi::CreateDtmfToolDto.validate_raw(obj: obj) - when "endCall" - Vapi::CreateEndCallToolDto.validate_raw(obj: obj) - when "voicemail" - Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) - when "function" - Vapi::CreateFunctionToolDto.validate_raw(obj: obj) - when "ghl" - Vapi::CreateGhlToolDto.validate_raw(obj: obj) - when "make" - Vapi::CreateMakeToolDto.validate_raw(obj: obj) - when "transferCall" - Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateDtmfToolDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateDtmfToolDto] - # @return [Vapi::OpenAiModelToolsItem] - def self.dtmf(member:) - new(member: member, discriminant: "dtmf") - end - - # @param member [Vapi::CreateEndCallToolDto] - # @return [Vapi::OpenAiModelToolsItem] - def self.end_call(member:) - new(member: member, discriminant: "endCall") - end - - # @param member [Vapi::CreateVoicemailToolDto] - # @return [Vapi::OpenAiModelToolsItem] - def self.voicemail(member:) - new(member: member, discriminant: "voicemail") - end - - # @param member [Vapi::CreateFunctionToolDto] - # @return [Vapi::OpenAiModelToolsItem] - def self.function(member:) - new(member: member, discriminant: "function") - end - - # @param member [Vapi::CreateGhlToolDto] - # @return [Vapi::OpenAiModelToolsItem] - def self.ghl(member:) - new(member: member, discriminant: "ghl") - end - - # @param member [Vapi::CreateMakeToolDto] - # @return [Vapi::OpenAiModelToolsItem] - def self.make(member:) - new(member: member, discriminant: "make") - end - - # @param member [Vapi::CreateTransferCallToolDto] - # @return [Vapi::OpenAiModelToolsItem] - def self.transfer_call(member:) - new(member: member, discriminant: "transferCall") + begin + return Vapi::CreateEndCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateFunctionToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateGhlToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateMakeToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/open_ai_voice.rb b/lib/vapi/types/open_ai_voice.rb index f72ece9..1fb89d2 100644 --- a/lib/vapi/types/open_ai_voice.rb +++ b/lib/vapi/types/open_ai_voice.rb @@ -11,6 +11,8 @@ class OpenAiVoice # inputting it into the voice provider. # Default `false` because you can achieve better results with prompting the model. attr_reader :filler_injection_enabled + # @return [String] This is the voice provider that will be used. + attr_reader :provider # @return [Vapi::OpenAiVoiceVoiceId] This is the provider-specific ID that will be used. attr_reader :voice_id # @return [Float] This is the speed multiplier that will be used. @@ -29,20 +31,24 @@ class OpenAiVoice # @param filler_injection_enabled [Boolean] This determines whether fillers are injected into the model output before # inputting it into the voice provider. # Default `false` because you can achieve better results with prompting the model. + # @param provider [String] This is the voice provider that will be used. # @param voice_id [Vapi::OpenAiVoiceVoiceId] This is the provider-specific ID that will be used. # @param speed [Float] This is the speed multiplier that will be used. # @param chunk_plan [Vapi::ChunkPlan] This is the plan for chunking the model output before it is sent to the voice # provider. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::OpenAiVoice] - def initialize(voice_id:, filler_injection_enabled: OMIT, speed: OMIT, chunk_plan: OMIT, additional_properties: nil) + def initialize(provider:, voice_id:, filler_injection_enabled: OMIT, speed: OMIT, chunk_plan: OMIT, + additional_properties: nil) @filler_injection_enabled = filler_injection_enabled if filler_injection_enabled != OMIT + @provider = provider @voice_id = voice_id @speed = speed if speed != OMIT @chunk_plan = chunk_plan if chunk_plan != OMIT @additional_properties = additional_properties @_field_set = { "fillerInjectionEnabled": filler_injection_enabled, + "provider": provider, "voiceId": voice_id, "speed": speed, "chunkPlan": chunk_plan @@ -59,6 +65,7 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) filler_injection_enabled = parsed_json["fillerInjectionEnabled"] + provider = parsed_json["provider"] voice_id = parsed_json["voiceId"] speed = parsed_json["speed"] if parsed_json["chunkPlan"].nil? @@ -69,6 +76,7 @@ def self.from_json(json_object:) end new( filler_injection_enabled: filler_injection_enabled, + provider: provider, voice_id: voice_id, speed: speed, chunk_plan: chunk_plan, @@ -91,6 +99,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.filler_injection_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.filler_injection_enabled is not the expected type, validation failed.") + obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") obj.voice_id.is_a?(Vapi::OpenAiVoiceVoiceId) != false || raise("Passed value for field obj.voice_id is not the expected type, validation failed.") obj.speed&.is_a?(Float) != false || raise("Passed value for field obj.speed is not the expected type, validation failed.") obj.chunk_plan.nil? || Vapi::ChunkPlan.validate_raw(obj: obj.chunk_plan) diff --git a/lib/vapi/types/open_router_model.rb b/lib/vapi/types/open_router_model.rb index 9146650..daf837d 100644 --- a/lib/vapi/types/open_router_model.rb +++ b/lib/vapi/types/open_router_model.rb @@ -18,6 +18,8 @@ class OpenRouterModel # tools, use `tools`. # Both `tools` and `toolIds` can be used together. attr_reader :tool_ids + # @return [String] + attr_reader :provider # @return [String] This is the name of the model. Ex. cognitivecomputations/dolphin-mixtral-8x7b attr_reader :model # @return [Float] This is the temperature that will be used for calls. Default is 0 to leverage @@ -55,6 +57,7 @@ class OpenRouterModel # @param tool_ids [Array] These are the tools that the assistant can use during the call. To use transient # tools, use `tools`. # Both `tools` and `toolIds` can be used together. + # @param provider [String] # @param model [String] This is the name of the model. Ex. cognitivecomputations/dolphin-mixtral-8x7b # @param temperature [Float] This is the temperature that will be used for calls. Default is 0 to leverage # caching for lower latency. @@ -73,11 +76,12 @@ class OpenRouterModel # @default 0 # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::OpenRouterModel] - def initialize(model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, temperature: OMIT, knowledge_base: OMIT, - max_tokens: OMIT, emotion_recognition_enabled: OMIT, num_fast_turns: OMIT, additional_properties: nil) + def initialize(provider:, model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, temperature: OMIT, + knowledge_base: OMIT, max_tokens: OMIT, emotion_recognition_enabled: OMIT, num_fast_turns: OMIT, additional_properties: nil) @messages = messages if messages != OMIT @tools = tools if tools != OMIT @tool_ids = tool_ids if tool_ids != OMIT + @provider = provider @model = model @temperature = temperature if temperature != OMIT @knowledge_base = knowledge_base if knowledge_base != OMIT @@ -89,6 +93,7 @@ def initialize(model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, temperature: "messages": messages, "tools": tools, "toolIds": tool_ids, + "provider": provider, "model": model, "temperature": temperature, "knowledgeBase": knowledge_base, @@ -116,6 +121,7 @@ def self.from_json(json_object:) Vapi::OpenRouterModelToolsItem.from_json(json_object: item) end tool_ids = parsed_json["toolIds"] + provider = parsed_json["provider"] model = parsed_json["model"] temperature = parsed_json["temperature"] if parsed_json["knowledgeBase"].nil? @@ -131,6 +137,7 @@ def self.from_json(json_object:) messages: messages, tools: tools, tool_ids: tool_ids, + provider: provider, model: model, temperature: temperature, knowledge_base: knowledge_base, @@ -158,6 +165,7 @@ 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.tools&.is_a?(Array) != false || raise("Passed value for field obj.tools is not the expected type, validation failed.") obj.tool_ids&.is_a?(Array) != false || raise("Passed value for field obj.tool_ids is not the expected type, validation failed.") + obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") obj.model.is_a?(String) != false || raise("Passed value for field obj.model is not the expected type, validation failed.") obj.temperature&.is_a?(Float) != false || raise("Passed value for field obj.temperature is not the expected type, validation failed.") obj.knowledge_base.nil? || Vapi::KnowledgeBase.validate_raw(obj: obj.knowledge_base) diff --git a/lib/vapi/types/open_router_model_tools_item.rb b/lib/vapi/types/open_router_model_tools_item.rb index 9b0e036..8f778da 100644 --- a/lib/vapi/types/open_router_model_tools_item.rb +++ b/lib/vapi/types/open_router_model_tools_item.rb @@ -11,72 +11,69 @@ module Vapi class OpenRouterModelToolsItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::OpenRouterModelToolsItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of OpenRouterModelToolsItem # # @param json_object [String] # @return [Vapi::OpenRouterModelToolsItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "dtmf" - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - when "endCall" - Vapi::CreateEndCallToolDto.from_json(json_object: json_object) - when "voicemail" - Vapi::CreateVoicemailToolDto.from_json(json_object: json_object) - when "function" - Vapi::CreateFunctionToolDto.from_json(json_object: json_object) - when "ghl" - Vapi::CreateGhlToolDto.from_json(json_object: json_object) - when "make" - Vapi::CreateMakeToolDto.from_json(json_object: json_object) - when "transferCall" - Vapi::CreateTransferCallToolDto.from_json(json_object: json_object) - else - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::CreateDtmfToolDto.validate_raw(obj: struct) + return Vapi::CreateDtmfToolDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "dtmf" - { **@member.to_json, type: @discriminant }.to_json - when "endCall" - { **@member.to_json, type: @discriminant }.to_json - when "voicemail" - { **@member.to_json, type: @discriminant }.to_json - when "function" - { **@member.to_json, type: @discriminant }.to_json - when "ghl" - { **@member.to_json, type: @discriminant }.to_json - when "make" - { **@member.to_json, type: @discriminant }.to_json - when "transferCall" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateEndCallToolDto.validate_raw(obj: struct) + return Vapi::CreateEndCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVoicemailToolDto.validate_raw(obj: struct) + return Vapi::CreateVoicemailToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateFunctionToolDto.validate_raw(obj: struct) + return Vapi::CreateFunctionToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::CreateGhlToolDto.validate_raw(obj: struct) + return Vapi::CreateGhlToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateMakeToolDto.validate_raw(obj: struct) + return Vapi::CreateMakeToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTransferCallToolDto.validate_raw(obj: struct) + return Vapi::CreateTransferCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -86,74 +83,42 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "dtmf" - Vapi::CreateDtmfToolDto.validate_raw(obj: obj) - when "endCall" - Vapi::CreateEndCallToolDto.validate_raw(obj: obj) - when "voicemail" - Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) - when "function" - Vapi::CreateFunctionToolDto.validate_raw(obj: obj) - when "ghl" - Vapi::CreateGhlToolDto.validate_raw(obj: obj) - when "make" - Vapi::CreateMakeToolDto.validate_raw(obj: obj) - when "transferCall" - Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateDtmfToolDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateDtmfToolDto] - # @return [Vapi::OpenRouterModelToolsItem] - def self.dtmf(member:) - new(member: member, discriminant: "dtmf") - end - - # @param member [Vapi::CreateEndCallToolDto] - # @return [Vapi::OpenRouterModelToolsItem] - def self.end_call(member:) - new(member: member, discriminant: "endCall") - end - - # @param member [Vapi::CreateVoicemailToolDto] - # @return [Vapi::OpenRouterModelToolsItem] - def self.voicemail(member:) - new(member: member, discriminant: "voicemail") - end - - # @param member [Vapi::CreateFunctionToolDto] - # @return [Vapi::OpenRouterModelToolsItem] - def self.function(member:) - new(member: member, discriminant: "function") - end - - # @param member [Vapi::CreateGhlToolDto] - # @return [Vapi::OpenRouterModelToolsItem] - def self.ghl(member:) - new(member: member, discriminant: "ghl") - end - - # @param member [Vapi::CreateMakeToolDto] - # @return [Vapi::OpenRouterModelToolsItem] - def self.make(member:) - new(member: member, discriminant: "make") - end - - # @param member [Vapi::CreateTransferCallToolDto] - # @return [Vapi::OpenRouterModelToolsItem] - def self.transfer_call(member:) - new(member: member, discriminant: "transferCall") + begin + return Vapi::CreateEndCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateFunctionToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateGhlToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateMakeToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/output_tool.rb b/lib/vapi/types/output_tool.rb index 48cfcd1..19e1f46 100644 --- a/lib/vapi/types/output_tool.rb +++ b/lib/vapi/types/output_tool.rb @@ -21,6 +21,8 @@ class OutputTool # `tool.destinations`. For others like the function tool, these can be custom # configured. attr_reader :messages + # @return [String] + attr_reader :type # @return [String] This is the unique identifier for the tool. attr_reader :id # @return [String] This is the unique identifier for the organization that this tool belongs to. @@ -64,6 +66,7 @@ class OutputTool # For some tools, this is auto-filled based on special fields like # `tool.destinations`. For others like the function tool, these can be custom # configured. + # @param type [String] # @param id [String] This is the unique identifier for the tool. # @param org_id [String] This is the unique identifier for the organization that this tool belongs to. # @param created_at [DateTime] This is the ISO 8601 date-time string of when the tool was created. @@ -85,10 +88,11 @@ class OutputTool # phoneNumber.serverUrl, then org.serverUrl. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::OutputTool] - def initialize(id:, org_id:, created_at:, updated_at:, async: OMIT, messages: OMIT, function: OMIT, server: OMIT, - additional_properties: nil) + def initialize(type:, id:, org_id:, created_at:, updated_at:, async: OMIT, messages: OMIT, function: OMIT, + server: OMIT, additional_properties: nil) @async = async if async != OMIT @messages = messages if messages != OMIT + @type = type @id = id @org_id = org_id @created_at = created_at @@ -99,6 +103,7 @@ def initialize(id:, org_id:, created_at:, updated_at:, async: OMIT, messages: OM @_field_set = { "async": async, "messages": messages, + "type": type, "id": id, "orgId": org_id, "createdAt": created_at, @@ -122,6 +127,7 @@ def self.from_json(json_object:) item = item.to_json Vapi::OutputToolMessagesItem.from_json(json_object: item) end + type = parsed_json["type"] id = parsed_json["id"] org_id = parsed_json["orgId"] created_at = (DateTime.parse(parsed_json["createdAt"]) unless parsed_json["createdAt"].nil?) @@ -141,6 +147,7 @@ def self.from_json(json_object:) new( async: async, messages: messages, + type: type, id: id, org_id: org_id, created_at: created_at, @@ -167,6 +174,7 @@ def to_json(*_args) def self.validate_raw(obj:) obj.async&.is_a?(Boolean) != false || raise("Passed value for field obj.async is not the expected type, validation failed.") obj.messages&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type 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.") diff --git a/lib/vapi/types/output_tool_messages_item.rb b/lib/vapi/types/output_tool_messages_item.rb index 7827eba..0df1277 100644 --- a/lib/vapi/types/output_tool_messages_item.rb +++ b/lib/vapi/types/output_tool_messages_item.rb @@ -8,60 +8,45 @@ module Vapi class OutputToolMessagesItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::OutputToolMessagesItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of OutputToolMessagesItem # # @param json_object [String] # @return [Vapi::OutputToolMessagesItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "request-start" - Vapi::ToolMessageStart.from_json(json_object: json_object) - when "request-complete" - Vapi::ToolMessageComplete.from_json(json_object: json_object) - when "request-failed" - Vapi::ToolMessageFailed.from_json(json_object: json_object) - when "request-response-delayed" - Vapi::ToolMessageDelayed.from_json(json_object: json_object) - else - Vapi::ToolMessageStart.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ToolMessageStart.validate_raw(obj: struct) + return Vapi::ToolMessageStart.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "request-start" - { **@member.to_json, type: @discriminant }.to_json - when "request-complete" - { **@member.to_json, type: @discriminant }.to_json - when "request-failed" - { **@member.to_json, type: @discriminant }.to_json - when "request-response-delayed" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageComplete.validate_raw(obj: struct) + return Vapi::ToolMessageComplete.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageFailed.validate_raw(obj: struct) + return Vapi::ToolMessageFailed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageDelayed.validate_raw(obj: struct) + return Vapi::ToolMessageDelayed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -71,50 +56,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "request-start" - Vapi::ToolMessageStart.validate_raw(obj: obj) - when "request-complete" - Vapi::ToolMessageComplete.validate_raw(obj: obj) - when "request-failed" - Vapi::ToolMessageFailed.validate_raw(obj: obj) - when "request-response-delayed" - Vapi::ToolMessageDelayed.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ToolMessageStart.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ToolMessageStart] - # @return [Vapi::OutputToolMessagesItem] - def self.request_start(member:) - new(member: member, discriminant: "request-start") - end - - # @param member [Vapi::ToolMessageComplete] - # @return [Vapi::OutputToolMessagesItem] - def self.request_complete(member:) - new(member: member, discriminant: "request-complete") - end - - # @param member [Vapi::ToolMessageFailed] - # @return [Vapi::OutputToolMessagesItem] - def self.request_failed(member:) - new(member: member, discriminant: "request-failed") - end - - # @param member [Vapi::ToolMessageDelayed] - # @return [Vapi::OutputToolMessagesItem] - def self.request_response_delayed(member:) - new(member: member, discriminant: "request-response-delayed") + begin + return Vapi::ToolMessageComplete.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageFailed.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageDelayed.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/perplexity_ai_model.rb b/lib/vapi/types/perplexity_ai_model.rb index 9cc780c..769a997 100644 --- a/lib/vapi/types/perplexity_ai_model.rb +++ b/lib/vapi/types/perplexity_ai_model.rb @@ -18,6 +18,8 @@ class PerplexityAiModel # tools, use `tools`. # Both `tools` and `toolIds` can be used together. attr_reader :tool_ids + # @return [String] + attr_reader :provider # @return [String] This is the name of the model. Ex. cognitivecomputations/dolphin-mixtral-8x7b attr_reader :model # @return [Float] This is the temperature that will be used for calls. Default is 0 to leverage @@ -55,6 +57,7 @@ class PerplexityAiModel # @param tool_ids [Array] These are the tools that the assistant can use during the call. To use transient # tools, use `tools`. # Both `tools` and `toolIds` can be used together. + # @param provider [String] # @param model [String] This is the name of the model. Ex. cognitivecomputations/dolphin-mixtral-8x7b # @param temperature [Float] This is the temperature that will be used for calls. Default is 0 to leverage # caching for lower latency. @@ -73,11 +76,12 @@ class PerplexityAiModel # @default 0 # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::PerplexityAiModel] - def initialize(model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, temperature: OMIT, knowledge_base: OMIT, - max_tokens: OMIT, emotion_recognition_enabled: OMIT, num_fast_turns: OMIT, additional_properties: nil) + def initialize(provider:, model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, temperature: OMIT, + knowledge_base: OMIT, max_tokens: OMIT, emotion_recognition_enabled: OMIT, num_fast_turns: OMIT, additional_properties: nil) @messages = messages if messages != OMIT @tools = tools if tools != OMIT @tool_ids = tool_ids if tool_ids != OMIT + @provider = provider @model = model @temperature = temperature if temperature != OMIT @knowledge_base = knowledge_base if knowledge_base != OMIT @@ -89,6 +93,7 @@ def initialize(model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, temperature: "messages": messages, "tools": tools, "toolIds": tool_ids, + "provider": provider, "model": model, "temperature": temperature, "knowledgeBase": knowledge_base, @@ -116,6 +121,7 @@ def self.from_json(json_object:) Vapi::PerplexityAiModelToolsItem.from_json(json_object: item) end tool_ids = parsed_json["toolIds"] + provider = parsed_json["provider"] model = parsed_json["model"] temperature = parsed_json["temperature"] if parsed_json["knowledgeBase"].nil? @@ -131,6 +137,7 @@ def self.from_json(json_object:) messages: messages, tools: tools, tool_ids: tool_ids, + provider: provider, model: model, temperature: temperature, knowledge_base: knowledge_base, @@ -158,6 +165,7 @@ 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.tools&.is_a?(Array) != false || raise("Passed value for field obj.tools is not the expected type, validation failed.") obj.tool_ids&.is_a?(Array) != false || raise("Passed value for field obj.tool_ids is not the expected type, validation failed.") + obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") obj.model.is_a?(String) != false || raise("Passed value for field obj.model is not the expected type, validation failed.") obj.temperature&.is_a?(Float) != false || raise("Passed value for field obj.temperature is not the expected type, validation failed.") obj.knowledge_base.nil? || Vapi::KnowledgeBase.validate_raw(obj: obj.knowledge_base) diff --git a/lib/vapi/types/perplexity_ai_model_tools_item.rb b/lib/vapi/types/perplexity_ai_model_tools_item.rb index 08d76b3..2f9084a 100644 --- a/lib/vapi/types/perplexity_ai_model_tools_item.rb +++ b/lib/vapi/types/perplexity_ai_model_tools_item.rb @@ -11,72 +11,69 @@ module Vapi class PerplexityAiModelToolsItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::PerplexityAiModelToolsItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of PerplexityAiModelToolsItem # # @param json_object [String] # @return [Vapi::PerplexityAiModelToolsItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "dtmf" - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - when "endCall" - Vapi::CreateEndCallToolDto.from_json(json_object: json_object) - when "voicemail" - Vapi::CreateVoicemailToolDto.from_json(json_object: json_object) - when "function" - Vapi::CreateFunctionToolDto.from_json(json_object: json_object) - when "ghl" - Vapi::CreateGhlToolDto.from_json(json_object: json_object) - when "make" - Vapi::CreateMakeToolDto.from_json(json_object: json_object) - when "transferCall" - Vapi::CreateTransferCallToolDto.from_json(json_object: json_object) - else - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::CreateDtmfToolDto.validate_raw(obj: struct) + return Vapi::CreateDtmfToolDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "dtmf" - { **@member.to_json, type: @discriminant }.to_json - when "endCall" - { **@member.to_json, type: @discriminant }.to_json - when "voicemail" - { **@member.to_json, type: @discriminant }.to_json - when "function" - { **@member.to_json, type: @discriminant }.to_json - when "ghl" - { **@member.to_json, type: @discriminant }.to_json - when "make" - { **@member.to_json, type: @discriminant }.to_json - when "transferCall" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateEndCallToolDto.validate_raw(obj: struct) + return Vapi::CreateEndCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVoicemailToolDto.validate_raw(obj: struct) + return Vapi::CreateVoicemailToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateFunctionToolDto.validate_raw(obj: struct) + return Vapi::CreateFunctionToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::CreateGhlToolDto.validate_raw(obj: struct) + return Vapi::CreateGhlToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateMakeToolDto.validate_raw(obj: struct) + return Vapi::CreateMakeToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTransferCallToolDto.validate_raw(obj: struct) + return Vapi::CreateTransferCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -86,74 +83,42 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "dtmf" - Vapi::CreateDtmfToolDto.validate_raw(obj: obj) - when "endCall" - Vapi::CreateEndCallToolDto.validate_raw(obj: obj) - when "voicemail" - Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) - when "function" - Vapi::CreateFunctionToolDto.validate_raw(obj: obj) - when "ghl" - Vapi::CreateGhlToolDto.validate_raw(obj: obj) - when "make" - Vapi::CreateMakeToolDto.validate_raw(obj: obj) - when "transferCall" - Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateDtmfToolDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateDtmfToolDto] - # @return [Vapi::PerplexityAiModelToolsItem] - def self.dtmf(member:) - new(member: member, discriminant: "dtmf") - end - - # @param member [Vapi::CreateEndCallToolDto] - # @return [Vapi::PerplexityAiModelToolsItem] - def self.end_call(member:) - new(member: member, discriminant: "endCall") - end - - # @param member [Vapi::CreateVoicemailToolDto] - # @return [Vapi::PerplexityAiModelToolsItem] - def self.voicemail(member:) - new(member: member, discriminant: "voicemail") - end - - # @param member [Vapi::CreateFunctionToolDto] - # @return [Vapi::PerplexityAiModelToolsItem] - def self.function(member:) - new(member: member, discriminant: "function") - end - - # @param member [Vapi::CreateGhlToolDto] - # @return [Vapi::PerplexityAiModelToolsItem] - def self.ghl(member:) - new(member: member, discriminant: "ghl") - end - - # @param member [Vapi::CreateMakeToolDto] - # @return [Vapi::PerplexityAiModelToolsItem] - def self.make(member:) - new(member: member, discriminant: "make") - end - - # @param member [Vapi::CreateTransferCallToolDto] - # @return [Vapi::PerplexityAiModelToolsItem] - def self.transfer_call(member:) - new(member: member, discriminant: "transferCall") + begin + return Vapi::CreateEndCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateFunctionToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateGhlToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateMakeToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/play_ht_voice.rb b/lib/vapi/types/play_ht_voice.rb index 2a96702..279209d 100644 --- a/lib/vapi/types/play_ht_voice.rb +++ b/lib/vapi/types/play_ht_voice.rb @@ -12,6 +12,8 @@ class PlayHtVoice # inputting it into the voice provider. # Default `false` because you can achieve better results with prompting the model. attr_reader :filler_injection_enabled + # @return [String] This is the voice provider that will be used. + attr_reader :provider # @return [Vapi::PlayHtVoiceVoiceId] This is the provider-specific ID that will be used. attr_reader :voice_id # @return [Float] This is the speed multiplier that will be used. @@ -50,6 +52,7 @@ class PlayHtVoice # @param filler_injection_enabled [Boolean] This determines whether fillers are injected into the model output before # inputting it into the voice provider. # Default `false` because you can achieve better results with prompting the model. + # @param provider [String] This is the voice provider that will be used. # @param voice_id [Vapi::PlayHtVoiceVoiceId] This is the provider-specific ID that will be used. # @param speed [Float] This is the speed multiplier that will be used. # @param temperature [Float] A floating point number between 0, exclusive, and 2, inclusive. If equal to null @@ -71,9 +74,10 @@ class PlayHtVoice # provider. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::PlayHtVoice] - def initialize(voice_id:, filler_injection_enabled: OMIT, speed: OMIT, temperature: OMIT, emotion: OMIT, + def initialize(provider:, voice_id:, filler_injection_enabled: OMIT, speed: OMIT, temperature: OMIT, emotion: OMIT, voice_guidance: OMIT, style_guidance: OMIT, text_guidance: OMIT, chunk_plan: OMIT, additional_properties: nil) @filler_injection_enabled = filler_injection_enabled if filler_injection_enabled != OMIT + @provider = provider @voice_id = voice_id @speed = speed if speed != OMIT @temperature = temperature if temperature != OMIT @@ -85,6 +89,7 @@ def initialize(voice_id:, filler_injection_enabled: OMIT, speed: OMIT, temperatu @additional_properties = additional_properties @_field_set = { "fillerInjectionEnabled": filler_injection_enabled, + "provider": provider, "voiceId": voice_id, "speed": speed, "temperature": temperature, @@ -106,6 +111,7 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) filler_injection_enabled = parsed_json["fillerInjectionEnabled"] + provider = parsed_json["provider"] if parsed_json["voiceId"].nil? voice_id = nil else @@ -126,6 +132,7 @@ def self.from_json(json_object:) end new( filler_injection_enabled: filler_injection_enabled, + provider: provider, voice_id: voice_id, speed: speed, temperature: temperature, @@ -153,6 +160,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.filler_injection_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.filler_injection_enabled is not the expected type, validation failed.") + obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") Vapi::PlayHtVoiceVoiceId.validate_raw(obj: obj.voice_id) obj.speed&.is_a?(Float) != false || raise("Passed value for field obj.speed is not the expected type, validation failed.") obj.temperature&.is_a?(Float) != false || raise("Passed value for field obj.temperature is not the expected type, validation failed.") diff --git a/lib/vapi/types/chunk_plan_punctuation_boundaries_item.rb b/lib/vapi/types/punctuation_boundary.rb similarity index 85% rename from lib/vapi/types/chunk_plan_punctuation_boundaries_item.rb rename to lib/vapi/types/punctuation_boundary.rb index 8b9f6e4..cd90d08 100644 --- a/lib/vapi/types/chunk_plan_punctuation_boundaries_item.rb +++ b/lib/vapi/types/punctuation_boundary.rb @@ -1,9 +1,9 @@ # frozen_string_literal: true module Vapi - class ChunkPlanPunctuationBoundariesItem + class PunctuationBoundary CIRCLE = "。" - COMMA = "," + FULL_WIDTH_COMMA = "," DOT = "." EXCLAMATION = "!" QUESTION = "?" diff --git a/lib/vapi/types/regex_replacement.rb b/lib/vapi/types/regex_replacement.rb index b211c4d..be99a71 100644 --- a/lib/vapi/types/regex_replacement.rb +++ b/lib/vapi/types/regex_replacement.rb @@ -6,6 +6,20 @@ module Vapi class RegexReplacement + # @return [String] This is the regex replacement type. You can use this to replace a word or phrase + # that matches a pattern. + # Usage: + # - Replace all numbers with "some number": { type: 'regex', regex: '\\d+', value: + # 'some number' } + # - Replace email addresses with "[EMAIL]": { type: 'regex', regex: + # '\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Z|a-z]{2,}\\b', value: '[EMAIL]' } + # - Replace phone numbers with a formatted version: { type: 'regex', regex: + # '(\\d{3})(\\d{3})(\\d{4})', value: '($1) $2-$3' } + # - Replace all instances of "color" or "colour" with "hue": { type: 'regex', + # regex: 'colou?r', value: 'hue' } + # - Capitalize the first letter of every sentence: { type: 'regex', regex: + # '(?<=\\. |^)[a-z]', value: (match) => match.toUpperCase() } + attr_reader :type # @return [String] This is the regex pattern to replace. attr_reader :regex # @return [Array] These are the options for the regex replacement. Default all options are @@ -22,6 +36,19 @@ class RegexReplacement OMIT = Object.new + # @param type [String] This is the regex replacement type. You can use this to replace a word or phrase + # that matches a pattern. + # Usage: + # - Replace all numbers with "some number": { type: 'regex', regex: '\\d+', value: + # 'some number' } + # - Replace email addresses with "[EMAIL]": { type: 'regex', regex: + # '\\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Z|a-z]{2,}\\b', value: '[EMAIL]' } + # - Replace phone numbers with a formatted version: { type: 'regex', regex: + # '(\\d{3})(\\d{3})(\\d{4})', value: '($1) $2-$3' } + # - Replace all instances of "color" or "colour" with "hue": { type: 'regex', + # regex: 'colou?r', value: 'hue' } + # - Capitalize the first letter of every sentence: { type: 'regex', regex: + # '(?<=\\. |^)[a-z]', value: (match) => match.toUpperCase() } # @param regex [String] This is the regex pattern to replace. # @param options [Array] These are the options for the regex replacement. Default all options are # disabled. @@ -29,12 +56,13 @@ class RegexReplacement # @param value [String] This is the value that will replace the match. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::RegexReplacement] - def initialize(regex:, value:, options: OMIT, additional_properties: nil) + def initialize(type:, regex:, value:, options: OMIT, additional_properties: nil) + @type = type @regex = regex @options = options if options != OMIT @value = value @additional_properties = additional_properties - @_field_set = { "regex": regex, "options": options, "value": value }.reject do |_k, v| + @_field_set = { "type": type, "regex": regex, "options": options, "value": value }.reject do |_k, v| v == OMIT end end @@ -46,6 +74,7 @@ def initialize(regex:, value:, options: OMIT, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + type = parsed_json["type"] regex = parsed_json["regex"] options = parsed_json["options"]&.map do |item| item = item.to_json @@ -53,6 +82,7 @@ def self.from_json(json_object:) end value = parsed_json["value"] new( + type: type, regex: regex, options: options, value: value, @@ -74,6 +104,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.regex.is_a?(String) != false || raise("Passed value for field obj.regex is not the expected type, validation failed.") obj.options&.is_a?(Array) != false || raise("Passed value for field obj.options is not the expected type, validation failed.") obj.value.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.") diff --git a/lib/vapi/types/rime_ai_voice.rb b/lib/vapi/types/rime_ai_voice.rb index 6f847d5..4a12985 100644 --- a/lib/vapi/types/rime_ai_voice.rb +++ b/lib/vapi/types/rime_ai_voice.rb @@ -12,6 +12,8 @@ class RimeAiVoice # inputting it into the voice provider. # Default `false` because you can achieve better results with prompting the model. attr_reader :filler_injection_enabled + # @return [String] This is the voice provider that will be used. + attr_reader :provider # @return [Vapi::RimeAiVoiceVoiceId] This is the provider-specific ID that will be used. attr_reader :voice_id # @return [Vapi::RimeAiVoiceModel] This is the model that will be used. Defaults to 'v1' when not specified. @@ -32,6 +34,7 @@ class RimeAiVoice # @param filler_injection_enabled [Boolean] This determines whether fillers are injected into the model output before # inputting it into the voice provider. # Default `false` because you can achieve better results with prompting the model. + # @param provider [String] This is the voice provider that will be used. # @param voice_id [Vapi::RimeAiVoiceVoiceId] This is the provider-specific ID that will be used. # @param model [Vapi::RimeAiVoiceModel] This is the model that will be used. Defaults to 'v1' when not specified. # @param speed [Float] This is the speed multiplier that will be used. @@ -39,9 +42,10 @@ class RimeAiVoice # provider. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::RimeAiVoice] - def initialize(voice_id:, filler_injection_enabled: OMIT, model: OMIT, speed: OMIT, chunk_plan: OMIT, + def initialize(provider:, voice_id:, filler_injection_enabled: OMIT, model: OMIT, speed: OMIT, chunk_plan: OMIT, additional_properties: nil) @filler_injection_enabled = filler_injection_enabled if filler_injection_enabled != OMIT + @provider = provider @voice_id = voice_id @model = model if model != OMIT @speed = speed if speed != OMIT @@ -49,6 +53,7 @@ def initialize(voice_id:, filler_injection_enabled: OMIT, model: OMIT, speed: OM @additional_properties = additional_properties @_field_set = { "fillerInjectionEnabled": filler_injection_enabled, + "provider": provider, "voiceId": voice_id, "model": model, "speed": speed, @@ -66,6 +71,7 @@ def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) filler_injection_enabled = parsed_json["fillerInjectionEnabled"] + provider = parsed_json["provider"] if parsed_json["voiceId"].nil? voice_id = nil else @@ -82,6 +88,7 @@ def self.from_json(json_object:) end new( filler_injection_enabled: filler_injection_enabled, + provider: provider, voice_id: voice_id, model: model, speed: speed, @@ -105,6 +112,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.filler_injection_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.filler_injection_enabled is not the expected type, validation failed.") + obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") Vapi::RimeAiVoiceVoiceId.validate_raw(obj: obj.voice_id) obj.model&.is_a?(Vapi::RimeAiVoiceModel) != false || raise("Passed value for field obj.model is not the expected type, validation failed.") obj.speed&.is_a?(Float) != false || raise("Passed value for field obj.speed is not the expected type, validation failed.") diff --git a/lib/vapi/types/rule_based_condition.rb b/lib/vapi/types/rule_based_condition.rb index d2f8c91..5fd8e8a 100644 --- a/lib/vapi/types/rule_based_condition.rb +++ b/lib/vapi/types/rule_based_condition.rb @@ -6,6 +6,8 @@ module Vapi class RuleBasedCondition + # @return [String] This condition is based on a strict rule. + attr_reader :type # @return [Vapi::RuleBasedConditionOperator] This is the operator you want to use to compare the left side and right side. # The operation becomes `(leftSide) operator (rightSide)`. attr_reader :operator @@ -81,6 +83,7 @@ class RuleBasedCondition OMIT = Object.new + # @param type [String] This condition is based on a strict rule. # @param operator [Vapi::RuleBasedConditionOperator] This is the operator you want to use to compare the left side and right side. # The operation becomes `(leftSide) operator (rightSide)`. # @param left_side [String] This is the left side of the operation. @@ -147,12 +150,13 @@ class RuleBasedCondition # blocks outside of a workflow with steps. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::RuleBasedCondition] - def initialize(operator:, left_side:, right_side:, additional_properties: nil) + def initialize(type:, operator:, left_side:, right_side:, additional_properties: nil) + @type = type @operator = operator @left_side = left_side @right_side = right_side @additional_properties = additional_properties - @_field_set = { "operator": operator, "leftSide": left_side, "rightSide": right_side } + @_field_set = { "type": type, "operator": operator, "leftSide": left_side, "rightSide": right_side } end # Deserialize a JSON object to an instance of RuleBasedCondition @@ -162,10 +166,12 @@ def initialize(operator:, left_side:, right_side:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + type = parsed_json["type"] operator = parsed_json["operator"] left_side = parsed_json["leftSide"] right_side = parsed_json["rightSide"] new( + type: type, operator: operator, left_side: left_side, right_side: right_side, @@ -187,6 +193,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.operator.is_a?(Vapi::RuleBasedConditionOperator) != false || raise("Passed value for field obj.operator is not the expected type, validation failed.") obj.left_side.is_a?(String) != false || raise("Passed value for field obj.left_side is not the expected type, validation failed.") obj.right_side.is_a?(String) != false || raise("Passed value for field obj.right_side is not the expected type, validation failed.") diff --git a/lib/vapi/types/server_message_assistant_request.rb b/lib/vapi/types/server_message_assistant_request.rb index 8eb12de..71671c6 100644 --- a/lib/vapi/types/server_message_assistant_request.rb +++ b/lib/vapi/types/server_message_assistant_request.rb @@ -15,6 +15,9 @@ class ServerMessageAssistantRequest # - `call.phoneNumber`, # - `call.phoneNumberId`. attr_reader :phone_number + # @return [String] This is the type of the message. "assistant-request" is sent to fetch assistant + # configuration for an incoming call. + attr_reader :type # @return [String] This is the ISO-8601 formatted timestamp of when the message was sent. attr_reader :timestamp # @return [Vapi::Artifact] This is a live version of the `call.artifact`. @@ -52,6 +55,8 @@ class ServerMessageAssistantRequest # This matches one of the following: # - `call.phoneNumber`, # - `call.phoneNumberId`. + # @param type [String] This is the type of the message. "assistant-request" is sent to fetch assistant + # configuration for an incoming call. # @param timestamp [String] This is the ISO-8601 formatted timestamp of when the message was sent. # @param artifact [Vapi::Artifact] This is a live version of the `call.artifact`. # This matches what is stored on `call.artifact` after the call. @@ -74,9 +79,10 @@ class ServerMessageAssistantRequest # especially after the call is ended, use GET /call/:id. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ServerMessageAssistantRequest] - def initialize(phone_number: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, customer: OMIT, call: OMIT, - additional_properties: nil) + def initialize(type:, phone_number: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, customer: OMIT, + call: OMIT, additional_properties: nil) @phone_number = phone_number if phone_number != OMIT + @type = type @timestamp = timestamp if timestamp != OMIT @artifact = artifact if artifact != OMIT @assistant = assistant if assistant != OMIT @@ -85,6 +91,7 @@ def initialize(phone_number: OMIT, timestamp: OMIT, artifact: OMIT, assistant: O @additional_properties = additional_properties @_field_set = { "phoneNumber": phone_number, + "type": type, "timestamp": timestamp, "artifact": artifact, "assistant": assistant, @@ -108,6 +115,7 @@ def self.from_json(json_object:) phone_number = parsed_json["phoneNumber"].to_json phone_number = Vapi::ServerMessageAssistantRequestPhoneNumber.from_json(json_object: phone_number) end + type = parsed_json["type"] timestamp = parsed_json["timestamp"] if parsed_json["artifact"].nil? artifact = nil @@ -135,6 +143,7 @@ def self.from_json(json_object:) end new( phone_number: phone_number, + type: type, timestamp: timestamp, artifact: artifact, assistant: assistant, @@ -159,6 +168,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.phone_number.nil? || Vapi::ServerMessageAssistantRequestPhoneNumber.validate_raw(obj: obj.phone_number) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.timestamp&.is_a?(String) != false || raise("Passed value for field obj.timestamp is not the expected type, validation failed.") obj.artifact.nil? || Vapi::Artifact.validate_raw(obj: obj.artifact) obj.assistant.nil? || Vapi::CreateAssistantDto.validate_raw(obj: obj.assistant) diff --git a/lib/vapi/types/server_message_assistant_request_phone_number.rb b/lib/vapi/types/server_message_assistant_request_phone_number.rb index cfd86b7..35b6e4a 100644 --- a/lib/vapi/types/server_message_assistant_request_phone_number.rb +++ b/lib/vapi/types/server_message_assistant_request_phone_number.rb @@ -12,22 +12,6 @@ module Vapi # - `call.phoneNumber`, # - `call.phoneNumberId`. class ServerMessageAssistantRequestPhoneNumber - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ServerMessageAssistantRequestPhoneNumber] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of # ServerMessageAssistantRequestPhoneNumber # @@ -35,38 +19,39 @@ def initialize(member:, discriminant:) # @return [Vapi::ServerMessageAssistantRequestPhoneNumber] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: json_object) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.from_json(json_object: json_object) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.from_json(json_object: json_object) - else - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end + begin + Vapi::CreateByoPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateByoPhoneNumberDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "byo-phone-number" - { **@member.to_json, provider: @discriminant }.to_json - when "twilio" - { **@member.to_json, provider: @discriminant }.to_json - when "vonage" - { **@member.to_json, provider: @discriminant }.to_json - when "vapi" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVonagePhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVapiPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -76,50 +61,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateByoPhoneNumberDto] - # @return [Vapi::ServerMessageAssistantRequestPhoneNumber] - def self.byo_phone_number(member:) - new(member: member, discriminant: "byo-phone-number") - end - - # @param member [Vapi::CreateTwilioPhoneNumberDto] - # @return [Vapi::ServerMessageAssistantRequestPhoneNumber] - def self.twilio(member:) - new(member: member, discriminant: "twilio") - end - - # @param member [Vapi::CreateVonagePhoneNumberDto] - # @return [Vapi::ServerMessageAssistantRequestPhoneNumber] - def self.vonage(member:) - new(member: member, discriminant: "vonage") - end - - # @param member [Vapi::CreateVapiPhoneNumberDto] - # @return [Vapi::ServerMessageAssistantRequestPhoneNumber] - def self.vapi(member:) - new(member: member, discriminant: "vapi") + begin + return Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/server_message_conversation_update.rb b/lib/vapi/types/server_message_conversation_update.rb index 3068ad7..7fd98ba 100644 --- a/lib/vapi/types/server_message_conversation_update.rb +++ b/lib/vapi/types/server_message_conversation_update.rb @@ -17,6 +17,9 @@ class ServerMessageConversationUpdate # - `call.phoneNumber`, # - `call.phoneNumberId`. attr_reader :phone_number + # @return [String] This is the type of the message. "conversation-update" is sent when an update is + # committed to the conversation history. + attr_reader :type # @return [Array] This is the most up-to-date conversation history at the time the message is # sent. attr_reader :messages @@ -60,6 +63,8 @@ class ServerMessageConversationUpdate # This matches one of the following: # - `call.phoneNumber`, # - `call.phoneNumberId`. + # @param type [String] This is the type of the message. "conversation-update" is sent when an update is + # committed to the conversation history. # @param messages [Array] This is the most up-to-date conversation history at the time the message is # sent. # @param messages_open_ai_formatted [Array] This is the most up-to-date conversation history at the time the message is @@ -86,9 +91,10 @@ class ServerMessageConversationUpdate # especially after the call is ended, use GET /call/:id. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ServerMessageConversationUpdate] - def initialize(messages_open_ai_formatted:, phone_number: OMIT, messages: OMIT, timestamp: OMIT, artifact: OMIT, - assistant: OMIT, customer: OMIT, call: OMIT, additional_properties: nil) + def initialize(type:, messages_open_ai_formatted:, phone_number: OMIT, messages: OMIT, timestamp: OMIT, + artifact: OMIT, assistant: OMIT, customer: OMIT, call: OMIT, additional_properties: nil) @phone_number = phone_number if phone_number != OMIT + @type = type @messages = messages if messages != OMIT @messages_open_ai_formatted = messages_open_ai_formatted @timestamp = timestamp if timestamp != OMIT @@ -99,6 +105,7 @@ def initialize(messages_open_ai_formatted:, phone_number: OMIT, messages: OMIT, @additional_properties = additional_properties @_field_set = { "phoneNumber": phone_number, + "type": type, "messages": messages, "messagesOpenAIFormatted": messages_open_ai_formatted, "timestamp": timestamp, @@ -124,6 +131,7 @@ def self.from_json(json_object:) phone_number = parsed_json["phoneNumber"].to_json phone_number = Vapi::ServerMessageConversationUpdatePhoneNumber.from_json(json_object: phone_number) end + type = parsed_json["type"] messages = parsed_json["messages"]&.map do |item| item = item.to_json Vapi::ServerMessageConversationUpdateMessagesItem.from_json(json_object: item) @@ -159,6 +167,7 @@ def self.from_json(json_object:) end new( phone_number: phone_number, + type: type, messages: messages, messages_open_ai_formatted: messages_open_ai_formatted, timestamp: timestamp, @@ -185,6 +194,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.phone_number.nil? || Vapi::ServerMessageConversationUpdatePhoneNumber.validate_raw(obj: obj.phone_number) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.messages&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.") obj.messages_open_ai_formatted.is_a?(Array) != false || raise("Passed value for field obj.messages_open_ai_formatted is not the expected type, validation failed.") obj.timestamp&.is_a?(String) != false || raise("Passed value for field obj.timestamp is not the expected type, validation failed.") diff --git a/lib/vapi/types/server_message_conversation_update_phone_number.rb b/lib/vapi/types/server_message_conversation_update_phone_number.rb index 710438a..b6700b8 100644 --- a/lib/vapi/types/server_message_conversation_update_phone_number.rb +++ b/lib/vapi/types/server_message_conversation_update_phone_number.rb @@ -12,22 +12,6 @@ module Vapi # - `call.phoneNumber`, # - `call.phoneNumberId`. class ServerMessageConversationUpdatePhoneNumber - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ServerMessageConversationUpdatePhoneNumber] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of # ServerMessageConversationUpdatePhoneNumber # @@ -35,38 +19,39 @@ def initialize(member:, discriminant:) # @return [Vapi::ServerMessageConversationUpdatePhoneNumber] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: json_object) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.from_json(json_object: json_object) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.from_json(json_object: json_object) - else - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end + begin + Vapi::CreateByoPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateByoPhoneNumberDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "byo-phone-number" - { **@member.to_json, provider: @discriminant }.to_json - when "twilio" - { **@member.to_json, provider: @discriminant }.to_json - when "vonage" - { **@member.to_json, provider: @discriminant }.to_json - when "vapi" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVonagePhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVapiPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -76,50 +61,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateByoPhoneNumberDto] - # @return [Vapi::ServerMessageConversationUpdatePhoneNumber] - def self.byo_phone_number(member:) - new(member: member, discriminant: "byo-phone-number") - end - - # @param member [Vapi::CreateTwilioPhoneNumberDto] - # @return [Vapi::ServerMessageConversationUpdatePhoneNumber] - def self.twilio(member:) - new(member: member, discriminant: "twilio") - end - - # @param member [Vapi::CreateVonagePhoneNumberDto] - # @return [Vapi::ServerMessageConversationUpdatePhoneNumber] - def self.vonage(member:) - new(member: member, discriminant: "vonage") - end - - # @param member [Vapi::CreateVapiPhoneNumberDto] - # @return [Vapi::ServerMessageConversationUpdatePhoneNumber] - def self.vapi(member:) - new(member: member, discriminant: "vapi") + begin + return Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/server_message_end_of_call_report.rb b/lib/vapi/types/server_message_end_of_call_report.rb index a746ac4..72be699 100644 --- a/lib/vapi/types/server_message_end_of_call_report.rb +++ b/lib/vapi/types/server_message_end_of_call_report.rb @@ -19,6 +19,9 @@ class ServerMessageEndOfCallReport # - `call.phoneNumber`, # - `call.phoneNumberId`. attr_reader :phone_number + # @return [String] This is the type of the message. "end-of-call-report" is sent when the call ends + # and post-processing is complete. + attr_reader :type # @return [Vapi::ServerMessageEndOfCallReportEndedReason] This is the reason the call ended. This can also be found at `call.endedReason` # on GET /call/:id. attr_reader :ended_reason @@ -74,6 +77,8 @@ class ServerMessageEndOfCallReport # This matches one of the following: # - `call.phoneNumber`, # - `call.phoneNumberId`. + # @param type [String] This is the type of the message. "end-of-call-report" is sent when the call ends + # and post-processing is complete. # @param ended_reason [Vapi::ServerMessageEndOfCallReportEndedReason] This is the reason the call ended. This can also be found at `call.endedReason` # on GET /call/:id. # @param cost [Float] This is the cost of the call in USD. This can also be found at `call.cost` on @@ -108,9 +113,10 @@ class ServerMessageEndOfCallReport # found at `call.endedAt` on GET /call/:id. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ServerMessageEndOfCallReport] - def initialize(ended_reason:, artifact:, analysis:, phone_number: OMIT, cost: OMIT, costs: OMIT, timestamp: OMIT, + def initialize(type:, ended_reason:, artifact:, analysis:, phone_number: OMIT, cost: OMIT, costs: OMIT, timestamp: OMIT, assistant: OMIT, customer: OMIT, call: OMIT, started_at: OMIT, ended_at: OMIT, additional_properties: nil) @phone_number = phone_number if phone_number != OMIT + @type = type @ended_reason = ended_reason @cost = cost if cost != OMIT @costs = costs if costs != OMIT @@ -125,6 +131,7 @@ def initialize(ended_reason:, artifact:, analysis:, phone_number: OMIT, cost: OM @additional_properties = additional_properties @_field_set = { "phoneNumber": phone_number, + "type": type, "endedReason": ended_reason, "cost": cost, "costs": costs, @@ -154,6 +161,7 @@ def self.from_json(json_object:) phone_number = parsed_json["phoneNumber"].to_json phone_number = Vapi::ServerMessageEndOfCallReportPhoneNumber.from_json(json_object: phone_number) end + type = parsed_json["type"] ended_reason = parsed_json["endedReason"] cost = parsed_json["cost"] costs = parsed_json["costs"]&.map do |item| @@ -195,6 +203,7 @@ def self.from_json(json_object:) ended_at = (DateTime.parse(parsed_json["endedAt"]) unless parsed_json["endedAt"].nil?) new( phone_number: phone_number, + type: type, ended_reason: ended_reason, cost: cost, costs: costs, @@ -225,6 +234,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.phone_number.nil? || Vapi::ServerMessageEndOfCallReportPhoneNumber.validate_raw(obj: obj.phone_number) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.ended_reason.is_a?(Vapi::ServerMessageEndOfCallReportEndedReason) != false || raise("Passed value for field obj.ended_reason is not the expected type, validation failed.") obj.cost&.is_a?(Float) != false || raise("Passed value for field obj.cost is not the expected type, validation failed.") obj.costs&.is_a?(Array) != false || raise("Passed value for field obj.costs is not the expected type, validation failed.") diff --git a/lib/vapi/types/server_message_end_of_call_report_costs_item.rb b/lib/vapi/types/server_message_end_of_call_report_costs_item.rb index e951ddc..5f08673 100644 --- a/lib/vapi/types/server_message_end_of_call_report_costs_item.rb +++ b/lib/vapi/types/server_message_end_of_call_report_costs_item.rb @@ -10,22 +10,6 @@ module Vapi class ServerMessageEndOfCallReportCostsItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ServerMessageEndOfCallReportCostsItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of # ServerMessageEndOfCallReportCostsItem # @@ -33,46 +17,55 @@ def initialize(member:, discriminant:) # @return [Vapi::ServerMessageEndOfCallReportCostsItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "transport" - Vapi::TransportCost.from_json(json_object: json_object) - when "transcriber" - Vapi::TranscriberCost.from_json(json_object: json_object) - when "model" - Vapi::ModelCost.from_json(json_object: json_object) - when "voice" - Vapi::VoiceCost.from_json(json_object: json_object) - when "vapi" - Vapi::VapiCost.from_json(json_object: json_object) - when "analysis" - Vapi::AnalysisCost.from_json(json_object: json_object) - else - Vapi::TransportCost.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::TransportCost.validate_raw(obj: struct) + return Vapi::TransportCost.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "transport" - { **@member.to_json, type: @discriminant }.to_json - when "transcriber" - { **@member.to_json, type: @discriminant }.to_json - when "model" - { **@member.to_json, type: @discriminant }.to_json - when "voice" - { **@member.to_json, type: @discriminant }.to_json - when "vapi" - { **@member.to_json, type: @discriminant }.to_json - when "analysis" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::TranscriberCost.validate_raw(obj: struct) + return Vapi::TranscriberCost.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ModelCost.validate_raw(obj: struct) + return Vapi::ModelCost.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::VoiceCost.validate_raw(obj: struct) + return Vapi::VoiceCost.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::VapiCost.validate_raw(obj: struct) + return Vapi::VapiCost.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::AnalysisCost.validate_raw(obj: struct) + return Vapi::AnalysisCost.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -82,66 +75,37 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "transport" - Vapi::TransportCost.validate_raw(obj: obj) - when "transcriber" - Vapi::TranscriberCost.validate_raw(obj: obj) - when "model" - Vapi::ModelCost.validate_raw(obj: obj) - when "voice" - Vapi::VoiceCost.validate_raw(obj: obj) - when "vapi" - Vapi::VapiCost.validate_raw(obj: obj) - when "analysis" - Vapi::AnalysisCost.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::TransportCost.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::TransportCost] - # @return [Vapi::ServerMessageEndOfCallReportCostsItem] - def self.transport(member:) - new(member: member, discriminant: "transport") - end - - # @param member [Vapi::TranscriberCost] - # @return [Vapi::ServerMessageEndOfCallReportCostsItem] - def self.transcriber(member:) - new(member: member, discriminant: "transcriber") - end - - # @param member [Vapi::ModelCost] - # @return [Vapi::ServerMessageEndOfCallReportCostsItem] - def self.model(member:) - new(member: member, discriminant: "model") - end - - # @param member [Vapi::VoiceCost] - # @return [Vapi::ServerMessageEndOfCallReportCostsItem] - def self.voice(member:) - new(member: member, discriminant: "voice") - end - - # @param member [Vapi::VapiCost] - # @return [Vapi::ServerMessageEndOfCallReportCostsItem] - def self.vapi(member:) - new(member: member, discriminant: "vapi") - end - - # @param member [Vapi::AnalysisCost] - # @return [Vapi::ServerMessageEndOfCallReportCostsItem] - def self.analysis(member:) - new(member: member, discriminant: "analysis") + begin + return Vapi::TranscriberCost.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ModelCost.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::VoiceCost.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::VapiCost.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::AnalysisCost.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/server_message_end_of_call_report_phone_number.rb b/lib/vapi/types/server_message_end_of_call_report_phone_number.rb index d4fe1e8..852f2f6 100644 --- a/lib/vapi/types/server_message_end_of_call_report_phone_number.rb +++ b/lib/vapi/types/server_message_end_of_call_report_phone_number.rb @@ -12,22 +12,6 @@ module Vapi # - `call.phoneNumber`, # - `call.phoneNumberId`. class ServerMessageEndOfCallReportPhoneNumber - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ServerMessageEndOfCallReportPhoneNumber] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of # ServerMessageEndOfCallReportPhoneNumber # @@ -35,38 +19,39 @@ def initialize(member:, discriminant:) # @return [Vapi::ServerMessageEndOfCallReportPhoneNumber] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: json_object) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.from_json(json_object: json_object) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.from_json(json_object: json_object) - else - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end + begin + Vapi::CreateByoPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateByoPhoneNumberDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "byo-phone-number" - { **@member.to_json, provider: @discriminant }.to_json - when "twilio" - { **@member.to_json, provider: @discriminant }.to_json - when "vonage" - { **@member.to_json, provider: @discriminant }.to_json - when "vapi" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVonagePhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVapiPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -76,50 +61,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateByoPhoneNumberDto] - # @return [Vapi::ServerMessageEndOfCallReportPhoneNumber] - def self.byo_phone_number(member:) - new(member: member, discriminant: "byo-phone-number") - end - - # @param member [Vapi::CreateTwilioPhoneNumberDto] - # @return [Vapi::ServerMessageEndOfCallReportPhoneNumber] - def self.twilio(member:) - new(member: member, discriminant: "twilio") - end - - # @param member [Vapi::CreateVonagePhoneNumberDto] - # @return [Vapi::ServerMessageEndOfCallReportPhoneNumber] - def self.vonage(member:) - new(member: member, discriminant: "vonage") - end - - # @param member [Vapi::CreateVapiPhoneNumberDto] - # @return [Vapi::ServerMessageEndOfCallReportPhoneNumber] - def self.vapi(member:) - new(member: member, discriminant: "vapi") + begin + return Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/server_message_hang.rb b/lib/vapi/types/server_message_hang.rb index 2852b0d..e2e4635 100644 --- a/lib/vapi/types/server_message_hang.rb +++ b/lib/vapi/types/server_message_hang.rb @@ -15,6 +15,13 @@ class ServerMessageHang # - `call.phoneNumber`, # - `call.phoneNumberId`. attr_reader :phone_number + # @return [String] This is the type of the message. "hang" is sent when the assistant is hanging + # due to a delay. The delay can be caused by many factors, such as: + # - the model is too slow to respond + # - the voice is too slow to respond + # - the tool call is still waiting for a response from your server + # - etc. + attr_reader :type # @return [String] This is the ISO-8601 formatted timestamp of when the message was sent. attr_reader :timestamp # @return [Vapi::Artifact] This is a live version of the `call.artifact`. @@ -52,6 +59,12 @@ class ServerMessageHang # This matches one of the following: # - `call.phoneNumber`, # - `call.phoneNumberId`. + # @param type [String] This is the type of the message. "hang" is sent when the assistant is hanging + # due to a delay. The delay can be caused by many factors, such as: + # - the model is too slow to respond + # - the voice is too slow to respond + # - the tool call is still waiting for a response from your server + # - etc. # @param timestamp [String] This is the ISO-8601 formatted timestamp of when the message was sent. # @param artifact [Vapi::Artifact] This is a live version of the `call.artifact`. # This matches what is stored on `call.artifact` after the call. @@ -74,9 +87,10 @@ class ServerMessageHang # especially after the call is ended, use GET /call/:id. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ServerMessageHang] - def initialize(phone_number: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, customer: OMIT, call: OMIT, - additional_properties: nil) + def initialize(type:, phone_number: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, customer: OMIT, + call: OMIT, additional_properties: nil) @phone_number = phone_number if phone_number != OMIT + @type = type @timestamp = timestamp if timestamp != OMIT @artifact = artifact if artifact != OMIT @assistant = assistant if assistant != OMIT @@ -85,6 +99,7 @@ def initialize(phone_number: OMIT, timestamp: OMIT, artifact: OMIT, assistant: O @additional_properties = additional_properties @_field_set = { "phoneNumber": phone_number, + "type": type, "timestamp": timestamp, "artifact": artifact, "assistant": assistant, @@ -108,6 +123,7 @@ def self.from_json(json_object:) phone_number = parsed_json["phoneNumber"].to_json phone_number = Vapi::ServerMessageHangPhoneNumber.from_json(json_object: phone_number) end + type = parsed_json["type"] timestamp = parsed_json["timestamp"] if parsed_json["artifact"].nil? artifact = nil @@ -135,6 +151,7 @@ def self.from_json(json_object:) end new( phone_number: phone_number, + type: type, timestamp: timestamp, artifact: artifact, assistant: assistant, @@ -159,6 +176,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.phone_number.nil? || Vapi::ServerMessageHangPhoneNumber.validate_raw(obj: obj.phone_number) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.timestamp&.is_a?(String) != false || raise("Passed value for field obj.timestamp is not the expected type, validation failed.") obj.artifact.nil? || Vapi::Artifact.validate_raw(obj: obj.artifact) obj.assistant.nil? || Vapi::CreateAssistantDto.validate_raw(obj: obj.assistant) diff --git a/lib/vapi/types/server_message_hang_phone_number.rb b/lib/vapi/types/server_message_hang_phone_number.rb index 29054e0..ce1a987 100644 --- a/lib/vapi/types/server_message_hang_phone_number.rb +++ b/lib/vapi/types/server_message_hang_phone_number.rb @@ -12,60 +12,45 @@ module Vapi # - `call.phoneNumber`, # - `call.phoneNumberId`. class ServerMessageHangPhoneNumber - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ServerMessageHangPhoneNumber] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of ServerMessageHangPhoneNumber # # @param json_object [String] # @return [Vapi::ServerMessageHangPhoneNumber] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: json_object) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.from_json(json_object: json_object) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.from_json(json_object: json_object) - else - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end + begin + Vapi::CreateByoPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateByoPhoneNumberDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "byo-phone-number" - { **@member.to_json, provider: @discriminant }.to_json - when "twilio" - { **@member.to_json, provider: @discriminant }.to_json - when "vonage" - { **@member.to_json, provider: @discriminant }.to_json - when "vapi" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVonagePhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVapiPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -75,50 +60,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateByoPhoneNumberDto] - # @return [Vapi::ServerMessageHangPhoneNumber] - def self.byo_phone_number(member:) - new(member: member, discriminant: "byo-phone-number") - end - - # @param member [Vapi::CreateTwilioPhoneNumberDto] - # @return [Vapi::ServerMessageHangPhoneNumber] - def self.twilio(member:) - new(member: member, discriminant: "twilio") - end - - # @param member [Vapi::CreateVonagePhoneNumberDto] - # @return [Vapi::ServerMessageHangPhoneNumber] - def self.vonage(member:) - new(member: member, discriminant: "vonage") - end - - # @param member [Vapi::CreateVapiPhoneNumberDto] - # @return [Vapi::ServerMessageHangPhoneNumber] - def self.vapi(member:) - new(member: member, discriminant: "vapi") + begin + return Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/server_message_language_changed.rb b/lib/vapi/types/server_message_language_changed.rb index fe3ab74..d074393 100644 --- a/lib/vapi/types/server_message_language_changed.rb +++ b/lib/vapi/types/server_message_language_changed.rb @@ -15,6 +15,9 @@ class ServerMessageLanguageChanged # - `call.phoneNumber`, # - `call.phoneNumberId`. attr_reader :phone_number + # @return [String] This is the type of the message. "language-switched" is sent when the + # transcriber is automatically switched based on the detected language. + attr_reader :type # @return [String] This is the ISO-8601 formatted timestamp of when the message was sent. attr_reader :timestamp # @return [Vapi::Artifact] This is a live version of the `call.artifact`. @@ -54,6 +57,8 @@ class ServerMessageLanguageChanged # This matches one of the following: # - `call.phoneNumber`, # - `call.phoneNumberId`. + # @param type [String] This is the type of the message. "language-switched" is sent when the + # transcriber is automatically switched based on the detected language. # @param timestamp [String] This is the ISO-8601 formatted timestamp of when the message was sent. # @param artifact [Vapi::Artifact] This is a live version of the `call.artifact`. # This matches what is stored on `call.artifact` after the call. @@ -77,9 +82,10 @@ class ServerMessageLanguageChanged # @param language [String] This is the language the transcriber is switched to. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ServerMessageLanguageChanged] - def initialize(language:, phone_number: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, customer: OMIT, + def initialize(type:, language:, phone_number: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, customer: OMIT, call: OMIT, additional_properties: nil) @phone_number = phone_number if phone_number != OMIT + @type = type @timestamp = timestamp if timestamp != OMIT @artifact = artifact if artifact != OMIT @assistant = assistant if assistant != OMIT @@ -89,6 +95,7 @@ def initialize(language:, phone_number: OMIT, timestamp: OMIT, artifact: OMIT, a @additional_properties = additional_properties @_field_set = { "phoneNumber": phone_number, + "type": type, "timestamp": timestamp, "artifact": artifact, "assistant": assistant, @@ -113,6 +120,7 @@ def self.from_json(json_object:) phone_number = parsed_json["phoneNumber"].to_json phone_number = Vapi::ServerMessageLanguageChangedPhoneNumber.from_json(json_object: phone_number) end + type = parsed_json["type"] timestamp = parsed_json["timestamp"] if parsed_json["artifact"].nil? artifact = nil @@ -141,6 +149,7 @@ def self.from_json(json_object:) language = parsed_json["language"] new( phone_number: phone_number, + type: type, timestamp: timestamp, artifact: artifact, assistant: assistant, @@ -166,6 +175,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.phone_number.nil? || Vapi::ServerMessageLanguageChangedPhoneNumber.validate_raw(obj: obj.phone_number) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.timestamp&.is_a?(String) != false || raise("Passed value for field obj.timestamp is not the expected type, validation failed.") obj.artifact.nil? || Vapi::Artifact.validate_raw(obj: obj.artifact) obj.assistant.nil? || Vapi::CreateAssistantDto.validate_raw(obj: obj.assistant) diff --git a/lib/vapi/types/server_message_language_changed_phone_number.rb b/lib/vapi/types/server_message_language_changed_phone_number.rb index 737f823..0130f38 100644 --- a/lib/vapi/types/server_message_language_changed_phone_number.rb +++ b/lib/vapi/types/server_message_language_changed_phone_number.rb @@ -12,22 +12,6 @@ module Vapi # - `call.phoneNumber`, # - `call.phoneNumberId`. class ServerMessageLanguageChangedPhoneNumber - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ServerMessageLanguageChangedPhoneNumber] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of # ServerMessageLanguageChangedPhoneNumber # @@ -35,38 +19,39 @@ def initialize(member:, discriminant:) # @return [Vapi::ServerMessageLanguageChangedPhoneNumber] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: json_object) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.from_json(json_object: json_object) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.from_json(json_object: json_object) - else - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end + begin + Vapi::CreateByoPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateByoPhoneNumberDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "byo-phone-number" - { **@member.to_json, provider: @discriminant }.to_json - when "twilio" - { **@member.to_json, provider: @discriminant }.to_json - when "vonage" - { **@member.to_json, provider: @discriminant }.to_json - when "vapi" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVonagePhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVapiPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -76,50 +61,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateByoPhoneNumberDto] - # @return [Vapi::ServerMessageLanguageChangedPhoneNumber] - def self.byo_phone_number(member:) - new(member: member, discriminant: "byo-phone-number") - end - - # @param member [Vapi::CreateTwilioPhoneNumberDto] - # @return [Vapi::ServerMessageLanguageChangedPhoneNumber] - def self.twilio(member:) - new(member: member, discriminant: "twilio") - end - - # @param member [Vapi::CreateVonagePhoneNumberDto] - # @return [Vapi::ServerMessageLanguageChangedPhoneNumber] - def self.vonage(member:) - new(member: member, discriminant: "vonage") - end - - # @param member [Vapi::CreateVapiPhoneNumberDto] - # @return [Vapi::ServerMessageLanguageChangedPhoneNumber] - def self.vapi(member:) - new(member: member, discriminant: "vapi") + begin + return Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/server_message_message.rb b/lib/vapi/types/server_message_message.rb index ebe0997..9be9863 100644 --- a/lib/vapi/types/server_message_message.rb +++ b/lib/vapi/types/server_message_message.rb @@ -29,257 +29,231 @@ module Vapi # 3. `phoneNumber.serverUrl` (if configured) # 4. `org.serverUrl` (if configured) class ServerMessageMessage - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ServerMessageMessage] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of ServerMessageMessage # # @param json_object [String] # @return [Vapi::ServerMessageMessage] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "assistant-request" - Vapi::ServerMessageAssistantRequest.from_json(json_object: json_object) - when "conversation-update" - Vapi::ServerMessageConversationUpdate.from_json(json_object: json_object) - when "end-of-call-report" - Vapi::ServerMessageEndOfCallReport.from_json(json_object: json_object) - when "hang" - Vapi::ServerMessageHang.from_json(json_object: json_object) - when "model-output" - Vapi::ServerMessageModelOutput.from_json(json_object: json_object) - when "phone-call-control" - Vapi::ServerMessagePhoneCallControl.from_json(json_object: json_object) - when "speech-update" - Vapi::ServerMessageSpeechUpdate.from_json(json_object: json_object) - when "status-update" - Vapi::ServerMessageStatusUpdate.from_json(json_object: json_object) - when "tool-calls" - Vapi::ServerMessageToolCalls.from_json(json_object: json_object) - when "transfer-destination-request" - Vapi::ServerMessageTransferDestinationRequest.from_json(json_object: json_object) - when "transfer-update" - Vapi::ServerMessageTransferUpdate.from_json(json_object: json_object) - when "transcript" - Vapi::ServerMessageTranscript.from_json(json_object: json_object) - when "user-interrupted" - Vapi::ServerMessageUserInterrupted.from_json(json_object: json_object) - when "language-changed" - Vapi::ServerMessageLanguageChanged.from_json(json_object: json_object) - when "voice-input" - Vapi::ServerMessageVoiceInput.from_json(json_object: json_object) - when "voice-request" - Vapi::ServerMessageVoiceRequest.from_json(json_object: json_object) - else - Vapi::ServerMessageAssistantRequest.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ServerMessageAssistantRequest.validate_raw(obj: struct) + return Vapi::ServerMessageAssistantRequest.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "assistant-request" - { **@member.to_json, type: @discriminant }.to_json - when "conversation-update" - { **@member.to_json, type: @discriminant }.to_json - when "end-of-call-report" - { **@member.to_json, type: @discriminant }.to_json - when "hang" - { **@member.to_json, type: @discriminant }.to_json - when "model-output" - { **@member.to_json, type: @discriminant }.to_json - when "phone-call-control" - { **@member.to_json, type: @discriminant }.to_json - when "speech-update" - { **@member.to_json, type: @discriminant }.to_json - when "status-update" - { **@member.to_json, type: @discriminant }.to_json - when "tool-calls" - { **@member.to_json, type: @discriminant }.to_json - when "transfer-destination-request" - { **@member.to_json, type: @discriminant }.to_json - when "transfer-update" - { **@member.to_json, type: @discriminant }.to_json - when "transcript" - { **@member.to_json, type: @discriminant }.to_json - when "user-interrupted" - { **@member.to_json, type: @discriminant }.to_json - when "language-changed" - { **@member.to_json, type: @discriminant }.to_json - when "voice-input" - { **@member.to_json, type: @discriminant }.to_json - when "voice-request" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json - end - @member.to_json - end - - # 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. - # - # @param obj [Object] - # @return [Void] - def self.validate_raw(obj:) - case obj.type - when "assistant-request" - Vapi::ServerMessageAssistantRequest.validate_raw(obj: obj) - when "conversation-update" - Vapi::ServerMessageConversationUpdate.validate_raw(obj: obj) - when "end-of-call-report" - Vapi::ServerMessageEndOfCallReport.validate_raw(obj: obj) - when "hang" - Vapi::ServerMessageHang.validate_raw(obj: obj) - when "model-output" - Vapi::ServerMessageModelOutput.validate_raw(obj: obj) - when "phone-call-control" - Vapi::ServerMessagePhoneCallControl.validate_raw(obj: obj) - when "speech-update" - Vapi::ServerMessageSpeechUpdate.validate_raw(obj: obj) - when "status-update" - Vapi::ServerMessageStatusUpdate.validate_raw(obj: obj) - when "tool-calls" - Vapi::ServerMessageToolCalls.validate_raw(obj: obj) - when "transfer-destination-request" - Vapi::ServerMessageTransferDestinationRequest.validate_raw(obj: obj) - when "transfer-update" - Vapi::ServerMessageTransferUpdate.validate_raw(obj: obj) - when "transcript" - Vapi::ServerMessageTranscript.validate_raw(obj: obj) - when "user-interrupted" - Vapi::ServerMessageUserInterrupted.validate_raw(obj: obj) - when "language-changed" - Vapi::ServerMessageLanguageChanged.validate_raw(obj: obj) - when "voice-input" - Vapi::ServerMessageVoiceInput.validate_raw(obj: obj) - when "voice-request" - Vapi::ServerMessageVoiceRequest.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + return nil + rescue StandardError + # noop end - end + begin + Vapi::ServerMessageConversationUpdate.validate_raw(obj: struct) + return Vapi::ServerMessageConversationUpdate.from_json(json_object: struct) unless struct.nil? - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ServerMessageAssistantRequest] - # @return [Vapi::ServerMessageMessage] - def self.assistant_request(member:) - new(member: member, discriminant: "assistant-request") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::ServerMessageEndOfCallReport.validate_raw(obj: struct) + return Vapi::ServerMessageEndOfCallReport.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::ServerMessageConversationUpdate] - # @return [Vapi::ServerMessageMessage] - def self.conversation_update(member:) - new(member: member, discriminant: "conversation-update") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::ServerMessageHang.validate_raw(obj: struct) + return Vapi::ServerMessageHang.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::ServerMessageEndOfCallReport] - # @return [Vapi::ServerMessageMessage] - def self.end_of_call_report(member:) - new(member: member, discriminant: "end-of-call-report") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::ServerMessageModelOutput.validate_raw(obj: struct) + return Vapi::ServerMessageModelOutput.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::ServerMessageHang] - # @return [Vapi::ServerMessageMessage] - def self.hang(member:) - new(member: member, discriminant: "hang") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::ServerMessagePhoneCallControl.validate_raw(obj: struct) + return Vapi::ServerMessagePhoneCallControl.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::ServerMessageModelOutput] - # @return [Vapi::ServerMessageMessage] - def self.model_output(member:) - new(member: member, discriminant: "model-output") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::ServerMessageSpeechUpdate.validate_raw(obj: struct) + return Vapi::ServerMessageSpeechUpdate.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::ServerMessagePhoneCallControl] - # @return [Vapi::ServerMessageMessage] - def self.phone_call_control(member:) - new(member: member, discriminant: "phone-call-control") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::ServerMessageStatusUpdate.validate_raw(obj: struct) + return Vapi::ServerMessageStatusUpdate.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::ServerMessageSpeechUpdate] - # @return [Vapi::ServerMessageMessage] - def self.speech_update(member:) - new(member: member, discriminant: "speech-update") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::ServerMessageToolCalls.validate_raw(obj: struct) + return Vapi::ServerMessageToolCalls.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::ServerMessageStatusUpdate] - # @return [Vapi::ServerMessageMessage] - def self.status_update(member:) - new(member: member, discriminant: "status-update") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::ServerMessageTransferDestinationRequest.validate_raw(obj: struct) + return Vapi::ServerMessageTransferDestinationRequest.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::ServerMessageToolCalls] - # @return [Vapi::ServerMessageMessage] - def self.tool_calls(member:) - new(member: member, discriminant: "tool-calls") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::ServerMessageTransferUpdate.validate_raw(obj: struct) + return Vapi::ServerMessageTransferUpdate.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::ServerMessageTransferDestinationRequest] - # @return [Vapi::ServerMessageMessage] - def self.transfer_destination_request(member:) - new(member: member, discriminant: "transfer-destination-request") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::ServerMessageTranscript.validate_raw(obj: struct) + return Vapi::ServerMessageTranscript.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::ServerMessageTransferUpdate] - # @return [Vapi::ServerMessageMessage] - def self.transfer_update(member:) - new(member: member, discriminant: "transfer-update") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::ServerMessageUserInterrupted.validate_raw(obj: struct) + return Vapi::ServerMessageUserInterrupted.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::ServerMessageTranscript] - # @return [Vapi::ServerMessageMessage] - def self.transcript(member:) - new(member: member, discriminant: "transcript") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::ServerMessageLanguageChanged.validate_raw(obj: struct) + return Vapi::ServerMessageLanguageChanged.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::ServerMessageUserInterrupted] - # @return [Vapi::ServerMessageMessage] - def self.user_interrupted(member:) - new(member: member, discriminant: "user-interrupted") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::ServerMessageVoiceInput.validate_raw(obj: struct) + return Vapi::ServerMessageVoiceInput.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::ServerMessageLanguageChanged] - # @return [Vapi::ServerMessageMessage] - def self.language_changed(member:) - new(member: member, discriminant: "language-changed") - end + return nil + rescue StandardError + # noop + end + begin + Vapi::ServerMessageVoiceRequest.validate_raw(obj: struct) + return Vapi::ServerMessageVoiceRequest.from_json(json_object: struct) unless struct.nil? - # @param member [Vapi::ServerMessageVoiceInput] - # @return [Vapi::ServerMessageMessage] - def self.voice_input(member:) - new(member: member, discriminant: "voice-input") + return nil + rescue StandardError + # noop + end + struct end - # @param member [Vapi::ServerMessageVoiceRequest] - # @return [Vapi::ServerMessageMessage] - def self.voice_request(member:) - new(member: member, discriminant: "voice-request") + # 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. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return Vapi::ServerMessageAssistantRequest.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ServerMessageConversationUpdate.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ServerMessageEndOfCallReport.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ServerMessageHang.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ServerMessageModelOutput.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ServerMessagePhoneCallControl.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ServerMessageSpeechUpdate.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ServerMessageStatusUpdate.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ServerMessageToolCalls.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ServerMessageTransferDestinationRequest.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ServerMessageTransferUpdate.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ServerMessageTranscript.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ServerMessageUserInterrupted.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ServerMessageLanguageChanged.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ServerMessageVoiceInput.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ServerMessageVoiceRequest.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/server_message_model_output.rb b/lib/vapi/types/server_message_model_output.rb index ee82237..61769eb 100644 --- a/lib/vapi/types/server_message_model_output.rb +++ b/lib/vapi/types/server_message_model_output.rb @@ -15,6 +15,9 @@ class ServerMessageModelOutput # - `call.phoneNumber`, # - `call.phoneNumberId`. attr_reader :phone_number + # @return [String] This is the type of the message. "model-output" is sent as the model outputs + # tokens. + attr_reader :type # @return [String] This is the ISO-8601 formatted timestamp of when the message was sent. attr_reader :timestamp # @return [Vapi::Artifact] This is a live version of the `call.artifact`. @@ -54,6 +57,8 @@ class ServerMessageModelOutput # This matches one of the following: # - `call.phoneNumber`, # - `call.phoneNumberId`. + # @param type [String] This is the type of the message. "model-output" is sent as the model outputs + # tokens. # @param timestamp [String] This is the ISO-8601 formatted timestamp of when the message was sent. # @param artifact [Vapi::Artifact] This is a live version of the `call.artifact`. # This matches what is stored on `call.artifact` after the call. @@ -77,9 +82,10 @@ class ServerMessageModelOutput # @param output [Hash{String => Object}] This is the output of the model. It can be a token or tool call. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ServerMessageModelOutput] - def initialize(output:, phone_number: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, customer: OMIT, + def initialize(type:, output:, phone_number: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, customer: OMIT, call: OMIT, additional_properties: nil) @phone_number = phone_number if phone_number != OMIT + @type = type @timestamp = timestamp if timestamp != OMIT @artifact = artifact if artifact != OMIT @assistant = assistant if assistant != OMIT @@ -89,6 +95,7 @@ def initialize(output:, phone_number: OMIT, timestamp: OMIT, artifact: OMIT, ass @additional_properties = additional_properties @_field_set = { "phoneNumber": phone_number, + "type": type, "timestamp": timestamp, "artifact": artifact, "assistant": assistant, @@ -113,6 +120,7 @@ def self.from_json(json_object:) phone_number = parsed_json["phoneNumber"].to_json phone_number = Vapi::ServerMessageModelOutputPhoneNumber.from_json(json_object: phone_number) end + type = parsed_json["type"] timestamp = parsed_json["timestamp"] if parsed_json["artifact"].nil? artifact = nil @@ -141,6 +149,7 @@ def self.from_json(json_object:) output = parsed_json["output"] new( phone_number: phone_number, + type: type, timestamp: timestamp, artifact: artifact, assistant: assistant, @@ -166,6 +175,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.phone_number.nil? || Vapi::ServerMessageModelOutputPhoneNumber.validate_raw(obj: obj.phone_number) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.timestamp&.is_a?(String) != false || raise("Passed value for field obj.timestamp is not the expected type, validation failed.") obj.artifact.nil? || Vapi::Artifact.validate_raw(obj: obj.artifact) obj.assistant.nil? || Vapi::CreateAssistantDto.validate_raw(obj: obj.assistant) diff --git a/lib/vapi/types/server_message_model_output_phone_number.rb b/lib/vapi/types/server_message_model_output_phone_number.rb index b5ede12..7d44e0b 100644 --- a/lib/vapi/types/server_message_model_output_phone_number.rb +++ b/lib/vapi/types/server_message_model_output_phone_number.rb @@ -12,60 +12,45 @@ module Vapi # - `call.phoneNumber`, # - `call.phoneNumberId`. class ServerMessageModelOutputPhoneNumber - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ServerMessageModelOutputPhoneNumber] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of ServerMessageModelOutputPhoneNumber # # @param json_object [String] # @return [Vapi::ServerMessageModelOutputPhoneNumber] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: json_object) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.from_json(json_object: json_object) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.from_json(json_object: json_object) - else - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end + begin + Vapi::CreateByoPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateByoPhoneNumberDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "byo-phone-number" - { **@member.to_json, provider: @discriminant }.to_json - when "twilio" - { **@member.to_json, provider: @discriminant }.to_json - when "vonage" - { **@member.to_json, provider: @discriminant }.to_json - when "vapi" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVonagePhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVapiPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -75,50 +60,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateByoPhoneNumberDto] - # @return [Vapi::ServerMessageModelOutputPhoneNumber] - def self.byo_phone_number(member:) - new(member: member, discriminant: "byo-phone-number") - end - - # @param member [Vapi::CreateTwilioPhoneNumberDto] - # @return [Vapi::ServerMessageModelOutputPhoneNumber] - def self.twilio(member:) - new(member: member, discriminant: "twilio") - end - - # @param member [Vapi::CreateVonagePhoneNumberDto] - # @return [Vapi::ServerMessageModelOutputPhoneNumber] - def self.vonage(member:) - new(member: member, discriminant: "vonage") - end - - # @param member [Vapi::CreateVapiPhoneNumberDto] - # @return [Vapi::ServerMessageModelOutputPhoneNumber] - def self.vapi(member:) - new(member: member, discriminant: "vapi") + begin + return Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/server_message_phone_call_control.rb b/lib/vapi/types/server_message_phone_call_control.rb index 34e6be6..d357b18 100644 --- a/lib/vapi/types/server_message_phone_call_control.rb +++ b/lib/vapi/types/server_message_phone_call_control.rb @@ -17,6 +17,12 @@ class ServerMessagePhoneCallControl # - `call.phoneNumber`, # - `call.phoneNumberId`. attr_reader :phone_number + # @return [String] This is the type of the message. "phone-call-control" is an advanced type of + # message. + # When it is requested in `assistant.serverMessages`, the hangup and forwarding + # responsibilities are delegated to your server. Vapi will no longer do the actual + # transfer and hangup. + attr_reader :type # @return [Vapi::ServerMessagePhoneCallControlRequest] This is the request to control the phone call. attr_reader :request # @return [Vapi::ServerMessagePhoneCallControlDestination] This is the destination to forward the call to if the request is "forward". @@ -58,6 +64,11 @@ class ServerMessagePhoneCallControl # This matches one of the following: # - `call.phoneNumber`, # - `call.phoneNumberId`. + # @param type [String] This is the type of the message. "phone-call-control" is an advanced type of + # message. + # When it is requested in `assistant.serverMessages`, the hangup and forwarding + # responsibilities are delegated to your server. Vapi will no longer do the actual + # transfer and hangup. # @param request [Vapi::ServerMessagePhoneCallControlRequest] This is the request to control the phone call. # @param destination [Vapi::ServerMessagePhoneCallControlDestination] This is the destination to forward the call to if the request is "forward". # @param timestamp [String] This is the ISO-8601 formatted timestamp of when the message was sent. @@ -82,9 +93,10 @@ class ServerMessagePhoneCallControl # especially after the call is ended, use GET /call/:id. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ServerMessagePhoneCallControl] - def initialize(request:, phone_number: OMIT, destination: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, - customer: OMIT, call: OMIT, additional_properties: nil) + def initialize(type:, request:, phone_number: OMIT, destination: OMIT, timestamp: OMIT, artifact: OMIT, + assistant: OMIT, customer: OMIT, call: OMIT, additional_properties: nil) @phone_number = phone_number if phone_number != OMIT + @type = type @request = request @destination = destination if destination != OMIT @timestamp = timestamp if timestamp != OMIT @@ -95,6 +107,7 @@ def initialize(request:, phone_number: OMIT, destination: OMIT, timestamp: OMIT, @additional_properties = additional_properties @_field_set = { "phoneNumber": phone_number, + "type": type, "request": request, "destination": destination, "timestamp": timestamp, @@ -120,6 +133,7 @@ def self.from_json(json_object:) phone_number = parsed_json["phoneNumber"].to_json phone_number = Vapi::ServerMessagePhoneCallControlPhoneNumber.from_json(json_object: phone_number) end + type = parsed_json["type"] request = parsed_json["request"] if parsed_json["destination"].nil? destination = nil @@ -154,6 +168,7 @@ def self.from_json(json_object:) end new( phone_number: phone_number, + type: type, request: request, destination: destination, timestamp: timestamp, @@ -180,6 +195,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.phone_number.nil? || Vapi::ServerMessagePhoneCallControlPhoneNumber.validate_raw(obj: obj.phone_number) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.request.is_a?(Vapi::ServerMessagePhoneCallControlRequest) != false || raise("Passed value for field obj.request is not the expected type, validation failed.") obj.destination.nil? || Vapi::ServerMessagePhoneCallControlDestination.validate_raw(obj: obj.destination) obj.timestamp&.is_a?(String) != false || raise("Passed value for field obj.timestamp is not the expected type, validation failed.") diff --git a/lib/vapi/types/server_message_phone_call_control_destination.rb b/lib/vapi/types/server_message_phone_call_control_destination.rb index b0ea427..6d5ae51 100644 --- a/lib/vapi/types/server_message_phone_call_control_destination.rb +++ b/lib/vapi/types/server_message_phone_call_control_destination.rb @@ -7,22 +7,6 @@ module Vapi # This is the destination to forward the call to if the request is "forward". class ServerMessagePhoneCallControlDestination - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ServerMessagePhoneCallControlDestination] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of # ServerMessagePhoneCallControlDestination # @@ -30,30 +14,23 @@ def initialize(member:, discriminant:) # @return [Vapi::ServerMessagePhoneCallControlDestination] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "number" - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - when "sip" - Vapi::TransferDestinationSip.from_json(json_object: json_object) - else - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::TransferDestinationNumber.validate_raw(obj: struct) + return Vapi::TransferDestinationNumber.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "number" - { **@member.to_json, type: @discriminant }.to_json - when "sip" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::TransferDestinationSip.validate_raw(obj: struct) + return Vapi::TransferDestinationSip.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -63,34 +40,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "number" - Vapi::TransferDestinationNumber.validate_raw(obj: obj) - when "sip" - Vapi::TransferDestinationSip.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::TransferDestinationNumber.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::TransferDestinationNumber] - # @return [Vapi::ServerMessagePhoneCallControlDestination] - def self.number(member:) - new(member: member, discriminant: "number") - end - - # @param member [Vapi::TransferDestinationSip] - # @return [Vapi::ServerMessagePhoneCallControlDestination] - def self.sip(member:) - new(member: member, discriminant: "sip") + begin + return Vapi::TransferDestinationSip.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/server_message_phone_call_control_phone_number.rb b/lib/vapi/types/server_message_phone_call_control_phone_number.rb index 7748ac1..9b7c031 100644 --- a/lib/vapi/types/server_message_phone_call_control_phone_number.rb +++ b/lib/vapi/types/server_message_phone_call_control_phone_number.rb @@ -12,22 +12,6 @@ module Vapi # - `call.phoneNumber`, # - `call.phoneNumberId`. class ServerMessagePhoneCallControlPhoneNumber - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ServerMessagePhoneCallControlPhoneNumber] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of # ServerMessagePhoneCallControlPhoneNumber # @@ -35,38 +19,39 @@ def initialize(member:, discriminant:) # @return [Vapi::ServerMessagePhoneCallControlPhoneNumber] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: json_object) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.from_json(json_object: json_object) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.from_json(json_object: json_object) - else - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end + begin + Vapi::CreateByoPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateByoPhoneNumberDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "byo-phone-number" - { **@member.to_json, provider: @discriminant }.to_json - when "twilio" - { **@member.to_json, provider: @discriminant }.to_json - when "vonage" - { **@member.to_json, provider: @discriminant }.to_json - when "vapi" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVonagePhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVapiPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -76,50 +61,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateByoPhoneNumberDto] - # @return [Vapi::ServerMessagePhoneCallControlPhoneNumber] - def self.byo_phone_number(member:) - new(member: member, discriminant: "byo-phone-number") - end - - # @param member [Vapi::CreateTwilioPhoneNumberDto] - # @return [Vapi::ServerMessagePhoneCallControlPhoneNumber] - def self.twilio(member:) - new(member: member, discriminant: "twilio") - end - - # @param member [Vapi::CreateVonagePhoneNumberDto] - # @return [Vapi::ServerMessagePhoneCallControlPhoneNumber] - def self.vonage(member:) - new(member: member, discriminant: "vonage") - end - - # @param member [Vapi::CreateVapiPhoneNumberDto] - # @return [Vapi::ServerMessagePhoneCallControlPhoneNumber] - def self.vapi(member:) - new(member: member, discriminant: "vapi") + begin + return Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/server_message_response_assistant_request_destination.rb b/lib/vapi/types/server_message_response_assistant_request_destination.rb index 4747fb9..bf74b28 100644 --- a/lib/vapi/types/server_message_response_assistant_request_destination.rb +++ b/lib/vapi/types/server_message_response_assistant_request_destination.rb @@ -9,22 +9,6 @@ module Vapi # transfer without using any assistants. # If this is sent, `assistantId`, `assistant`, `squadId`, and `squad` are ignored. class ServerMessageResponseAssistantRequestDestination - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ServerMessageResponseAssistantRequestDestination] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of # ServerMessageResponseAssistantRequestDestination # @@ -32,30 +16,23 @@ def initialize(member:, discriminant:) # @return [Vapi::ServerMessageResponseAssistantRequestDestination] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "number" - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - when "sip" - Vapi::TransferDestinationSip.from_json(json_object: json_object) - else - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::TransferDestinationNumber.validate_raw(obj: struct) + return Vapi::TransferDestinationNumber.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "number" - { **@member.to_json, type: @discriminant }.to_json - when "sip" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::TransferDestinationSip.validate_raw(obj: struct) + return Vapi::TransferDestinationSip.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -65,34 +42,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "number" - Vapi::TransferDestinationNumber.validate_raw(obj: obj) - when "sip" - Vapi::TransferDestinationSip.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::TransferDestinationNumber.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::TransferDestinationNumber] - # @return [Vapi::ServerMessageResponseAssistantRequestDestination] - def self.number(member:) - new(member: member, discriminant: "number") - end - - # @param member [Vapi::TransferDestinationSip] - # @return [Vapi::ServerMessageResponseAssistantRequestDestination] - def self.sip(member:) - new(member: member, discriminant: "sip") + begin + return Vapi::TransferDestinationSip.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/server_message_response_transfer_destination_request_destination.rb b/lib/vapi/types/server_message_response_transfer_destination_request_destination.rb index 9d85a38..d36a326 100644 --- a/lib/vapi/types/server_message_response_transfer_destination_request_destination.rb +++ b/lib/vapi/types/server_message_response_transfer_destination_request_destination.rb @@ -9,22 +9,6 @@ module Vapi # This is the destination you'd like the call to be transferred to. class ServerMessageResponseTransferDestinationRequestDestination - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ServerMessageResponseTransferDestinationRequestDestination] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of # ServerMessageResponseTransferDestinationRequestDestination # @@ -32,38 +16,39 @@ def initialize(member:, discriminant:) # @return [Vapi::ServerMessageResponseTransferDestinationRequestDestination] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "assistant" - Vapi::TransferDestinationAssistant.from_json(json_object: json_object) - when "step" - Vapi::TransferDestinationStep.from_json(json_object: json_object) - when "number" - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - when "sip" - Vapi::TransferDestinationSip.from_json(json_object: json_object) - else - Vapi::TransferDestinationAssistant.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::TransferDestinationAssistant.validate_raw(obj: struct) + return Vapi::TransferDestinationAssistant.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "assistant" - { **@member.to_json, type: @discriminant }.to_json - when "step" - { **@member.to_json, type: @discriminant }.to_json - when "number" - { **@member.to_json, type: @discriminant }.to_json - when "sip" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::TransferDestinationStep.validate_raw(obj: struct) + return Vapi::TransferDestinationStep.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::TransferDestinationNumber.validate_raw(obj: struct) + return Vapi::TransferDestinationNumber.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::TransferDestinationSip.validate_raw(obj: struct) + return Vapi::TransferDestinationSip.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -73,50 +58,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "assistant" - Vapi::TransferDestinationAssistant.validate_raw(obj: obj) - when "step" - Vapi::TransferDestinationStep.validate_raw(obj: obj) - when "number" - Vapi::TransferDestinationNumber.validate_raw(obj: obj) - when "sip" - Vapi::TransferDestinationSip.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::TransferDestinationAssistant.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::TransferDestinationAssistant] - # @return [Vapi::ServerMessageResponseTransferDestinationRequestDestination] - def self.assistant(member:) - new(member: member, discriminant: "assistant") - end - - # @param member [Vapi::TransferDestinationStep] - # @return [Vapi::ServerMessageResponseTransferDestinationRequestDestination] - def self.step(member:) - new(member: member, discriminant: "step") - end - - # @param member [Vapi::TransferDestinationNumber] - # @return [Vapi::ServerMessageResponseTransferDestinationRequestDestination] - def self.number(member:) - new(member: member, discriminant: "number") - end - - # @param member [Vapi::TransferDestinationSip] - # @return [Vapi::ServerMessageResponseTransferDestinationRequestDestination] - def self.sip(member:) - new(member: member, discriminant: "sip") + begin + return Vapi::TransferDestinationStep.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::TransferDestinationNumber.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::TransferDestinationSip.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/server_message_speech_update.rb b/lib/vapi/types/server_message_speech_update.rb index d16a04d..bd928b1 100644 --- a/lib/vapi/types/server_message_speech_update.rb +++ b/lib/vapi/types/server_message_speech_update.rb @@ -17,6 +17,9 @@ class ServerMessageSpeechUpdate # - `call.phoneNumber`, # - `call.phoneNumberId`. attr_reader :phone_number + # @return [String] This is the type of the message. "speech-update" is sent whenever assistant or + # user start or stop speaking. + attr_reader :type # @return [Vapi::ServerMessageSpeechUpdateStatus] This is the status of the speech update. attr_reader :status # @return [Vapi::ServerMessageSpeechUpdateRole] This is the role which the speech update is for. @@ -58,6 +61,8 @@ class ServerMessageSpeechUpdate # This matches one of the following: # - `call.phoneNumber`, # - `call.phoneNumberId`. + # @param type [String] This is the type of the message. "speech-update" is sent whenever assistant or + # user start or stop speaking. # @param status [Vapi::ServerMessageSpeechUpdateStatus] This is the status of the speech update. # @param role [Vapi::ServerMessageSpeechUpdateRole] This is the role which the speech update is for. # @param timestamp [String] This is the ISO-8601 formatted timestamp of when the message was sent. @@ -82,9 +87,10 @@ class ServerMessageSpeechUpdate # especially after the call is ended, use GET /call/:id. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ServerMessageSpeechUpdate] - def initialize(status:, role:, phone_number: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, + def initialize(type:, status:, role:, phone_number: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, customer: OMIT, call: OMIT, additional_properties: nil) @phone_number = phone_number if phone_number != OMIT + @type = type @status = status @role = role @timestamp = timestamp if timestamp != OMIT @@ -95,6 +101,7 @@ def initialize(status:, role:, phone_number: OMIT, timestamp: OMIT, artifact: OM @additional_properties = additional_properties @_field_set = { "phoneNumber": phone_number, + "type": type, "status": status, "role": role, "timestamp": timestamp, @@ -120,6 +127,7 @@ def self.from_json(json_object:) phone_number = parsed_json["phoneNumber"].to_json phone_number = Vapi::ServerMessageSpeechUpdatePhoneNumber.from_json(json_object: phone_number) end + type = parsed_json["type"] status = parsed_json["status"] role = parsed_json["role"] timestamp = parsed_json["timestamp"] @@ -149,6 +157,7 @@ def self.from_json(json_object:) end new( phone_number: phone_number, + type: type, status: status, role: role, timestamp: timestamp, @@ -175,6 +184,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.phone_number.nil? || Vapi::ServerMessageSpeechUpdatePhoneNumber.validate_raw(obj: obj.phone_number) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.status.is_a?(Vapi::ServerMessageSpeechUpdateStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") obj.role.is_a?(Vapi::ServerMessageSpeechUpdateRole) != false || raise("Passed value for field obj.role is not the expected type, validation failed.") obj.timestamp&.is_a?(String) != false || raise("Passed value for field obj.timestamp is not the expected type, validation failed.") diff --git a/lib/vapi/types/server_message_speech_update_phone_number.rb b/lib/vapi/types/server_message_speech_update_phone_number.rb index a79fe29..9834cf8 100644 --- a/lib/vapi/types/server_message_speech_update_phone_number.rb +++ b/lib/vapi/types/server_message_speech_update_phone_number.rb @@ -12,60 +12,45 @@ module Vapi # - `call.phoneNumber`, # - `call.phoneNumberId`. class ServerMessageSpeechUpdatePhoneNumber - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ServerMessageSpeechUpdatePhoneNumber] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of ServerMessageSpeechUpdatePhoneNumber # # @param json_object [String] # @return [Vapi::ServerMessageSpeechUpdatePhoneNumber] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: json_object) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.from_json(json_object: json_object) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.from_json(json_object: json_object) - else - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end + begin + Vapi::CreateByoPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateByoPhoneNumberDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "byo-phone-number" - { **@member.to_json, provider: @discriminant }.to_json - when "twilio" - { **@member.to_json, provider: @discriminant }.to_json - when "vonage" - { **@member.to_json, provider: @discriminant }.to_json - when "vapi" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVonagePhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVapiPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -75,50 +60,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateByoPhoneNumberDto] - # @return [Vapi::ServerMessageSpeechUpdatePhoneNumber] - def self.byo_phone_number(member:) - new(member: member, discriminant: "byo-phone-number") - end - - # @param member [Vapi::CreateTwilioPhoneNumberDto] - # @return [Vapi::ServerMessageSpeechUpdatePhoneNumber] - def self.twilio(member:) - new(member: member, discriminant: "twilio") - end - - # @param member [Vapi::CreateVonagePhoneNumberDto] - # @return [Vapi::ServerMessageSpeechUpdatePhoneNumber] - def self.vonage(member:) - new(member: member, discriminant: "vonage") - end - - # @param member [Vapi::CreateVapiPhoneNumberDto] - # @return [Vapi::ServerMessageSpeechUpdatePhoneNumber] - def self.vapi(member:) - new(member: member, discriminant: "vapi") + begin + return Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/server_message_status_update.rb b/lib/vapi/types/server_message_status_update.rb index dd176ae..f6deb91 100644 --- a/lib/vapi/types/server_message_status_update.rb +++ b/lib/vapi/types/server_message_status_update.rb @@ -20,6 +20,9 @@ class ServerMessageStatusUpdate # - `call.phoneNumber`, # - `call.phoneNumberId`. attr_reader :phone_number + # @return [String] This is the type of the message. "status-update" is sent whenever the + # `call.status` changes. + attr_reader :type # @return [Vapi::ServerMessageStatusUpdateStatus] This is the status of the call. attr_reader :status # @return [Vapi::ServerMessageStatusUpdateEndedReason] This is the reason the call ended. This is only sent if the status is "ended". @@ -77,6 +80,8 @@ class ServerMessageStatusUpdate # This matches one of the following: # - `call.phoneNumber`, # - `call.phoneNumberId`. + # @param type [String] This is the type of the message. "status-update" is sent whenever the + # `call.status` changes. # @param status [Vapi::ServerMessageStatusUpdateStatus] This is the status of the call. # @param ended_reason [Vapi::ServerMessageStatusUpdateEndedReason] This is the reason the call ended. This is only sent if the status is "ended". # @param messages [Array] These are the conversation messages of the call. This is only sent if the status @@ -112,9 +117,10 @@ class ServerMessageStatusUpdate # This will include any errors related to the "assistant-request" if one was made. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ServerMessageStatusUpdate] - def initialize(status:, phone_number: OMIT, ended_reason: OMIT, messages: OMIT, messages_open_ai_formatted: OMIT, - destination: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, customer: OMIT, call: OMIT, transcript: OMIT, inbound_phone_call_debugging_artifacts: OMIT, additional_properties: nil) + def initialize(type:, status:, phone_number: OMIT, ended_reason: OMIT, messages: OMIT, + messages_open_ai_formatted: OMIT, destination: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, customer: OMIT, call: OMIT, transcript: OMIT, inbound_phone_call_debugging_artifacts: OMIT, additional_properties: nil) @phone_number = phone_number if phone_number != OMIT + @type = type @status = status @ended_reason = ended_reason if ended_reason != OMIT @messages = messages if messages != OMIT @@ -132,6 +138,7 @@ def initialize(status:, phone_number: OMIT, ended_reason: OMIT, messages: OMIT, @additional_properties = additional_properties @_field_set = { "phoneNumber": phone_number, + "type": type, "status": status, "endedReason": ended_reason, "messages": messages, @@ -162,6 +169,7 @@ def self.from_json(json_object:) phone_number = parsed_json["phoneNumber"].to_json phone_number = Vapi::ServerMessageStatusUpdatePhoneNumber.from_json(json_object: phone_number) end + type = parsed_json["type"] status = parsed_json["status"] ended_reason = parsed_json["endedReason"] messages = parsed_json["messages"]&.map do |item| @@ -207,6 +215,7 @@ def self.from_json(json_object:) inbound_phone_call_debugging_artifacts = parsed_json["inboundPhoneCallDebuggingArtifacts"] new( phone_number: phone_number, + type: type, status: status, ended_reason: ended_reason, messages: messages, @@ -238,6 +247,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.phone_number.nil? || Vapi::ServerMessageStatusUpdatePhoneNumber.validate_raw(obj: obj.phone_number) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.status.is_a?(Vapi::ServerMessageStatusUpdateStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") obj.ended_reason&.is_a?(Vapi::ServerMessageStatusUpdateEndedReason) != false || raise("Passed value for field obj.ended_reason is not the expected type, validation failed.") obj.messages&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.") diff --git a/lib/vapi/types/server_message_status_update_destination.rb b/lib/vapi/types/server_message_status_update_destination.rb index 6132a83..3e14bae 100644 --- a/lib/vapi/types/server_message_status_update_destination.rb +++ b/lib/vapi/types/server_message_status_update_destination.rb @@ -8,52 +8,29 @@ module Vapi # This is the destination the call is being transferred to. This is only sent if # the status is "forwarding". class ServerMessageStatusUpdateDestination - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ServerMessageStatusUpdateDestination] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of ServerMessageStatusUpdateDestination # # @param json_object [String] # @return [Vapi::ServerMessageStatusUpdateDestination] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "number" - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - when "sip" - Vapi::TransferDestinationSip.from_json(json_object: json_object) - else - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::TransferDestinationNumber.validate_raw(obj: struct) + return Vapi::TransferDestinationNumber.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "number" - { **@member.to_json, type: @discriminant }.to_json - when "sip" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::TransferDestinationSip.validate_raw(obj: struct) + return Vapi::TransferDestinationSip.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -63,34 +40,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "number" - Vapi::TransferDestinationNumber.validate_raw(obj: obj) - when "sip" - Vapi::TransferDestinationSip.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::TransferDestinationNumber.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::TransferDestinationNumber] - # @return [Vapi::ServerMessageStatusUpdateDestination] - def self.number(member:) - new(member: member, discriminant: "number") - end - - # @param member [Vapi::TransferDestinationSip] - # @return [Vapi::ServerMessageStatusUpdateDestination] - def self.sip(member:) - new(member: member, discriminant: "sip") + begin + return Vapi::TransferDestinationSip.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/server_message_status_update_phone_number.rb b/lib/vapi/types/server_message_status_update_phone_number.rb index 803a098..4485afc 100644 --- a/lib/vapi/types/server_message_status_update_phone_number.rb +++ b/lib/vapi/types/server_message_status_update_phone_number.rb @@ -12,60 +12,45 @@ module Vapi # - `call.phoneNumber`, # - `call.phoneNumberId`. class ServerMessageStatusUpdatePhoneNumber - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ServerMessageStatusUpdatePhoneNumber] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of ServerMessageStatusUpdatePhoneNumber # # @param json_object [String] # @return [Vapi::ServerMessageStatusUpdatePhoneNumber] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: json_object) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.from_json(json_object: json_object) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.from_json(json_object: json_object) - else - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end + begin + Vapi::CreateByoPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateByoPhoneNumberDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "byo-phone-number" - { **@member.to_json, provider: @discriminant }.to_json - when "twilio" - { **@member.to_json, provider: @discriminant }.to_json - when "vonage" - { **@member.to_json, provider: @discriminant }.to_json - when "vapi" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVonagePhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVapiPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -75,50 +60,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateByoPhoneNumberDto] - # @return [Vapi::ServerMessageStatusUpdatePhoneNumber] - def self.byo_phone_number(member:) - new(member: member, discriminant: "byo-phone-number") - end - - # @param member [Vapi::CreateTwilioPhoneNumberDto] - # @return [Vapi::ServerMessageStatusUpdatePhoneNumber] - def self.twilio(member:) - new(member: member, discriminant: "twilio") - end - - # @param member [Vapi::CreateVonagePhoneNumberDto] - # @return [Vapi::ServerMessageStatusUpdatePhoneNumber] - def self.vonage(member:) - new(member: member, discriminant: "vonage") - end - - # @param member [Vapi::CreateVapiPhoneNumberDto] - # @return [Vapi::ServerMessageStatusUpdatePhoneNumber] - def self.vapi(member:) - new(member: member, discriminant: "vapi") + begin + return Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/server_message_tool_calls.rb b/lib/vapi/types/server_message_tool_calls.rb index be2a2ee..16ccdc8 100644 --- a/lib/vapi/types/server_message_tool_calls.rb +++ b/lib/vapi/types/server_message_tool_calls.rb @@ -17,6 +17,8 @@ class ServerMessageToolCalls # - `call.phoneNumber`, # - `call.phoneNumberId`. attr_reader :phone_number + # @return [String] This is the type of the message. "tool-calls" is sent to call a tool. + attr_reader :type # @return [Array] This is the list of tools calls that the model is requesting along with the # original tool configuration. attr_reader :tool_with_tool_call_list @@ -59,6 +61,7 @@ class ServerMessageToolCalls # This matches one of the following: # - `call.phoneNumber`, # - `call.phoneNumberId`. + # @param type [String] This is the type of the message. "tool-calls" is sent to call a tool. # @param tool_with_tool_call_list [Array] This is the list of tools calls that the model is requesting along with the # original tool configuration. # @param timestamp [String] This is the ISO-8601 formatted timestamp of when the message was sent. @@ -84,9 +87,10 @@ class ServerMessageToolCalls # @param tool_call_list [Array] This is the list of tool calls that the model is requesting. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ServerMessageToolCalls] - def initialize(tool_with_tool_call_list:, tool_call_list:, phone_number: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, - customer: OMIT, call: OMIT, additional_properties: nil) + def initialize(tool_with_tool_call_list:, tool_call_list:, phone_number: OMIT, type: OMIT, timestamp: OMIT, artifact: OMIT, + assistant: OMIT, customer: OMIT, call: OMIT, additional_properties: nil) @phone_number = phone_number if phone_number != OMIT + @type = type if type != OMIT @tool_with_tool_call_list = tool_with_tool_call_list @timestamp = timestamp if timestamp != OMIT @artifact = artifact if artifact != OMIT @@ -97,6 +101,7 @@ def initialize(tool_with_tool_call_list:, tool_call_list:, phone_number: OMIT, t @additional_properties = additional_properties @_field_set = { "phoneNumber": phone_number, + "type": type, "toolWithToolCallList": tool_with_tool_call_list, "timestamp": timestamp, "artifact": artifact, @@ -122,6 +127,7 @@ def self.from_json(json_object:) phone_number = parsed_json["phoneNumber"].to_json phone_number = Vapi::ServerMessageToolCallsPhoneNumber.from_json(json_object: phone_number) end + type = parsed_json["type"] tool_with_tool_call_list = parsed_json["toolWithToolCallList"]&.map do |item| item = item.to_json Vapi::ServerMessageToolCallsToolWithToolCallListItem.from_json(json_object: item) @@ -157,6 +163,7 @@ def self.from_json(json_object:) end new( phone_number: phone_number, + type: type, tool_with_tool_call_list: tool_with_tool_call_list, timestamp: timestamp, artifact: artifact, @@ -183,6 +190,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.phone_number.nil? || Vapi::ServerMessageToolCallsPhoneNumber.validate_raw(obj: obj.phone_number) + obj.type&.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.tool_with_tool_call_list.is_a?(Array) != false || raise("Passed value for field obj.tool_with_tool_call_list is not the expected type, validation failed.") obj.timestamp&.is_a?(String) != false || raise("Passed value for field obj.timestamp is not the expected type, validation failed.") obj.artifact.nil? || Vapi::Artifact.validate_raw(obj: obj.artifact) diff --git a/lib/vapi/types/server_message_tool_calls_phone_number.rb b/lib/vapi/types/server_message_tool_calls_phone_number.rb index 0010a9c..cf0c675 100644 --- a/lib/vapi/types/server_message_tool_calls_phone_number.rb +++ b/lib/vapi/types/server_message_tool_calls_phone_number.rb @@ -12,60 +12,45 @@ module Vapi # - `call.phoneNumber`, # - `call.phoneNumberId`. class ServerMessageToolCallsPhoneNumber - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ServerMessageToolCallsPhoneNumber] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of ServerMessageToolCallsPhoneNumber # # @param json_object [String] # @return [Vapi::ServerMessageToolCallsPhoneNumber] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: json_object) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.from_json(json_object: json_object) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.from_json(json_object: json_object) - else - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end + begin + Vapi::CreateByoPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateByoPhoneNumberDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "byo-phone-number" - { **@member.to_json, provider: @discriminant }.to_json - when "twilio" - { **@member.to_json, provider: @discriminant }.to_json - when "vonage" - { **@member.to_json, provider: @discriminant }.to_json - when "vapi" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVonagePhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVapiPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -75,50 +60,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateByoPhoneNumberDto] - # @return [Vapi::ServerMessageToolCallsPhoneNumber] - def self.byo_phone_number(member:) - new(member: member, discriminant: "byo-phone-number") - end - - # @param member [Vapi::CreateTwilioPhoneNumberDto] - # @return [Vapi::ServerMessageToolCallsPhoneNumber] - def self.twilio(member:) - new(member: member, discriminant: "twilio") - end - - # @param member [Vapi::CreateVonagePhoneNumberDto] - # @return [Vapi::ServerMessageToolCallsPhoneNumber] - def self.vonage(member:) - new(member: member, discriminant: "vonage") - end - - # @param member [Vapi::CreateVapiPhoneNumberDto] - # @return [Vapi::ServerMessageToolCallsPhoneNumber] - def self.vapi(member:) - new(member: member, discriminant: "vapi") + begin + return Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/server_message_tool_calls_tool_with_tool_call_list_item.rb b/lib/vapi/types/server_message_tool_calls_tool_with_tool_call_list_item.rb index 8fdca6f..8e7962c 100644 --- a/lib/vapi/types/server_message_tool_calls_tool_with_tool_call_list_item.rb +++ b/lib/vapi/types/server_message_tool_calls_tool_with_tool_call_list_item.rb @@ -7,22 +7,6 @@ module Vapi class ServerMessageToolCallsToolWithToolCallListItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ServerMessageToolCallsToolWithToolCallListItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of # ServerMessageToolCallsToolWithToolCallListItem # @@ -30,34 +14,31 @@ def initialize(member:, discriminant:) # @return [Vapi::ServerMessageToolCallsToolWithToolCallListItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "function" - Vapi::FunctionToolWithToolCall.from_json(json_object: json_object) - when "ghl" - Vapi::GhlToolWithToolCall.from_json(json_object: json_object) - when "make" - Vapi::MakeToolWithToolCall.from_json(json_object: json_object) - else - Vapi::FunctionToolWithToolCall.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::FunctionToolWithToolCall.validate_raw(obj: struct) + return Vapi::FunctionToolWithToolCall.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "function" - { **@member.to_json, type: @discriminant }.to_json - when "ghl" - { **@member.to_json, type: @discriminant }.to_json - when "make" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::GhlToolWithToolCall.validate_raw(obj: struct) + return Vapi::GhlToolWithToolCall.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::MakeToolWithToolCall.validate_raw(obj: struct) + return Vapi::MakeToolWithToolCall.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -67,42 +48,22 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "function" - Vapi::FunctionToolWithToolCall.validate_raw(obj: obj) - when "ghl" - Vapi::GhlToolWithToolCall.validate_raw(obj: obj) - when "make" - Vapi::MakeToolWithToolCall.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::FunctionToolWithToolCall.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::FunctionToolWithToolCall] - # @return [Vapi::ServerMessageToolCallsToolWithToolCallListItem] - def self.function(member:) - new(member: member, discriminant: "function") - end - - # @param member [Vapi::GhlToolWithToolCall] - # @return [Vapi::ServerMessageToolCallsToolWithToolCallListItem] - def self.ghl(member:) - new(member: member, discriminant: "ghl") - end - - # @param member [Vapi::MakeToolWithToolCall] - # @return [Vapi::ServerMessageToolCallsToolWithToolCallListItem] - def self.make(member:) - new(member: member, discriminant: "make") + begin + return Vapi::GhlToolWithToolCall.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::MakeToolWithToolCall.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/server_message_transcript.rb b/lib/vapi/types/server_message_transcript.rb index 6310fe1..cb8582a 100644 --- a/lib/vapi/types/server_message_transcript.rb +++ b/lib/vapi/types/server_message_transcript.rb @@ -17,6 +17,9 @@ class ServerMessageTranscript # - `call.phoneNumber`, # - `call.phoneNumberId`. attr_reader :phone_number + # @return [String] This is the type of the message. "transcript" is sent as transcriber outputs + # partial or final transcript. + attr_reader :type # @return [String] This is the ISO-8601 formatted timestamp of when the message was sent. attr_reader :timestamp # @return [Vapi::Artifact] This is a live version of the `call.artifact`. @@ -60,6 +63,8 @@ class ServerMessageTranscript # This matches one of the following: # - `call.phoneNumber`, # - `call.phoneNumberId`. + # @param type [String] This is the type of the message. "transcript" is sent as transcriber outputs + # partial or final transcript. # @param timestamp [String] This is the ISO-8601 formatted timestamp of when the message was sent. # @param artifact [Vapi::Artifact] This is a live version of the `call.artifact`. # This matches what is stored on `call.artifact` after the call. @@ -85,9 +90,10 @@ class ServerMessageTranscript # @param transcript [String] This is the transcript content. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ServerMessageTranscript] - def initialize(role:, transcript_type:, transcript:, phone_number: OMIT, timestamp: OMIT, artifact: OMIT, - assistant: OMIT, customer: OMIT, call: OMIT, additional_properties: nil) + def initialize(type:, role:, transcript_type:, transcript:, phone_number: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, customer: OMIT, + call: OMIT, additional_properties: nil) @phone_number = phone_number if phone_number != OMIT + @type = type @timestamp = timestamp if timestamp != OMIT @artifact = artifact if artifact != OMIT @assistant = assistant if assistant != OMIT @@ -99,6 +105,7 @@ def initialize(role:, transcript_type:, transcript:, phone_number: OMIT, timesta @additional_properties = additional_properties @_field_set = { "phoneNumber": phone_number, + "type": type, "timestamp": timestamp, "artifact": artifact, "assistant": assistant, @@ -125,6 +132,7 @@ def self.from_json(json_object:) phone_number = parsed_json["phoneNumber"].to_json phone_number = Vapi::ServerMessageTranscriptPhoneNumber.from_json(json_object: phone_number) end + type = parsed_json["type"] timestamp = parsed_json["timestamp"] if parsed_json["artifact"].nil? artifact = nil @@ -155,6 +163,7 @@ def self.from_json(json_object:) transcript = parsed_json["transcript"] new( phone_number: phone_number, + type: type, timestamp: timestamp, artifact: artifact, assistant: assistant, @@ -182,6 +191,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.phone_number.nil? || Vapi::ServerMessageTranscriptPhoneNumber.validate_raw(obj: obj.phone_number) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.timestamp&.is_a?(String) != false || raise("Passed value for field obj.timestamp is not the expected type, validation failed.") obj.artifact.nil? || Vapi::Artifact.validate_raw(obj: obj.artifact) obj.assistant.nil? || Vapi::CreateAssistantDto.validate_raw(obj: obj.assistant) diff --git a/lib/vapi/types/server_message_transcript_phone_number.rb b/lib/vapi/types/server_message_transcript_phone_number.rb index 027a3dd..1dda54b 100644 --- a/lib/vapi/types/server_message_transcript_phone_number.rb +++ b/lib/vapi/types/server_message_transcript_phone_number.rb @@ -12,60 +12,45 @@ module Vapi # - `call.phoneNumber`, # - `call.phoneNumberId`. class ServerMessageTranscriptPhoneNumber - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ServerMessageTranscriptPhoneNumber] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of ServerMessageTranscriptPhoneNumber # # @param json_object [String] # @return [Vapi::ServerMessageTranscriptPhoneNumber] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: json_object) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.from_json(json_object: json_object) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.from_json(json_object: json_object) - else - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end + begin + Vapi::CreateByoPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateByoPhoneNumberDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "byo-phone-number" - { **@member.to_json, provider: @discriminant }.to_json - when "twilio" - { **@member.to_json, provider: @discriminant }.to_json - when "vonage" - { **@member.to_json, provider: @discriminant }.to_json - when "vapi" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVonagePhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVapiPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -75,50 +60,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateByoPhoneNumberDto] - # @return [Vapi::ServerMessageTranscriptPhoneNumber] - def self.byo_phone_number(member:) - new(member: member, discriminant: "byo-phone-number") - end - - # @param member [Vapi::CreateTwilioPhoneNumberDto] - # @return [Vapi::ServerMessageTranscriptPhoneNumber] - def self.twilio(member:) - new(member: member, discriminant: "twilio") - end - - # @param member [Vapi::CreateVonagePhoneNumberDto] - # @return [Vapi::ServerMessageTranscriptPhoneNumber] - def self.vonage(member:) - new(member: member, discriminant: "vonage") - end - - # @param member [Vapi::CreateVapiPhoneNumberDto] - # @return [Vapi::ServerMessageTranscriptPhoneNumber] - def self.vapi(member:) - new(member: member, discriminant: "vapi") + begin + return Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/server_message_transfer_destination_request.rb b/lib/vapi/types/server_message_transfer_destination_request.rb index bcce5df..eef20ea 100644 --- a/lib/vapi/types/server_message_transfer_destination_request.rb +++ b/lib/vapi/types/server_message_transfer_destination_request.rb @@ -15,6 +15,9 @@ class ServerMessageTransferDestinationRequest # - `call.phoneNumber`, # - `call.phoneNumberId`. attr_reader :phone_number + # @return [String] This is the type of the message. "transfer-destination-request" is sent when the + # model is requesting transfer but destination is unknown. + attr_reader :type # @return [String] This is the ISO-8601 formatted timestamp of when the message was sent. attr_reader :timestamp # @return [Vapi::Artifact] This is a live version of the `call.artifact`. @@ -52,6 +55,8 @@ class ServerMessageTransferDestinationRequest # This matches one of the following: # - `call.phoneNumber`, # - `call.phoneNumberId`. + # @param type [String] This is the type of the message. "transfer-destination-request" is sent when the + # model is requesting transfer but destination is unknown. # @param timestamp [String] This is the ISO-8601 formatted timestamp of when the message was sent. # @param artifact [Vapi::Artifact] This is a live version of the `call.artifact`. # This matches what is stored on `call.artifact` after the call. @@ -74,9 +79,10 @@ class ServerMessageTransferDestinationRequest # especially after the call is ended, use GET /call/:id. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ServerMessageTransferDestinationRequest] - def initialize(phone_number: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, customer: OMIT, call: OMIT, - additional_properties: nil) + def initialize(type:, phone_number: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, customer: OMIT, + call: OMIT, additional_properties: nil) @phone_number = phone_number if phone_number != OMIT + @type = type @timestamp = timestamp if timestamp != OMIT @artifact = artifact if artifact != OMIT @assistant = assistant if assistant != OMIT @@ -85,6 +91,7 @@ def initialize(phone_number: OMIT, timestamp: OMIT, artifact: OMIT, assistant: O @additional_properties = additional_properties @_field_set = { "phoneNumber": phone_number, + "type": type, "timestamp": timestamp, "artifact": artifact, "assistant": assistant, @@ -109,6 +116,7 @@ def self.from_json(json_object:) phone_number = parsed_json["phoneNumber"].to_json phone_number = Vapi::ServerMessageTransferDestinationRequestPhoneNumber.from_json(json_object: phone_number) end + type = parsed_json["type"] timestamp = parsed_json["timestamp"] if parsed_json["artifact"].nil? artifact = nil @@ -136,6 +144,7 @@ def self.from_json(json_object:) end new( phone_number: phone_number, + type: type, timestamp: timestamp, artifact: artifact, assistant: assistant, @@ -161,6 +170,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.phone_number.nil? || Vapi::ServerMessageTransferDestinationRequestPhoneNumber.validate_raw(obj: obj.phone_number) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.timestamp&.is_a?(String) != false || raise("Passed value for field obj.timestamp is not the expected type, validation failed.") obj.artifact.nil? || Vapi::Artifact.validate_raw(obj: obj.artifact) obj.assistant.nil? || Vapi::CreateAssistantDto.validate_raw(obj: obj.assistant) diff --git a/lib/vapi/types/server_message_transfer_destination_request_phone_number.rb b/lib/vapi/types/server_message_transfer_destination_request_phone_number.rb index e7d190c..f122067 100644 --- a/lib/vapi/types/server_message_transfer_destination_request_phone_number.rb +++ b/lib/vapi/types/server_message_transfer_destination_request_phone_number.rb @@ -12,22 +12,6 @@ module Vapi # - `call.phoneNumber`, # - `call.phoneNumberId`. class ServerMessageTransferDestinationRequestPhoneNumber - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ServerMessageTransferDestinationRequestPhoneNumber] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of # ServerMessageTransferDestinationRequestPhoneNumber # @@ -35,38 +19,39 @@ def initialize(member:, discriminant:) # @return [Vapi::ServerMessageTransferDestinationRequestPhoneNumber] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: json_object) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.from_json(json_object: json_object) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.from_json(json_object: json_object) - else - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end + begin + Vapi::CreateByoPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateByoPhoneNumberDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "byo-phone-number" - { **@member.to_json, provider: @discriminant }.to_json - when "twilio" - { **@member.to_json, provider: @discriminant }.to_json - when "vonage" - { **@member.to_json, provider: @discriminant }.to_json - when "vapi" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVonagePhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVapiPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -76,50 +61,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateByoPhoneNumberDto] - # @return [Vapi::ServerMessageTransferDestinationRequestPhoneNumber] - def self.byo_phone_number(member:) - new(member: member, discriminant: "byo-phone-number") - end - - # @param member [Vapi::CreateTwilioPhoneNumberDto] - # @return [Vapi::ServerMessageTransferDestinationRequestPhoneNumber] - def self.twilio(member:) - new(member: member, discriminant: "twilio") - end - - # @param member [Vapi::CreateVonagePhoneNumberDto] - # @return [Vapi::ServerMessageTransferDestinationRequestPhoneNumber] - def self.vonage(member:) - new(member: member, discriminant: "vonage") - end - - # @param member [Vapi::CreateVapiPhoneNumberDto] - # @return [Vapi::ServerMessageTransferDestinationRequestPhoneNumber] - def self.vapi(member:) - new(member: member, discriminant: "vapi") + begin + return Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/server_message_transfer_update.rb b/lib/vapi/types/server_message_transfer_update.rb index 4b76acd..0f3b509 100644 --- a/lib/vapi/types/server_message_transfer_update.rb +++ b/lib/vapi/types/server_message_transfer_update.rb @@ -16,6 +16,9 @@ class ServerMessageTransferUpdate # - `call.phoneNumber`, # - `call.phoneNumberId`. attr_reader :phone_number + # @return [String] This is the type of the message. "transfer-update" is sent whenever a transfer + # happens. + attr_reader :type # @return [Vapi::ServerMessageTransferUpdateDestination] This is the destination of the transfer. attr_reader :destination # @return [String] This is the ISO-8601 formatted timestamp of when the message was sent. @@ -61,6 +64,8 @@ class ServerMessageTransferUpdate # This matches one of the following: # - `call.phoneNumber`, # - `call.phoneNumberId`. + # @param type [String] This is the type of the message. "transfer-update" is sent whenever a transfer + # happens. # @param destination [Vapi::ServerMessageTransferUpdateDestination] This is the destination of the transfer. # @param timestamp [String] This is the ISO-8601 formatted timestamp of when the message was sent. # @param artifact [Vapi::Artifact] This is a live version of the `call.artifact`. @@ -88,9 +93,10 @@ class ServerMessageTransferUpdate # if `destination.type` is "assistant". # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ServerMessageTransferUpdate] - def initialize(phone_number: OMIT, destination: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, + def initialize(type:, phone_number: OMIT, destination: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, customer: OMIT, call: OMIT, to_assistant: OMIT, from_assistant: OMIT, additional_properties: nil) @phone_number = phone_number if phone_number != OMIT + @type = type @destination = destination if destination != OMIT @timestamp = timestamp if timestamp != OMIT @artifact = artifact if artifact != OMIT @@ -102,6 +108,7 @@ def initialize(phone_number: OMIT, destination: OMIT, timestamp: OMIT, artifact: @additional_properties = additional_properties @_field_set = { "phoneNumber": phone_number, + "type": type, "destination": destination, "timestamp": timestamp, "artifact": artifact, @@ -128,6 +135,7 @@ def self.from_json(json_object:) phone_number = parsed_json["phoneNumber"].to_json phone_number = Vapi::ServerMessageTransferUpdatePhoneNumber.from_json(json_object: phone_number) end + type = parsed_json["type"] if parsed_json["destination"].nil? destination = nil else @@ -173,6 +181,7 @@ def self.from_json(json_object:) end new( phone_number: phone_number, + type: type, destination: destination, timestamp: timestamp, artifact: artifact, @@ -200,6 +209,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.phone_number.nil? || Vapi::ServerMessageTransferUpdatePhoneNumber.validate_raw(obj: obj.phone_number) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.destination.nil? || Vapi::ServerMessageTransferUpdateDestination.validate_raw(obj: obj.destination) obj.timestamp&.is_a?(String) != false || raise("Passed value for field obj.timestamp is not the expected type, validation failed.") obj.artifact.nil? || Vapi::Artifact.validate_raw(obj: obj.artifact) diff --git a/lib/vapi/types/server_message_transfer_update_destination.rb b/lib/vapi/types/server_message_transfer_update_destination.rb index 87805d1..16f8ea7 100644 --- a/lib/vapi/types/server_message_transfer_update_destination.rb +++ b/lib/vapi/types/server_message_transfer_update_destination.rb @@ -9,22 +9,6 @@ module Vapi # This is the destination of the transfer. class ServerMessageTransferUpdateDestination - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ServerMessageTransferUpdateDestination] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of # ServerMessageTransferUpdateDestination # @@ -32,38 +16,39 @@ def initialize(member:, discriminant:) # @return [Vapi::ServerMessageTransferUpdateDestination] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "assistant" - Vapi::TransferDestinationAssistant.from_json(json_object: json_object) - when "step" - Vapi::TransferDestinationStep.from_json(json_object: json_object) - when "number" - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - when "sip" - Vapi::TransferDestinationSip.from_json(json_object: json_object) - else - Vapi::TransferDestinationAssistant.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::TransferDestinationAssistant.validate_raw(obj: struct) + return Vapi::TransferDestinationAssistant.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "assistant" - { **@member.to_json, type: @discriminant }.to_json - when "step" - { **@member.to_json, type: @discriminant }.to_json - when "number" - { **@member.to_json, type: @discriminant }.to_json - when "sip" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::TransferDestinationStep.validate_raw(obj: struct) + return Vapi::TransferDestinationStep.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::TransferDestinationNumber.validate_raw(obj: struct) + return Vapi::TransferDestinationNumber.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::TransferDestinationSip.validate_raw(obj: struct) + return Vapi::TransferDestinationSip.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -73,50 +58,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "assistant" - Vapi::TransferDestinationAssistant.validate_raw(obj: obj) - when "step" - Vapi::TransferDestinationStep.validate_raw(obj: obj) - when "number" - Vapi::TransferDestinationNumber.validate_raw(obj: obj) - when "sip" - Vapi::TransferDestinationSip.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::TransferDestinationAssistant.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::TransferDestinationAssistant] - # @return [Vapi::ServerMessageTransferUpdateDestination] - def self.assistant(member:) - new(member: member, discriminant: "assistant") - end - - # @param member [Vapi::TransferDestinationStep] - # @return [Vapi::ServerMessageTransferUpdateDestination] - def self.step(member:) - new(member: member, discriminant: "step") - end - - # @param member [Vapi::TransferDestinationNumber] - # @return [Vapi::ServerMessageTransferUpdateDestination] - def self.number(member:) - new(member: member, discriminant: "number") - end - - # @param member [Vapi::TransferDestinationSip] - # @return [Vapi::ServerMessageTransferUpdateDestination] - def self.sip(member:) - new(member: member, discriminant: "sip") + begin + return Vapi::TransferDestinationStep.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::TransferDestinationNumber.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::TransferDestinationSip.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/server_message_transfer_update_phone_number.rb b/lib/vapi/types/server_message_transfer_update_phone_number.rb index 18be2c0..4d51b63 100644 --- a/lib/vapi/types/server_message_transfer_update_phone_number.rb +++ b/lib/vapi/types/server_message_transfer_update_phone_number.rb @@ -12,22 +12,6 @@ module Vapi # - `call.phoneNumber`, # - `call.phoneNumberId`. class ServerMessageTransferUpdatePhoneNumber - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ServerMessageTransferUpdatePhoneNumber] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of # ServerMessageTransferUpdatePhoneNumber # @@ -35,38 +19,39 @@ def initialize(member:, discriminant:) # @return [Vapi::ServerMessageTransferUpdatePhoneNumber] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: json_object) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.from_json(json_object: json_object) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.from_json(json_object: json_object) - else - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end + begin + Vapi::CreateByoPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateByoPhoneNumberDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "byo-phone-number" - { **@member.to_json, provider: @discriminant }.to_json - when "twilio" - { **@member.to_json, provider: @discriminant }.to_json - when "vonage" - { **@member.to_json, provider: @discriminant }.to_json - when "vapi" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVonagePhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVapiPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -76,50 +61,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateByoPhoneNumberDto] - # @return [Vapi::ServerMessageTransferUpdatePhoneNumber] - def self.byo_phone_number(member:) - new(member: member, discriminant: "byo-phone-number") - end - - # @param member [Vapi::CreateTwilioPhoneNumberDto] - # @return [Vapi::ServerMessageTransferUpdatePhoneNumber] - def self.twilio(member:) - new(member: member, discriminant: "twilio") - end - - # @param member [Vapi::CreateVonagePhoneNumberDto] - # @return [Vapi::ServerMessageTransferUpdatePhoneNumber] - def self.vonage(member:) - new(member: member, discriminant: "vonage") - end - - # @param member [Vapi::CreateVapiPhoneNumberDto] - # @return [Vapi::ServerMessageTransferUpdatePhoneNumber] - def self.vapi(member:) - new(member: member, discriminant: "vapi") + begin + return Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/server_message_user_interrupted.rb b/lib/vapi/types/server_message_user_interrupted.rb index bac4dd8..b06bf23 100644 --- a/lib/vapi/types/server_message_user_interrupted.rb +++ b/lib/vapi/types/server_message_user_interrupted.rb @@ -15,6 +15,9 @@ class ServerMessageUserInterrupted # - `call.phoneNumber`, # - `call.phoneNumberId`. attr_reader :phone_number + # @return [String] This is the type of the message. "user-interrupted" is sent when the user + # interrupts the assistant. + attr_reader :type # @return [String] This is the ISO-8601 formatted timestamp of when the message was sent. attr_reader :timestamp # @return [Vapi::Artifact] This is a live version of the `call.artifact`. @@ -52,6 +55,8 @@ class ServerMessageUserInterrupted # This matches one of the following: # - `call.phoneNumber`, # - `call.phoneNumberId`. + # @param type [String] This is the type of the message. "user-interrupted" is sent when the user + # interrupts the assistant. # @param timestamp [String] This is the ISO-8601 formatted timestamp of when the message was sent. # @param artifact [Vapi::Artifact] This is a live version of the `call.artifact`. # This matches what is stored on `call.artifact` after the call. @@ -74,9 +79,10 @@ class ServerMessageUserInterrupted # especially after the call is ended, use GET /call/:id. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ServerMessageUserInterrupted] - def initialize(phone_number: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, customer: OMIT, call: OMIT, - additional_properties: nil) + def initialize(type:, phone_number: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, customer: OMIT, + call: OMIT, additional_properties: nil) @phone_number = phone_number if phone_number != OMIT + @type = type @timestamp = timestamp if timestamp != OMIT @artifact = artifact if artifact != OMIT @assistant = assistant if assistant != OMIT @@ -85,6 +91,7 @@ def initialize(phone_number: OMIT, timestamp: OMIT, artifact: OMIT, assistant: O @additional_properties = additional_properties @_field_set = { "phoneNumber": phone_number, + "type": type, "timestamp": timestamp, "artifact": artifact, "assistant": assistant, @@ -108,6 +115,7 @@ def self.from_json(json_object:) phone_number = parsed_json["phoneNumber"].to_json phone_number = Vapi::ServerMessageUserInterruptedPhoneNumber.from_json(json_object: phone_number) end + type = parsed_json["type"] timestamp = parsed_json["timestamp"] if parsed_json["artifact"].nil? artifact = nil @@ -135,6 +143,7 @@ def self.from_json(json_object:) end new( phone_number: phone_number, + type: type, timestamp: timestamp, artifact: artifact, assistant: assistant, @@ -159,6 +168,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.phone_number.nil? || Vapi::ServerMessageUserInterruptedPhoneNumber.validate_raw(obj: obj.phone_number) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.timestamp&.is_a?(String) != false || raise("Passed value for field obj.timestamp is not the expected type, validation failed.") obj.artifact.nil? || Vapi::Artifact.validate_raw(obj: obj.artifact) obj.assistant.nil? || Vapi::CreateAssistantDto.validate_raw(obj: obj.assistant) diff --git a/lib/vapi/types/server_message_user_interrupted_phone_number.rb b/lib/vapi/types/server_message_user_interrupted_phone_number.rb index febba5e..0cedbd3 100644 --- a/lib/vapi/types/server_message_user_interrupted_phone_number.rb +++ b/lib/vapi/types/server_message_user_interrupted_phone_number.rb @@ -12,22 +12,6 @@ module Vapi # - `call.phoneNumber`, # - `call.phoneNumberId`. class ServerMessageUserInterruptedPhoneNumber - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ServerMessageUserInterruptedPhoneNumber] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of # ServerMessageUserInterruptedPhoneNumber # @@ -35,38 +19,39 @@ def initialize(member:, discriminant:) # @return [Vapi::ServerMessageUserInterruptedPhoneNumber] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: json_object) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.from_json(json_object: json_object) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.from_json(json_object: json_object) - else - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end + begin + Vapi::CreateByoPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateByoPhoneNumberDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "byo-phone-number" - { **@member.to_json, provider: @discriminant }.to_json - when "twilio" - { **@member.to_json, provider: @discriminant }.to_json - when "vonage" - { **@member.to_json, provider: @discriminant }.to_json - when "vapi" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVonagePhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVapiPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -76,50 +61,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateByoPhoneNumberDto] - # @return [Vapi::ServerMessageUserInterruptedPhoneNumber] - def self.byo_phone_number(member:) - new(member: member, discriminant: "byo-phone-number") - end - - # @param member [Vapi::CreateTwilioPhoneNumberDto] - # @return [Vapi::ServerMessageUserInterruptedPhoneNumber] - def self.twilio(member:) - new(member: member, discriminant: "twilio") - end - - # @param member [Vapi::CreateVonagePhoneNumberDto] - # @return [Vapi::ServerMessageUserInterruptedPhoneNumber] - def self.vonage(member:) - new(member: member, discriminant: "vonage") - end - - # @param member [Vapi::CreateVapiPhoneNumberDto] - # @return [Vapi::ServerMessageUserInterruptedPhoneNumber] - def self.vapi(member:) - new(member: member, discriminant: "vapi") + begin + return Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/server_message_voice_input.rb b/lib/vapi/types/server_message_voice_input.rb index 4cc4db1..05d934c 100644 --- a/lib/vapi/types/server_message_voice_input.rb +++ b/lib/vapi/types/server_message_voice_input.rb @@ -15,6 +15,9 @@ class ServerMessageVoiceInput # - `call.phoneNumber`, # - `call.phoneNumberId`. attr_reader :phone_number + # @return [String] This is the type of the message. "voice-input" is sent when a generation is + # requested from voice provider. + attr_reader :type # @return [String] This is the ISO-8601 formatted timestamp of when the message was sent. attr_reader :timestamp # @return [Vapi::Artifact] This is a live version of the `call.artifact`. @@ -54,6 +57,8 @@ class ServerMessageVoiceInput # This matches one of the following: # - `call.phoneNumber`, # - `call.phoneNumberId`. + # @param type [String] This is the type of the message. "voice-input" is sent when a generation is + # requested from voice provider. # @param timestamp [String] This is the ISO-8601 formatted timestamp of when the message was sent. # @param artifact [Vapi::Artifact] This is a live version of the `call.artifact`. # This matches what is stored on `call.artifact` after the call. @@ -77,9 +82,10 @@ class ServerMessageVoiceInput # @param input [String] This is the voice input content # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ServerMessageVoiceInput] - def initialize(input:, phone_number: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, customer: OMIT, + def initialize(type:, input:, phone_number: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, customer: OMIT, call: OMIT, additional_properties: nil) @phone_number = phone_number if phone_number != OMIT + @type = type @timestamp = timestamp if timestamp != OMIT @artifact = artifact if artifact != OMIT @assistant = assistant if assistant != OMIT @@ -89,6 +95,7 @@ def initialize(input:, phone_number: OMIT, timestamp: OMIT, artifact: OMIT, assi @additional_properties = additional_properties @_field_set = { "phoneNumber": phone_number, + "type": type, "timestamp": timestamp, "artifact": artifact, "assistant": assistant, @@ -113,6 +120,7 @@ def self.from_json(json_object:) phone_number = parsed_json["phoneNumber"].to_json phone_number = Vapi::ServerMessageVoiceInputPhoneNumber.from_json(json_object: phone_number) end + type = parsed_json["type"] timestamp = parsed_json["timestamp"] if parsed_json["artifact"].nil? artifact = nil @@ -141,6 +149,7 @@ def self.from_json(json_object:) input = parsed_json["input"] new( phone_number: phone_number, + type: type, timestamp: timestamp, artifact: artifact, assistant: assistant, @@ -166,6 +175,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.phone_number.nil? || Vapi::ServerMessageVoiceInputPhoneNumber.validate_raw(obj: obj.phone_number) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.timestamp&.is_a?(String) != false || raise("Passed value for field obj.timestamp is not the expected type, validation failed.") obj.artifact.nil? || Vapi::Artifact.validate_raw(obj: obj.artifact) obj.assistant.nil? || Vapi::CreateAssistantDto.validate_raw(obj: obj.assistant) diff --git a/lib/vapi/types/server_message_voice_input_phone_number.rb b/lib/vapi/types/server_message_voice_input_phone_number.rb index 3e4d8d6..0888868 100644 --- a/lib/vapi/types/server_message_voice_input_phone_number.rb +++ b/lib/vapi/types/server_message_voice_input_phone_number.rb @@ -12,60 +12,45 @@ module Vapi # - `call.phoneNumber`, # - `call.phoneNumberId`. class ServerMessageVoiceInputPhoneNumber - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ServerMessageVoiceInputPhoneNumber] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of ServerMessageVoiceInputPhoneNumber # # @param json_object [String] # @return [Vapi::ServerMessageVoiceInputPhoneNumber] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: json_object) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.from_json(json_object: json_object) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.from_json(json_object: json_object) - else - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end + begin + Vapi::CreateByoPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateByoPhoneNumberDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "byo-phone-number" - { **@member.to_json, provider: @discriminant }.to_json - when "twilio" - { **@member.to_json, provider: @discriminant }.to_json - when "vonage" - { **@member.to_json, provider: @discriminant }.to_json - when "vapi" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVonagePhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVapiPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -75,50 +60,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateByoPhoneNumberDto] - # @return [Vapi::ServerMessageVoiceInputPhoneNumber] - def self.byo_phone_number(member:) - new(member: member, discriminant: "byo-phone-number") - end - - # @param member [Vapi::CreateTwilioPhoneNumberDto] - # @return [Vapi::ServerMessageVoiceInputPhoneNumber] - def self.twilio(member:) - new(member: member, discriminant: "twilio") - end - - # @param member [Vapi::CreateVonagePhoneNumberDto] - # @return [Vapi::ServerMessageVoiceInputPhoneNumber] - def self.vonage(member:) - new(member: member, discriminant: "vonage") - end - - # @param member [Vapi::CreateVapiPhoneNumberDto] - # @return [Vapi::ServerMessageVoiceInputPhoneNumber] - def self.vapi(member:) - new(member: member, discriminant: "vapi") + begin + return Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/server_message_voice_request.rb b/lib/vapi/types/server_message_voice_request.rb index 0e9cdd4..be0d428 100644 --- a/lib/vapi/types/server_message_voice_request.rb +++ b/lib/vapi/types/server_message_voice_request.rb @@ -15,6 +15,28 @@ class ServerMessageVoiceRequest # - `call.phoneNumber`, # - `call.phoneNumberId`. attr_reader :phone_number + # @return [String] This is the type of the message. "voice-request" is sent when using + # `assistant.voice={ "type": "custom-voice" }`. + # Here is what the request will look like: + # POST https://{assistant.voice.server.url} + # Content-Type: application/json + # { + # "messsage": { + # "type": "voice-request", + # "text": "Hello, world!", + # "sampleRate": 24000, + # ...other metadata about the call... + # } + # } + # The expected response is 1-channel 16-bit raw PCM audio at the sample rate + # specified in the request. Here is how the response will be piped to the + # transport: + # ``` + # response.on('data', (chunk: Buffer) => { + # outputStream.write(chunk); + # }); + # ``` + attr_reader :type # @return [String] This is the ISO-8601 formatted timestamp of when the message was sent. attr_reader :timestamp # @return [Vapi::Artifact] This is a live version of the `call.artifact`. @@ -56,6 +78,27 @@ class ServerMessageVoiceRequest # This matches one of the following: # - `call.phoneNumber`, # - `call.phoneNumberId`. + # @param type [String] This is the type of the message. "voice-request" is sent when using + # `assistant.voice={ "type": "custom-voice" }`. + # Here is what the request will look like: + # POST https://{assistant.voice.server.url} + # Content-Type: application/json + # { + # "messsage": { + # "type": "voice-request", + # "text": "Hello, world!", + # "sampleRate": 24000, + # ...other metadata about the call... + # } + # } + # The expected response is 1-channel 16-bit raw PCM audio at the sample rate + # specified in the request. Here is how the response will be piped to the + # transport: + # ``` + # response.on('data', (chunk: Buffer) => { + # outputStream.write(chunk); + # }); + # ``` # @param timestamp [String] This is the ISO-8601 formatted timestamp of when the message was sent. # @param artifact [Vapi::Artifact] This is a live version of the `call.artifact`. # This matches what is stored on `call.artifact` after the call. @@ -80,9 +123,10 @@ class ServerMessageVoiceRequest # @param sample_rate [Float] This is the sample rate to be synthesized. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ServerMessageVoiceRequest] - def initialize(text:, sample_rate:, phone_number: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, - customer: OMIT, call: OMIT, additional_properties: nil) + def initialize(type:, text:, sample_rate:, phone_number: OMIT, timestamp: OMIT, artifact: OMIT, assistant: OMIT, customer: OMIT, + call: OMIT, additional_properties: nil) @phone_number = phone_number if phone_number != OMIT + @type = type @timestamp = timestamp if timestamp != OMIT @artifact = artifact if artifact != OMIT @assistant = assistant if assistant != OMIT @@ -93,6 +137,7 @@ def initialize(text:, sample_rate:, phone_number: OMIT, timestamp: OMIT, artifac @additional_properties = additional_properties @_field_set = { "phoneNumber": phone_number, + "type": type, "timestamp": timestamp, "artifact": artifact, "assistant": assistant, @@ -118,6 +163,7 @@ def self.from_json(json_object:) phone_number = parsed_json["phoneNumber"].to_json phone_number = Vapi::ServerMessageVoiceRequestPhoneNumber.from_json(json_object: phone_number) end + type = parsed_json["type"] timestamp = parsed_json["timestamp"] if parsed_json["artifact"].nil? artifact = nil @@ -147,6 +193,7 @@ def self.from_json(json_object:) sample_rate = parsed_json["sampleRate"] new( phone_number: phone_number, + type: type, timestamp: timestamp, artifact: artifact, assistant: assistant, @@ -173,6 +220,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.phone_number.nil? || Vapi::ServerMessageVoiceRequestPhoneNumber.validate_raw(obj: obj.phone_number) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.timestamp&.is_a?(String) != false || raise("Passed value for field obj.timestamp is not the expected type, validation failed.") obj.artifact.nil? || Vapi::Artifact.validate_raw(obj: obj.artifact) obj.assistant.nil? || Vapi::CreateAssistantDto.validate_raw(obj: obj.assistant) diff --git a/lib/vapi/types/server_message_voice_request_phone_number.rb b/lib/vapi/types/server_message_voice_request_phone_number.rb index 11e8f61..85381d9 100644 --- a/lib/vapi/types/server_message_voice_request_phone_number.rb +++ b/lib/vapi/types/server_message_voice_request_phone_number.rb @@ -12,60 +12,45 @@ module Vapi # - `call.phoneNumber`, # - `call.phoneNumberId`. class ServerMessageVoiceRequestPhoneNumber - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ServerMessageVoiceRequestPhoneNumber] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of ServerMessageVoiceRequestPhoneNumber # # @param json_object [String] # @return [Vapi::ServerMessageVoiceRequestPhoneNumber] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: json_object) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.from_json(json_object: json_object) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.from_json(json_object: json_object) - else - Vapi::CreateByoPhoneNumberDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.provider) - end + begin + Vapi::CreateByoPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateByoPhoneNumberDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "byo-phone-number" - { **@member.to_json, provider: @discriminant }.to_json - when "twilio" - { **@member.to_json, provider: @discriminant }.to_json - when "vonage" - { **@member.to_json, provider: @discriminant }.to_json - when "vapi" - { **@member.to_json, provider: @discriminant }.to_json - else - { "provider": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateTwilioPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVonagePhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: struct) + return Vapi::CreateVapiPhoneNumberDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -75,50 +60,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.provider - when "byo-phone-number" - Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) - when "twilio" - Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) - when "vonage" - Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) - when "vapi" - Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateByoPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateByoPhoneNumberDto] - # @return [Vapi::ServerMessageVoiceRequestPhoneNumber] - def self.byo_phone_number(member:) - new(member: member, discriminant: "byo-phone-number") - end - - # @param member [Vapi::CreateTwilioPhoneNumberDto] - # @return [Vapi::ServerMessageVoiceRequestPhoneNumber] - def self.twilio(member:) - new(member: member, discriminant: "twilio") - end - - # @param member [Vapi::CreateVonagePhoneNumberDto] - # @return [Vapi::ServerMessageVoiceRequestPhoneNumber] - def self.vonage(member:) - new(member: member, discriminant: "vonage") - end - - # @param member [Vapi::CreateVapiPhoneNumberDto] - # @return [Vapi::ServerMessageVoiceRequestPhoneNumber] - def self.vapi(member:) - new(member: member, discriminant: "vapi") + begin + return Vapi::CreateTwilioPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVonagePhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVapiPhoneNumberDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/step_destination_conditions_item.rb b/lib/vapi/types/step_destination_conditions_item.rb index 12ea795..5ceba9b 100644 --- a/lib/vapi/types/step_destination_conditions_item.rb +++ b/lib/vapi/types/step_destination_conditions_item.rb @@ -6,52 +6,29 @@ module Vapi class StepDestinationConditionsItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::StepDestinationConditionsItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of StepDestinationConditionsItem # # @param json_object [String] # @return [Vapi::StepDestinationConditionsItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "model-based" - Vapi::ModelBasedCondition.from_json(json_object: json_object) - when "rule-based" - Vapi::RuleBasedCondition.from_json(json_object: json_object) - else - Vapi::ModelBasedCondition.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ModelBasedCondition.validate_raw(obj: struct) + return Vapi::ModelBasedCondition.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "model-based" - { **@member.to_json, type: @discriminant }.to_json - when "rule-based" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::RuleBasedCondition.validate_raw(obj: struct) + return Vapi::RuleBasedCondition.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -61,34 +38,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "model-based" - Vapi::ModelBasedCondition.validate_raw(obj: obj) - when "rule-based" - Vapi::RuleBasedCondition.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ModelBasedCondition.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ModelBasedCondition] - # @return [Vapi::StepDestinationConditionsItem] - def self.model_based(member:) - new(member: member, discriminant: "model-based") - end - - # @param member [Vapi::RuleBasedCondition] - # @return [Vapi::StepDestinationConditionsItem] - def self.rule_based(member:) - new(member: member, discriminant: "rule-based") + begin + return Vapi::RuleBasedCondition.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/talkscriber_transcriber.rb b/lib/vapi/types/talkscriber_transcriber.rb index 01c7e69..2baf2a6 100644 --- a/lib/vapi/types/talkscriber_transcriber.rb +++ b/lib/vapi/types/talkscriber_transcriber.rb @@ -6,6 +6,8 @@ module Vapi class TalkscriberTranscriber + # @return [String] This is the transcription provider that will be used. + attr_reader :provider # @return [String] This is the model that will be used for the transcription. attr_reader :model # @return [Vapi::TalkscriberTranscriberLanguage] This is the language that will be set for the transcription. The list of @@ -20,17 +22,19 @@ class TalkscriberTranscriber OMIT = Object.new + # @param provider [String] This is the transcription provider that will be used. # @param model [String] This is the model that will be used for the transcription. # @param language [Vapi::TalkscriberTranscriberLanguage] This is the language that will be set for the transcription. The list of # languages Whisper supports can be found here: # https://github.com/openai/whisper/blob/main/whisper/tokenizer.py # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::TalkscriberTranscriber] - def initialize(model: OMIT, language: OMIT, additional_properties: nil) + def initialize(provider:, model: OMIT, language: OMIT, additional_properties: nil) + @provider = provider @model = model if model != OMIT @language = language if language != OMIT @additional_properties = additional_properties - @_field_set = { "model": model, "language": language }.reject do |_k, v| + @_field_set = { "provider": provider, "model": model, "language": language }.reject do |_k, v| v == OMIT end end @@ -42,9 +46,11 @@ def initialize(model: OMIT, language: OMIT, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + provider = parsed_json["provider"] model = parsed_json["model"] language = parsed_json["language"] new( + provider: provider, model: model, language: language, additional_properties: struct @@ -65,6 +71,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") obj.model&.is_a?(String) != false || raise("Passed value for field obj.model is not the expected type, validation failed.") obj.language&.is_a?(Vapi::TalkscriberTranscriberLanguage) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") end diff --git a/lib/vapi/types/template_details.rb b/lib/vapi/types/template_details.rb index 9089acf..d0cfa1a 100644 --- a/lib/vapi/types/template_details.rb +++ b/lib/vapi/types/template_details.rb @@ -11,72 +11,69 @@ module Vapi class TemplateDetails - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::TemplateDetails] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of TemplateDetails # # @param json_object [String] # @return [Vapi::TemplateDetails] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "dtmf" - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - when "endCall" - Vapi::CreateEndCallToolDto.from_json(json_object: json_object) - when "voicemail" - Vapi::CreateVoicemailToolDto.from_json(json_object: json_object) - when "function" - Vapi::CreateFunctionToolDto.from_json(json_object: json_object) - when "ghl" - Vapi::CreateGhlToolDto.from_json(json_object: json_object) - when "make" - Vapi::CreateMakeToolDto.from_json(json_object: json_object) - when "transferCall" - Vapi::CreateTransferCallToolDto.from_json(json_object: json_object) - else - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::CreateDtmfToolDto.validate_raw(obj: struct) + return Vapi::CreateDtmfToolDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "dtmf" - { **@member.to_json, type: @discriminant }.to_json - when "endCall" - { **@member.to_json, type: @discriminant }.to_json - when "voicemail" - { **@member.to_json, type: @discriminant }.to_json - when "function" - { **@member.to_json, type: @discriminant }.to_json - when "ghl" - { **@member.to_json, type: @discriminant }.to_json - when "make" - { **@member.to_json, type: @discriminant }.to_json - when "transferCall" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateEndCallToolDto.validate_raw(obj: struct) + return Vapi::CreateEndCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVoicemailToolDto.validate_raw(obj: struct) + return Vapi::CreateVoicemailToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateFunctionToolDto.validate_raw(obj: struct) + return Vapi::CreateFunctionToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::CreateGhlToolDto.validate_raw(obj: struct) + return Vapi::CreateGhlToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateMakeToolDto.validate_raw(obj: struct) + return Vapi::CreateMakeToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTransferCallToolDto.validate_raw(obj: struct) + return Vapi::CreateTransferCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -86,74 +83,42 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "dtmf" - Vapi::CreateDtmfToolDto.validate_raw(obj: obj) - when "endCall" - Vapi::CreateEndCallToolDto.validate_raw(obj: obj) - when "voicemail" - Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) - when "function" - Vapi::CreateFunctionToolDto.validate_raw(obj: obj) - when "ghl" - Vapi::CreateGhlToolDto.validate_raw(obj: obj) - when "make" - Vapi::CreateMakeToolDto.validate_raw(obj: obj) - when "transferCall" - Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateDtmfToolDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateDtmfToolDto] - # @return [Vapi::TemplateDetails] - def self.dtmf(member:) - new(member: member, discriminant: "dtmf") - end - - # @param member [Vapi::CreateEndCallToolDto] - # @return [Vapi::TemplateDetails] - def self.end_call(member:) - new(member: member, discriminant: "endCall") - end - - # @param member [Vapi::CreateVoicemailToolDto] - # @return [Vapi::TemplateDetails] - def self.voicemail(member:) - new(member: member, discriminant: "voicemail") - end - - # @param member [Vapi::CreateFunctionToolDto] - # @return [Vapi::TemplateDetails] - def self.function(member:) - new(member: member, discriminant: "function") - end - - # @param member [Vapi::CreateGhlToolDto] - # @return [Vapi::TemplateDetails] - def self.ghl(member:) - new(member: member, discriminant: "ghl") - end - - # @param member [Vapi::CreateMakeToolDto] - # @return [Vapi::TemplateDetails] - def self.make(member:) - new(member: member, discriminant: "make") - end - - # @param member [Vapi::CreateTransferCallToolDto] - # @return [Vapi::TemplateDetails] - def self.transfer_call(member:) - new(member: member, discriminant: "transferCall") + begin + return Vapi::CreateEndCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateFunctionToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateGhlToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateMakeToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/template_provider_details.rb b/lib/vapi/types/template_provider_details.rb index a79f513..eb9897a 100644 --- a/lib/vapi/types/template_provider_details.rb +++ b/lib/vapi/types/template_provider_details.rb @@ -7,56 +7,37 @@ module Vapi class TemplateProviderDetails - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::TemplateProviderDetails] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of TemplateProviderDetails # # @param json_object [String] # @return [Vapi::TemplateProviderDetails] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "make" - Vapi::MakeToolProviderDetails.from_json(json_object: json_object) - when "ghl" - Vapi::GhlToolProviderDetails.from_json(json_object: json_object) - when "function" - Vapi::FunctionToolProviderDetails.from_json(json_object: json_object) - else - Vapi::MakeToolProviderDetails.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::MakeToolProviderDetails.validate_raw(obj: struct) + return Vapi::MakeToolProviderDetails.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "make" - { **@member.to_json, type: @discriminant }.to_json - when "ghl" - { **@member.to_json, type: @discriminant }.to_json - when "function" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::GhlToolProviderDetails.validate_raw(obj: struct) + return Vapi::GhlToolProviderDetails.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::FunctionToolProviderDetails.validate_raw(obj: struct) + return Vapi::FunctionToolProviderDetails.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -66,42 +47,22 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "make" - Vapi::MakeToolProviderDetails.validate_raw(obj: obj) - when "ghl" - Vapi::GhlToolProviderDetails.validate_raw(obj: obj) - when "function" - Vapi::FunctionToolProviderDetails.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::MakeToolProviderDetails.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::MakeToolProviderDetails] - # @return [Vapi::TemplateProviderDetails] - def self.make(member:) - new(member: member, discriminant: "make") - end - - # @param member [Vapi::GhlToolProviderDetails] - # @return [Vapi::TemplateProviderDetails] - def self.ghl(member:) - new(member: member, discriminant: "ghl") - end - - # @param member [Vapi::FunctionToolProviderDetails] - # @return [Vapi::TemplateProviderDetails] - def self.function(member:) - new(member: member, discriminant: "function") + begin + return Vapi::GhlToolProviderDetails.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::FunctionToolProviderDetails.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/together_ai_model.rb b/lib/vapi/types/together_ai_model.rb index 8f567d1..07bdd3f 100644 --- a/lib/vapi/types/together_ai_model.rb +++ b/lib/vapi/types/together_ai_model.rb @@ -18,6 +18,8 @@ class TogetherAiModel # tools, use `tools`. # Both `tools` and `toolIds` can be used together. attr_reader :tool_ids + # @return [String] + attr_reader :provider # @return [String] This is the name of the model. Ex. cognitivecomputations/dolphin-mixtral-8x7b attr_reader :model # @return [Float] This is the temperature that will be used for calls. Default is 0 to leverage @@ -55,6 +57,7 @@ class TogetherAiModel # @param tool_ids [Array] These are the tools that the assistant can use during the call. To use transient # tools, use `tools`. # Both `tools` and `toolIds` can be used together. + # @param provider [String] # @param model [String] This is the name of the model. Ex. cognitivecomputations/dolphin-mixtral-8x7b # @param temperature [Float] This is the temperature that will be used for calls. Default is 0 to leverage # caching for lower latency. @@ -73,11 +76,12 @@ class TogetherAiModel # @default 0 # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::TogetherAiModel] - def initialize(model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, temperature: OMIT, knowledge_base: OMIT, - max_tokens: OMIT, emotion_recognition_enabled: OMIT, num_fast_turns: OMIT, additional_properties: nil) + def initialize(provider:, model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, temperature: OMIT, + knowledge_base: OMIT, max_tokens: OMIT, emotion_recognition_enabled: OMIT, num_fast_turns: OMIT, additional_properties: nil) @messages = messages if messages != OMIT @tools = tools if tools != OMIT @tool_ids = tool_ids if tool_ids != OMIT + @provider = provider @model = model @temperature = temperature if temperature != OMIT @knowledge_base = knowledge_base if knowledge_base != OMIT @@ -89,6 +93,7 @@ def initialize(model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, temperature: "messages": messages, "tools": tools, "toolIds": tool_ids, + "provider": provider, "model": model, "temperature": temperature, "knowledgeBase": knowledge_base, @@ -116,6 +121,7 @@ def self.from_json(json_object:) Vapi::TogetherAiModelToolsItem.from_json(json_object: item) end tool_ids = parsed_json["toolIds"] + provider = parsed_json["provider"] model = parsed_json["model"] temperature = parsed_json["temperature"] if parsed_json["knowledgeBase"].nil? @@ -131,6 +137,7 @@ def self.from_json(json_object:) messages: messages, tools: tools, tool_ids: tool_ids, + provider: provider, model: model, temperature: temperature, knowledge_base: knowledge_base, @@ -158,6 +165,7 @@ 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.tools&.is_a?(Array) != false || raise("Passed value for field obj.tools is not the expected type, validation failed.") obj.tool_ids&.is_a?(Array) != false || raise("Passed value for field obj.tool_ids is not the expected type, validation failed.") + obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") obj.model.is_a?(String) != false || raise("Passed value for field obj.model is not the expected type, validation failed.") obj.temperature&.is_a?(Float) != false || raise("Passed value for field obj.temperature is not the expected type, validation failed.") obj.knowledge_base.nil? || Vapi::KnowledgeBase.validate_raw(obj: obj.knowledge_base) diff --git a/lib/vapi/types/together_ai_model_tools_item.rb b/lib/vapi/types/together_ai_model_tools_item.rb index 8b02371..e320050 100644 --- a/lib/vapi/types/together_ai_model_tools_item.rb +++ b/lib/vapi/types/together_ai_model_tools_item.rb @@ -11,72 +11,69 @@ module Vapi class TogetherAiModelToolsItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::TogetherAiModelToolsItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of TogetherAiModelToolsItem # # @param json_object [String] # @return [Vapi::TogetherAiModelToolsItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "dtmf" - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - when "endCall" - Vapi::CreateEndCallToolDto.from_json(json_object: json_object) - when "voicemail" - Vapi::CreateVoicemailToolDto.from_json(json_object: json_object) - when "function" - Vapi::CreateFunctionToolDto.from_json(json_object: json_object) - when "ghl" - Vapi::CreateGhlToolDto.from_json(json_object: json_object) - when "make" - Vapi::CreateMakeToolDto.from_json(json_object: json_object) - when "transferCall" - Vapi::CreateTransferCallToolDto.from_json(json_object: json_object) - else - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::CreateDtmfToolDto.validate_raw(obj: struct) + return Vapi::CreateDtmfToolDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "dtmf" - { **@member.to_json, type: @discriminant }.to_json - when "endCall" - { **@member.to_json, type: @discriminant }.to_json - when "voicemail" - { **@member.to_json, type: @discriminant }.to_json - when "function" - { **@member.to_json, type: @discriminant }.to_json - when "ghl" - { **@member.to_json, type: @discriminant }.to_json - when "make" - { **@member.to_json, type: @discriminant }.to_json - when "transferCall" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateEndCallToolDto.validate_raw(obj: struct) + return Vapi::CreateEndCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVoicemailToolDto.validate_raw(obj: struct) + return Vapi::CreateVoicemailToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateFunctionToolDto.validate_raw(obj: struct) + return Vapi::CreateFunctionToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::CreateGhlToolDto.validate_raw(obj: struct) + return Vapi::CreateGhlToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateMakeToolDto.validate_raw(obj: struct) + return Vapi::CreateMakeToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTransferCallToolDto.validate_raw(obj: struct) + return Vapi::CreateTransferCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -86,74 +83,42 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "dtmf" - Vapi::CreateDtmfToolDto.validate_raw(obj: obj) - when "endCall" - Vapi::CreateEndCallToolDto.validate_raw(obj: obj) - when "voicemail" - Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) - when "function" - Vapi::CreateFunctionToolDto.validate_raw(obj: obj) - when "ghl" - Vapi::CreateGhlToolDto.validate_raw(obj: obj) - when "make" - Vapi::CreateMakeToolDto.validate_raw(obj: obj) - when "transferCall" - Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateDtmfToolDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateDtmfToolDto] - # @return [Vapi::TogetherAiModelToolsItem] - def self.dtmf(member:) - new(member: member, discriminant: "dtmf") - end - - # @param member [Vapi::CreateEndCallToolDto] - # @return [Vapi::TogetherAiModelToolsItem] - def self.end_call(member:) - new(member: member, discriminant: "endCall") - end - - # @param member [Vapi::CreateVoicemailToolDto] - # @return [Vapi::TogetherAiModelToolsItem] - def self.voicemail(member:) - new(member: member, discriminant: "voicemail") - end - - # @param member [Vapi::CreateFunctionToolDto] - # @return [Vapi::TogetherAiModelToolsItem] - def self.function(member:) - new(member: member, discriminant: "function") - end - - # @param member [Vapi::CreateGhlToolDto] - # @return [Vapi::TogetherAiModelToolsItem] - def self.ghl(member:) - new(member: member, discriminant: "ghl") - end - - # @param member [Vapi::CreateMakeToolDto] - # @return [Vapi::TogetherAiModelToolsItem] - def self.make(member:) - new(member: member, discriminant: "make") - end - - # @param member [Vapi::CreateTransferCallToolDto] - # @return [Vapi::TogetherAiModelToolsItem] - def self.transfer_call(member:) - new(member: member, discriminant: "transferCall") + begin + return Vapi::CreateEndCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateFunctionToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateGhlToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateMakeToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/tool_call_block.rb b/lib/vapi/types/tool_call_block.rb index 9a456fc..4766ccd 100644 --- a/lib/vapi/types/tool_call_block.rb +++ b/lib/vapi/types/tool_call_block.rb @@ -35,6 +35,8 @@ class ToolCallBlock # this liquid variable is just provided for convenience when creating blocks # outside of a workflow with steps. attr_reader :output_schema + # @return [String] + attr_reader :type # @return [Vapi::ToolCallBlockTool] This is the tool that the block will call. To use an existing tool, use # `toolId`. attr_reader :tool @@ -82,6 +84,7 @@ class ToolCallBlock # {{blockName.output.propertyName}} will reference the latest usage of the block. # this liquid variable is just provided for convenience when creating blocks # outside of a workflow with steps. + # @param type [String] # @param tool [Vapi::ToolCallBlockTool] This is the tool that the block will call. To use an existing tool, use # `toolId`. # @param id [String] This is the unique identifier for the block. @@ -93,11 +96,12 @@ class ToolCallBlock # use `tool`. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ToolCallBlock] - def initialize(id:, org_id:, created_at:, updated_at:, messages: OMIT, input_schema: OMIT, output_schema: OMIT, - tool: OMIT, name: OMIT, tool_id: OMIT, additional_properties: nil) + def initialize(type:, id:, org_id:, created_at:, updated_at:, messages: OMIT, input_schema: OMIT, + output_schema: OMIT, tool: OMIT, name: OMIT, tool_id: OMIT, additional_properties: nil) @messages = messages if messages != OMIT @input_schema = input_schema if input_schema != OMIT @output_schema = output_schema if output_schema != OMIT + @type = type @tool = tool if tool != OMIT @id = id @org_id = org_id @@ -110,6 +114,7 @@ def initialize(id:, org_id:, created_at:, updated_at:, messages: OMIT, input_sch "messages": messages, "inputSchema": input_schema, "outputSchema": output_schema, + "type": type, "tool": tool, "id": id, "orgId": org_id, @@ -145,6 +150,7 @@ def self.from_json(json_object:) output_schema = parsed_json["outputSchema"].to_json output_schema = Vapi::JsonSchema.from_json(json_object: output_schema) end + type = parsed_json["type"] if parsed_json["tool"].nil? tool = nil else @@ -161,6 +167,7 @@ def self.from_json(json_object:) messages: messages, input_schema: input_schema, output_schema: output_schema, + type: type, tool: tool, id: id, org_id: org_id, @@ -189,6 +196,7 @@ 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.input_schema.nil? || Vapi::JsonSchema.validate_raw(obj: obj.input_schema) obj.output_schema.nil? || Vapi::JsonSchema.validate_raw(obj: obj.output_schema) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.tool.nil? || Vapi::ToolCallBlockTool.validate_raw(obj: obj.tool) 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.") diff --git a/lib/vapi/types/tool_call_block_messages_item.rb b/lib/vapi/types/tool_call_block_messages_item.rb index c066d71..5e17585 100644 --- a/lib/vapi/types/tool_call_block_messages_item.rb +++ b/lib/vapi/types/tool_call_block_messages_item.rb @@ -6,52 +6,29 @@ module Vapi class ToolCallBlockMessagesItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ToolCallBlockMessagesItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of ToolCallBlockMessagesItem # # @param json_object [String] # @return [Vapi::ToolCallBlockMessagesItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "block-start" - Vapi::BlockStartMessage.from_json(json_object: json_object) - when "block-complete" - Vapi::BlockCompleteMessage.from_json(json_object: json_object) - else - Vapi::BlockStartMessage.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::BlockStartMessage.validate_raw(obj: struct) + return Vapi::BlockStartMessage.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "block-start" - { **@member.to_json, type: @discriminant }.to_json - when "block-complete" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::BlockCompleteMessage.validate_raw(obj: struct) + return Vapi::BlockCompleteMessage.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -61,34 +38,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "block-start" - Vapi::BlockStartMessage.validate_raw(obj: obj) - when "block-complete" - Vapi::BlockCompleteMessage.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::BlockStartMessage.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::BlockStartMessage] - # @return [Vapi::ToolCallBlockMessagesItem] - def self.block_start(member:) - new(member: member, discriminant: "block-start") - end - - # @param member [Vapi::BlockCompleteMessage] - # @return [Vapi::ToolCallBlockMessagesItem] - def self.block_complete(member:) - new(member: member, discriminant: "block-complete") + begin + return Vapi::BlockCompleteMessage.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/tool_call_block_tool.rb b/lib/vapi/types/tool_call_block_tool.rb index a33995e..9b049db 100644 --- a/lib/vapi/types/tool_call_block_tool.rb +++ b/lib/vapi/types/tool_call_block_tool.rb @@ -13,72 +13,69 @@ module Vapi # This is the tool that the block will call. To use an existing tool, use # `toolId`. class ToolCallBlockTool - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ToolCallBlockTool] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of ToolCallBlockTool # # @param json_object [String] # @return [Vapi::ToolCallBlockTool] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "dtmf" - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - when "endCall" - Vapi::CreateEndCallToolDto.from_json(json_object: json_object) - when "voicemail" - Vapi::CreateVoicemailToolDto.from_json(json_object: json_object) - when "function" - Vapi::CreateFunctionToolDto.from_json(json_object: json_object) - when "ghl" - Vapi::CreateGhlToolDto.from_json(json_object: json_object) - when "make" - Vapi::CreateMakeToolDto.from_json(json_object: json_object) - when "transferCall" - Vapi::CreateTransferCallToolDto.from_json(json_object: json_object) - else - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::CreateDtmfToolDto.validate_raw(obj: struct) + return Vapi::CreateDtmfToolDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "dtmf" - { **@member.to_json, type: @discriminant }.to_json - when "endCall" - { **@member.to_json, type: @discriminant }.to_json - when "voicemail" - { **@member.to_json, type: @discriminant }.to_json - when "function" - { **@member.to_json, type: @discriminant }.to_json - when "ghl" - { **@member.to_json, type: @discriminant }.to_json - when "make" - { **@member.to_json, type: @discriminant }.to_json - when "transferCall" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateEndCallToolDto.validate_raw(obj: struct) + return Vapi::CreateEndCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVoicemailToolDto.validate_raw(obj: struct) + return Vapi::CreateVoicemailToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateFunctionToolDto.validate_raw(obj: struct) + return Vapi::CreateFunctionToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::CreateGhlToolDto.validate_raw(obj: struct) + return Vapi::CreateGhlToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateMakeToolDto.validate_raw(obj: struct) + return Vapi::CreateMakeToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTransferCallToolDto.validate_raw(obj: struct) + return Vapi::CreateTransferCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -88,74 +85,42 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "dtmf" - Vapi::CreateDtmfToolDto.validate_raw(obj: obj) - when "endCall" - Vapi::CreateEndCallToolDto.validate_raw(obj: obj) - when "voicemail" - Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) - when "function" - Vapi::CreateFunctionToolDto.validate_raw(obj: obj) - when "ghl" - Vapi::CreateGhlToolDto.validate_raw(obj: obj) - when "make" - Vapi::CreateMakeToolDto.validate_raw(obj: obj) - when "transferCall" - Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateDtmfToolDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateDtmfToolDto] - # @return [Vapi::ToolCallBlockTool] - def self.dtmf(member:) - new(member: member, discriminant: "dtmf") - end - - # @param member [Vapi::CreateEndCallToolDto] - # @return [Vapi::ToolCallBlockTool] - def self.end_call(member:) - new(member: member, discriminant: "endCall") - end - - # @param member [Vapi::CreateVoicemailToolDto] - # @return [Vapi::ToolCallBlockTool] - def self.voicemail(member:) - new(member: member, discriminant: "voicemail") - end - - # @param member [Vapi::CreateFunctionToolDto] - # @return [Vapi::ToolCallBlockTool] - def self.function(member:) - new(member: member, discriminant: "function") - end - - # @param member [Vapi::CreateGhlToolDto] - # @return [Vapi::ToolCallBlockTool] - def self.ghl(member:) - new(member: member, discriminant: "ghl") - end - - # @param member [Vapi::CreateMakeToolDto] - # @return [Vapi::ToolCallBlockTool] - def self.make(member:) - new(member: member, discriminant: "make") - end - - # @param member [Vapi::CreateTransferCallToolDto] - # @return [Vapi::ToolCallBlockTool] - def self.transfer_call(member:) - new(member: member, discriminant: "transferCall") + begin + return Vapi::CreateEndCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateFunctionToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateGhlToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateMakeToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/tool_call_result_message_item.rb b/lib/vapi/types/tool_call_result_message_item.rb index 6c183b8..ef8537c 100644 --- a/lib/vapi/types/tool_call_result_message_item.rb +++ b/lib/vapi/types/tool_call_result_message_item.rb @@ -6,52 +6,29 @@ module Vapi class ToolCallResultMessageItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::ToolCallResultMessageItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of ToolCallResultMessageItem # # @param json_object [String] # @return [Vapi::ToolCallResultMessageItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "request-complete" - Vapi::ToolMessageComplete.from_json(json_object: json_object) - when "request-failed" - Vapi::ToolMessageFailed.from_json(json_object: json_object) - else - Vapi::ToolMessageComplete.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ToolMessageComplete.validate_raw(obj: struct) + return Vapi::ToolMessageComplete.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "request-complete" - { **@member.to_json, type: @discriminant }.to_json - when "request-failed" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::ToolMessageFailed.validate_raw(obj: struct) + return Vapi::ToolMessageFailed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -61,34 +38,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "request-complete" - Vapi::ToolMessageComplete.validate_raw(obj: obj) - when "request-failed" - Vapi::ToolMessageFailed.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ToolMessageComplete.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ToolMessageComplete] - # @return [Vapi::ToolCallResultMessageItem] - def self.request_complete(member:) - new(member: member, discriminant: "request-complete") - end - - # @param member [Vapi::ToolMessageFailed] - # @return [Vapi::ToolCallResultMessageItem] - def self.request_failed(member:) - new(member: member, discriminant: "request-failed") + begin + return Vapi::ToolMessageFailed.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/tool_message_complete.rb b/lib/vapi/types/tool_message_complete.rb index 2fb5ee0..88a57cc 100644 --- a/lib/vapi/types/tool_message_complete.rb +++ b/lib/vapi/types/tool_message_complete.rb @@ -7,6 +7,13 @@ module Vapi class ToolMessageComplete + # @return [String] This message is triggered when the tool call is complete. + # This message is triggered immediately without waiting for your server to respond + # for async tool calls. + # If this message is not provided, the model will be requested to respond. + # If this message is provided, only this message will be spoken and the model will + # not be requested to come up with a response. It's an exclusive OR. + attr_reader :type # @return [Vapi::ToolMessageCompleteRole] This is optional and defaults to "assistant". # When role=assistant, `content` is said out loud. # When role=system, `content` is passed to the model in a system message. Example: @@ -42,6 +49,12 @@ class ToolMessageComplete OMIT = Object.new + # @param type [String] This message is triggered when the tool call is complete. + # This message is triggered immediately without waiting for your server to respond + # for async tool calls. + # If this message is not provided, the model will be requested to respond. + # If this message is provided, only this message will be spoken and the model will + # not be requested to come up with a response. It's an exclusive OR. # @param role [Vapi::ToolMessageCompleteRole] This is optional and defaults to "assistant". # When role=assistant, `content` is said out loud. # When role=system, `content` is passed to the model in a system message. Example: @@ -67,14 +80,16 @@ class ToolMessageComplete # in order for this message to be triggered. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ToolMessageComplete] - def initialize(content:, role: OMIT, end_call_after_spoken_enabled: OMIT, conditions: OMIT, + def initialize(type:, content:, role: OMIT, end_call_after_spoken_enabled: OMIT, conditions: OMIT, additional_properties: nil) + @type = type @role = role if role != OMIT @end_call_after_spoken_enabled = end_call_after_spoken_enabled if end_call_after_spoken_enabled != OMIT @content = content @conditions = conditions if conditions != OMIT @additional_properties = additional_properties @_field_set = { + "type": type, "role": role, "endCallAfterSpokenEnabled": end_call_after_spoken_enabled, "content": content, @@ -91,6 +106,7 @@ def initialize(content:, role: OMIT, end_call_after_spoken_enabled: OMIT, condit def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + type = parsed_json["type"] role = parsed_json["role"] end_call_after_spoken_enabled = parsed_json["endCallAfterSpokenEnabled"] content = parsed_json["content"] @@ -99,6 +115,7 @@ def self.from_json(json_object:) Vapi::Condition.from_json(json_object: item) end new( + type: type, role: role, end_call_after_spoken_enabled: end_call_after_spoken_enabled, content: content, @@ -121,6 +138,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.role&.is_a?(Vapi::ToolMessageCompleteRole) != false || raise("Passed value for field obj.role is not the expected type, validation failed.") obj.end_call_after_spoken_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.end_call_after_spoken_enabled is not the expected type, validation failed.") obj.content.is_a?(String) != false || raise("Passed value for field obj.content is not the expected type, validation failed.") diff --git a/lib/vapi/types/tool_message_delayed.rb b/lib/vapi/types/tool_message_delayed.rb index 95f6260..9ba7965 100644 --- a/lib/vapi/types/tool_message_delayed.rb +++ b/lib/vapi/types/tool_message_delayed.rb @@ -6,6 +6,13 @@ module Vapi class ToolMessageDelayed + # @return [String] This message is triggered when the tool call is delayed. + # There are the two things that can trigger this message: + # 1. The user talks with the assistant while your server is processing the + # request. Default is "Sorry, a few more seconds." + # 2. The server doesn't respond within `timingMilliseconds`. + # This message is never triggered for async tool calls. + attr_reader :type # @return [Float] The number of milliseconds to wait for the server response before saying this # message. attr_reader :timing_milliseconds @@ -22,6 +29,12 @@ class ToolMessageDelayed OMIT = Object.new + # @param type [String] This message is triggered when the tool call is delayed. + # There are the two things that can trigger this message: + # 1. The user talks with the assistant while your server is processing the + # request. Default is "Sorry, a few more seconds." + # 2. The server doesn't respond within `timingMilliseconds`. + # This message is never triggered for async tool calls. # @param timing_milliseconds [Float] The number of milliseconds to wait for the server response before saying this # message. # @param content [String] This is the content that the assistant says when this message is triggered. @@ -29,12 +42,14 @@ class ToolMessageDelayed # in order for this message to be triggered. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ToolMessageDelayed] - def initialize(content:, timing_milliseconds: OMIT, conditions: OMIT, additional_properties: nil) + def initialize(type:, content:, timing_milliseconds: OMIT, conditions: OMIT, additional_properties: nil) + @type = type @timing_milliseconds = timing_milliseconds if timing_milliseconds != OMIT @content = content @conditions = conditions if conditions != OMIT @additional_properties = additional_properties @_field_set = { + "type": type, "timingMilliseconds": timing_milliseconds, "content": content, "conditions": conditions @@ -50,6 +65,7 @@ def initialize(content:, timing_milliseconds: OMIT, conditions: OMIT, additional def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + type = parsed_json["type"] timing_milliseconds = parsed_json["timingMilliseconds"] content = parsed_json["content"] conditions = parsed_json["conditions"]&.map do |item| @@ -57,6 +73,7 @@ def self.from_json(json_object:) Vapi::Condition.from_json(json_object: item) end new( + type: type, timing_milliseconds: timing_milliseconds, content: content, conditions: conditions, @@ -78,6 +95,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.timing_milliseconds&.is_a?(Float) != false || raise("Passed value for field obj.timing_milliseconds is not the expected type, validation failed.") obj.content.is_a?(String) != false || raise("Passed value for field obj.content is not the expected type, validation failed.") obj.conditions&.is_a?(Array) != false || raise("Passed value for field obj.conditions is not the expected type, validation failed.") diff --git a/lib/vapi/types/tool_message_failed.rb b/lib/vapi/types/tool_message_failed.rb index 46a6ff2..2f5c17a 100644 --- a/lib/vapi/types/tool_message_failed.rb +++ b/lib/vapi/types/tool_message_failed.rb @@ -6,6 +6,12 @@ module Vapi class ToolMessageFailed + # @return [String] This message is triggered when the tool call fails. + # This message is never triggered for async tool calls. + # If this message is not provided, the model will be requested to respond. + # If this message is provided, only this message will be spoken and the model will + # not be requested to come up with a response. It's an exclusive OR. + attr_reader :type # @return [Boolean] This is an optional boolean that if true, the call will end after the message is # spoken. Default is false. # @default false @@ -23,6 +29,11 @@ class ToolMessageFailed OMIT = Object.new + # @param type [String] This message is triggered when the tool call fails. + # This message is never triggered for async tool calls. + # If this message is not provided, the model will be requested to respond. + # If this message is provided, only this message will be spoken and the model will + # not be requested to come up with a response. It's an exclusive OR. # @param end_call_after_spoken_enabled [Boolean] This is an optional boolean that if true, the call will end after the message is # spoken. Default is false. # @default false @@ -31,12 +42,14 @@ class ToolMessageFailed # in order for this message to be triggered. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ToolMessageFailed] - def initialize(content:, end_call_after_spoken_enabled: OMIT, conditions: OMIT, additional_properties: nil) + def initialize(type:, content:, end_call_after_spoken_enabled: OMIT, conditions: OMIT, additional_properties: nil) + @type = type @end_call_after_spoken_enabled = end_call_after_spoken_enabled if end_call_after_spoken_enabled != OMIT @content = content @conditions = conditions if conditions != OMIT @additional_properties = additional_properties @_field_set = { + "type": type, "endCallAfterSpokenEnabled": end_call_after_spoken_enabled, "content": content, "conditions": conditions @@ -52,6 +65,7 @@ def initialize(content:, end_call_after_spoken_enabled: OMIT, conditions: OMIT, def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + type = parsed_json["type"] end_call_after_spoken_enabled = parsed_json["endCallAfterSpokenEnabled"] content = parsed_json["content"] conditions = parsed_json["conditions"]&.map do |item| @@ -59,6 +73,7 @@ def self.from_json(json_object:) Vapi::Condition.from_json(json_object: item) end new( + type: type, end_call_after_spoken_enabled: end_call_after_spoken_enabled, content: content, conditions: conditions, @@ -80,6 +95,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.end_call_after_spoken_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.end_call_after_spoken_enabled is not the expected type, validation failed.") obj.content.is_a?(String) != false || raise("Passed value for field obj.content is not the expected type, validation failed.") obj.conditions&.is_a?(Array) != false || raise("Passed value for field obj.conditions is not the expected type, validation failed.") diff --git a/lib/vapi/types/tool_message_start.rb b/lib/vapi/types/tool_message_start.rb index 83a0ebc..d3d72bf 100644 --- a/lib/vapi/types/tool_message_start.rb +++ b/lib/vapi/types/tool_message_start.rb @@ -6,6 +6,12 @@ module Vapi class ToolMessageStart + # @return [String] This message is triggered when the tool call starts. + # This message is never triggered for async tools. + # If this message is not provided, one of the default filler messages "Hold on a + # sec", "One moment", "Just a sec", "Give me a moment" or "This'll just take a + # sec" will be used. + attr_reader :type # @return [String] This is the content that the assistant says when this message is triggered. attr_reader :content # @return [Array] This is an optional array of conditions that the tool call arguments must meet @@ -19,16 +25,22 @@ class ToolMessageStart OMIT = Object.new + # @param type [String] This message is triggered when the tool call starts. + # This message is never triggered for async tools. + # If this message is not provided, one of the default filler messages "Hold on a + # sec", "One moment", "Just a sec", "Give me a moment" or "This'll just take a + # sec" will be used. # @param content [String] This is the content that the assistant says when this message is triggered. # @param conditions [Array] This is an optional array of conditions that the tool call arguments must meet # in order for this message to be triggered. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::ToolMessageStart] - def initialize(content:, conditions: OMIT, additional_properties: nil) + def initialize(type:, content:, conditions: OMIT, additional_properties: nil) + @type = type @content = content @conditions = conditions if conditions != OMIT @additional_properties = additional_properties - @_field_set = { "content": content, "conditions": conditions }.reject do |_k, v| + @_field_set = { "type": type, "content": content, "conditions": conditions }.reject do |_k, v| v == OMIT end end @@ -40,12 +52,14 @@ def initialize(content:, conditions: OMIT, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + type = parsed_json["type"] content = parsed_json["content"] conditions = parsed_json["conditions"]&.map do |item| item = item.to_json Vapi::Condition.from_json(json_object: item) end new( + type: type, content: content, conditions: conditions, additional_properties: struct @@ -66,6 +80,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.content.is_a?(String) != false || raise("Passed value for field obj.content is not the expected type, validation failed.") obj.conditions&.is_a?(Array) != false || raise("Passed value for field obj.conditions is not the expected type, validation failed.") end diff --git a/lib/vapi/types/transcriber_cost.rb b/lib/vapi/types/transcriber_cost.rb index a7d6524..2305ff6 100644 --- a/lib/vapi/types/transcriber_cost.rb +++ b/lib/vapi/types/transcriber_cost.rb @@ -5,6 +5,8 @@ module Vapi class TranscriberCost + # @return [String] This is the type of cost, always 'transcriber' for this class. + attr_reader :type # @return [Hash{String => Object}] This is the transcriber that was used during the call. # This matches one of the below: # - `call.assistant.transcriber`, @@ -28,6 +30,7 @@ class TranscriberCost OMIT = Object.new + # @param type [String] This is the type of cost, always 'transcriber' for this class. # @param transcriber [Hash{String => Object}] This is the transcriber that was used during the call. # This matches one of the below: # - `call.assistant.transcriber`, @@ -42,12 +45,13 @@ class TranscriberCost # @param cost [Float] This is the cost of the component in USD. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::TranscriberCost] - def initialize(transcriber:, minutes:, cost:, additional_properties: nil) + def initialize(type:, transcriber:, minutes:, cost:, additional_properties: nil) + @type = type @transcriber = transcriber @minutes = minutes @cost = cost @additional_properties = additional_properties - @_field_set = { "transcriber": transcriber, "minutes": minutes, "cost": cost } + @_field_set = { "type": type, "transcriber": transcriber, "minutes": minutes, "cost": cost } end # Deserialize a JSON object to an instance of TranscriberCost @@ -57,10 +61,12 @@ def initialize(transcriber:, minutes:, cost:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + type = parsed_json["type"] transcriber = parsed_json["transcriber"] minutes = parsed_json["minutes"] cost = parsed_json["cost"] new( + type: type, transcriber: transcriber, minutes: minutes, cost: cost, @@ -82,6 +88,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.transcriber.is_a?(Hash) != false || raise("Passed value for field obj.transcriber is not the expected type, validation failed.") obj.minutes.is_a?(Float) != false || raise("Passed value for field obj.minutes is not the expected type, validation failed.") obj.cost.is_a?(Float) != false || raise("Passed value for field obj.cost is not the expected type, validation failed.") diff --git a/lib/vapi/types/transfer_call_tool.rb b/lib/vapi/types/transfer_call_tool.rb index 82a3f6a..426b9fe 100644 --- a/lib/vapi/types/transfer_call_tool.rb +++ b/lib/vapi/types/transfer_call_tool.rb @@ -22,6 +22,8 @@ class TransferCallTool # `tool.destinations`. For others like the function tool, these can be custom # configured. attr_reader :messages + # @return [String] + attr_reader :type # @return [Array] These are the destinations that the call can be transferred to. If no # destinations are provided, server.url will be used to get the transfer # destination once the tool is called. @@ -69,6 +71,7 @@ class TransferCallTool # For some tools, this is auto-filled based on special fields like # `tool.destinations`. For others like the function tool, these can be custom # configured. + # @param type [String] # @param destinations [Array] These are the destinations that the call can be transferred to. If no # destinations are provided, server.url will be used to get the transfer # destination once the tool is called. @@ -93,10 +96,11 @@ class TransferCallTool # phoneNumber.serverUrl, then org.serverUrl. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::TransferCallTool] - def initialize(id:, org_id:, created_at:, updated_at:, async: OMIT, messages: OMIT, destinations: OMIT, + def initialize(type:, id:, org_id:, created_at:, updated_at:, async: OMIT, messages: OMIT, destinations: OMIT, function: OMIT, server: OMIT, additional_properties: nil) @async = async if async != OMIT @messages = messages if messages != OMIT + @type = type @destinations = destinations if destinations != OMIT @id = id @org_id = org_id @@ -108,6 +112,7 @@ def initialize(id:, org_id:, created_at:, updated_at:, async: OMIT, messages: OM @_field_set = { "async": async, "messages": messages, + "type": type, "destinations": destinations, "id": id, "orgId": org_id, @@ -132,6 +137,7 @@ def self.from_json(json_object:) item = item.to_json Vapi::TransferCallToolMessagesItem.from_json(json_object: item) end + type = parsed_json["type"] destinations = parsed_json["destinations"]&.map do |item| item = item.to_json Vapi::TransferCallToolDestinationsItem.from_json(json_object: item) @@ -155,6 +161,7 @@ def self.from_json(json_object:) new( async: async, messages: messages, + type: type, destinations: destinations, id: id, org_id: org_id, @@ -182,6 +189,7 @@ def to_json(*_args) def self.validate_raw(obj:) obj.async&.is_a?(Boolean) != false || raise("Passed value for field obj.async is not the expected type, validation failed.") obj.messages&.is_a?(Array) != false || raise("Passed value for field obj.messages is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.destinations&.is_a?(Array) != false || raise("Passed value for field obj.destinations 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.") diff --git a/lib/vapi/types/transfer_call_tool_destinations_item.rb b/lib/vapi/types/transfer_call_tool_destinations_item.rb index 42fbd7c..6cca64f 100644 --- a/lib/vapi/types/transfer_call_tool_destinations_item.rb +++ b/lib/vapi/types/transfer_call_tool_destinations_item.rb @@ -8,60 +8,45 @@ module Vapi class TransferCallToolDestinationsItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::TransferCallToolDestinationsItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of TransferCallToolDestinationsItem # # @param json_object [String] # @return [Vapi::TransferCallToolDestinationsItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "assistant" - Vapi::TransferDestinationAssistant.from_json(json_object: json_object) - when "step" - Vapi::TransferDestinationStep.from_json(json_object: json_object) - when "number" - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - when "sip" - Vapi::TransferDestinationSip.from_json(json_object: json_object) - else - Vapi::TransferDestinationAssistant.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::TransferDestinationAssistant.validate_raw(obj: struct) + return Vapi::TransferDestinationAssistant.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "assistant" - { **@member.to_json, type: @discriminant }.to_json - when "step" - { **@member.to_json, type: @discriminant }.to_json - when "number" - { **@member.to_json, type: @discriminant }.to_json - when "sip" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::TransferDestinationStep.validate_raw(obj: struct) + return Vapi::TransferDestinationStep.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::TransferDestinationNumber.validate_raw(obj: struct) + return Vapi::TransferDestinationNumber.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::TransferDestinationSip.validate_raw(obj: struct) + return Vapi::TransferDestinationSip.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -71,50 +56,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "assistant" - Vapi::TransferDestinationAssistant.validate_raw(obj: obj) - when "step" - Vapi::TransferDestinationStep.validate_raw(obj: obj) - when "number" - Vapi::TransferDestinationNumber.validate_raw(obj: obj) - when "sip" - Vapi::TransferDestinationSip.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::TransferDestinationAssistant.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::TransferDestinationAssistant] - # @return [Vapi::TransferCallToolDestinationsItem] - def self.assistant(member:) - new(member: member, discriminant: "assistant") - end - - # @param member [Vapi::TransferDestinationStep] - # @return [Vapi::TransferCallToolDestinationsItem] - def self.step(member:) - new(member: member, discriminant: "step") - end - - # @param member [Vapi::TransferDestinationNumber] - # @return [Vapi::TransferCallToolDestinationsItem] - def self.number(member:) - new(member: member, discriminant: "number") - end - - # @param member [Vapi::TransferDestinationSip] - # @return [Vapi::TransferCallToolDestinationsItem] - def self.sip(member:) - new(member: member, discriminant: "sip") + begin + return Vapi::TransferDestinationStep.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::TransferDestinationNumber.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::TransferDestinationSip.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/transfer_call_tool_messages_item.rb b/lib/vapi/types/transfer_call_tool_messages_item.rb index 612b984..13d2e62 100644 --- a/lib/vapi/types/transfer_call_tool_messages_item.rb +++ b/lib/vapi/types/transfer_call_tool_messages_item.rb @@ -8,60 +8,45 @@ module Vapi class TransferCallToolMessagesItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::TransferCallToolMessagesItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of TransferCallToolMessagesItem # # @param json_object [String] # @return [Vapi::TransferCallToolMessagesItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "request-start" - Vapi::ToolMessageStart.from_json(json_object: json_object) - when "request-complete" - Vapi::ToolMessageComplete.from_json(json_object: json_object) - when "request-failed" - Vapi::ToolMessageFailed.from_json(json_object: json_object) - when "request-response-delayed" - Vapi::ToolMessageDelayed.from_json(json_object: json_object) - else - Vapi::ToolMessageStart.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::ToolMessageStart.validate_raw(obj: struct) + return Vapi::ToolMessageStart.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "request-start" - { **@member.to_json, type: @discriminant }.to_json - when "request-complete" - { **@member.to_json, type: @discriminant }.to_json - when "request-failed" - { **@member.to_json, type: @discriminant }.to_json - when "request-response-delayed" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageComplete.validate_raw(obj: struct) + return Vapi::ToolMessageComplete.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageFailed.validate_raw(obj: struct) + return Vapi::ToolMessageFailed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::ToolMessageDelayed.validate_raw(obj: struct) + return Vapi::ToolMessageDelayed.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -71,50 +56,27 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "request-start" - Vapi::ToolMessageStart.validate_raw(obj: obj) - when "request-complete" - Vapi::ToolMessageComplete.validate_raw(obj: obj) - when "request-failed" - Vapi::ToolMessageFailed.validate_raw(obj: obj) - when "request-response-delayed" - Vapi::ToolMessageDelayed.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::ToolMessageStart.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::ToolMessageStart] - # @return [Vapi::TransferCallToolMessagesItem] - def self.request_start(member:) - new(member: member, discriminant: "request-start") - end - - # @param member [Vapi::ToolMessageComplete] - # @return [Vapi::TransferCallToolMessagesItem] - def self.request_complete(member:) - new(member: member, discriminant: "request-complete") - end - - # @param member [Vapi::ToolMessageFailed] - # @return [Vapi::TransferCallToolMessagesItem] - def self.request_failed(member:) - new(member: member, discriminant: "request-failed") - end - - # @param member [Vapi::ToolMessageDelayed] - # @return [Vapi::TransferCallToolMessagesItem] - def self.request_response_delayed(member:) - new(member: member, discriminant: "request-response-delayed") + begin + return Vapi::ToolMessageComplete.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageFailed.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::ToolMessageDelayed.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/transfer_destination_assistant.rb b/lib/vapi/types/transfer_destination_assistant.rb index 847ccf4..82e8a8e 100644 --- a/lib/vapi/types/transfer_destination_assistant.rb +++ b/lib/vapi/types/transfer_destination_assistant.rb @@ -1,12 +1,14 @@ # frozen_string_literal: true -require_relative "transfer_destination_assistant_transfer_mode" +require_relative "transfer_mode" require "ostruct" require "json" module Vapi class TransferDestinationAssistant - # @return [Vapi::TransferDestinationAssistantTransferMode] This is the mode to use for the transfer. Default is `rolling-history`. + # @return [String] + attr_reader :type + # @return [Vapi::TransferMode] This is the mode to use for the transfer. Default is `rolling-history`. # - `rolling-history`: This is the default mode. It keeps the entire conversation # history and appends the new assistant's system message on transfer. # Example: @@ -69,7 +71,8 @@ class TransferDestinationAssistant OMIT = Object.new - # @param transfer_mode [Vapi::TransferDestinationAssistantTransferMode] This is the mode to use for the transfer. Default is `rolling-history`. + # @param type [String] + # @param transfer_mode [Vapi::TransferMode] This is the mode to use for the transfer. Default is `rolling-history`. # - `rolling-history`: This is the default mode. It keeps the entire conversation # history and appends the new assistant's system message on transfer. # Example: @@ -122,13 +125,16 @@ class TransferDestinationAssistant # how to transfer the call. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::TransferDestinationAssistant] - def initialize(assistant_name:, transfer_mode: OMIT, message: OMIT, description: OMIT, additional_properties: nil) + def initialize(type:, assistant_name:, transfer_mode: OMIT, message: OMIT, description: OMIT, + additional_properties: nil) + @type = type @transfer_mode = transfer_mode if transfer_mode != OMIT @assistant_name = assistant_name @message = message if message != OMIT @description = description if description != OMIT @additional_properties = additional_properties @_field_set = { + "type": type, "transferMode": transfer_mode, "assistantName": assistant_name, "message": message, @@ -145,11 +151,13 @@ def initialize(assistant_name:, transfer_mode: OMIT, message: OMIT, description: def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + type = parsed_json["type"] transfer_mode = parsed_json["transferMode"] assistant_name = parsed_json["assistantName"] message = parsed_json["message"] description = parsed_json["description"] new( + type: type, transfer_mode: transfer_mode, assistant_name: assistant_name, message: message, @@ -172,7 +180,8 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - obj.transfer_mode&.is_a?(Vapi::TransferDestinationAssistantTransferMode) != false || raise("Passed value for field obj.transfer_mode is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + obj.transfer_mode&.is_a?(Vapi::TransferMode) != false || raise("Passed value for field obj.transfer_mode is not the expected type, validation failed.") obj.assistant_name.is_a?(String) != false || raise("Passed value for field obj.assistant_name is not the expected type, validation failed.") obj.message&.is_a?(String) != false || raise("Passed value for field obj.message 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.") diff --git a/lib/vapi/types/transfer_destination_assistant_transfer_mode.rb b/lib/vapi/types/transfer_destination_assistant_transfer_mode.rb deleted file mode 100644 index f9fe57b..0000000 --- a/lib/vapi/types/transfer_destination_assistant_transfer_mode.rb +++ /dev/null @@ -1,48 +0,0 @@ -# frozen_string_literal: true - -module Vapi - # This is the mode to use for the transfer. Default is `rolling-history`. - # - `rolling-history`: This is the default mode. It keeps the entire conversation - # history and appends the new assistant's system message on transfer. - # Example: - # Pre-transfer: - # system: assistant1 system message - # assistant: assistant1 first message - # user: hey, good morning - # assistant: how can i help? - # user: i need help with my account - # assistant: (destination.message) - # Post-transfer: - # system: assistant1 system message - # assistant: assistant1 first message - # user: hey, good morning - # assistant: how can i help? - # user: i need help with my account - # assistant: (destination.message) - # system: assistant2 system message - # assistant: assistant2 first message (or model generated if firstMessageMode is - # set to `assistant-speaks-first-with-model-generated-message`) - # - `swap-system-message-in-history`: This replaces the original system message - # with the new assistant's system message on transfer. - # Example: - # Pre-transfer: - # system: assistant1 system message - # assistant: assistant1 first message - # user: hey, good morning - # assistant: how can i help? - # user: i need help with my account - # assistant: (destination.message) - # Post-transfer: - # system: assistant2 system message - # assistant: assistant1 first message - # user: hey, good morning - # assistant: how can i help? - # user: i need help with my account - # assistant: (destination.message) - # assistant: assistant2 first message (or model generated if firstMessageMode is - # set to `assistant-speaks-first-with-model-generated-message`) - class TransferDestinationAssistantTransferMode - ROLLING_HISTORY = "rolling-history" - SWAP_SYSTEM_MESSAGE_IN_HISTORY = "swap-system-message-in-history" - end -end diff --git a/lib/vapi/types/transfer_destination_number.rb b/lib/vapi/types/transfer_destination_number.rb index 82ee4f4..6732e93 100644 --- a/lib/vapi/types/transfer_destination_number.rb +++ b/lib/vapi/types/transfer_destination_number.rb @@ -5,6 +5,8 @@ module Vapi class TransferDestinationNumber + # @return [String] + attr_reader :type # @return [Boolean] This is the flag to toggle the E164 check for the `number` field. This is an # advanced property which should be used if you know your use case requires it. # Use cases: @@ -55,6 +57,7 @@ class TransferDestinationNumber OMIT = Object.new + # @param type [String] # @param number_e_164_check_enabled [Boolean] This is the flag to toggle the E164 check for the `number` field. This is an # advanced property which should be used if you know your use case requires it. # Use cases: @@ -93,8 +96,9 @@ class TransferDestinationNumber # how to transfer the call. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::TransferDestinationNumber] - def initialize(number:, number_e_164_check_enabled: OMIT, extension: OMIT, caller_id: OMIT, message: OMIT, + def initialize(type:, number:, number_e_164_check_enabled: OMIT, extension: OMIT, caller_id: OMIT, message: OMIT, description: OMIT, additional_properties: nil) + @type = type @number_e_164_check_enabled = number_e_164_check_enabled if number_e_164_check_enabled != OMIT @number = number @extension = extension if extension != OMIT @@ -103,6 +107,7 @@ def initialize(number:, number_e_164_check_enabled: OMIT, extension: OMIT, calle @description = description if description != OMIT @additional_properties = additional_properties @_field_set = { + "type": type, "numberE164CheckEnabled": number_e_164_check_enabled, "number": number, "extension": extension, @@ -121,6 +126,7 @@ def initialize(number:, number_e_164_check_enabled: OMIT, extension: OMIT, calle def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + type = parsed_json["type"] number_e_164_check_enabled = parsed_json["numberE164CheckEnabled"] number = parsed_json["number"] extension = parsed_json["extension"] @@ -128,6 +134,7 @@ def self.from_json(json_object:) message = parsed_json["message"] description = parsed_json["description"] new( + type: type, number_e_164_check_enabled: number_e_164_check_enabled, number: number, extension: extension, @@ -152,6 +159,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.number_e_164_check_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.number_e_164_check_enabled is not the expected type, validation failed.") obj.number.is_a?(String) != false || raise("Passed value for field obj.number is not the expected type, validation failed.") obj.extension&.is_a?(String) != false || raise("Passed value for field obj.extension is not the expected type, validation failed.") diff --git a/lib/vapi/types/transfer_destination_sip.rb b/lib/vapi/types/transfer_destination_sip.rb index 359f68b..39bc219 100644 --- a/lib/vapi/types/transfer_destination_sip.rb +++ b/lib/vapi/types/transfer_destination_sip.rb @@ -5,6 +5,8 @@ module Vapi class TransferDestinationSip + # @return [String] + attr_reader :type # @return [String] This is the SIP URI to transfer the call to. attr_reader :sip_uri # @return [String] This is the message to say before transferring the call to the destination. @@ -27,6 +29,7 @@ class TransferDestinationSip OMIT = Object.new + # @param type [String] # @param sip_uri [String] This is the SIP URI to transfer the call to. # @param message [String] This is the message to say before transferring the call to the destination. # If this is not provided and transfer tool messages is not provided, default is @@ -40,12 +43,18 @@ class TransferDestinationSip # how to transfer the call. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::TransferDestinationSip] - def initialize(sip_uri:, message: OMIT, description: OMIT, additional_properties: nil) + def initialize(type:, sip_uri:, message: OMIT, description: OMIT, additional_properties: nil) + @type = type @sip_uri = sip_uri @message = message if message != OMIT @description = description if description != OMIT @additional_properties = additional_properties - @_field_set = { "sipUri": sip_uri, "message": message, "description": description }.reject do |_k, v| + @_field_set = { + "type": type, + "sipUri": sip_uri, + "message": message, + "description": description + }.reject do |_k, v| v == OMIT end end @@ -57,10 +66,12 @@ def initialize(sip_uri:, message: OMIT, description: OMIT, additional_properties def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + type = parsed_json["type"] sip_uri = parsed_json["sipUri"] message = parsed_json["message"] description = parsed_json["description"] new( + type: type, sip_uri: sip_uri, message: message, description: description, @@ -82,6 +93,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.sip_uri.is_a?(String) != false || raise("Passed value for field obj.sip_uri is not the expected type, validation failed.") obj.message&.is_a?(String) != false || raise("Passed value for field obj.message 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.") diff --git a/lib/vapi/types/transfer_destination_step.rb b/lib/vapi/types/transfer_destination_step.rb index 7bccbe2..ddaa7f7 100644 --- a/lib/vapi/types/transfer_destination_step.rb +++ b/lib/vapi/types/transfer_destination_step.rb @@ -5,6 +5,8 @@ module Vapi class TransferDestinationStep + # @return [String] + attr_reader :type # @return [String] This is the step to transfer to. attr_reader :step_name # @return [String] This is the message to say before transferring the call to the destination. @@ -27,6 +29,7 @@ class TransferDestinationStep OMIT = Object.new + # @param type [String] # @param step_name [String] This is the step to transfer to. # @param message [String] This is the message to say before transferring the call to the destination. # If this is not provided and transfer tool messages is not provided, default is @@ -40,12 +43,18 @@ class TransferDestinationStep # how to transfer the call. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::TransferDestinationStep] - def initialize(step_name:, message: OMIT, description: OMIT, additional_properties: nil) + def initialize(type:, step_name:, message: OMIT, description: OMIT, additional_properties: nil) + @type = type @step_name = step_name @message = message if message != OMIT @description = description if description != OMIT @additional_properties = additional_properties - @_field_set = { "stepName": step_name, "message": message, "description": description }.reject do |_k, v| + @_field_set = { + "type": type, + "stepName": step_name, + "message": message, + "description": description + }.reject do |_k, v| v == OMIT end end @@ -57,10 +66,12 @@ def initialize(step_name:, message: OMIT, description: OMIT, additional_properti def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + type = parsed_json["type"] step_name = parsed_json["stepName"] message = parsed_json["message"] description = parsed_json["description"] new( + type: type, step_name: step_name, message: message, description: description, @@ -82,6 +93,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.step_name.is_a?(String) != false || raise("Passed value for field obj.step_name is not the expected type, validation failed.") obj.message&.is_a?(String) != false || raise("Passed value for field obj.message 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.") diff --git a/lib/vapi/types/transfer_mode.rb b/lib/vapi/types/transfer_mode.rb new file mode 100644 index 0000000..8dc5c7a --- /dev/null +++ b/lib/vapi/types/transfer_mode.rb @@ -0,0 +1,8 @@ +# frozen_string_literal: true + +module Vapi + class TransferMode + ROLLING_HISTORY = "rolling-history" + SWAP_SYSTEM_MESSAGE_IN_HISTORY = "swap-system-message-in-history" + end +end diff --git a/lib/vapi/types/transport_cost.rb b/lib/vapi/types/transport_cost.rb index ac9240f..c3f82c1 100644 --- a/lib/vapi/types/transport_cost.rb +++ b/lib/vapi/types/transport_cost.rb @@ -5,6 +5,8 @@ module Vapi class TransportCost + # @return [String] This is the type of cost, always 'transport' for this class. + attr_reader :type # @return [Float] This is the minutes of `transport` usage. This should match `call.endedAt` - # `call.startedAt`. attr_reader :minutes @@ -18,16 +20,18 @@ class TransportCost OMIT = Object.new + # @param type [String] This is the type of cost, always 'transport' for this class. # @param minutes [Float] This is the minutes of `transport` usage. This should match `call.endedAt` - # `call.startedAt`. # @param cost [Float] This is the cost of the component in USD. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::TransportCost] - def initialize(minutes:, cost:, additional_properties: nil) + def initialize(type:, minutes:, cost:, additional_properties: nil) + @type = type @minutes = minutes @cost = cost @additional_properties = additional_properties - @_field_set = { "minutes": minutes, "cost": cost } + @_field_set = { "type": type, "minutes": minutes, "cost": cost } end # Deserialize a JSON object to an instance of TransportCost @@ -37,9 +41,11 @@ def initialize(minutes:, cost:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + type = parsed_json["type"] minutes = parsed_json["minutes"] cost = parsed_json["cost"] new( + type: type, minutes: minutes, cost: cost, additional_properties: struct @@ -60,6 +66,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.minutes.is_a?(Float) != false || raise("Passed value for field obj.minutes is not the expected type, validation failed.") obj.cost.is_a?(Float) != false || raise("Passed value for field obj.cost is not the expected type, validation failed.") end diff --git a/lib/vapi/types/twilio_phone_number.rb b/lib/vapi/types/twilio_phone_number.rb index 6218833..0710659 100644 --- a/lib/vapi/types/twilio_phone_number.rb +++ b/lib/vapi/types/twilio_phone_number.rb @@ -14,6 +14,8 @@ class TwilioPhoneNumber # If this is not set and above conditions are met, the inbound call is hung up # with an error message. attr_reader :fallback_destination + # @return [String] + attr_reader :provider # @return [String] This is the unique identifier for the phone number. attr_reader :id # @return [String] This is the unique identifier for the org that this phone number belongs to. @@ -64,6 +66,7 @@ class TwilioPhoneNumber # 3. and, `assistant-request` message to the `serverUrl` fails # If this is not set and above conditions are met, the inbound call is hung up # with an error message. + # @param provider [String] # @param id [String] This is the unique identifier for the phone number. # @param org_id [String] This is the unique identifier for the org that this phone number belongs to. # @param created_at [DateTime] This is the ISO 8601 date-time string of when the phone number was created. @@ -90,9 +93,10 @@ class TwilioPhoneNumber # @param twilio_auth_token [String] This is the Twilio Auth Token for the phone number. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::TwilioPhoneNumber] - def initialize(id:, org_id:, created_at:, updated_at:, number:, twilio_account_sid:, twilio_auth_token:, fallback_destination: OMIT, name: OMIT, assistant_id: OMIT, - squad_id: OMIT, server_url: OMIT, server_url_secret: OMIT, additional_properties: nil) + def initialize(provider:, id:, org_id:, created_at:, updated_at:, number:, twilio_account_sid:, twilio_auth_token:, fallback_destination: OMIT, name: OMIT, + assistant_id: OMIT, squad_id: OMIT, server_url: OMIT, server_url_secret: OMIT, additional_properties: nil) @fallback_destination = fallback_destination if fallback_destination != OMIT + @provider = provider @id = id @org_id = org_id @created_at = created_at @@ -108,6 +112,7 @@ def initialize(id:, org_id:, created_at:, updated_at:, number:, twilio_account_s @additional_properties = additional_properties @_field_set = { "fallbackDestination": fallback_destination, + "provider": provider, "id": id, "orgId": org_id, "createdAt": created_at, @@ -138,6 +143,7 @@ def self.from_json(json_object:) fallback_destination = parsed_json["fallbackDestination"].to_json fallback_destination = Vapi::TwilioPhoneNumberFallbackDestination.from_json(json_object: fallback_destination) end + provider = parsed_json["provider"] id = parsed_json["id"] org_id = parsed_json["orgId"] created_at = (DateTime.parse(parsed_json["createdAt"]) unless parsed_json["createdAt"].nil?) @@ -152,6 +158,7 @@ def self.from_json(json_object:) twilio_auth_token = parsed_json["twilioAuthToken"] new( fallback_destination: fallback_destination, + provider: provider, id: id, org_id: org_id, created_at: created_at, @@ -183,6 +190,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.fallback_destination.nil? || Vapi::TwilioPhoneNumberFallbackDestination.validate_raw(obj: obj.fallback_destination) + obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider 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.") diff --git a/lib/vapi/types/twilio_phone_number_fallback_destination.rb b/lib/vapi/types/twilio_phone_number_fallback_destination.rb index 026c220..e99ea4f 100644 --- a/lib/vapi/types/twilio_phone_number_fallback_destination.rb +++ b/lib/vapi/types/twilio_phone_number_fallback_destination.rb @@ -12,52 +12,29 @@ module Vapi # If this is not set and above conditions are met, the inbound call is hung up # with an error message. class TwilioPhoneNumberFallbackDestination - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::TwilioPhoneNumberFallbackDestination] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of TwilioPhoneNumberFallbackDestination # # @param json_object [String] # @return [Vapi::TwilioPhoneNumberFallbackDestination] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "number" - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - when "sip" - Vapi::TransferDestinationSip.from_json(json_object: json_object) - else - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::TransferDestinationNumber.validate_raw(obj: struct) + return Vapi::TransferDestinationNumber.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "number" - { **@member.to_json, type: @discriminant }.to_json - when "sip" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::TransferDestinationSip.validate_raw(obj: struct) + return Vapi::TransferDestinationSip.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -67,34 +44,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "number" - Vapi::TransferDestinationNumber.validate_raw(obj: obj) - when "sip" - Vapi::TransferDestinationSip.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::TransferDestinationNumber.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::TransferDestinationNumber] - # @return [Vapi::TwilioPhoneNumberFallbackDestination] - def self.number(member:) - new(member: member, discriminant: "number") - end - - # @param member [Vapi::TransferDestinationSip] - # @return [Vapi::TwilioPhoneNumberFallbackDestination] - def self.sip(member:) - new(member: member, discriminant: "sip") + begin + return Vapi::TransferDestinationSip.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/update_tool_template_dto_details.rb b/lib/vapi/types/update_tool_template_dto_details.rb index c870638..cd2ae79 100644 --- a/lib/vapi/types/update_tool_template_dto_details.rb +++ b/lib/vapi/types/update_tool_template_dto_details.rb @@ -11,72 +11,69 @@ module Vapi class UpdateToolTemplateDtoDetails - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::UpdateToolTemplateDtoDetails] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of UpdateToolTemplateDtoDetails # # @param json_object [String] # @return [Vapi::UpdateToolTemplateDtoDetails] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "dtmf" - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - when "endCall" - Vapi::CreateEndCallToolDto.from_json(json_object: json_object) - when "voicemail" - Vapi::CreateVoicemailToolDto.from_json(json_object: json_object) - when "function" - Vapi::CreateFunctionToolDto.from_json(json_object: json_object) - when "ghl" - Vapi::CreateGhlToolDto.from_json(json_object: json_object) - when "make" - Vapi::CreateMakeToolDto.from_json(json_object: json_object) - when "transferCall" - Vapi::CreateTransferCallToolDto.from_json(json_object: json_object) - else - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::CreateDtmfToolDto.validate_raw(obj: struct) + return Vapi::CreateDtmfToolDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "dtmf" - { **@member.to_json, type: @discriminant }.to_json - when "endCall" - { **@member.to_json, type: @discriminant }.to_json - when "voicemail" - { **@member.to_json, type: @discriminant }.to_json - when "function" - { **@member.to_json, type: @discriminant }.to_json - when "ghl" - { **@member.to_json, type: @discriminant }.to_json - when "make" - { **@member.to_json, type: @discriminant }.to_json - when "transferCall" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateEndCallToolDto.validate_raw(obj: struct) + return Vapi::CreateEndCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVoicemailToolDto.validate_raw(obj: struct) + return Vapi::CreateVoicemailToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateFunctionToolDto.validate_raw(obj: struct) + return Vapi::CreateFunctionToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::CreateGhlToolDto.validate_raw(obj: struct) + return Vapi::CreateGhlToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateMakeToolDto.validate_raw(obj: struct) + return Vapi::CreateMakeToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTransferCallToolDto.validate_raw(obj: struct) + return Vapi::CreateTransferCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -86,74 +83,42 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "dtmf" - Vapi::CreateDtmfToolDto.validate_raw(obj: obj) - when "endCall" - Vapi::CreateEndCallToolDto.validate_raw(obj: obj) - when "voicemail" - Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) - when "function" - Vapi::CreateFunctionToolDto.validate_raw(obj: obj) - when "ghl" - Vapi::CreateGhlToolDto.validate_raw(obj: obj) - when "make" - Vapi::CreateMakeToolDto.validate_raw(obj: obj) - when "transferCall" - Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateDtmfToolDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateDtmfToolDto] - # @return [Vapi::UpdateToolTemplateDtoDetails] - def self.dtmf(member:) - new(member: member, discriminant: "dtmf") - end - - # @param member [Vapi::CreateEndCallToolDto] - # @return [Vapi::UpdateToolTemplateDtoDetails] - def self.end_call(member:) - new(member: member, discriminant: "endCall") - end - - # @param member [Vapi::CreateVoicemailToolDto] - # @return [Vapi::UpdateToolTemplateDtoDetails] - def self.voicemail(member:) - new(member: member, discriminant: "voicemail") - end - - # @param member [Vapi::CreateFunctionToolDto] - # @return [Vapi::UpdateToolTemplateDtoDetails] - def self.function(member:) - new(member: member, discriminant: "function") - end - - # @param member [Vapi::CreateGhlToolDto] - # @return [Vapi::UpdateToolTemplateDtoDetails] - def self.ghl(member:) - new(member: member, discriminant: "ghl") - end - - # @param member [Vapi::CreateMakeToolDto] - # @return [Vapi::UpdateToolTemplateDtoDetails] - def self.make(member:) - new(member: member, discriminant: "make") - end - - # @param member [Vapi::CreateTransferCallToolDto] - # @return [Vapi::UpdateToolTemplateDtoDetails] - def self.transfer_call(member:) - new(member: member, discriminant: "transferCall") + begin + return Vapi::CreateEndCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateFunctionToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateGhlToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateMakeToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/update_tool_template_dto_provider_details.rb b/lib/vapi/types/update_tool_template_dto_provider_details.rb index 1250ee9..917fef9 100644 --- a/lib/vapi/types/update_tool_template_dto_provider_details.rb +++ b/lib/vapi/types/update_tool_template_dto_provider_details.rb @@ -7,56 +7,37 @@ module Vapi class UpdateToolTemplateDtoProviderDetails - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::UpdateToolTemplateDtoProviderDetails] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of UpdateToolTemplateDtoProviderDetails # # @param json_object [String] # @return [Vapi::UpdateToolTemplateDtoProviderDetails] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "make" - Vapi::MakeToolProviderDetails.from_json(json_object: json_object) - when "ghl" - Vapi::GhlToolProviderDetails.from_json(json_object: json_object) - when "function" - Vapi::FunctionToolProviderDetails.from_json(json_object: json_object) - else - Vapi::MakeToolProviderDetails.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::MakeToolProviderDetails.validate_raw(obj: struct) + return Vapi::MakeToolProviderDetails.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "make" - { **@member.to_json, type: @discriminant }.to_json - when "ghl" - { **@member.to_json, type: @discriminant }.to_json - when "function" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::GhlToolProviderDetails.validate_raw(obj: struct) + return Vapi::GhlToolProviderDetails.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::FunctionToolProviderDetails.validate_raw(obj: struct) + return Vapi::FunctionToolProviderDetails.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -66,42 +47,22 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "make" - Vapi::MakeToolProviderDetails.validate_raw(obj: obj) - when "ghl" - Vapi::GhlToolProviderDetails.validate_raw(obj: obj) - when "function" - Vapi::FunctionToolProviderDetails.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::MakeToolProviderDetails.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::MakeToolProviderDetails] - # @return [Vapi::UpdateToolTemplateDtoProviderDetails] - def self.make(member:) - new(member: member, discriminant: "make") - end - - # @param member [Vapi::GhlToolProviderDetails] - # @return [Vapi::UpdateToolTemplateDtoProviderDetails] - def self.ghl(member:) - new(member: member, discriminant: "ghl") - end - - # @param member [Vapi::FunctionToolProviderDetails] - # @return [Vapi::UpdateToolTemplateDtoProviderDetails] - def self.function(member:) - new(member: member, discriminant: "function") + begin + return Vapi::GhlToolProviderDetails.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::FunctionToolProviderDetails.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/vapi_cost.rb b/lib/vapi/types/vapi_cost.rb index 1d64ab5..356c501 100644 --- a/lib/vapi/types/vapi_cost.rb +++ b/lib/vapi/types/vapi_cost.rb @@ -5,6 +5,8 @@ module Vapi class VapiCost + # @return [String] This is the type of cost, always 'vapi' for this class. + attr_reader :type # @return [Float] This is the minutes of Vapi usage. This should match `call.endedAt` - # `call.startedAt`. attr_reader :minutes @@ -18,16 +20,18 @@ class VapiCost OMIT = Object.new + # @param type [String] This is the type of cost, always 'vapi' for this class. # @param minutes [Float] This is the minutes of Vapi usage. This should match `call.endedAt` - # `call.startedAt`. # @param cost [Float] This is the cost of the component in USD. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::VapiCost] - def initialize(minutes:, cost:, additional_properties: nil) + def initialize(type:, minutes:, cost:, additional_properties: nil) + @type = type @minutes = minutes @cost = cost @additional_properties = additional_properties - @_field_set = { "minutes": minutes, "cost": cost } + @_field_set = { "type": type, "minutes": minutes, "cost": cost } end # Deserialize a JSON object to an instance of VapiCost @@ -37,9 +41,11 @@ def initialize(minutes:, cost:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + type = parsed_json["type"] minutes = parsed_json["minutes"] cost = parsed_json["cost"] new( + type: type, minutes: minutes, cost: cost, additional_properties: struct @@ -60,6 +66,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.minutes.is_a?(Float) != false || raise("Passed value for field obj.minutes is not the expected type, validation failed.") obj.cost.is_a?(Float) != false || raise("Passed value for field obj.cost is not the expected type, validation failed.") end diff --git a/lib/vapi/types/vapi_model.rb b/lib/vapi/types/vapi_model.rb index 63abce4..c588ece 100644 --- a/lib/vapi/types/vapi_model.rb +++ b/lib/vapi/types/vapi_model.rb @@ -21,6 +21,8 @@ class VapiModel attr_reader :tool_ids # @return [Array] attr_reader :steps + # @return [String] + attr_reader :provider # @return [String] This is the name of the model. Ex. cognitivecomputations/dolphin-mixtral-8x7b attr_reader :model # @return [Float] This is the temperature that will be used for calls. Default is 0 to leverage @@ -59,6 +61,7 @@ class VapiModel # tools, use `tools`. # Both `tools` and `toolIds` can be used together. # @param steps [Array] + # @param provider [String] # @param model [String] This is the name of the model. Ex. cognitivecomputations/dolphin-mixtral-8x7b # @param temperature [Float] This is the temperature that will be used for calls. Default is 0 to leverage # caching for lower latency. @@ -77,12 +80,13 @@ class VapiModel # @default 0 # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::VapiModel] - def initialize(model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, steps: OMIT, temperature: OMIT, + def initialize(provider:, model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, steps: OMIT, temperature: OMIT, knowledge_base: OMIT, max_tokens: OMIT, emotion_recognition_enabled: OMIT, num_fast_turns: OMIT, additional_properties: nil) @messages = messages if messages != OMIT @tools = tools if tools != OMIT @tool_ids = tool_ids if tool_ids != OMIT @steps = steps if steps != OMIT + @provider = provider @model = model @temperature = temperature if temperature != OMIT @knowledge_base = knowledge_base if knowledge_base != OMIT @@ -95,6 +99,7 @@ def initialize(model:, messages: OMIT, tools: OMIT, tool_ids: OMIT, steps: OMIT, "tools": tools, "toolIds": tool_ids, "steps": steps, + "provider": provider, "model": model, "temperature": temperature, "knowledgeBase": knowledge_base, @@ -126,6 +131,7 @@ def self.from_json(json_object:) item = item.to_json Vapi::VapiModelStepsItem.from_json(json_object: item) end + provider = parsed_json["provider"] model = parsed_json["model"] temperature = parsed_json["temperature"] if parsed_json["knowledgeBase"].nil? @@ -142,6 +148,7 @@ def self.from_json(json_object:) tools: tools, tool_ids: tool_ids, steps: steps, + provider: provider, model: model, temperature: temperature, knowledge_base: knowledge_base, @@ -170,6 +177,7 @@ def self.validate_raw(obj:) obj.tools&.is_a?(Array) != false || raise("Passed value for field obj.tools is not the expected type, validation failed.") obj.tool_ids&.is_a?(Array) != false || raise("Passed value for field obj.tool_ids is not the expected type, validation failed.") obj.steps&.is_a?(Array) != false || raise("Passed value for field obj.steps is not the expected type, validation failed.") + obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") obj.model.is_a?(String) != false || raise("Passed value for field obj.model is not the expected type, validation failed.") obj.temperature&.is_a?(Float) != false || raise("Passed value for field obj.temperature is not the expected type, validation failed.") obj.knowledge_base.nil? || Vapi::KnowledgeBase.validate_raw(obj: obj.knowledge_base) diff --git a/lib/vapi/types/vapi_model_steps_item.rb b/lib/vapi/types/vapi_model_steps_item.rb index 4cf70cd..ffea5e0 100644 --- a/lib/vapi/types/vapi_model_steps_item.rb +++ b/lib/vapi/types/vapi_model_steps_item.rb @@ -6,52 +6,29 @@ module Vapi class VapiModelStepsItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::VapiModelStepsItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of VapiModelStepsItem # # @param json_object [String] # @return [Vapi::VapiModelStepsItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "handoff" - Vapi::HandoffStep.from_json(json_object: json_object) - when "callback" - Vapi::CallbackStep.from_json(json_object: json_object) - else - Vapi::HandoffStep.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::HandoffStep.validate_raw(obj: struct) + return Vapi::HandoffStep.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "handoff" - { **@member.to_json, type: @discriminant }.to_json - when "callback" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::CallbackStep.validate_raw(obj: struct) + return Vapi::CallbackStep.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -61,34 +38,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "handoff" - Vapi::HandoffStep.validate_raw(obj: obj) - when "callback" - Vapi::CallbackStep.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::HandoffStep.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::HandoffStep] - # @return [Vapi::VapiModelStepsItem] - def self.handoff(member:) - new(member: member, discriminant: "handoff") - end - - # @param member [Vapi::CallbackStep] - # @return [Vapi::VapiModelStepsItem] - def self.callback(member:) - new(member: member, discriminant: "callback") + begin + return Vapi::CallbackStep.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/vapi_model_tools_item.rb b/lib/vapi/types/vapi_model_tools_item.rb index a4c75d3..4088835 100644 --- a/lib/vapi/types/vapi_model_tools_item.rb +++ b/lib/vapi/types/vapi_model_tools_item.rb @@ -11,72 +11,69 @@ module Vapi class VapiModelToolsItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::VapiModelToolsItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of VapiModelToolsItem # # @param json_object [String] # @return [Vapi::VapiModelToolsItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "dtmf" - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - when "endCall" - Vapi::CreateEndCallToolDto.from_json(json_object: json_object) - when "voicemail" - Vapi::CreateVoicemailToolDto.from_json(json_object: json_object) - when "function" - Vapi::CreateFunctionToolDto.from_json(json_object: json_object) - when "ghl" - Vapi::CreateGhlToolDto.from_json(json_object: json_object) - when "make" - Vapi::CreateMakeToolDto.from_json(json_object: json_object) - when "transferCall" - Vapi::CreateTransferCallToolDto.from_json(json_object: json_object) - else - Vapi::CreateDtmfToolDto.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::CreateDtmfToolDto.validate_raw(obj: struct) + return Vapi::CreateDtmfToolDto.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "dtmf" - { **@member.to_json, type: @discriminant }.to_json - when "endCall" - { **@member.to_json, type: @discriminant }.to_json - when "voicemail" - { **@member.to_json, type: @discriminant }.to_json - when "function" - { **@member.to_json, type: @discriminant }.to_json - when "ghl" - { **@member.to_json, type: @discriminant }.to_json - when "make" - { **@member.to_json, type: @discriminant }.to_json - when "transferCall" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateEndCallToolDto.validate_raw(obj: struct) + return Vapi::CreateEndCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateVoicemailToolDto.validate_raw(obj: struct) + return Vapi::CreateVoicemailToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateFunctionToolDto.validate_raw(obj: struct) + return Vapi::CreateFunctionToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::CreateGhlToolDto.validate_raw(obj: struct) + return Vapi::CreateGhlToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateMakeToolDto.validate_raw(obj: struct) + return Vapi::CreateMakeToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + begin + Vapi::CreateTransferCallToolDto.validate_raw(obj: struct) + return Vapi::CreateTransferCallToolDto.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -86,74 +83,42 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "dtmf" - Vapi::CreateDtmfToolDto.validate_raw(obj: obj) - when "endCall" - Vapi::CreateEndCallToolDto.validate_raw(obj: obj) - when "voicemail" - Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) - when "function" - Vapi::CreateFunctionToolDto.validate_raw(obj: obj) - when "ghl" - Vapi::CreateGhlToolDto.validate_raw(obj: obj) - when "make" - Vapi::CreateMakeToolDto.validate_raw(obj: obj) - when "transferCall" - Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::CreateDtmfToolDto.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::CreateDtmfToolDto] - # @return [Vapi::VapiModelToolsItem] - def self.dtmf(member:) - new(member: member, discriminant: "dtmf") - end - - # @param member [Vapi::CreateEndCallToolDto] - # @return [Vapi::VapiModelToolsItem] - def self.end_call(member:) - new(member: member, discriminant: "endCall") - end - - # @param member [Vapi::CreateVoicemailToolDto] - # @return [Vapi::VapiModelToolsItem] - def self.voicemail(member:) - new(member: member, discriminant: "voicemail") - end - - # @param member [Vapi::CreateFunctionToolDto] - # @return [Vapi::VapiModelToolsItem] - def self.function(member:) - new(member: member, discriminant: "function") - end - - # @param member [Vapi::CreateGhlToolDto] - # @return [Vapi::VapiModelToolsItem] - def self.ghl(member:) - new(member: member, discriminant: "ghl") - end - - # @param member [Vapi::CreateMakeToolDto] - # @return [Vapi::VapiModelToolsItem] - def self.make(member:) - new(member: member, discriminant: "make") - end - - # @param member [Vapi::CreateTransferCallToolDto] - # @return [Vapi::VapiModelToolsItem] - def self.transfer_call(member:) - new(member: member, discriminant: "transferCall") + begin + return Vapi::CreateEndCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateVoicemailToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateFunctionToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateGhlToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateMakeToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Vapi::CreateTransferCallToolDto.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/vapi_phone_number.rb b/lib/vapi/types/vapi_phone_number.rb index 6311854..9d3ad62 100644 --- a/lib/vapi/types/vapi_phone_number.rb +++ b/lib/vapi/types/vapi_phone_number.rb @@ -14,6 +14,8 @@ class VapiPhoneNumber # If this is not set and above conditions are met, the inbound call is hung up # with an error message. attr_reader :fallback_destination + # @return [String] + attr_reader :provider # @return [String] This is the unique identifier for the phone number. attr_reader :id # @return [String] This is the unique identifier for the org that this phone number belongs to. @@ -62,6 +64,7 @@ class VapiPhoneNumber # 3. and, `assistant-request` message to the `serverUrl` fails # If this is not set and above conditions are met, the inbound call is hung up # with an error message. + # @param provider [String] # @param id [String] This is the unique identifier for the phone number. # @param org_id [String] This is the unique identifier for the org that this phone number belongs to. # @param created_at [DateTime] This is the ISO 8601 date-time string of when the phone number was created. @@ -88,9 +91,10 @@ class VapiPhoneNumber # This is case-insensitive. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::VapiPhoneNumber] - def initialize(id:, org_id:, created_at:, updated_at:, sip_uri:, fallback_destination: OMIT, name: OMIT, assistant_id: OMIT, - squad_id: OMIT, server_url: OMIT, server_url_secret: OMIT, additional_properties: nil) + def initialize(provider:, id:, org_id:, created_at:, updated_at:, sip_uri:, fallback_destination: OMIT, name: OMIT, + assistant_id: OMIT, squad_id: OMIT, server_url: OMIT, server_url_secret: OMIT, additional_properties: nil) @fallback_destination = fallback_destination if fallback_destination != OMIT + @provider = provider @id = id @org_id = org_id @created_at = created_at @@ -104,6 +108,7 @@ def initialize(id:, org_id:, created_at:, updated_at:, sip_uri:, fallback_destin @additional_properties = additional_properties @_field_set = { "fallbackDestination": fallback_destination, + "provider": provider, "id": id, "orgId": org_id, "createdAt": created_at, @@ -132,6 +137,7 @@ def self.from_json(json_object:) fallback_destination = parsed_json["fallbackDestination"].to_json fallback_destination = Vapi::VapiPhoneNumberFallbackDestination.from_json(json_object: fallback_destination) end + provider = parsed_json["provider"] id = parsed_json["id"] org_id = parsed_json["orgId"] created_at = (DateTime.parse(parsed_json["createdAt"]) unless parsed_json["createdAt"].nil?) @@ -144,6 +150,7 @@ def self.from_json(json_object:) sip_uri = parsed_json["sipUri"] new( fallback_destination: fallback_destination, + provider: provider, id: id, org_id: org_id, created_at: created_at, @@ -173,6 +180,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.fallback_destination.nil? || Vapi::VapiPhoneNumberFallbackDestination.validate_raw(obj: obj.fallback_destination) + obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider 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.") diff --git a/lib/vapi/types/vapi_phone_number_fallback_destination.rb b/lib/vapi/types/vapi_phone_number_fallback_destination.rb index 50c1be8..98ff430 100644 --- a/lib/vapi/types/vapi_phone_number_fallback_destination.rb +++ b/lib/vapi/types/vapi_phone_number_fallback_destination.rb @@ -12,52 +12,29 @@ module Vapi # If this is not set and above conditions are met, the inbound call is hung up # with an error message. class VapiPhoneNumberFallbackDestination - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::VapiPhoneNumberFallbackDestination] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of VapiPhoneNumberFallbackDestination # # @param json_object [String] # @return [Vapi::VapiPhoneNumberFallbackDestination] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "number" - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - when "sip" - Vapi::TransferDestinationSip.from_json(json_object: json_object) - else - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::TransferDestinationNumber.validate_raw(obj: struct) + return Vapi::TransferDestinationNumber.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "number" - { **@member.to_json, type: @discriminant }.to_json - when "sip" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::TransferDestinationSip.validate_raw(obj: struct) + return Vapi::TransferDestinationSip.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -67,34 +44,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "number" - Vapi::TransferDestinationNumber.validate_raw(obj: obj) - when "sip" - Vapi::TransferDestinationSip.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::TransferDestinationNumber.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::TransferDestinationNumber] - # @return [Vapi::VapiPhoneNumberFallbackDestination] - def self.number(member:) - new(member: member, discriminant: "number") - end - - # @param member [Vapi::TransferDestinationSip] - # @return [Vapi::VapiPhoneNumberFallbackDestination] - def self.sip(member:) - new(member: member, discriminant: "sip") + begin + return Vapi::TransferDestinationSip.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/voice_cost.rb b/lib/vapi/types/voice_cost.rb index c0b82ab..e704545 100644 --- a/lib/vapi/types/voice_cost.rb +++ b/lib/vapi/types/voice_cost.rb @@ -5,6 +5,8 @@ module Vapi class VoiceCost + # @return [String] This is the type of cost, always 'voice' for this class. + attr_reader :type # @return [Hash{String => Object}] This is the voice that was used during the call. # This matches one of the following: # - `call.assistant.voice`, @@ -28,6 +30,7 @@ class VoiceCost OMIT = Object.new + # @param type [String] This is the type of cost, always 'voice' for this class. # @param voice [Hash{String => Object}] This is the voice that was used during the call. # This matches one of the following: # - `call.assistant.voice`, @@ -42,12 +45,13 @@ class VoiceCost # @param cost [Float] This is the cost of the component in USD. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::VoiceCost] - def initialize(voice:, characters:, cost:, additional_properties: nil) + def initialize(type:, voice:, characters:, cost:, additional_properties: nil) + @type = type @voice = voice @characters = characters @cost = cost @additional_properties = additional_properties - @_field_set = { "voice": voice, "characters": characters, "cost": cost } + @_field_set = { "type": type, "voice": voice, "characters": characters, "cost": cost } end # Deserialize a JSON object to an instance of VoiceCost @@ -57,10 +61,12 @@ def initialize(voice:, characters:, cost:, additional_properties: nil) def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) parsed_json = JSON.parse(json_object) + type = parsed_json["type"] voice = parsed_json["voice"] characters = parsed_json["characters"] cost = parsed_json["cost"] new( + type: type, voice: voice, characters: characters, cost: cost, @@ -82,6 +88,7 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.voice.is_a?(Hash) != false || raise("Passed value for field obj.voice is not the expected type, validation failed.") obj.characters.is_a?(Float) != false || raise("Passed value for field obj.characters is not the expected type, validation failed.") obj.cost.is_a?(Float) != false || raise("Passed value for field obj.cost is not the expected type, validation failed.") diff --git a/lib/vapi/types/vonage_phone_number.rb b/lib/vapi/types/vonage_phone_number.rb index 05264e1..9c6b1b6 100644 --- a/lib/vapi/types/vonage_phone_number.rb +++ b/lib/vapi/types/vonage_phone_number.rb @@ -14,6 +14,8 @@ class VonagePhoneNumber # If this is not set and above conditions are met, the inbound call is hung up # with an error message. attr_reader :fallback_destination + # @return [String] + attr_reader :provider # @return [String] This is the unique identifier for the phone number. attr_reader :id # @return [String] This is the unique identifier for the org that this phone number belongs to. @@ -63,6 +65,7 @@ class VonagePhoneNumber # 3. and, `assistant-request` message to the `serverUrl` fails # If this is not set and above conditions are met, the inbound call is hung up # with an error message. + # @param provider [String] # @param id [String] This is the unique identifier for the phone number. # @param org_id [String] This is the unique identifier for the org that this phone number belongs to. # @param created_at [DateTime] This is the ISO 8601 date-time string of when the phone number was created. @@ -89,9 +92,10 @@ class VonagePhoneNumber # like call transfer and hang up. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::VonagePhoneNumber] - def initialize(id:, org_id:, created_at:, updated_at:, number:, credential_id:, fallback_destination: OMIT, name: OMIT, assistant_id: OMIT, - squad_id: OMIT, server_url: OMIT, server_url_secret: OMIT, additional_properties: nil) + def initialize(provider:, id:, org_id:, created_at:, updated_at:, number:, credential_id:, fallback_destination: OMIT, name: OMIT, + assistant_id: OMIT, squad_id: OMIT, server_url: OMIT, server_url_secret: OMIT, additional_properties: nil) @fallback_destination = fallback_destination if fallback_destination != OMIT + @provider = provider @id = id @org_id = org_id @created_at = created_at @@ -106,6 +110,7 @@ def initialize(id:, org_id:, created_at:, updated_at:, number:, credential_id:, @additional_properties = additional_properties @_field_set = { "fallbackDestination": fallback_destination, + "provider": provider, "id": id, "orgId": org_id, "createdAt": created_at, @@ -135,6 +140,7 @@ def self.from_json(json_object:) fallback_destination = parsed_json["fallbackDestination"].to_json fallback_destination = Vapi::VonagePhoneNumberFallbackDestination.from_json(json_object: fallback_destination) end + provider = parsed_json["provider"] id = parsed_json["id"] org_id = parsed_json["orgId"] created_at = (DateTime.parse(parsed_json["createdAt"]) unless parsed_json["createdAt"].nil?) @@ -148,6 +154,7 @@ def self.from_json(json_object:) credential_id = parsed_json["credentialId"] new( fallback_destination: fallback_destination, + provider: provider, id: id, org_id: org_id, created_at: created_at, @@ -178,6 +185,7 @@ def to_json(*_args) # @return [Void] def self.validate_raw(obj:) obj.fallback_destination.nil? || Vapi::VonagePhoneNumberFallbackDestination.validate_raw(obj: obj.fallback_destination) + obj.provider.is_a?(String) != false || raise("Passed value for field obj.provider 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.") diff --git a/lib/vapi/types/vonage_phone_number_fallback_destination.rb b/lib/vapi/types/vonage_phone_number_fallback_destination.rb index a0dc398..bcbfe57 100644 --- a/lib/vapi/types/vonage_phone_number_fallback_destination.rb +++ b/lib/vapi/types/vonage_phone_number_fallback_destination.rb @@ -12,52 +12,29 @@ module Vapi # If this is not set and above conditions are met, the inbound call is hung up # with an error message. class VonagePhoneNumberFallbackDestination - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::VonagePhoneNumberFallbackDestination] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of VonagePhoneNumberFallbackDestination # # @param json_object [String] # @return [Vapi::VonagePhoneNumberFallbackDestination] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "number" - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - when "sip" - Vapi::TransferDestinationSip.from_json(json_object: json_object) - else - Vapi::TransferDestinationNumber.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::TransferDestinationNumber.validate_raw(obj: struct) + return Vapi::TransferDestinationNumber.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "number" - { **@member.to_json, type: @discriminant }.to_json - when "sip" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::TransferDestinationSip.validate_raw(obj: struct) + return Vapi::TransferDestinationSip.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -67,34 +44,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "number" - Vapi::TransferDestinationNumber.validate_raw(obj: obj) - when "sip" - Vapi::TransferDestinationSip.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::TransferDestinationNumber.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::TransferDestinationNumber] - # @return [Vapi::VonagePhoneNumberFallbackDestination] - def self.number(member:) - new(member: member, discriminant: "number") - end - - # @param member [Vapi::TransferDestinationSip] - # @return [Vapi::VonagePhoneNumberFallbackDestination] - def self.sip(member:) - new(member: member, discriminant: "sip") + begin + return Vapi::TransferDestinationSip.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/workflow_block.rb b/lib/vapi/types/workflow_block.rb index ecbcada..71d5b13 100644 --- a/lib/vapi/types/workflow_block.rb +++ b/lib/vapi/types/workflow_block.rb @@ -35,6 +35,8 @@ class WorkflowBlock # this liquid variable is just provided for convenience when creating blocks # outside of a workflow with steps. attr_reader :output_schema + # @return [String] + attr_reader :type # @return [Array] These are the steps in the workflow. attr_reader :steps # @return [String] This is the unique identifier for the block. @@ -78,6 +80,7 @@ class WorkflowBlock # {{blockName.output.propertyName}} will reference the latest usage of the block. # this liquid variable is just provided for convenience when creating blocks # outside of a workflow with steps. + # @param type [String] # @param steps [Array] These are the steps in the workflow. # @param id [String] This is the unique identifier for the block. # @param org_id [String] This is the unique identifier for the organization that this block belongs to. @@ -86,11 +89,12 @@ class WorkflowBlock # @param name [String] This is the name of the block. This is just for your reference. # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition # @return [Vapi::WorkflowBlock] - def initialize(id:, org_id:, created_at:, updated_at:, messages: OMIT, input_schema: OMIT, output_schema: OMIT, - steps: OMIT, name: OMIT, additional_properties: nil) + def initialize(type:, id:, org_id:, created_at:, updated_at:, messages: OMIT, input_schema: OMIT, + output_schema: OMIT, steps: OMIT, name: OMIT, additional_properties: nil) @messages = messages if messages != OMIT @input_schema = input_schema if input_schema != OMIT @output_schema = output_schema if output_schema != OMIT + @type = type @steps = steps if steps != OMIT @id = id @org_id = org_id @@ -102,6 +106,7 @@ def initialize(id:, org_id:, created_at:, updated_at:, messages: OMIT, input_sch "messages": messages, "inputSchema": input_schema, "outputSchema": output_schema, + "type": type, "steps": steps, "id": id, "orgId": org_id, @@ -136,6 +141,7 @@ def self.from_json(json_object:) output_schema = parsed_json["outputSchema"].to_json output_schema = Vapi::JsonSchema.from_json(json_object: output_schema) end + type = parsed_json["type"] steps = parsed_json["steps"]&.map do |item| item = item.to_json Vapi::WorkflowBlockStepsItem.from_json(json_object: item) @@ -149,6 +155,7 @@ def self.from_json(json_object:) messages: messages, input_schema: input_schema, output_schema: output_schema, + type: type, steps: steps, id: id, org_id: org_id, @@ -176,6 +183,7 @@ 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.input_schema.nil? || Vapi::JsonSchema.validate_raw(obj: obj.input_schema) obj.output_schema.nil? || Vapi::JsonSchema.validate_raw(obj: obj.output_schema) + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") obj.steps&.is_a?(Array) != false || raise("Passed value for field obj.steps 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.") diff --git a/lib/vapi/types/workflow_block_messages_item.rb b/lib/vapi/types/workflow_block_messages_item.rb index afe5eb5..6c5eb16 100644 --- a/lib/vapi/types/workflow_block_messages_item.rb +++ b/lib/vapi/types/workflow_block_messages_item.rb @@ -6,52 +6,29 @@ module Vapi class WorkflowBlockMessagesItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::WorkflowBlockMessagesItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of WorkflowBlockMessagesItem # # @param json_object [String] # @return [Vapi::WorkflowBlockMessagesItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "block-start" - Vapi::BlockStartMessage.from_json(json_object: json_object) - when "block-complete" - Vapi::BlockCompleteMessage.from_json(json_object: json_object) - else - Vapi::BlockStartMessage.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::BlockStartMessage.validate_raw(obj: struct) + return Vapi::BlockStartMessage.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "block-start" - { **@member.to_json, type: @discriminant }.to_json - when "block-complete" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::BlockCompleteMessage.validate_raw(obj: struct) + return Vapi::BlockCompleteMessage.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -61,34 +38,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "block-start" - Vapi::BlockStartMessage.validate_raw(obj: obj) - when "block-complete" - Vapi::BlockCompleteMessage.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::BlockStartMessage.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::BlockStartMessage] - # @return [Vapi::WorkflowBlockMessagesItem] - def self.block_start(member:) - new(member: member, discriminant: "block-start") - end - - # @param member [Vapi::BlockCompleteMessage] - # @return [Vapi::WorkflowBlockMessagesItem] - def self.block_complete(member:) - new(member: member, discriminant: "block-complete") + begin + return Vapi::BlockCompleteMessage.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/lib/vapi/types/workflow_block_steps_item.rb b/lib/vapi/types/workflow_block_steps_item.rb index 1bac44a..ca2d0bd 100644 --- a/lib/vapi/types/workflow_block_steps_item.rb +++ b/lib/vapi/types/workflow_block_steps_item.rb @@ -6,52 +6,29 @@ module Vapi class WorkflowBlockStepsItem - # @return [Object] - attr_reader :member - # @return [String] - attr_reader :discriminant - - private_class_method :new - alias kind_of? is_a? - - # @param member [Object] - # @param discriminant [String] - # @return [Vapi::WorkflowBlockStepsItem] - def initialize(member:, discriminant:) - @member = member - @discriminant = discriminant - end - # Deserialize a JSON object to an instance of WorkflowBlockStepsItem # # @param json_object [String] # @return [Vapi::WorkflowBlockStepsItem] def self.from_json(json_object:) struct = JSON.parse(json_object, object_class: OpenStruct) - member = case struct.type - when "handoff" - Vapi::HandoffStep.from_json(json_object: json_object) - when "callback" - Vapi::CallbackStep.from_json(json_object: json_object) - else - Vapi::HandoffStep.from_json(json_object: json_object) - end - new(member: member, discriminant: struct.type) - end + begin + Vapi::HandoffStep.validate_raw(obj: struct) + return Vapi::HandoffStep.from_json(json_object: struct) unless struct.nil? - # For Union Types, to_json functionality is delegated to the wrapped member. - # - # @return [String] - def to_json(*_args) - case @discriminant - when "handoff" - { **@member.to_json, type: @discriminant }.to_json - when "callback" - { **@member.to_json, type: @discriminant }.to_json - else - { "type": @discriminant, value: @member }.to_json + return nil + rescue StandardError + # noop end - @member.to_json + begin + Vapi::CallbackStep.validate_raw(obj: struct) + return Vapi::CallbackStep.from_json(json_object: struct) unless struct.nil? + + return nil + rescue StandardError + # noop + end + struct end # Leveraged for Union-type generation, validate_raw attempts to parse the given @@ -61,34 +38,17 @@ def to_json(*_args) # @param obj [Object] # @return [Void] def self.validate_raw(obj:) - case obj.type - when "handoff" - Vapi::HandoffStep.validate_raw(obj: obj) - when "callback" - Vapi::CallbackStep.validate_raw(obj: obj) - else - raise("Passed value matched no type within the union, validation failed.") + begin + return Vapi::HandoffStep.validate_raw(obj: obj) + rescue StandardError + # noop end - end - - # For Union Types, is_a? functionality is delegated to the wrapped member. - # - # @param obj [Object] - # @return [Boolean] - def is_a?(obj) - @member.is_a?(obj) - end - - # @param member [Vapi::HandoffStep] - # @return [Vapi::WorkflowBlockStepsItem] - def self.handoff(member:) - new(member: member, discriminant: "handoff") - end - - # @param member [Vapi::CallbackStep] - # @return [Vapi::WorkflowBlockStepsItem] - def self.callback(member:) - new(member: member, discriminant: "callback") + begin + return Vapi::CallbackStep.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") end end end diff --git a/vapi.gemspec b/vapi.gemspec index cf58a9c..58b30e2 100644 --- a/vapi.gemspec +++ b/vapi.gemspec @@ -4,7 +4,7 @@ require_relative "lib/gemconfig" Gem::Specification.new do |spec| spec.name = "vapi" - spec.version = "0.0.16" + spec.version = "0.0.0-alpha2" spec.authors = Vapi::Gemconfig::AUTHORS spec.email = Vapi::Gemconfig::EMAIL spec.summary = Vapi::Gemconfig::SUMMARY