This repository has been archived by the owner on Apr 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #318 from aspriddell/update-dragonfruit-data
Update data library
- Loading branch information
Showing
6 changed files
with
44 additions
and
22 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
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
10 changes: 7 additions & 3 deletions
10
DragonFruit.Six.Api/Services/Developer/Dragon6DeveloperApiRequest.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,20 +1,24 @@ | ||
// Dragon6 API Copyright DragonFruit Network <[email protected]> | ||
// Licensed under Apache-2. Refer to the LICENSE file for more info | ||
|
||
using System.Threading.Tasks; | ||
using DragonFruit.Data; | ||
using DragonFruit.Data.Extensions; | ||
using DragonFruit.Data.Requests; | ||
|
||
namespace DragonFruit.Six.Api.Services.Developer | ||
{ | ||
public abstract class Dragon6DeveloperApiRequest : ApiRequest | ||
public abstract class Dragon6DeveloperApiRequest : ApiRequest, IAsyncRequestExecutingCallback | ||
{ | ||
protected override bool RequireAuth => true; | ||
|
||
protected override void OnRequestExecuting(ApiClient client) | ||
async ValueTask IAsyncRequestExecutingCallback.OnRequestExecutingAsync(ApiClient client) | ||
{ | ||
// get access token if using a developer client | ||
if (client is Dragon6DeveloperClient devClient) | ||
{ | ||
this.WithAuthHeader($"Bearer {devClient.RequestDragonFruitAccessToken().AccessToken}"); | ||
var token = await devClient.RequestDragonFruitAccessToken().ConfigureAwait(false); | ||
this.WithAuthHeader($"Bearer {token.AccessToken}"); | ||
} | ||
} | ||
} | ||
|
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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
// Dragon6 API Copyright DragonFruit Network <[email protected]> | ||
// Licensed under Apache-2. Refer to the LICENSE file for more info | ||
|
||
using System.Threading.Tasks; | ||
using DragonFruit.Data; | ||
using DragonFruit.Data.Requests; | ||
|
||
#nullable enable | ||
|
||
|
@@ -11,15 +13,19 @@ namespace DragonFruit.Six.Api | |
/// Represents a Ubisoft API request that requires authentication. | ||
/// Supports header injection via a <see cref="Dragon6Client"/> | ||
/// </summary> | ||
public abstract class UbiApiRequest : ApiRequest | ||
public abstract class UbiApiRequest : ApiRequest, IAsyncRequestExecutingCallback | ||
{ | ||
protected override bool RequireAuth => true; | ||
|
||
protected override void OnRequestExecuting(ApiClient client) | ||
async ValueTask IAsyncRequestExecutingCallback.OnRequestExecutingAsync(ApiClient client) | ||
{ | ||
// all ubisoft api requests need authentication | ||
// the Dragon6Client caches auth tokens and allows the headers to be injected | ||
(client as Dragon6Client)?.RequestAccessToken().Inject(this); | ||
if (client is Dragon6Client d6Client) | ||
{ | ||
var token = await d6Client.RequestAccessToken().ConfigureAwait(false); | ||
token.Inject(this); | ||
} | ||
} | ||
} | ||
} |