-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba2a065
commit 93db068
Showing
109 changed files
with
1,958 additions
and
701 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -475,6 +475,3 @@ $RECYCLE.BIN/ | |
|
||
# Windows shortcuts | ||
*.lnk | ||
|
||
.idea | ||
.runsettings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.5.0"/> | ||
<PackageReference Include="NUnit" Version="3.13.3"/> | ||
<PackageReference Include="NUnit3TestAdapter" Version="4.4.2"/> | ||
<PackageReference Include="NUnit.Analyzers" Version="3.6.1"/> | ||
<PackageReference Include="coverlet.collector" Version="3.2.0"/> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\AssemblyAI\AssemblyAI.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using NUnit.Framework; | ||
|
||
#nullable enable | ||
|
||
namespace AssemblyAI.Test; | ||
|
||
[TestFixture] | ||
public class TestClient { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using AssemblyAI.Core; | ||
|
||
#nullable enable | ||
|
||
namespace AssemblyAI.Core; | ||
|
||
/// <summary> | ||
/// This exception type will be thrown for any non-2XX API responses. | ||
/// </summary> | ||
public class AssemblyAIClientApiException(string message, int statusCode, object body) | ||
: AssemblyAIClientException(message) | ||
{ | ||
/// <summary> | ||
/// The error code of the response that triggered the exception. | ||
/// </summary> | ||
public int StatusCode { get; } = statusCode; | ||
|
||
/// <summary> | ||
/// The body of the response that triggered the exception. | ||
/// </summary> | ||
public object Body { get; } = body; | ||
|
||
public override string ToString() | ||
{ | ||
return $"AssemblyAIClientApiException {{ message: {Message}, statusCode: {StatusCode}, body: {Body} }}"; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
src/AssemblyAI/Core/Environments.cs → ...blyAI/Core/AssemblyAIClientEnvironment.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
namespace AssemblyAI.Core; | ||
|
||
public class Environments | ||
public class AssemblyAIClientEnvironment | ||
{ | ||
public static string DEFAULT = "https://api.assemblyai.com"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
|
||
#nullable enable | ||
|
||
namespace AssemblyAI.Core; | ||
|
||
/// <summary> | ||
/// Base exception class for all exceptions thrown by the SDK. | ||
/// </summary> | ||
public class AssemblyAIClientException(string message, Exception? innerException = null) | ||
: Exception(message, innerException) { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System; | ||
using System.Net.Http; | ||
using AssemblyAI.Core; | ||
|
||
#nullable enable | ||
|
||
namespace AssemblyAI.Core; | ||
|
||
public partial class ClientOptions | ||
{ | ||
/// <summary> | ||
/// The Base URL for the API. | ||
/// </summary> | ||
public string BaseUrl { get; init; } = AssemblyAIClientEnvironment.DEFAULT; | ||
|
||
/// <summary> | ||
/// The http client used to make requests. | ||
/// </summary> | ||
public HttpClient HttpClient { get; init; } = new HttpClient(); | ||
|
||
/// <summary> | ||
/// The http client used to make requests. | ||
/// </summary> | ||
public int MaxRetries { get; init; } = 2; | ||
|
||
/// <summary> | ||
/// The timeout for the request. | ||
/// </summary> | ||
public TimeSpan Timeout { get; init; } = TimeSpan.FromSeconds(30); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
namespace AssemblyAI.Core; | ||
|
||
internal static class Constants | ||
public static class Constants | ||
{ | ||
internal const string Version = "0.0.2-alpha"; | ||
} | ||
public const string DateTimeFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.fffK"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using System.Globalization; | ||
using System.Text.Json; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace AssemblyAI.Core; | ||
|
||
public class DateTimeSerializer : JsonConverter<DateTime> | ||
{ | ||
public override DateTime Read( | ||
ref Utf8JsonReader reader, | ||
System.Type typeToConvert, | ||
JsonSerializerOptions options | ||
) | ||
{ | ||
return DateTime.Parse(reader.GetString()!, null, DateTimeStyles.RoundtripKind); | ||
} | ||
|
||
public override void Write(Utf8JsonWriter writer, DateTime value, JsonSerializerOptions options) | ||
{ | ||
writer.WriteStringValue(value.ToString(Constants.DateTimeFormat)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.Text.Json; | ||
|
||
namespace AssemblyAI.Core; | ||
|
||
public static class JsonOptions | ||
{ | ||
public static readonly JsonSerializerOptions JsonSerializerOptions; | ||
|
||
static JsonOptions() | ||
{ | ||
JsonSerializerOptions = new JsonSerializerOptions | ||
{ | ||
Converters = { new DateTimeSerializer() }, | ||
WriteIndented = true | ||
}; | ||
} | ||
} | ||
|
||
public static class JsonUtils | ||
{ | ||
public static string Serialize<T>(T obj) | ||
{ | ||
return JsonSerializer.Serialize(obj, JsonOptions.JsonSerializerOptions); | ||
} | ||
|
||
public static T Deserialize<T>(string json) | ||
{ | ||
return JsonSerializer.Deserialize<T>(json, JsonOptions.JsonSerializerOptions)!; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.