Skip to content
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
Expand Up @@ -51,8 +51,10 @@ namespace Ultravox
typeof(global::Ultravox.JsonConverters.InvoiceStatusEnumNullableJsonConverter),
typeof(global::Ultravox.JsonConverters.OwnershipEnumJsonConverter),
typeof(global::Ultravox.JsonConverters.OwnershipEnumNullableJsonConverter),
typeof(global::Ultravox.JsonConverters.StatusEnumJsonConverter),
typeof(global::Ultravox.JsonConverters.StatusEnumNullableJsonConverter),
typeof(global::Ultravox.JsonConverters.ScheduledCallStatusEnumJsonConverter),
typeof(global::Ultravox.JsonConverters.ScheduledCallStatusEnumNullableJsonConverter),
typeof(global::Ultravox.JsonConverters.WebhookStatusEnumJsonConverter),
typeof(global::Ultravox.JsonConverters.WebhookStatusEnumNullableJsonConverter),
typeof(global::Ultravox.JsonConverters.UltravoxV1CorpusStatsStatusJsonConverter),
typeof(global::Ultravox.JsonConverters.UltravoxV1CorpusStatsStatusNullableJsonConverter),
typeof(global::Ultravox.JsonConverters.UltravoxV1SourceStatsStatusJsonConverter),
Expand All @@ -67,6 +69,8 @@ namespace Ultravox
typeof(global::Ultravox.JsonConverters.UltravoxV1StartCallRequestFirstSpeakerNullableJsonConverter),
typeof(global::Ultravox.JsonConverters.UltravoxV1StartCallRequestInitialOutputMediumJsonConverter),
typeof(global::Ultravox.JsonConverters.UltravoxV1StartCallRequestInitialOutputMediumNullableJsonConverter),
typeof(global::Ultravox.JsonConverters.AgentsScheduledBatchesScheduledCallsListStatusJsonConverter),
typeof(global::Ultravox.JsonConverters.AgentsScheduledBatchesScheduledCallsListStatusNullableJsonConverter),
typeof(global::Ultravox.JsonConverters.CallsEventsListMinimumSeverityJsonConverter),
typeof(global::Ultravox.JsonConverters.CallsEventsListMinimumSeverityNullableJsonConverter),
typeof(global::Ultravox.JsonConverters.CallsMessagesListModeJsonConverter),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@

#nullable enable

namespace Ultravox
{
public partial class AgentsClient
{
partial void PrepareAgentsScheduledBatchesCreateArguments(
global::System.Net.Http.HttpClient httpClient,
ref global::System.Guid agentId,
global::Ultravox.ScheduledCallBatch request);
partial void PrepareAgentsScheduledBatchesCreateRequest(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
global::System.Guid agentId,
global::Ultravox.ScheduledCallBatch request);
partial void ProcessAgentsScheduledBatchesCreateResponse(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage);

partial void ProcessAgentsScheduledBatchesCreateResponseContent(
global::System.Net.Http.HttpClient httpClient,
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
ref string content);

/// <summary>
///
/// </summary>
/// <param name="agentId"></param>
/// <param name="request"></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.ScheduledCallBatch> AgentsScheduledBatchesCreateAsync(
global::System.Guid agentId,
global::Ultravox.ScheduledCallBatch request,
global::System.Threading.CancellationToken cancellationToken = default)
{
request = request ?? throw new global::System.ArgumentNullException(nameof(request));

PrepareArguments(
client: HttpClient);
PrepareAgentsScheduledBatchesCreateArguments(
httpClient: HttpClient,
agentId: ref agentId,
request: request);

var __pathBuilder = new global::Ultravox.PathBuilder(
path: $"/api/agents/{agentId}/scheduled_batches",
baseUri: HttpClient.BaseAddress);
var __path = __pathBuilder.ToString();
using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
method: global::System.Net.Http.HttpMethod.Post,
requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
#if NET6_0_OR_GREATER
__httpRequest.Version = global::System.Net.HttpVersion.Version11;
__httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
#endif

foreach (var __authorization in Authorizations)
{
if (__authorization.Type == "Http" ||
__authorization.Type == "OAuth2")
{
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
scheme: __authorization.Name,
parameter: __authorization.Value);
}
else if (__authorization.Type == "ApiKey" &&
__authorization.Location == "Header")
{
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
}
}
var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
var __httpRequestContent = new global::System.Net.Http.StringContent(
content: __httpRequestContentBody,
encoding: global::System.Text.Encoding.UTF8,
mediaType: "application/json");
__httpRequest.Content = __httpRequestContent;

PrepareRequest(
client: HttpClient,
request: __httpRequest);
PrepareAgentsScheduledBatchesCreateRequest(
httpClient: HttpClient,
httpRequestMessage: __httpRequest,
agentId: agentId,
request: request);

using var __response = await HttpClient.SendAsync(
request: __httpRequest,
completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
cancellationToken: cancellationToken).ConfigureAwait(false);

ProcessResponse(
client: HttpClient,
response: __response);
ProcessAgentsScheduledBatchesCreateResponse(
httpClient: HttpClient,
httpResponseMessage: __response);

if (ReadResponseAsString)
{
var __content = await __response.Content.ReadAsStringAsync(
#if NET5_0_OR_GREATER
cancellationToken
#endif
).ConfigureAwait(false);

ProcessResponseContent(
client: HttpClient,
response: __response,
content: ref __content);
ProcessAgentsScheduledBatchesCreateResponseContent(
httpClient: HttpClient,
httpResponseMessage: __response,
content: ref __content);

try
{
__response.EnsureSuccessStatusCode();

return
global::Ultravox.ScheduledCallBatch.FromJson(__content, JsonSerializerContext) ??
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
}
catch (global::System.Exception __ex)
{
throw new global::Ultravox.ApiException(
message: __content ?? __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
statusCode: __response.StatusCode)
{
ResponseBody = __content,
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
h => h.Value),
};
}
}
else
{
try
{
__response.EnsureSuccessStatusCode();

using var __content = await __response.Content.ReadAsStreamAsync(
#if NET5_0_OR_GREATER
cancellationToken
#endif
).ConfigureAwait(false);

return
await global::Ultravox.ScheduledCallBatch.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
throw new global::System.InvalidOperationException("Response deserialization failed.");
}
catch (global::System.Exception __ex)
{
throw new global::Ultravox.ApiException(
message: __response.ReasonPhrase ?? string.Empty,
innerException: __ex,
statusCode: __response.StatusCode)
{
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
__response.Headers,
h => h.Key,
h => h.Value),
};
}
}
}

/// <summary>
///
/// </summary>
/// <param name="agentId"></param>
/// <param name="windowStart">
/// The start of the time window during which calls can be made.
/// </param>
/// <param name="windowEnd">
/// The end of the time window during which calls can be made.
/// </param>
/// <param name="webhookUrl">
/// The URL to which a request will be made (synchronously) when a call in the batch is created, excluding those with an outgoing sip medium. Required if any call has a medium other than outgoing sip.
/// </param>
/// <param name="webhookSecret">
/// The signing secret for requests made to the webhookUrl. This is used to verify that the request came from Ultravox. If unset, an appropriate secret will be chosen for you (but you'll still need to make your endpoint aware of it to verify requests).
/// </param>
/// <param name="paused"></param>
/// <param name="calls">
/// Included only in requests
/// </param>
/// <param name="cancellationToken">The token to cancel the operation with</param>
/// <exception cref="global::System.InvalidOperationException"></exception>
public async global::System.Threading.Tasks.Task<global::Ultravox.ScheduledCallBatch> AgentsScheduledBatchesCreateAsync(
global::System.Guid agentId,
global::System.Collections.Generic.IList<global::Ultravox.ScheduledCall> calls,
global::System.DateTime? windowStart = default,
global::System.DateTime? windowEnd = default,
string? webhookUrl = default,
string? webhookSecret = default,
bool? paused = default,
global::System.Threading.CancellationToken cancellationToken = default)
{
var __request = new global::Ultravox.ScheduledCallBatch
{
WindowStart = windowStart,
WindowEnd = windowEnd,
WebhookUrl = webhookUrl,
WebhookSecret = webhookSecret,
Paused = paused,
Calls = calls,
};

return await AgentsScheduledBatchesCreateAsync(
agentId: agentId,
request: __request,
cancellationToken: cancellationToken).ConfigureAwait(false);
}
}
}
Loading