Class: Vapi::AsyncToolsClient
- Inherits:
-
Object
- Object
- Vapi::AsyncToolsClient
- Defined in:
- lib/vapi_server_sdk/tools/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #create(request:, request_options: nil) ⇒ Vapi::Tools::ToolsCreateResponse
- #delete(id:, request_options: nil) ⇒ Vapi::Tools::ToolsDeleteResponse
- #get(id:, request_options: nil) ⇒ Vapi::Tools::ToolsGetResponse
- #initialize(request_client:) ⇒ Vapi::AsyncToolsClient constructor
- #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::Tools::ToolsListResponseItem>
- #update(id:, async: nil, messages: nil, function: nil, server: nil, request_options: nil) ⇒ Vapi::Tools::ToolsUpdateResponse
Constructor Details
#initialize(request_client:) ⇒ Vapi::AsyncToolsClient
247 248 249 |
# File 'lib/vapi_server_sdk/tools/client.rb', line 247 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Vapi::AsyncRequestClient (readonly)
243 244 245 |
# File 'lib/vapi_server_sdk/tools/client.rb', line 243 def request_client @request_client end |
Instance Method Details
#create(request:, request_options: nil) ⇒ Vapi::Tools::ToolsCreateResponse
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
# File 'lib/vapi_server_sdk/tools/client.rb', line 319 def create(request:, request_options: nil) Async do 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 = { **(request || {}), **(&.additional_body_parameters || {}) }.compact req.url "#{@request_client.get_url(request_options: )}/tool" end Vapi::Tools::ToolsCreateResponse.from_json(json_object: response.body) end end |
#delete(id:, request_options: nil) ⇒ Vapi::Tools::ToolsDeleteResponse
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 |
# File 'lib/vapi_server_sdk/tools/client.rb', line 381 def delete(id:, request_options: nil) Async do 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: )}/tool/#{id}" end Vapi::Tools::ToolsDeleteResponse.from_json(json_object: response.body) end end |
#get(id:, request_options: nil) ⇒ Vapi::Tools::ToolsGetResponse
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 |
# File 'lib/vapi_server_sdk/tools/client.rb', line 349 def get(id:, request_options: nil) Async do 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: )}/tool/#{id}" end Vapi::Tools::ToolsGetResponse.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::Tools::ToolsListResponseItem>
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
# File 'lib/vapi_server_sdk/tools/client.rb', line 273 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..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 || {}), "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: )}/tool" end parsed_json = JSON.parse(response.body) parsed_json&.map do |item| item = item.to_json Vapi::Tools::ToolsListResponseItem.from_json(json_object: item) end end end |
#update(id:, async: nil, messages: nil, function: nil, server: nil, request_options: nil) ⇒ Vapi::Tools::ToolsUpdateResponse
447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 |
# File 'lib/vapi_server_sdk/tools/client.rb', line 447 def update(id:, async: nil, messages: nil, function: nil, server: nil, request_options: nil) Async do 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 || {}), async: async, messages: , function: function, server: server }.compact req.url "#{@request_client.get_url(request_options: )}/tool/#{id}" end Vapi::Tools::ToolsUpdateResponse.from_json(json_object: response.body) end end |