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

[ACL-231] Support for generate idempotency keys when not provided #233

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
7 changes: 3 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
filter: tree:0
Comment on lines +20 to +22
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the benefit of this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's required for minver

- name: Setup .NET 9.0
uses: actions/setup-dotnet@v2
with:
Expand All @@ -29,10 +32,6 @@ jobs:
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x
- name: Setup .NET 3.1
uses: actions/setup-dotnet@v2
with:
dotnet-version: 3.1.x
- name: Restore tools
run: dotnet tool restore
- name: Run the build script
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
filter: tree:0
- name: Setup .NET 9.0
uses: actions/setup-dotnet@v2
with:
Expand All @@ -35,10 +38,6 @@ jobs:
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x
- name: Setup .NET 3.1
uses: actions/setup-dotnet@v2
with:
dotnet-version: 3.1.x
- name: Restore tools
run: dotnet tool restore
- name: Run the build script
Expand Down
70 changes: 60 additions & 10 deletions src/TrueLayer/Mandates/IMandatesApi.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using OneOf;
Expand Down Expand Up @@ -28,11 +29,15 @@ public interface IMandatesApi
/// <param name="idempotencyKey">
/// An idempotency key to allow safe retrying without the operation being performed multiple times.
/// The value should be unique for each operation, e.g. a UUID, with the same key being sent on a retry of the same request.
/// If not provided an idempotency key is automatically generated.
/// </param>
/// <param name="cancellationToken">The cancellation token to cancel the operation
/// </param>
/// <param name="cancellationToken">The cancellation token to cancel the operation</param>
/// <returns>An API response that includes details of the created mandate if successful, otherwise problem details</returns>
Task<ApiResponse<CreateMandateResponse>> CreateMandate(
CreateMandateRequest mandateRequest, string idempotencyKey, CancellationToken cancellationToken = default);
CreateMandateRequest mandateRequest,
string? idempotencyKey = null,
CancellationToken cancellationToken = default);

/// <summary>
/// Gets a mandate
Expand All @@ -42,7 +47,24 @@ Task<ApiResponse<CreateMandateResponse>> CreateMandate(
/// <param name="cancellationToken">The cancellation token to cancel the operation</param>
/// <returns>An API response that includes details of the mandate if successful, otherwise problem details</returns>
Task<ApiResponse<MandateDetailUnion>> GetMandate(
string mandateId, MandateType mandateType, CancellationToken cancellationToken = default);
string mandateId,
MandateType mandateType,
CancellationToken cancellationToken = default);

/// <summary>
/// Generates a link to the TrueLayer hosted payment page
/// </summary>
/// <param name="mandateId">The mandate identifier</param>
/// <param name="resourceToken">The resource token, returned from <see cref="CreateMandate"/></param>
/// <param name="returnUri">
/// Your return URI to which the end user will be redirected after the mandate is completed.
/// Note this should be configured in the TrueLayer console under your application settings.
/// </param>
/// <returns>The HPP link you can redirect the end user to</returns>
string CreateHostedPaymentPageLink(
string mandateId,
string resourceToken,
Uri returnUri);

/// <summary>
/// Lists mandates for a user
Expand All @@ -52,7 +74,9 @@ Task<ApiResponse<MandateDetailUnion>> GetMandate(
/// <param name="cancellationToken">The cancellation token to cancel the operation</param>
/// <returns>An API response that includes details of the mandate if successful, otherwise problem details</returns>
Task<ApiResponse<ResourceCollection<MandateDetailUnion>>> ListMandates(
ListMandatesQuery query, MandateType mandateType, CancellationToken cancellationToken = default);
ListMandatesQuery query,
MandateType mandateType,
CancellationToken cancellationToken = default);

/// <summary>
/// Start the authorization flow for a mandate.
Expand All @@ -63,11 +87,16 @@ Task<ApiResponse<ResourceCollection<MandateDetailUnion>>> ListMandates(
/// <param name="idempotencyKey">
/// An idempotency key to allow safe retrying without the operation being performed multiple times.
/// The value should be unique for each operation, e.g. a UUID, with the same key being sent on a retry of the same request.
/// If not provided an idempotency key is automatically generated.
/// </param>
/// <param name="cancellationToken">The cancellation token to cancel the operation</param>
/// <returns>An API response that includes details of the mandate if successful, otherwise problem details</returns>
Task<ApiResponse<AuthorizationResponseUnion>> StartAuthorizationFlow(
string mandateId, StartAuthorizationFlowRequest request, string idempotencyKey, MandateType mandateType, CancellationToken cancellationToken = default);
string mandateId,
StartAuthorizationFlowRequest request,
string? idempotencyKey,
MandateType mandateType,
CancellationToken cancellationToken = default);

/// <summary>
/// Submit the provider details selected by the PSU.
Expand All @@ -78,11 +107,16 @@ Task<ApiResponse<AuthorizationResponseUnion>> StartAuthorizationFlow(
/// <param name="idempotencyKey">
/// An idempotency key to allow safe retrying without the operation being performed multiple times.
/// The value should be unique for each operation, e.g. a UUID, with the same key being sent on a retry of the same request.
/// If not provided an idempotency key is automatically generated.
/// </param>
/// <param name="cancellationToken">The cancellation token to cancel the operation</param>
/// <returns>An API response that includes details of the mandate if successful, otherwise problem details</returns>
Task<ApiResponse<AuthorizationResponseUnion>> SubmitProviderSelection(
string mandateId, SubmitProviderSelectionRequest request, string idempotencyKey, MandateType mandateType, CancellationToken cancellationToken = default);
string mandateId,
SubmitProviderSelectionRequest request,
string? idempotencyKey,
MandateType mandateType,
CancellationToken cancellationToken = default);

/// <summary>
/// Submit the consent given by the user
Expand All @@ -95,7 +129,11 @@ Task<ApiResponse<AuthorizationResponseUnion>> SubmitProviderSelection(
/// </param>
/// <param name="cancellationToken">The cancellation token to cancel the operation</param>
/// <returns>An API response that includes the authorization flow action details if successful, otherwise problem details</returns>
Task<ApiResponse<AuthorizationResponseUnion>> SubmitConsent(string mandateId, string idempotencyKey, MandateType mandateType, CancellationToken cancellationToken = default);
Task<ApiResponse<AuthorizationResponseUnion>> SubmitConsent(
string mandateId,
string? idempotencyKey,
MandateType mandateType,
CancellationToken cancellationToken = default);

/// <summary>
/// Get Confirmation Of Funds
Expand All @@ -107,7 +145,11 @@ Task<ApiResponse<AuthorizationResponseUnion>> SubmitProviderSelection(
/// <param name="cancellationToken">The cancellation token to cancel the operation</param>
/// <returns>An API response that includes details of the mandate if successful, otherwise problem details</returns>
Task<ApiResponse<GetConfirmationOfFundsResponse>> GetConfirmationOfFunds(
string mandateId, int amountInMinor, string currency, MandateType mandateType, CancellationToken cancellationToken = default);
string mandateId,
int amountInMinor,
string currency,
MandateType mandateType,
CancellationToken cancellationToken = default);

/// <summary>
/// Gets a mandates constraints
Expand All @@ -117,18 +159,26 @@ Task<ApiResponse<GetConfirmationOfFundsResponse>> GetConfirmationOfFunds(
/// <param name="cancellationToken">The cancellation token to cancel the operation</param>
/// <returns>An API response that includes details of the mandate if successful, otherwise problem details</returns>
Task<ApiResponse<GetConstraintsResponse>> GetMandateConstraints(
string mandateId, MandateType mandateType, CancellationToken cancellationToken = default);
string mandateId,
MandateType mandateType,
CancellationToken cancellationToken = default);

/// <summary>
/// Revoke mandate
/// </summary>
/// <param name="mandateId">The id of the mandate</param>
/// <param name="mandateType">The type of the mandate. Either sweeping or commercial</param>
/// <param name="idempotencyKey">
/// An idempotency key to allow safe retrying without the operation being performed multiple times.
/// The value should be unique for each operation, e.g. a UUID, with the same key being sent on a retry of the same request.
/// If not provided an idempotency key is automatically generated.
/// </param>
/// <param name="cancellationToken">The cancellation token to cancel the operation</param>
/// <returns>An API response that includes the payment details if successful, otherwise problem details</returns>
Task<ApiResponse> RevokeMandate(string mandateId, string idempotencyKey, MandateType mandateType, CancellationToken cancellationToken = default);
Task<ApiResponse> RevokeMandate(
string mandateId,
string? idempotencyKey,
MandateType mandateType,
CancellationToken cancellationToken = default);
}
}
Loading
Loading