Class: Vapi::ToolsClient
- Inherits:
-
Object
- Object
- Vapi::ToolsClient
- 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::ToolsClient 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::ToolsClient
24 25 26 |
# File 'lib/vapi_server_sdk/tools/client.rb', line 24 def initialize(request_client:) @request_client = request_client end |
Instance Attribute Details
#request_client ⇒ Vapi::RequestClient (readonly)
20 21 22 |
# File 'lib/vapi_server_sdk/tools/client.rb', line 20 def request_client @request_client end |
Instance Method Details
#create(request:, request_options: nil) ⇒ Vapi::Tools::ToolsCreateResponse
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/vapi_server_sdk/tools/client.rb', line 94 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: )}/tool" end Vapi::Tools::ToolsCreateResponse.from_json(json_object: response.body) end |
#delete(id:, request_options: nil) ⇒ Vapi::Tools::ToolsDeleteResponse
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/vapi_server_sdk/tools/client.rb', line 152 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: )}/tool/#{id}" end Vapi::Tools::ToolsDeleteResponse.from_json(json_object: response.body) end |
#get(id:, request_options: nil) ⇒ Vapi::Tools::ToolsGetResponse
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/vapi_server_sdk/tools/client.rb', line 122 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: )}/tool/#{id}" end Vapi::Tools::ToolsGetResponse.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::Tools::ToolsListResponseItem>
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 82 |
# File 'lib/vapi_server_sdk/tools/client.rb', line 50 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: )}/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 |
#update(id:, async: nil, messages: nil, function: nil, server: nil, request_options: nil) ⇒ Vapi::Tools::ToolsUpdateResponse
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 |
# File 'lib/vapi_server_sdk/tools/client.rb', line 216 def update(id:, async: nil, messages: nil, function: nil, server: 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 || {}), 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 |