Class: Vapi::BlocksClient
- Inherits:
-
Object
- Object
- Vapi::BlocksClient
- 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::BlocksClient 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::BlocksClient
25 26 27 |
# File 'lib/vapi_server_sdk/blocks/client.rb', line 25 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Vapi::RequestClient (readonly)
21 22 23 |
# File 'lib/vapi_server_sdk/blocks/client.rb', line 21 def request_client @request_client end |
Instance Method Details
#create(request:, request_options: nil) ⇒ Vapi::Blocks::BlocksCreateResponse
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/vapi_server_sdk/blocks/client.rb', line 95 def create(request:, 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 = { **(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 |
#delete(id:, request_options: nil) ⇒ Vapi::Blocks::BlocksDeleteResponse
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 |
# File 'lib/vapi_server_sdk/blocks/client.rb', line 153 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: )}/block/#{id}" end Vapi::Blocks::BlocksDeleteResponse.from_json(json_object: response.body) end |
#get(id:, request_options: nil) ⇒ Vapi::Blocks::BlocksGetResponse
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
# File 'lib/vapi_server_sdk/blocks/client.rb', line 123 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: )}/block/#{id}" end Vapi::Blocks::BlocksGetResponse.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::Blocks::BlocksListResponseItem>
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 82 83 |
# File 'lib/vapi_server_sdk/blocks/client.rb', line 51 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..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 |
#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
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 |
# File 'lib/vapi_server_sdk/blocks/client.rb', line 251 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) 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 |