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

Add base url property to ApiClient #142

Merged
merged 4 commits into from
Aug 9, 2024
Merged
Changes from 1 commit
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
Prev Previous commit
add baseAddress ctor overload
aspriddell committed Aug 9, 2024
commit 5815634ad91d4cd6aa24db99c9ab8e92926cace5
13 changes: 12 additions & 1 deletion DragonFruit.Data/ApiClient.cs
Original file line number Diff line number Diff line change
@@ -22,7 +22,18 @@
/// Represents a strongly-typed serializer version of <see cref="ApiClient"/>
/// </summary>
/// <typeparam name="T">The type of the <see cref="ApiSerializer"/></typeparam>
public class ApiClient<T>() : ApiClient(new T()) where T : ApiSerializer, new();
public class ApiClient<T> : ApiClient where T : ApiSerializer, new()
{
public ApiClient()
: base(new T())
{
}

public ApiClient(Uri baseAddress)
: base(new T(), baseAddress)
{
}
}

/// <summary>
/// The <see cref="ApiClient"/> responsible for building, submitting and processing HTTP requests
@@ -32,7 +43,7 @@
private HttpClient _client;
private Uri _baseAddress;

public ApiClient(ApiSerializer serializer)

Check notice on line 46 in DragonFruit.Data/ApiClient.cs

GitHub Actions / quality

Convert into primary constructor in DragonFruit.Data\ApiClient.cs on line 46
{
Serializers = new SerializerResolver(serializer);
}
@@ -389,16 +400,16 @@
{
switch (request)
{
case IRequestExecutingCallback callback:

Check warning on line 403 in DragonFruit.Data/ApiClient.cs

GitHub Actions / quality

Suspicious type check: there is no type in the solution that is inherited from both 'DragonFruit.Data.ApiRequest' and 'DragonFruit.Data.Requests.IRequestExecutingCallback' in DragonFruit.Data\ApiClient.cs on line 403
callback.OnRequestExecuting(this);
break;

case IAsyncRequestExecutingCallback asyncCallback:

Check warning on line 407 in DragonFruit.Data/ApiClient.cs

GitHub Actions / quality

Suspicious type check: there is no type in the solution that is inherited from both 'DragonFruit.Data.ApiRequest' and 'DragonFruit.Data.Requests.IAsyncRequestExecutingCallback' in DragonFruit.Data\ApiClient.cs on line 407
await asyncCallback.OnRequestExecuting(this);
break;
}

var requestMessage = (request as IRequestBuilder)?.BuildRequest(Serializers) ?? ReflectionRequestMessageBuilder.CreateHttpRequestMessage(request, Serializers);

Check warning on line 412 in DragonFruit.Data/ApiClient.cs

GitHub Actions / quality

Suspicious cast: there is no type in the solution which is inherited from both 'DragonFruit.Data.ApiRequest' and 'DragonFruit.Data.Requests.IRequestBuilder' in DragonFruit.Data\ApiClient.cs on line 412
requestMessage.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(expectedContentType));

return requestMessage;
Loading