Class: Vapi::AsyncBlocksClient
- Inherits:
-
Object
- Object
- Vapi::AsyncBlocksClient
- Defined in:
- lib/vapi_server_sdk/blocks/client.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
- #create(request:, request_options: nil) ⇒ Vapi::Blocks::BlocksCreateResponse
- #delete(id:, request_options: nil) ⇒ Vapi::Blocks::BlocksDeleteResponse
- #get(id:, request_options: nil) ⇒ Vapi::Blocks::BlocksGetResponse
- #initialize(request_client:) ⇒ Vapi::AsyncBlocksClient 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::Blocks::BlocksListResponseItem>
- #update(id:, messages: nil, input_schema: nil, output_schema: nil, tool: nil, steps: nil, name: nil, instruction: nil, tool_id: nil, request_options: nil) ⇒ Vapi::Blocks::BlocksUpdateResponse
Constructor Details
#initialize(request_client:) ⇒ Vapi::AsyncBlocksClient
287 288 289 |
# File 'lib/vapi_server_sdk/blocks/client.rb', line 287 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Vapi::AsyncRequestClient (readonly)
283 284 285 |
# File 'lib/vapi_server_sdk/blocks/client.rb', line 283 def request_client @request_client end |
Instance Method Details
#create(request:, request_options: nil) ⇒ Vapi::Blocks::BlocksCreateResponse
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 |
# File 'lib/vapi_server_sdk/blocks/client.rb', line 359 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: )}/block" end Vapi::Blocks::BlocksCreateResponse.from_json(json_object: response.body) end end |
#delete(id:, request_options: nil) ⇒ Vapi::Blocks::BlocksDeleteResponse
421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 |
# File 'lib/vapi_server_sdk/blocks/client.rb', line 421 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: )}/block/#{id}" end Vapi::Blocks::BlocksDeleteResponse.from_json(json_object: response.body) end end |
#get(id:, request_options: nil) ⇒ Vapi::Blocks::BlocksGetResponse
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 |
# File 'lib/vapi_server_sdk/blocks/client.rb', line 389 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: )}/block/#{id}" end Vapi::Blocks::BlocksGetResponse.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::Blocks::BlocksListResponseItem>
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 |
# File 'lib/vapi_server_sdk/blocks/client.rb', line 313 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: )}/block" end parsed_json = JSON.parse(response.body) parsed_json&.map do |item| item = item.to_json Vapi::Blocks::BlocksListResponseItem.from_json(json_object: item) end end end |
#update(id:, messages: nil, input_schema: nil, output_schema: nil, tool: nil, steps: nil, name: nil, instruction: nil, tool_id: nil, request_options: nil) ⇒ Vapi::Blocks::BlocksUpdateResponse
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 |
# File 'lib/vapi_server_sdk/blocks/client.rb', line 521 def update(id:, messages: nil, input_schema: nil, output_schema: nil, tool: nil, steps: nil, name: nil, instruction: nil, tool_id: 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 || {}), messages: , inputSchema: input_schema, outputSchema: output_schema, tool: tool, steps: steps, name: name, instruction: instruction, toolId: tool_id }.compact req.url "#{@request_client.get_url(request_options: )}/block/#{id}" end Vapi::Blocks::BlocksUpdateResponse.from_json(json_object: response.body) end end |