Class: Vapi::AssistantsClient

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ Vapi::AssistantsClient



39
40
41
# File 'lib/vapi_server_sdk/assistants/client.rb', line 39

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientVapi::RequestClient (readonly)



35
36
37
# File 'lib/vapi_server_sdk/assistants/client.rb', line 35

def request_client
  @request_client
end

Instance Method Details

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



210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# File 'lib/vapi_server_sdk/assistants/client.rb', line 210

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?
    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)}/assistant"
  end
  Vapi::Assistant.from_json(json_object: response.body)
end

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



254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
# File 'lib/vapi_server_sdk/assistants/client.rb', line 254

def delete(id:, request_options: nil)
  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)}/assistant/#{id}"
  end
  Vapi::Assistant.from_json(json_object: response.body)
end

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



231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
# File 'lib/vapi_server_sdk/assistants/client.rb', line 231

def get(id:, request_options: nil)
  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)}/assistant/#{id}"
  end
  Vapi::Assistant.from_json(json_object: response.body)
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::Assistant>



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# File 'lib/vapi_server_sdk/assistants/client.rb', line 58

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)
  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)}/assistant"
  end
  parsed_json = JSON.parse(response.body)
  parsed_json&.map do |item|
    item = item.to_json
    Vapi::Assistant.from_json(json_object: item)
  end
end

#update(id:, transcriber: nil, model: nil, voice: nil, first_message: nil, first_message_interruptions_enabled: nil, first_message_mode: nil, voicemail_detection: nil, client_messages: nil, server_messages: nil, silence_timeout_seconds: nil, max_duration_seconds: nil, background_sound: nil, background_denoising_enabled: nil, model_output_in_messages_enabled: nil, transport_configurations: nil, observability_plan: nil, credentials: nil, hooks: nil, name: nil, voicemail_message: nil, end_call_message: nil, end_call_phrases: nil, compliance_plan: nil, metadata: nil, background_speech_denoising_plan: nil, analysis_plan: nil, artifact_plan: nil, message_plan: nil, start_speaking_plan: nil, stop_speaking_plan: nil, monitor_plan: nil, credential_ids: nil, server: nil, keypad_input_plan: nil, request_options: nil) ⇒ Vapi::Assistant



478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
# File 'lib/vapi_server_sdk/assistants/client.rb', line 478

def update(id:, transcriber: nil, model: nil, voice: nil, first_message: nil,
           first_message_interruptions_enabled: nil, first_message_mode: nil, voicemail_detection: nil, client_messages: nil, server_messages: nil, silence_timeout_seconds: nil, max_duration_seconds: nil, background_sound: nil, background_denoising_enabled: nil, model_output_in_messages_enabled: nil, transport_configurations: nil, observability_plan: nil, credentials: nil, hooks: nil, name: nil, voicemail_message: nil, end_call_message: nil, end_call_phrases: nil, compliance_plan: nil, metadata: nil, background_speech_denoising_plan: nil, analysis_plan: nil, artifact_plan: nil, message_plan: nil, start_speaking_plan: nil, stop_speaking_plan: nil, monitor_plan: nil, credential_ids: nil, server: nil, keypad_input_plan: nil, request_options: nil)
  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 || {}),
      transcriber: transcriber,
      model: model,
      voice: voice,
      firstMessage: first_message,
      firstMessageInterruptionsEnabled: first_message_interruptions_enabled,
      firstMessageMode: first_message_mode,
      voicemailDetection: voicemail_detection,
      clientMessages: client_messages,
      serverMessages: server_messages,
      silenceTimeoutSeconds: silence_timeout_seconds,
      maxDurationSeconds: max_duration_seconds,
      backgroundSound: background_sound,
      backgroundDenoisingEnabled: background_denoising_enabled,
      modelOutputInMessagesEnabled: model_output_in_messages_enabled,
      transportConfigurations: transport_configurations,
      observabilityPlan: observability_plan,
      credentials: credentials,
      hooks: hooks,
      name: name,
      voicemailMessage: voicemail_message,
      endCallMessage: end_call_message,
      endCallPhrases: end_call_phrases,
      compliancePlan: compliance_plan,
      metadata: ,
      backgroundSpeechDenoisingPlan: background_speech_denoising_plan,
      analysisPlan: analysis_plan,
      artifactPlan: artifact_plan,
      messagePlan: message_plan,
      startSpeakingPlan: start_speaking_plan,
      stopSpeakingPlan: stop_speaking_plan,
      monitorPlan: monitor_plan,
      credentialIds: credential_ids,
      server: server,
      keypadInputPlan: keypad_input_plan
    }.compact
    req.url "#{@request_client.get_url(request_options: request_options)}/assistant/#{id}"
  end
  Vapi::Assistant.from_json(json_object: response.body)
end