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

Fix Update ClientOptions Based on HTTP and WS #265

Merged
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 @@ -18,7 +18,10 @@ public class AbstractRestfulClientTests
public void Setup()
{
_apiKey = new Faker().Random.Guid().ToString();
_clientOptions = new DeepgramHttpClientOptions(_apiKey, null, null, true);
_clientOptions = new DeepgramHttpClientOptions(_apiKey)
{
OnPrem = true,
};
}

[Test]
Expand Down
5 changes: 4 additions & 1 deletion Deepgram.Tests/UnitTests/ClientTests/AnalyzeClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ public class AnalyzeClientTests
public void Setup()
{
_apiKey = new Faker().Random.Guid().ToString();
_options = new DeepgramHttpClientOptions(_apiKey, null, null, true);
_options = new DeepgramHttpClientOptions(_apiKey)
{
OnPrem = true,
};
}

[Test]
Expand Down
5 changes: 4 additions & 1 deletion Deepgram.Tests/UnitTests/ClientTests/ManageClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ public class ManageClientTest
public void Setup()
{
_apiKey = new Faker().Random.Guid().ToString();
_options = new DeepgramHttpClientOptions(_apiKey, null, null, true);
_options = new DeepgramHttpClientOptions(_apiKey)
{
OnPrem = true,
};
_projectId = new Faker().Random.Guid().ToString();
}

Expand Down
5 changes: 4 additions & 1 deletion Deepgram.Tests/UnitTests/ClientTests/OnPremClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ public class OnPremClientTests
public void Setup()
{
_apiKey = new Faker().Random.Guid().ToString();
_options = new DeepgramHttpClientOptions(_apiKey, null, null, true);
_options = new DeepgramHttpClientOptions(_apiKey)
{
OnPrem = true,
};
_projectId = new Faker().Random.Guid().ToString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ public class PreRecordedClientTests
public void Setup()
{
_apiKey = new Faker().Random.Guid().ToString();
_options = new DeepgramHttpClientOptions(_apiKey, null, null, true);
_options = new DeepgramHttpClientOptions(_apiKey)
{
OnPrem = true,
};
}

[Test]
Expand Down
5 changes: 4 additions & 1 deletion Deepgram.Tests/UnitTests/ClientTests/SpeakClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ public class SpeakClientTests
public void Setup()
{
_apiKey = new Faker().Random.Guid().ToString();
_options = new DeepgramHttpClientOptions(_apiKey, null, null, true);
_options = new DeepgramHttpClientOptions(_apiKey)
{
OnPrem = true,
};
}

//[Test]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void Should_Return_HttpClient_With_Default_BaseAddress_And_Custom_Headers
{
// Input and Output
var _apiKey = new Faker().Random.Guid().ToString();
var _clientOptions = new DeepgramHttpClientOptions(_apiKey, null, null, null, FakeHeaders());
var _clientOptions = new DeepgramHttpClientOptions(_apiKey, null, null, FakeHeaders());

// Fake Clients
var httpClient = MockHttpClient.CreateHttpClientWithResult(new MessageResponse(), HttpStatusCode.OK);
Expand All @@ -95,7 +95,7 @@ public void Should_Return_HttpClient_With_Custom_BaseAddress_And_Custom_Headers(
var expectedBaseAddress = $"https://{_customUrl}/v1";
var customBaseAddress = $"https://{_customUrl}";
var _apiKey = new Faker().Random.Guid().ToString();
var _clientOptions = new DeepgramHttpClientOptions(_apiKey, customBaseAddress, null, null, FakeHeaders());
var _clientOptions = new DeepgramHttpClientOptions(_apiKey, customBaseAddress, null, FakeHeaders());

// Fake Clients
var httpClient = MockHttpClient.CreateHttpClientWithResult(new MessageResponse(), HttpStatusCode.OK);
Expand All @@ -122,7 +122,7 @@ public void Should_Return_HttpClient_With_Predefined_Values()
var expectedBaseAddress = $"https://{_customUrl}/v1";
var customBaseAddress = $"https://{_customUrl}";
var _apiKey = new Faker().Random.Guid().ToString();
var _clientOptions = new DeepgramHttpClientOptions(_apiKey, customBaseAddress, null, null, FakeHeaders());
var _clientOptions = new DeepgramHttpClientOptions(_apiKey, customBaseAddress, null, FakeHeaders());

// Fake Clients
var httpClient = MockHttpClient.CreateHttpClientWithResult(new MessageResponse(), HttpStatusCode.OK, expectedBaseAddress);
Expand Down
1 change: 0 additions & 1 deletion Deepgram/Abstractions/AbstractRestClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ internal AbstractRestClient(string? apiKey = null, DeepgramHttpClientOptions? op

Log.Debug("AbstractRestClient", $"APIVersion: {options.APIVersion}");
Log.Debug("AbstractRestClient", $"BaseAddress: {options.BaseAddress}");
Log.Debug("AbstractRestClient", $"KeepAlive: {options.KeepAlive}");
Log.Debug("AbstractRestClient", $"options: {options.OnPrem}");
Log.Verbose("AbstractRestClient", "LEAVE");
}
Expand Down
19 changes: 5 additions & 14 deletions Deepgram/Models/Authenticate/v1/DeepgramHttpClientOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,6 @@ public class DeepgramHttpClientOptions
// Prerecorded
/*****************************/

/*****************************/
// Live
/*****************************/
/// <summary>
/// Enable sending KeepAlives for Streaming
/// </summary>
public bool KeepAlive { get; set; } = false;

/*****************************/
// OnPrem
/*****************************/
Expand All @@ -61,27 +53,26 @@ public class DeepgramHttpClientOptions
// Analyze
/*****************************/

/*****************************/
// Speak
/*****************************/

/*****************************/
// Constructor
/*****************************/
public DeepgramHttpClientOptions(string? apiKey = null, string? baseAddress = null, bool? keepAlive = null, bool? onPrem = null, Dictionary<string, string>? headers = null, string? apiVersion = null)
public DeepgramHttpClientOptions(string? apiKey = null, string? baseAddress = null, bool? onPrem = null, Dictionary<string, string>? headers = null)
{
Log.Verbose("DeepgramHttpClientOptions", "ENTER");
Log.Debug("DeepgramHttpClientOptions", apiKey == null ? "API KEY is null" : "API KEY provided");
Log.Debug("DeepgramHttpClientOptions", baseAddress == null ? "BaseAddress is null" : "BaseAddress provided");
Log.Debug("DeepgramHttpClientOptions", keepAlive == null ? "KeepAlive is null" : "KeepAlive provided");
Log.Debug("DeepgramHttpClientOptions", onPrem == null ? "OnPrem is null" : "OnPrem provided");
Log.Debug("DeepgramHttpClientOptions", headers == null ? "Headers is null" : "Headers provided");
Log.Debug("DeepgramHttpClientOptions", apiVersion == null ? "API Version is null" : "API Version provided");

ApiKey = apiKey ?? "";
BaseAddress = baseAddress ?? Defaults.DEFAULT_URI;
KeepAlive = keepAlive ?? false;
OnPrem = onPrem ?? false;
Headers = headers ?? new Dictionary<string, string>();
APIVersion = apiVersion ?? Defaults.DEFAULT_API_VERSION;

Log.Information("DeepgramHttpClientOptions", $"KeepAlive: {KeepAlive}");
Log.Information("DeepgramHttpClientOptions", $"OnPrem: {OnPrem}");
Log.Information("DeepgramHttpClientOptions", $"APIVersion: {APIVersion}");

Expand Down
14 changes: 2 additions & 12 deletions Deepgram/Models/Authenticate/v1/DeepgramWsClientOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ public class DeepgramWsClientOptions
/// </summary>
public Dictionary<string, string> Headers { get; set; }

/*****************************/
// Prerecorded
/*****************************/

/*****************************/
// Live
/*****************************/
Expand All @@ -54,32 +50,26 @@ public class DeepgramWsClientOptions
public bool OnPrem { get; set; } = false;

/*****************************/
// Manage
/*****************************/

/*****************************/
// Analyze
// Speak
/*****************************/

/*****************************/
// Constructor
/*****************************/
public DeepgramWsClientOptions(string? apiKey = null, string? baseAddress = null, bool? keepAlive = null, bool? onPrem = null, Dictionary<string, string>? headers = null, string? apiVersion = null)
public DeepgramWsClientOptions(string? apiKey = null, string? baseAddress = null, bool? keepAlive = null, bool? onPrem = null, Dictionary<string, string>? headers = null)
{
Log.Verbose("DeepgramWsClientOptions", "ENTER");
Log.Debug("DeepgramWsClientOptions", apiKey == null ? "API KEY is null" : "API KEY provided");
Log.Debug("DeepgramWsClientOptions", baseAddress == null ? "BaseAddress is null" : "BaseAddress provided");
Log.Debug("DeepgramWsClientOptions", keepAlive == null ? "KeepAlive is null" : "KeepAlive provided");
Log.Debug("DeepgramWsClientOptions", onPrem == null ? "OnPrem is null" : "OnPrem provided");
Log.Debug("DeepgramWsClientOptions", headers == null ? "Headers is null" : "Headers provided");
Log.Debug("DeepgramWsClientOptions", apiVersion == null ? "API Version is null" : "API Version provided");

ApiKey = apiKey ?? "";
BaseAddress = baseAddress ?? Defaults.DEFAULT_URI;
KeepAlive = keepAlive ?? false;
OnPrem = onPrem ?? false;
Headers = headers ?? new Dictionary<string, string>();
APIVersion = apiVersion ?? Defaults.DEFAULT_API_VERSION;

Log.Information("DeepgramWsClientOptions", $"KeepAlive: {KeepAlive}");
Log.Information("DeepgramWsClientOptions", $"OnPrem: {OnPrem}");
Expand Down
1 change: 1 addition & 0 deletions examples/prerecorded/file/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ static async Task Main(string[] args)
});

Console.WriteLine($"\n\n{JsonSerializer.Serialize(response, options)}\n\n");
Console.WriteLine("Press any key to exit...");
Console.ReadKey();

// Teardown Library
Expand Down
Loading