Skip to content

Commit 1bfe99f

Browse files
feat(client): add EnvironmentUrl
1 parent 1df879b commit 1bfe99f

File tree

6 files changed

+16
-11
lines changed

6 files changed

+16
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ var customer = await client
8484
.WithOptions(options =>
8585
options with
8686
{
87-
BaseUrl = new("https://example.com"),
87+
BaseUrl = "https://example.com",
8888
Timeout = TimeSpan.FromSeconds(42),
8989
}
9090
)

src/Orb.Tests/TestBase.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ public TestBase()
1111
{
1212
client = new OrbClient()
1313
{
14-
BaseUrl = new Uri(
15-
Environment.GetEnvironmentVariable("TEST_API_BASE_URL") ?? "http://localhost:4010"
16-
),
14+
BaseUrl =
15+
Environment.GetEnvironmentVariable("TEST_API_BASE_URL") ?? "http://localhost:4010",
1716
APIKey = "My API Key",
1817
};
1918
}

src/Orb/Core/ClientOptions.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ public struct ClientOptions()
2424
/// </summary>
2525
public HttpClient HttpClient { get; set; } = new();
2626

27-
Lazy<Uri> _baseUrl = new(() =>
28-
new Uri(Environment.GetEnvironmentVariable("ORB_BASE_URL") ?? "https://api.withorb.com/v1")
27+
Lazy<string> _baseUrl = new(() =>
28+
Environment.GetEnvironmentVariable("ORB_BASE_URL") ?? EnvironmentUrl.Production
2929
);
3030

3131
/// <summary>
3232
/// The base URL to use for every request.
3333
///
34-
/// <para>Defaults to the production environment: https://api.withorb.com/v1</para>
34+
/// <para>Defaults to the production environment: <see cref="EnvironmentUrl.Production"/></para>
3535
/// </summary>
36-
public Uri BaseUrl
36+
public string BaseUrl
3737
{
3838
readonly get { return _baseUrl.Value; }
3939
set { _baseUrl = new(() => value); }

src/Orb/Core/EnvironmentUrl.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
namespace Orb.Core;
2+
3+
public static class EnvironmentUrl
4+
{
5+
public static readonly string Production = "https://api.withorb.com/v1";
6+
}

src/Orb/IOrbClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ public interface IOrbClient
2929
/// <summary>
3030
/// The base URL to use for every request.
3131
///
32-
/// <para>Defaults to the production environment: https://api.withorb.com/v1</para>
32+
/// <para>Defaults to the production environment: <see cref="EnvironmentUrl.Production"/></para>
3333
/// </summary>
34-
Uri BaseUrl { get; init; }
34+
string BaseUrl { get; init; }
3535

3636
/// <summary>
3737
/// Whether to validate every response before returning it.

src/Orb/OrbClient.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public HttpClient HttpClient
3131
}
3232

3333
/// <inheritdoc/>
34-
public Uri BaseUrl
34+
public string BaseUrl
3535
{
3636
get { return this._options.BaseUrl; }
3737
init { this._options.BaseUrl = value; }

0 commit comments

Comments
 (0)