Class: Vapi::AsyncSquadsClient

Inherits:
Object
  • Object
show all
Defined in:
lib/vapi_server_sdk/squads/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ Vapi::AsyncSquadsClient

Parameters:



533
534
535
# File 'lib/vapi_server_sdk/squads/client.rb', line 533

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientVapi::AsyncRequestClient (readonly)



529
530
531
# File 'lib/vapi_server_sdk/squads/client.rb', line 529

def request_client
  @request_client
end

Instance Method Details

#create(request:, request_options: nil) ⇒ Vapi::Squad

Examples:

api = Vapi::Client.new(
  base_url: "https://api.example.com",
  environment: Vapi::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.squads.create(request: { members: [{  }] })

Parameters:

  • request (Hash)

    Request of type Vapi::CreateSquadDto, as a Hash

    • :name (String)

    • :members (Array<Vapi::SquadMemberDto>)

    • :members_overrides (Hash)

      • :transcriber (Hash)

      • :model (Hash)

      • :voice (Hash)

      • :first_message_mode (Vapi::AssistantOverridesFirstMessageMode)

      • :hipaa_enabled (Boolean)

      • :client_messages (Array<Vapi::AssistantOverridesClientMessagesItem>)

      • :server_messages (Array<Vapi::AssistantOverridesServerMessagesItem>)

      • :silence_timeout_seconds (Float)

      • :max_duration_seconds (Float)

      • :background_sound (Vapi::AssistantOverridesBackgroundSound)

      • :backchanneling_enabled (Boolean)

      • :background_denoising_enabled (Boolean)

      • :model_output_in_messages_enabled (Boolean)

      • :transport_configurations (Array<Vapi::TransportConfigurationTwilio>)

      • :variable_values (Hash=> Object)

      • :name (String)

      • :first_message (String)

      • :voicemail_detection (Hash)

        • :provider (String)

        • :voicemail_detection_types (Array<Vapi::TwilioVoicemailDetectionVoicemailDetectionTypesItem>)

        • :enabled (Boolean)

        • :machine_detection_timeout (Float)

        • :machine_detection_speech_threshold (Float)

        • :machine_detection_speech_end_threshold (Float)

        • :machine_detection_silence_timeout (Float)

      • :voicemail_message (String)

      • :end_call_message (String)

      • :end_call_phrases (Array<String>)

      • :metadata (Hash=> Object)

      • :server_url (String)

      • :server_url_secret (String)

      • :analysis_plan (Hash)

        • :summary_plan (Hash)

          • :messages (Array<Hash=> Object>)

          • :enabled (Boolean)

          • :timeout_seconds (Float)

        • :structured_data_plan (Hash)

          • :messages (Array<Hash=> Object>)

          • :enabled (Boolean)

          • :schema (Hash)

            • :type (Vapi::JsonSchemaType)

            • :items (Hash=> Object)

            • :properties (Hash=> Object)

            • :description (String)

            • :required (Array<String>)

          • :timeout_seconds (Float)

        • :success_evaluation_plan (Hash)

          • :rubric (Vapi::SuccessEvaluationPlanRubric)

          • :messages (Array<Hash=> Object>)

          • :enabled (Boolean)

          • :timeout_seconds (Float)

      • :artifact_plan (Hash)

        • :recording_enabled (Boolean)

        • :video_recording_enabled (Boolean)

        • :transcript_plan (Hash)

          • :enabled (Boolean)

          • :assistant_name (String)

          • :user_name (String)

        • :recording_path (String)

      • :message_plan (Hash)

        • :idle_messages (Array<String>)

        • :idle_message_max_spoken_count (Float)

        • :idle_timeout_seconds (Float)

      • :start_speaking_plan (Hash)

        • :wait_seconds (Float)

        • :smart_endpointing_enabled (Boolean)

        • :transcription_endpointing_plan (Hash)

          • :on_punctuation_seconds (Float)

          • :on_no_punctuation_seconds (Float)

          • :on_number_seconds (Float)

      • :stop_speaking_plan (Hash)

        • :num_words (Float)

        • :voice_seconds (Float)

        • :backoff_seconds (Float)

      • :monitor_plan (Hash)

        • :listen_enabled (Boolean)

        • :control_enabled (Boolean)

      • :credential_ids (Array<String>)

  • request_options (Vapi::RequestOptions) (defaults to: nil)

Returns:



686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
# File 'lib/vapi_server_sdk/squads/client.rb', line 686

def create(request:, request_options: nil)
  Async do
    response = @request_client.conn.post do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
      req.headers = {
    **(req.headers || {}),
    **@request_client.get_headers,
    **(request_options&.additional_headers || {})
      }.compact
      unless request_options.nil? || request_options&.additional_query_parameters.nil?
        req.params = { **(request_options&.additional_query_parameters || {}) }.compact
      end
      req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact
      req.url "#{@request_client.get_url(request_options: request_options)}/squad"
    end
    Vapi::Squad.from_json(json_object: response.body)
  end
end

#delete(id:, request_options: nil) ⇒ Vapi::Squad

Examples:

api = Vapi::Client.new(
  base_url: "https://api.example.com",
  environment: Vapi::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.squads.delete(id: "id")

Parameters:

Returns:



748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
# File 'lib/vapi_server_sdk/squads/client.rb', line 748

def delete(id:, request_options: nil)
  Async do
    response = @request_client.conn.delete do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
      req.headers = {
    **(req.headers || {}),
    **@request_client.get_headers,
    **(request_options&.additional_headers || {})
      }.compact
      unless request_options.nil? || request_options&.additional_query_parameters.nil?
        req.params = { **(request_options&.additional_query_parameters || {}) }.compact
      end
      unless request_options.nil? || request_options&.additional_body_parameters.nil?
        req.body = { **(request_options&.additional_body_parameters || {}) }.compact
      end
      req.url "#{@request_client.get_url(request_options: request_options)}/squad/#{id}"
    end
    Vapi::Squad.from_json(json_object: response.body)
  end
end

#get(id:, request_options: nil) ⇒ Vapi::Squad

Examples:

api = Vapi::Client.new(
  base_url: "https://api.example.com",
  environment: Vapi::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.squads.get(id: "id")

Parameters:

Returns:



716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
# File 'lib/vapi_server_sdk/squads/client.rb', line 716

def get(id:, request_options: nil)
  Async do
    response = @request_client.conn.get do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
      req.headers = {
    **(req.headers || {}),
    **@request_client.get_headers,
    **(request_options&.additional_headers || {})
      }.compact
      unless request_options.nil? || request_options&.additional_query_parameters.nil?
        req.params = { **(request_options&.additional_query_parameters || {}) }.compact
      end
      unless request_options.nil? || request_options&.additional_body_parameters.nil?
        req.body = { **(request_options&.additional_body_parameters || {}) }.compact
      end
      req.url "#{@request_client.get_url(request_options: request_options)}/squad/#{id}"
    end
    Vapi::Squad.from_json(json_object: response.body)
  end
end

#list(limit: nil, created_at_gt: nil, created_at_lt: nil, created_at_ge: nil, created_at_le: nil, updated_at_gt: nil, updated_at_lt: nil, updated_at_ge: nil, updated_at_le: nil, request_options: nil) ⇒ Array<Vapi::Squad>

Examples:

api = Vapi::Client.new(
  base_url: "https://api.example.com",
  environment: Vapi::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.squads.list

Parameters:

  • limit (Float) (defaults to: nil)

    This is the maximum number of items to return. Defaults to 100.

  • created_at_gt (DateTime) (defaults to: nil)

    This will return items where the createdAt is greater than the specified value.

  • created_at_lt (DateTime) (defaults to: nil)

    This will return items where the createdAt is less than the specified value.

  • created_at_ge (DateTime) (defaults to: nil)

    This will return items where the createdAt is greater than or equal to the specified value.

  • created_at_le (DateTime) (defaults to: nil)

    This will return items where the createdAt is less than or equal to the specified value.

  • updated_at_gt (DateTime) (defaults to: nil)

    This will return items where the updatedAt is greater than the specified value.

  • updated_at_lt (DateTime) (defaults to: nil)

    This will return items where the updatedAt is less than the specified value.

  • updated_at_ge (DateTime) (defaults to: nil)

    This will return items where the updatedAt is greater than or equal to the specified value.

  • updated_at_le (DateTime) (defaults to: nil)

    This will return items where the updatedAt is less than or equal to the specified value.

  • request_options (Vapi::RequestOptions) (defaults to: nil)

Returns:



559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
# File 'lib/vapi_server_sdk/squads/client.rb', line 559

def list(limit: nil, created_at_gt: nil, created_at_lt: nil, created_at_ge: nil, created_at_le: nil,
         updated_at_gt: nil, updated_at_lt: nil, updated_at_ge: nil, updated_at_le: nil, request_options: nil)
  Async do
    response = @request_client.conn.get do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
      req.headers = {
    **(req.headers || {}),
    **@request_client.get_headers,
    **(request_options&.additional_headers || {})
      }.compact
      req.params = {
        **(request_options&.additional_query_parameters || {}),
        "limit": limit,
        "createdAtGt": created_at_gt,
        "createdAtLt": created_at_lt,
        "createdAtGe": created_at_ge,
        "createdAtLe": created_at_le,
        "updatedAtGt": updated_at_gt,
        "updatedAtLt": updated_at_lt,
        "updatedAtGe": updated_at_ge,
        "updatedAtLe": updated_at_le
      }.compact
      unless request_options.nil? || request_options&.additional_body_parameters.nil?
        req.body = { **(request_options&.additional_body_parameters || {}) }.compact
      end
      req.url "#{@request_client.get_url(request_options: request_options)}/squad"
    end
    parsed_json = JSON.parse(response.body)
    parsed_json&.map do |item|
      item = item.to_json
      Vapi::Squad.from_json(json_object: item)
    end
  end
end

#update(id:, members:, name: nil, members_overrides: nil, request_options: nil) ⇒ Vapi::Squad

Examples:

api = Vapi::Client.new(
  base_url: "https://api.example.com",
  environment: Vapi::Environment::DEFAULT,
  token: "YOUR_AUTH_TOKEN"
)
api.squads.update(id: "id", members: [{  }])

Parameters:

  • id (String)
  • name (String) (defaults to: nil)

    This is the name of the squad.

  • members (Array<Hash>)

    This is the list of assistants that make up the squad. The call will start with the first assistant in the list.Request of type Array<Vapi::SquadMemberDto>, as a Hash

    * :assistant_id (String)
    * :assistant (Hash)
      * :transcriber (Hash)
      * :model (Hash)
      * :voice (Hash)
      * :first_message_mode (Vapi::CreateAssistantDtoFirstMessageMode)
      * :hipaa_enabled (Boolean)
      * :client_messages (Array<Vapi::CreateAssistantDtoClientMessagesItem>)
      * :server_messages (Array<Vapi::CreateAssistantDtoServerMessagesItem>)
      * :silence_timeout_seconds (Float)
      * :max_duration_seconds (Float)
      * :background_sound (Vapi::CreateAssistantDtoBackgroundSound)
      * :backchanneling_enabled (Boolean)
      * :background_denoising_enabled (Boolean)
      * :model_output_in_messages_enabled (Boolean)
      * :transport_configurations (Array<Vapi::TransportConfigurationTwilio>)
      * :name (String)
      * :first_message (String)
      * :voicemail_detection (Hash)
        * :provider (String)
        * :voicemail_detection_types (Array<Vapi::TwilioVoicemailDetectionVoicemailDetectionTypesItem>)
        * :enabled (Boolean)
        * :machine_detection_timeout (Float)
        * :machine_detection_speech_threshold (Float)
        * :machine_detection_speech_end_threshold (Float)
        * :machine_detection_silence_timeout (Float)
      * :voicemail_message (String)
      * :end_call_message (String)
      * :end_call_phrases (Array<String>)
      * :metadata (Hash{String => Object})
      * :server_url (String)
      * :server_url_secret (String)
      * :analysis_plan (Hash)
        * :summary_plan (Hash)
          * :messages (Array<Hash{String => Object}>)
          * :enabled (Boolean)
          * :timeout_seconds (Float)
        * :structured_data_plan (Hash)
          * :messages (Array<Hash{String => Object}>)
          * :enabled (Boolean)
          * :schema (Hash)
            * :type (Vapi::JsonSchemaType)
            * :items (Hash{String => Object})
            * :properties (Hash{String => Object})
            * :description (String)
            * :required (Array<String>)
          * :timeout_seconds (Float)
        * :success_evaluation_plan (Hash)
          * :rubric (Vapi::SuccessEvaluationPlanRubric)
          * :messages (Array<Hash{String => Object}>)
          * :enabled (Boolean)
          * :timeout_seconds (Float)
      * :artifact_plan (Hash)
        * :recording_enabled (Boolean)
        * :video_recording_enabled (Boolean)
        * :transcript_plan (Hash)
          * :enabled (Boolean)
          * :assistant_name (String)
          * :user_name (String)
        * :recording_path (String)
      * :message_plan (Hash)
        * :idle_messages (Array<String>)
        * :idle_message_max_spoken_count (Float)
        * :idle_timeout_seconds (Float)
      * :start_speaking_plan (Hash)
        * :wait_seconds (Float)
        * :smart_endpointing_enabled (Boolean)
        * :transcription_endpointing_plan (Hash)
          * :on_punctuation_seconds (Float)
          * :on_no_punctuation_seconds (Float)
          * :on_number_seconds (Float)
      * :stop_speaking_plan (Hash)
        * :num_words (Float)
        * :voice_seconds (Float)
        * :backoff_seconds (Float)
      * :monitor_plan (Hash)
        * :listen_enabled (Boolean)
        * :control_enabled (Boolean)
      * :credential_ids (Array<String>)
    * :assistant_overrides (Hash)
      * :transcriber (Hash)
      * :model (Hash)
      * :voice (Hash)
      * :first_message_mode (Vapi::AssistantOverridesFirstMessageMode)
      * :hipaa_enabled (Boolean)
      * :client_messages (Array<Vapi::AssistantOverridesClientMessagesItem>)
      * :server_messages (Array<Vapi::AssistantOverridesServerMessagesItem>)
      * :silence_timeout_seconds (Float)
      * :max_duration_seconds (Float)
      * :background_sound (Vapi::AssistantOverridesBackgroundSound)
      * :backchanneling_enabled (Boolean)
      * :background_denoising_enabled (Boolean)
      * :model_output_in_messages_enabled (Boolean)
      * :transport_configurations (Array<Vapi::TransportConfigurationTwilio>)
      * :variable_values (Hash{String => Object})
      * :name (String)
      * :first_message (String)
      * :voicemail_detection (Hash)
        * :provider (String)
        * :voicemail_detection_types (Array<Vapi::TwilioVoicemailDetectionVoicemailDetectionTypesItem>)
        * :enabled (Boolean)
        * :machine_detection_timeout (Float)
        * :machine_detection_speech_threshold (Float)
        * :machine_detection_speech_end_threshold (Float)
        * :machine_detection_silence_timeout (Float)
      * :voicemail_message (String)
      * :end_call_message (String)
      * :end_call_phrases (Array<String>)
      * :metadata (Hash{String => Object})
      * :server_url (String)
      * :server_url_secret (String)
      * :analysis_plan (Hash)
        * :summary_plan (Hash)
          * :messages (Array<Hash{String => Object}>)
          * :enabled (Boolean)
          * :timeout_seconds (Float)
        * :structured_data_plan (Hash)
          * :messages (Array<Hash{String => Object}>)
          * :enabled (Boolean)
          * :schema (Hash)
            * :type (Vapi::JsonSchemaType)
            * :items (Hash{String => Object})
            * :properties (Hash{String => Object})
            * :description (String)
            * :required (Array<String>)
          * :timeout_seconds (Float)
        * :success_evaluation_plan (Hash)
          * :rubric (Vapi::SuccessEvaluationPlanRubric)
          * :messages (Array<Hash{String => Object}>)
          * :enabled (Boolean)
          * :timeout_seconds (Float)
      * :artifact_plan (Hash)
        * :recording_enabled (Boolean)
        * :video_recording_enabled (Boolean)
        * :transcript_plan (Hash)
          * :enabled (Boolean)
          * :assistant_name (String)
          * :user_name (String)
        * :recording_path (String)
      * :message_plan (Hash)
        * :idle_messages (Array<String>)
        * :idle_message_max_spoken_count (Float)
        * :idle_timeout_seconds (Float)
      * :start_speaking_plan (Hash)
        * :wait_seconds (Float)
        * :smart_endpointing_enabled (Boolean)
        * :transcription_endpointing_plan (Hash)
          * :on_punctuation_seconds (Float)
          * :on_no_punctuation_seconds (Float)
          * :on_number_seconds (Float)
      * :stop_speaking_plan (Hash)
        * :num_words (Float)
        * :voice_seconds (Float)
        * :backoff_seconds (Float)
      * :monitor_plan (Hash)
        * :listen_enabled (Boolean)
        * :control_enabled (Boolean)
      * :credential_ids (Array<String>)
    * :assistant_destinations (Array<Vapi::TransferDestinationAssistant>)
    
  • members_overrides (Hash) (defaults to: nil)

    This can be used to override all the assistants’ settings and provide values for their template variables. Both ‘membersOverrides` and `members.assistantOverrides` can be used together. First, `members.assistantOverrides` is applied. Then, `membersOverrides` is applied as a global override.Request of type Vapi::AssistantOverrides, as a Hash

    * :transcriber (Hash)
    * :model (Hash)
    * :voice (Hash)
    * :first_message_mode (Vapi::AssistantOverridesFirstMessageMode)
    * :hipaa_enabled (Boolean)
    * :client_messages (Array<Vapi::AssistantOverridesClientMessagesItem>)
    * :server_messages (Array<Vapi::AssistantOverridesServerMessagesItem>)
    * :silence_timeout_seconds (Float)
    * :max_duration_seconds (Float)
    * :background_sound (Vapi::AssistantOverridesBackgroundSound)
    * :backchanneling_enabled (Boolean)
    * :background_denoising_enabled (Boolean)
    * :model_output_in_messages_enabled (Boolean)
    * :transport_configurations (Array<Vapi::TransportConfigurationTwilio>)
    * :variable_values (Hash{String => Object})
    * :name (String)
    * :first_message (String)
    * :voicemail_detection (Hash)
      * :provider (String)
      * :voicemail_detection_types (Array<Vapi::TwilioVoicemailDetectionVoicemailDetectionTypesItem>)
      * :enabled (Boolean)
      * :machine_detection_timeout (Float)
      * :machine_detection_speech_threshold (Float)
      * :machine_detection_speech_end_threshold (Float)
      * :machine_detection_silence_timeout (Float)
    * :voicemail_message (String)
    * :end_call_message (String)
    * :end_call_phrases (Array<String>)
    * :metadata (Hash{String => Object})
    * :server_url (String)
    * :server_url_secret (String)
    * :analysis_plan (Hash)
      * :summary_plan (Hash)
        * :messages (Array<Hash{String => Object}>)
        * :enabled (Boolean)
        * :timeout_seconds (Float)
      * :structured_data_plan (Hash)
        * :messages (Array<Hash{String => Object}>)
        * :enabled (Boolean)
        * :schema (Hash)
          * :type (Vapi::JsonSchemaType)
          * :items (Hash{String => Object})
          * :properties (Hash{String => Object})
          * :description (String)
          * :required (Array<String>)
        * :timeout_seconds (Float)
      * :success_evaluation_plan (Hash)
        * :rubric (Vapi::SuccessEvaluationPlanRubric)
        * :messages (Array<Hash{String => Object}>)
        * :enabled (Boolean)
        * :timeout_seconds (Float)
    * :artifact_plan (Hash)
      * :recording_enabled (Boolean)
      * :video_recording_enabled (Boolean)
      * :transcript_plan (Hash)
        * :enabled (Boolean)
        * :assistant_name (String)
        * :user_name (String)
      * :recording_path (String)
    * :message_plan (Hash)
      * :idle_messages (Array<String>)
      * :idle_message_max_spoken_count (Float)
      * :idle_timeout_seconds (Float)
    * :start_speaking_plan (Hash)
      * :wait_seconds (Float)
      * :smart_endpointing_enabled (Boolean)
      * :transcription_endpointing_plan (Hash)
        * :on_punctuation_seconds (Float)
        * :on_no_punctuation_seconds (Float)
        * :on_number_seconds (Float)
    * :stop_speaking_plan (Hash)
      * :num_words (Float)
      * :voice_seconds (Float)
      * :backoff_seconds (Float)
    * :monitor_plan (Hash)
      * :listen_enabled (Boolean)
      * :control_enabled (Boolean)
    * :credential_ids (Array<String>)
    
  • request_options (Vapi::RequestOptions) (defaults to: nil)

Returns:



1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
# File 'lib/vapi_server_sdk/squads/client.rb', line 1025

def update(id:, members:, name: nil, members_overrides: nil, request_options: nil)
  Async do
    response = @request_client.conn.patch do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.token unless request_options&.token.nil?
      req.headers = {
    **(req.headers || {}),
    **@request_client.get_headers,
    **(request_options&.additional_headers || {})
      }.compact
      unless request_options.nil? || request_options&.additional_query_parameters.nil?
        req.params = { **(request_options&.additional_query_parameters || {}) }.compact
      end
      req.body = {
        **(request_options&.additional_body_parameters || {}),
        name: name,
        members: members,
        membersOverrides: members_overrides
      }.compact
      req.url "#{@request_client.get_url(request_options: request_options)}/squad/#{id}"
    end
    Vapi::Squad.from_json(json_object: response.body)
  end
end