Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:Enhance Ultravox OpenAPI with Pagination and Error Tracking Improvements #16

Merged
merged 1 commit into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#nullable enable

namespace Ultravox.JsonConverters
{
/// <inheritdoc />
public sealed class UltravoxV1MessageMediumJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Ultravox.UltravoxV1MessageMedium>
{
/// <inheritdoc />
public override global::Ultravox.UltravoxV1MessageMedium Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
{
switch (reader.TokenType)
{
case global::System.Text.Json.JsonTokenType.String:
{
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::Ultravox.UltravoxV1MessageMediumExtensions.ToEnum(stringValue) ?? default;
}

break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::Ultravox.UltravoxV1MessageMedium)numValue;
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
}

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::Ultravox.UltravoxV1MessageMedium value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));

writer.WriteStringValue(global::Ultravox.UltravoxV1MessageMediumExtensions.ToValueString(value));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#nullable enable

namespace Ultravox.JsonConverters
{
/// <inheritdoc />
public sealed class UltravoxV1MessageMediumNullableJsonConverter : global::System.Text.Json.Serialization.JsonConverter<global::Ultravox.UltravoxV1MessageMedium?>
{
/// <inheritdoc />
public override global::Ultravox.UltravoxV1MessageMedium? Read(
ref global::System.Text.Json.Utf8JsonReader reader,
global::System.Type typeToConvert,
global::System.Text.Json.JsonSerializerOptions options)
{
switch (reader.TokenType)
{
case global::System.Text.Json.JsonTokenType.String:
{
var stringValue = reader.GetString();
if (stringValue != null)
{
return global::Ultravox.UltravoxV1MessageMediumExtensions.ToEnum(stringValue);
}

break;
}
case global::System.Text.Json.JsonTokenType.Number:
{
var numValue = reader.GetInt32();
return (global::Ultravox.UltravoxV1MessageMedium)numValue;
}
default:
throw new global::System.ArgumentOutOfRangeException(nameof(reader));
}

return default;
}

/// <inheritdoc />
public override void Write(
global::System.Text.Json.Utf8JsonWriter writer,
global::Ultravox.UltravoxV1MessageMedium? value,
global::System.Text.Json.JsonSerializerOptions options)
{
writer = writer ?? throw new global::System.ArgumentNullException(nameof(writer));

if (value == null)
{
writer.WriteNullValue();
}
else
{
writer.WriteStringValue(global::Ultravox.UltravoxV1MessageMediumExtensions.ToValueString(value.Value));
}
}
}
}
2 changes: 2 additions & 0 deletions src/libs/Ultravox/Generated/JsonSerializerContext.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ namespace Ultravox
typeof(global::Ultravox.JsonConverters.EventsEnumNullableJsonConverter),
typeof(global::Ultravox.JsonConverters.UltravoxV1MessageRoleJsonConverter),
typeof(global::Ultravox.JsonConverters.UltravoxV1MessageRoleNullableJsonConverter),
typeof(global::Ultravox.JsonConverters.UltravoxV1MessageMediumJsonConverter),
typeof(global::Ultravox.JsonConverters.UltravoxV1MessageMediumNullableJsonConverter),
typeof(global::Ultravox.JsonConverters.UltravoxV1StartCallRequestInitiatorJsonConverter),
typeof(global::Ultravox.JsonConverters.UltravoxV1StartCallRequestInitiatorNullableJsonConverter),
typeof(global::Ultravox.JsonConverters.UltravoxV1StartCallRequestFirstSpeakerJsonConverter),
Expand Down
38 changes: 21 additions & 17 deletions src/libs/Ultravox/Generated/JsonSerializerContextTypes.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,70 +302,74 @@ public sealed partial class JsonSerializerContextTypes
/// <summary>
///
/// </summary>
public global::Ultravox.PatchedAPIKey? Type71 { get; set; }
public global::Ultravox.UltravoxV1MessageMedium? Type71 { get; set; }
/// <summary>
///
/// </summary>
public global::Ultravox.PatchedWebhook? Type72 { get; set; }
public global::Ultravox.PatchedAPIKey? Type72 { get; set; }
/// <summary>
///
/// </summary>
public global::Ultravox.UltravoxV1SelectedTool? Type73 { get; set; }
public global::Ultravox.PatchedWebhook? Type73 { get; set; }
/// <summary>
///
/// </summary>
public global::System.Collections.Generic.Dictionary<string, string>? Type74 { get; set; }
public global::Ultravox.UltravoxV1SelectedTool? Type74 { get; set; }
/// <summary>
///
/// </summary>
public global::Ultravox.UltravoxV1StartCallRequest? Type75 { get; set; }
public global::System.Collections.Generic.Dictionary<string, string>? Type75 { get; set; }
/// <summary>
///
/// </summary>
public float? Type76 { get; set; }
public global::Ultravox.UltravoxV1StartCallRequest? Type76 { get; set; }
/// <summary>
///
/// </summary>
public global::System.Collections.Generic.IList<global::Ultravox.UltravoxV1SelectedTool>? Type77 { get; set; }
public float? Type77 { get; set; }
/// <summary>
///
/// </summary>
public global::Ultravox.UltravoxV1StartCallRequestInitiator? Type78 { get; set; }
public global::System.Collections.Generic.IList<global::Ultravox.UltravoxV1SelectedTool>? Type78 { get; set; }
/// <summary>
///
/// </summary>
public global::Ultravox.UltravoxV1StartCallRequestFirstSpeaker? Type79 { get; set; }
public global::Ultravox.UltravoxV1StartCallRequestInitiator? Type79 { get; set; }
/// <summary>
///
/// </summary>
public global::Ultravox.UltravoxV1StartCallRequestInitialOutputMedium? Type80 { get; set; }
public global::Ultravox.UltravoxV1StartCallRequestFirstSpeaker? Type80 { get; set; }
/// <summary>
///
/// </summary>
public global::Ultravox.ToolsCreateRequest? Type81 { get; set; }
public global::Ultravox.UltravoxV1StartCallRequestInitialOutputMedium? Type81 { get; set; }
/// <summary>
///
/// </summary>
public byte[]? Type82 { get; set; }
public global::Ultravox.ToolsCreateRequest? Type82 { get; set; }
/// <summary>
///
/// </summary>
public global::Ultravox.VoicesCreateRequest? Type83 { get; set; }
public byte[]? Type83 { get; set; }
/// <summary>
///
/// </summary>
public global::Ultravox.SchemaRetrieveFormat? Type84 { get; set; }
public global::Ultravox.VoicesCreateRequest? Type84 { get; set; }
/// <summary>
///
/// </summary>
public global::Ultravox.SchemaRetrieveLang? Type85 { get; set; }
public global::Ultravox.SchemaRetrieveFormat? Type85 { get; set; }
/// <summary>
///
/// </summary>
public global::System.Collections.Generic.IList<global::Ultravox.Account>? Type86 { get; set; }
public global::Ultravox.SchemaRetrieveLang? Type86 { get; set; }
/// <summary>
///
/// </summary>
public global::System.Collections.Generic.IList<global::Ultravox.CallTool>? Type87 { get; set; }
public global::System.Collections.Generic.IList<global::Ultravox.Account>? Type87 { get; set; }
/// <summary>
///
/// </summary>
public global::System.Collections.Generic.IList<global::Ultravox.CallTool>? Type88 { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ public partial class ApiKeysClient
{
partial void PrepareApiKeysListArguments(
global::System.Net.Http.HttpClient httpClient,
ref string? cursor);
ref string? cursor,
ref int? pageSize);
partial void PrepareApiKeysListRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
string? cursor);
string? cursor,
int? pageSize);
partial void ProcessApiKeysListResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);
Expand All @@ -25,23 +27,27 @@ partial void ProcessApiKeysListResponseContent(
/// Gets the current user's API keys.
/// </summary>
/// <param name="cursor"></param>
/// <param name="pageSize"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::Ultravox.ApiException"></exception>
public async global::System.Threading.Tasks.Task<global::Ultravox.PaginatedAPIKeyList> ApiKeysListAsync(
string? cursor = default,
int? pageSize = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
client: HttpClient);
PrepareApiKeysListArguments(
httpClient: HttpClient,
cursor: ref cursor);
cursor: ref cursor,
pageSize: ref pageSize);

var __pathBuilder = new PathBuilder(
path: "/api/api_keys",
baseUri: HttpClient.BaseAddress);
__pathBuilder
.AddOptionalParameter("cursor", cursor)
.AddOptionalParameter("pageSize", pageSize?.ToString())
;
var __path = __pathBuilder.ToString();
using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
Expand Down Expand Up @@ -74,7 +80,8 @@ partial void ProcessApiKeysListResponseContent(
PrepareApiKeysListRequest(
httpClient: HttpClient,
httpRequestMessage: __httpRequest,
cursor: cursor);
cursor: cursor,
pageSize: pageSize);

using var __response = await HttpClient.SendAsync(
request: __httpRequest,
Expand Down
15 changes: 11 additions & 4 deletions src/libs/Ultravox/Generated/Ultravox.CallsClient.CallsList.g.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ public partial class CallsClient
{
partial void PrepareCallsListArguments(
global::System.Net.Http.HttpClient httpClient,
ref string? cursor);
ref string? cursor,
ref int? pageSize);
partial void PrepareCallsListRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
string? cursor);
string? cursor,
int? pageSize);
partial void ProcessCallsListResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);
Expand All @@ -25,23 +27,27 @@ partial void ProcessCallsListResponseContent(
///
/// </summary>
/// <param name="cursor"></param>
/// <param name="pageSize"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::Ultravox.ApiException"></exception>
public async global::System.Threading.Tasks.Task<global::Ultravox.PaginatedCallList> CallsListAsync(
string? cursor = default,
int? pageSize = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
client: HttpClient);
PrepareCallsListArguments(
httpClient: HttpClient,
cursor: ref cursor);
cursor: ref cursor,
pageSize: ref pageSize);

var __pathBuilder = new PathBuilder(
path: "/api/calls",
baseUri: HttpClient.BaseAddress);
__pathBuilder
.AddOptionalParameter("cursor", cursor)
.AddOptionalParameter("pageSize", pageSize?.ToString())
;
var __path = __pathBuilder.ToString();
using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
Expand Down Expand Up @@ -74,7 +80,8 @@ partial void ProcessCallsListResponseContent(
PrepareCallsListRequest(
httpClient: HttpClient,
httpRequestMessage: __httpRequest,
cursor: cursor);
cursor: cursor,
pageSize: pageSize);

using var __response = await HttpClient.SendAsync(
request: __httpRequest,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ public partial class CallsClient
partial void PrepareCallsMessagesListArguments(
global::System.Net.Http.HttpClient httpClient,
ref global::System.Guid callId,
ref string? cursor);
ref string? cursor,
ref int? pageSize);
partial void PrepareCallsMessagesListRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
global::System.Guid callId,
string? cursor);
string? cursor,
int? pageSize);
partial void ProcessCallsMessagesListResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);
Expand All @@ -28,25 +30,29 @@ partial void ProcessCallsMessagesListResponseContent(
/// </summary>
/// <param name="callId"></param>
/// <param name="cursor"></param>
/// <param name="pageSize"></param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::Ultravox.ApiException"></exception>
public async global::System.Threading.Tasks.Task<global::Ultravox.PaginatedultravoxV1MessageList> CallsMessagesListAsync(
global::System.Guid callId,
string? cursor = default,
int? pageSize = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
PrepareArguments(
client: HttpClient);
PrepareCallsMessagesListArguments(
httpClient: HttpClient,
callId: ref callId,
cursor: ref cursor);
cursor: ref cursor,
pageSize: ref pageSize);

var __pathBuilder = new PathBuilder(
path: $"/api/calls/{callId}/messages",
baseUri: HttpClient.BaseAddress);
__pathBuilder
.AddOptionalParameter("cursor", cursor)
.AddOptionalParameter("pageSize", pageSize?.ToString())
;
var __path = __pathBuilder.ToString();
using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
Expand Down Expand Up @@ -80,7 +86,8 @@ partial void ProcessCallsMessagesListResponseContent(
httpClient: HttpClient,
httpRequestMessage: __httpRequest,
callId: callId,
cursor: cursor);
cursor: cursor,
pageSize: pageSize);

using var __response = await HttpClient.SendAsync(
request: __httpRequest,
Expand Down
Loading
Loading