Class: Vapi::CallsClient
- Inherits:
-
Object
- Object
- Vapi::CallsClient
- Defined in:
- lib/vapi_server_sdk/calls/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #create(name: nil, assistant_id: nil, assistant: nil, assistant_overrides: nil, squad_id: nil, squad: nil, phone_number_id: nil, phone_number: nil, customer_id: nil, customer: nil, request_options: nil) ⇒ Vapi::Call
- #delete(id:, request_options: nil) ⇒ Vapi::Call
- #get(id:, request_options: nil) ⇒ Vapi::Call
- #initialize(request_client:) ⇒ Vapi::CallsClient constructor
- #list(assistant_id: nil, 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::Call>
- #update(id:, name: nil, request_options: nil) ⇒ Vapi::Call
Constructor Details
#initialize(request_client:) ⇒ Vapi::CallsClient
21 22 23 |
# File 'lib/vapi_server_sdk/calls/client.rb', line 21 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Vapi::RequestClient (readonly)
17 18 19 |
# File 'lib/vapi_server_sdk/calls/client.rb', line 17 def request_client @request_client end |
Instance Method Details
#create(name: nil, assistant_id: nil, assistant: nil, assistant_overrides: nil, squad_id: nil, squad: nil, phone_number_id: nil, phone_number: nil, customer_id: nil, customer: nil, request_options: nil) ⇒ Vapi::Call
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 |
# File 'lib/vapi_server_sdk/calls/client.rb', line 365 def create(name: nil, assistant_id: nil, assistant: nil, assistant_overrides: nil, squad_id: nil, squad: nil, phone_number_id: nil, phone_number: nil, customer_id: nil, customer: nil, request_options: nil) response = @request_client.conn.post do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end req.body = { **(&.additional_body_parameters || {}), name: name, assistantId: assistant_id, assistant: assistant, assistantOverrides: assistant_overrides, squadId: squad_id, squad: squad, phoneNumberId: phone_number_id, phoneNumber: phone_number, customerId: customer_id, customer: customer }.compact req.url "#{@request_client.get_url(request_options: )}/call" end Vapi::Call.from_json(json_object: response.body) end |
#delete(id:, request_options: nil) ⇒ Vapi::Call
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 |
# File 'lib/vapi_server_sdk/calls/client.rb', line 436 def delete(id:, request_options: nil) response = @request_client.conn.delete do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/call/#{id}" end Vapi::Call.from_json(json_object: response.body) end |
#get(id:, request_options: nil) ⇒ Vapi::Call
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 |
# File 'lib/vapi_server_sdk/calls/client.rb', line 406 def get(id:, request_options: nil) response = @request_client.conn.get do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end unless .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/call/#{id}" end Vapi::Call.from_json(json_object: response.body) end |
#list(assistant_id: nil, 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::Call>
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/vapi_server_sdk/calls/client.rb', line 48 def list(assistant_id: nil, 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..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact req.params = { **(&.additional_query_parameters || {}), "assistantId": assistant_id, "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 .nil? || &.additional_body_parameters.nil? req.body = { **(&.additional_body_parameters || {}) }.compact end req.url "#{@request_client.get_url(request_options: )}/call" end parsed_json = JSON.parse(response.body) parsed_json&.map do |item| item = item.to_json Vapi::Call.from_json(json_object: item) end end |
#update(id:, name: nil, request_options: nil) ⇒ Vapi::Call
467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 |
# File 'lib/vapi_server_sdk/calls/client.rb', line 467 def update(id:, name: nil, request_options: nil) response = @request_client.conn.patch do |req| req..timeout = .timeout_in_seconds unless &.timeout_in_seconds.nil? req.headers["Authorization"] = .token unless &.token.nil? req.headers = { **(req.headers || {}), **@request_client.get_headers, **(&.additional_headers || {}) }.compact unless .nil? || &.additional_query_parameters.nil? req.params = { **(&.additional_query_parameters || {}) }.compact end req.body = { **(&.additional_body_parameters || {}), name: name }.compact req.url "#{@request_client.get_url(request_options: )}/call/#{id}" end Vapi::Call.from_json(json_object: response.body) end |