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

Refactor and Enhance Account Entity Management #439

Merged
merged 1 commit into from
Dec 16, 2024
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
10 changes: 0 additions & 10 deletions src/CheckoutSdk/Accounts/AccountPhone.cs

This file was deleted.

6 changes: 4 additions & 2 deletions src/CheckoutSdk/Accounts/AccountsAccountHolder.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Checkout.Common;
using Checkout.Accounts.Entities.Common;
using Checkout.Accounts.Entities.Common.Company;
using Checkout.Common;

namespace Checkout.Accounts
{
Expand All @@ -16,7 +18,7 @@ public abstract class AccountsAccountHolder

public Address BillingAddress { get; set; }

public AccountPhone Phone { get; set; }
public Phone Phone { get; set; }

public AccountHolderIdentification Identification { get; set; }

Expand Down
124 changes: 96 additions & 28 deletions src/CheckoutSdk/Accounts/AccountsClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Checkout.Accounts.Payout.Request;
using Checkout.Accounts.Entities.Request;
using Checkout.Accounts.Entities.Response;
using Checkout.Accounts.Payout.Request;
using Checkout.Accounts.Payout.Response;
using Checkout.Common;
using Checkout.Files;
Expand All @@ -12,6 +14,8 @@ public class AccountsClient : FilesClient, IAccountsClient
{
private const string AccountsPath = "accounts";
private const string EntitiesPath = "entities";
private const string MembersPath = "members";
private const string FilesPath = "files";
private const string InstrumentPath = "instruments";
private const string PayoutSchedulePath = "payout-schedules";
private const string PaymentInstrumentsPath = "payment-instruments";
Expand All @@ -24,37 +28,46 @@ public AccountsClient(
{
}

public async Task<IdResponse> SubmitFile(AccountsFileRequest accountsFileRequest,
public async Task<OnboardEntityResponse> CreateEntity(
OnboardEntityRequest entityRequest,
CancellationToken cancellationToken = default)
{
CheckoutUtils.ValidateParams("accountsFileRequest", accountsFileRequest,
"accountsFileRequest.purpose", accountsFileRequest.Purpose);
return await SubmitFileToFilesApi(accountsFileRequest.File, accountsFileRequest.Purpose.Value,
CheckoutUtils.ValidateParams("entityRequest", entityRequest);
return await ApiClient.Post<OnboardEntityResponse>(
BuildPath(AccountsPath, EntitiesPath),
SdkAuthorization(),
entityRequest,
cancellationToken);
}

public async Task<OnboardEntityResponse> CreateEntity(OnboardEntityRequest entityRequest,
public async Task<OnboardSubEntityDetailsResponse> GetSubEntityMembers(
string entityId,
CancellationToken cancellationToken = default)
{
CheckoutUtils.ValidateParams("entityRequest", entityRequest);
return await ApiClient.Post<OnboardEntityResponse>(
BuildPath(AccountsPath, EntitiesPath),
CheckoutUtils.ValidateParams("entityId", entityId);
return await ApiClient.Get<OnboardSubEntityDetailsResponse>(
BuildPath(AccountsPath, EntitiesPath, entityId, MembersPath),
SdkAuthorization(),
entityRequest,
cancellationToken);
}

public async Task<PaymentInstrumentDetailsResponse> RetrievePaymentInstrumentDetails(string entityId,
string paymentInstrumentId, CancellationToken cancellationToken = default)
public async Task<OnboardSubEntityResponse> ReinviteSubEntityMember(
string entityId,
string userId,
OnboardSubEntityRequest subEntityRequest,
CancellationToken cancellationToken = default)
{
CheckoutUtils.ValidateParams("entityId", entityId, "paymentInstrumentId", paymentInstrumentId);
return await ApiClient.Get<PaymentInstrumentDetailsResponse>(
BuildPath(AccountsPath, EntitiesPath, entityId, PaymentInstrumentsPath, paymentInstrumentId),
CheckoutUtils.ValidateParams("entityId", entityId, "userId", userId,
"subEntityRequest", subEntityRequest);
return await ApiClient.Put<OnboardSubEntityResponse>(
BuildPath(AccountsPath, EntitiesPath, entityId, MembersPath, userId),
SdkAuthorization(),
subEntityRequest,
cancellationToken);
}

public async Task<OnboardEntityDetailsResponse> GetEntity(string entityId,
public async Task<OnboardEntityDetailsResponse> GetEntity(
string entityId,
CancellationToken cancellationToken = default)
{
CheckoutUtils.ValidateParams("entityId", entityId);
Expand All @@ -64,31 +77,34 @@ public async Task<OnboardEntityDetailsResponse> GetEntity(string entityId,
cancellationToken);
}

public async Task<OnboardEntityResponse> UpdateEntity(string entityId, OnboardEntityRequest entityRequest,
public async Task<OnboardEntityResponse> UpdateEntity(
string entityId,
OnboardEntityRequest entityRequest,
CancellationToken cancellationToken = default)
{
CheckoutUtils.ValidateParams("entityRequest", entityRequest, "entityId", entityId);
CheckoutUtils.ValidateParams("entityId", entityId, "entityRequest", entityRequest);
return await ApiClient.Put<OnboardEntityResponse>(
BuildPath(AccountsPath, EntitiesPath, entityId),
SdkAuthorization(),
entityRequest,
cancellationToken);
}

public async Task<EmptyResponse> CreatePaymentInstrument(string entityId,
public async Task<EmptyResponse> CreatePaymentInstrument(
string entityId,
AccountsPaymentInstrument accountsPaymentInstrument,
CancellationToken cancellationToken = default)
{
CheckoutUtils.ValidateParams("accountsPaymentInstrument", accountsPaymentInstrument, "entityId",
entityId);
CheckoutUtils.ValidateParams("entityId", entityId, "accountsPaymentInstrument", accountsPaymentInstrument);
return await ApiClient.Post<EmptyResponse>(
BuildPath(AccountsPath, EntitiesPath, entityId, InstrumentPath),
SdkAuthorization(),
accountsPaymentInstrument,
cancellationToken);
}

public async Task<IdResponse> CreatePaymentInstrument(string entityId,
public async Task<IdResponse> CreatePaymentInstrument(
string entityId,
PaymentInstrumentRequest paymentInstrumentRequest,
CancellationToken cancellationToken = default)
{
Expand All @@ -100,21 +116,35 @@ public async Task<IdResponse> CreatePaymentInstrument(string entityId,
cancellationToken);
}

public async Task<IdResponse> UpdatePaymentInstrument(string entityId,
public async Task<PaymentInstrumentDetailsResponse> RetrievePaymentInstrumentDetails(
string entityId,
string paymentInstrumentId,
CancellationToken cancellationToken = default)
{
CheckoutUtils.ValidateParams("entityId", entityId, "paymentInstrumentId", paymentInstrumentId);
return await ApiClient.Get<PaymentInstrumentDetailsResponse>(
BuildPath(AccountsPath, EntitiesPath, entityId, PaymentInstrumentsPath, paymentInstrumentId),
SdkAuthorization(),
cancellationToken);
}

public async Task<IdResponse> UpdatePaymentInstrument(
string entityId,
string instrumentId,
UpdatePaymentInstrumentRequest updatePaymentInstrumentRequest,
CancellationToken cancellationToken = default)
{
CheckoutUtils.ValidateParams("entityId", entityId, "updatePaymentInstrumentRequest",
updatePaymentInstrumentRequest);
CheckoutUtils.ValidateParams("entityId", entityId, "instrumentId", instrumentId,
"updatePaymentInstrumentRequest", updatePaymentInstrumentRequest);
return await ApiClient.Patch<IdResponse>(
BuildPath(AccountsPath, EntitiesPath, entityId, PaymentInstrumentsPath, instrumentId),
SdkAuthorization(),
updatePaymentInstrumentRequest,
cancellationToken);
}

public async Task<PaymentInstrumentQueryResponse> QueryPaymentInstruments(string entityId,
public async Task<PaymentInstrumentQueryResponse> QueryPaymentInstruments(
string entityId,
PaymentInstrumentsQuery query = null,
CancellationToken cancellationToken = default)
{
Expand All @@ -126,7 +156,8 @@ public async Task<PaymentInstrumentQueryResponse> QueryPaymentInstruments(string
cancellationToken);
}

public async Task<GetScheduleResponse> RetrievePayoutSchedule(string entityId,
public async Task<GetScheduleResponse> RetrievePayoutSchedule(
string entityId,
CancellationToken cancellationToken = default)
{
CheckoutUtils.ValidateParams("entityId", entityId);
Expand All @@ -136,7 +167,9 @@ public async Task<GetScheduleResponse> RetrievePayoutSchedule(string entityId,
cancellationToken);
}

public async Task<EmptyResponse> UpdatePayoutSchedule(string entityId, Currency currency,
public async Task<EmptyResponse> UpdatePayoutSchedule(
string entityId,
Currency currency,
UpdateScheduleRequest updateScheduleRequest,
CancellationToken cancellationToken = default)
{
Expand All @@ -148,5 +181,40 @@ public async Task<EmptyResponse> UpdatePayoutSchedule(string entityId, Currency
new Dictionary<Currency, UpdateScheduleRequest>() { { currency, updateScheduleRequest } },
cancellationToken);
}

public async Task<IdResponse> SubmitFile(
AccountsFileRequest accountsFileRequest,
CancellationToken cancellationToken = default)
{
CheckoutUtils.ValidateParams("accountsFileRequest", accountsFileRequest,
"accountsFileRequest.purpose", accountsFileRequest.Purpose);
return await SubmitFileToFilesApi(accountsFileRequest.File, accountsFileRequest.Purpose.Value,
cancellationToken);
}

public async Task<UploadFileResponse> UploadFile(
string entityId,
AccountsFileRequest accountsFileRequest,
CancellationToken cancellationToken = default)
{
CheckoutUtils.ValidateParams("accountsFileRequest", accountsFileRequest);
return await ApiClient.Post<UploadFileResponse>(
BuildPath(AccountsPath, entityId, FilesPath),
SdkAuthorization(),
accountsFileRequest,
cancellationToken);
}

public async Task<FileDetailsResponse> RetrieveFile(
string entityId,
string fileId,
CancellationToken cancellationToken = default)
{
CheckoutUtils.ValidateParams("entityId", entityId, "fileId", fileId);
return await ApiClient.Get<FileDetailsResponse>(
BuildPath(AccountsPath, entityId, FilesPath, fileId),
SdkAuthorization(),
cancellationToken);
}
}
}
21 changes: 21 additions & 0 deletions src/CheckoutSdk/Accounts/AccountsFilePurpose.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,38 @@ private AccountsFilePurpose(string purpose)
}

public string Value { get; }

public static AccountsFilePurpose AdditionalDocument => new AccountsFilePurpose("additional_document");

public static AccountsFilePurpose ArticlesOfAssociation => new AccountsFilePurpose("articles_of_association");

public static AccountsFilePurpose BankVerification => new AccountsFilePurpose("bank_verification");

public static AccountsFilePurpose CertifiedAuthorisedSignatory => new AccountsFilePurpose("certified_authorised_signatory");

public static AccountsFilePurpose CompanyOwnership => new AccountsFilePurpose("company_ownership");

public static AccountsFilePurpose Identification => new AccountsFilePurpose("identification");

public static AccountsFilePurpose IdentityVerification => new AccountsFilePurpose("identity_verification");

public static AccountsFilePurpose DisputeEvidence => new AccountsFilePurpose("dispute_evidence");

public static AccountsFilePurpose CompanyVerification => new AccountsFilePurpose("company_verification");

public static AccountsFilePurpose FinancialVerification => new AccountsFilePurpose("financial_verification");

public static AccountsFilePurpose TaxVerification => new AccountsFilePurpose("tax_verification");

public static AccountsFilePurpose ProofOfLegality => new AccountsFilePurpose("proof_of_legality");

public static AccountsFilePurpose ProofOfPrincipalAddress => new AccountsFilePurpose("proof_of_principal_address");

public static AccountsFilePurpose ShareholderStructure => new AccountsFilePurpose("shareholder_structure");

public static AccountsFilePurpose ProofOfResidentialAddress => new AccountsFilePurpose("proof_of_residential_address");

public static AccountsFilePurpose ProofOfRegistration => new AccountsFilePurpose("proof_of_registration");

}
}
15 changes: 0 additions & 15 deletions src/CheckoutSdk/Accounts/BusinessType.cs

This file was deleted.

11 changes: 0 additions & 11 deletions src/CheckoutSdk/Accounts/ContactDetails.cs

This file was deleted.

13 changes: 0 additions & 13 deletions src/CheckoutSdk/Accounts/Document.cs

This file was deleted.

Loading
Loading