From c74bc2aa5888be25f312010a43270b54ea93ea0e Mon Sep 17 00:00:00 2001 From: Asimakis Ant Date: Fri, 5 Jun 2026 08:57:57 +0200 Subject: [PATCH] NXC-267: Add customer person methods Introduce new methods to our SDK for the customer person endpoints --- src/Nexus.Crypto.SDK/INexusAPIService.cs | 1 + src/Nexus.Crypto.SDK/Models/CustomerPerson.cs | 171 ++++++++++++++++++ src/Nexus.Crypto.SDK/NexusAPIService.cs | 3 +- .../Services/CustomerPersonService.cs | 37 ++++ .../Services/ICustomerPersonService.cs | 12 ++ 5 files changed, 223 insertions(+), 1 deletion(-) create mode 100644 src/Nexus.Crypto.SDK/Models/CustomerPerson.cs create mode 100644 src/Nexus.Crypto.SDK/Services/CustomerPersonService.cs create mode 100644 src/Nexus.Crypto.SDK/Services/ICustomerPersonService.cs diff --git a/src/Nexus.Crypto.SDK/INexusAPIService.cs b/src/Nexus.Crypto.SDK/INexusAPIService.cs index 3a5e165..a6a9fbf 100644 --- a/src/Nexus.Crypto.SDK/INexusAPIService.cs +++ b/src/Nexus.Crypto.SDK/INexusAPIService.cs @@ -11,6 +11,7 @@ public interface INexusAPIService { IDocumentStoreService DocumentStore { get; } ICustomerService Customer { get; } + ICustomerPersonService CustomerPerson { get; } Task> GetLabelPartner(); Task> GetCurrencies(); Task> GetPrices(string currency); diff --git a/src/Nexus.Crypto.SDK/Models/CustomerPerson.cs b/src/Nexus.Crypto.SDK/Models/CustomerPerson.cs new file mode 100644 index 0000000..11b3ab5 --- /dev/null +++ b/src/Nexus.Crypto.SDK/Models/CustomerPerson.cs @@ -0,0 +1,171 @@ +using System.ComponentModel.DataAnnotations; + +namespace Nexus.Crypto.SDK.Models; + +public class PersonResponse +{ + /// + /// Unique identifier of the person. + /// + public Guid Id { get; set; } + + /// + /// Unique identifier of the customer linked to this person. + /// + public string CustomerCode { get; set; } + + /// + /// First name of the person. + /// + public string? FirstName { get; set; } + + /// + /// Last name of the person. + /// + public string? LastName { get; set; } + + /// + /// This person is linked to a customer in one or more ways. + /// + public List Types { get; set; } = []; + + /// + /// Date of birth of this person. + /// + public string? DateOfBirth { get; set; } + + /// + /// Country of this person's nationality (ISO 4217). + /// + public PersonCountry? Nationality { get; set; } + + /// + /// Country of this person's residence (ISO 4217). + /// + public PersonCountry? ResidenceCountry { get; set; } + + /// + /// Person's ownership percentage of the business + /// + /// + /// 0.39 represents 39% + /// + public decimal? OwnershipPercentage { get; set; } + + /// + /// Date the person was created. + /// + public string CreatedOn { get; set; } + + /// + /// User that created the person. + /// + public string CreatedBy { get; set; } + + /// + /// Date the person was last updated. + /// + public string? UpdatedOn { get; set; } + + /// + /// User that updated the person last. + /// + public string? UpdatedBy { get; set; } +} + +public class CustomerPersonRequestBase +{ + /// + /// First name of the person. + /// + [StringLength(100)] + public string? FirstName { get; set; } + + /// + /// Last name of the person. + /// + [StringLength(100)] + public string? LastName { get; set; } + + /// + /// Person's date of birth (ISO 8601). Date format needs to be: yyyy-MM-dd. + /// + [RegularExpression(@"^\d{4}-\d{2}-\d{2}$", + ErrorMessage = "The value must be in the exact format: yyyy-MM-dd")] + public string? DateOfBirth { get; set; } + + /// + /// Country code of this person's nationality (ISO 4217). + /// + /// NL + [StringLength(3, MinimumLength = 2)] + public string? NationalityCountryCode { get; set; } + + /// + /// Country code of this person's residence country (ISO 4217). + /// + /// NL + [StringLength(3, MinimumLength = 2)] + public string? ResidenceCountryCode { get; set; } + + /// + /// Person's ownership percentage of the business and should be expressed as a decimal fraction. + /// + /// + /// 0.39 represents 39% + /// + [Range(0.01, 1, ErrorMessage = "If value is specified, it must be between 0.01 and 1.")] + public decimal? OwnershipPercentage { get; set; } +} + +public class CreateCustomerPersonRequest : CustomerPersonRequestBase +{ + /// + /// This person is linked to a customer in the below way: + /// + [Required(ErrorMessage = "The Types field is required.")] + [MinLength(1, ErrorMessage = "At least one type must be provided.")] + public List Types { get; set; } = []; +} + +public class UpdateCustomerPersonRequest : CustomerPersonRequestBase +{ + /// + /// Update the way a person is linked to a customer: + /// + [MinLength(1)] + public List? Types { get; set; } + + + /// + /// Array of field names to explicitly clear (set to null/empty). + /// Supported fields: FirstName, LastName, DateOfBirth, NationalityCountryCode, ResidenceCountryCode, OwnershipPercentage, + /// and type flags via Type.Director, Type.UltimateBeneficialOwner, Type.PseudoUltimateBeneficialOwner, Type.AuthorisedRepresentative. + /// + /// + /// ["FirstName", "Type.UltimateBeneficialOwner", "OwnershipPercentage"] + /// + public string[]? FieldsToClear { get; set; } +} + + +public enum CustomerPersonType +{ + Director, + UltimateBeneficialOwner, + PseudoUltimateBeneficialOwner, + AuthorisedRepresentative +} + +public class PersonCountry +{ + /// + /// Code of this country (ISO 4217). + /// + public string Code { get; set; } + + /// + /// Name of this country. + /// + public string Name { get; set; } +} \ No newline at end of file diff --git a/src/Nexus.Crypto.SDK/NexusAPIService.cs b/src/Nexus.Crypto.SDK/NexusAPIService.cs index 01261c1..b351afa 100644 --- a/src/Nexus.Crypto.SDK/NexusAPIService.cs +++ b/src/Nexus.Crypto.SDK/NexusAPIService.cs @@ -20,7 +20,8 @@ public class NexusAPIService(INexusApiClientFactory nexusApiClientFactory) public IDocumentStoreService DocumentStore => new DocumentStoreService(this); public ICustomerService Customer => new CustomerService(this); - + public ICustomerPersonService CustomerPerson => new CustomerPersonService(this); + public async Task> GetCurrencies() { return await GetAsync>("currencies", ApiVersion1_2); diff --git a/src/Nexus.Crypto.SDK/Services/CustomerPersonService.cs b/src/Nexus.Crypto.SDK/Services/CustomerPersonService.cs new file mode 100644 index 0000000..be254a2 --- /dev/null +++ b/src/Nexus.Crypto.SDK/Services/CustomerPersonService.cs @@ -0,0 +1,37 @@ +using Nexus.Crypto.SDK.Models; +using Nexus.Crypto.SDK.Models.Response; + +namespace Nexus.Crypto.SDK.Services; + +public class CustomerPersonService(BaseService service) : ICustomerPersonService +{ + public Task> CreateCustomerPerson(string customerCode, CreateCustomerPersonRequest request) + { + return service.PostAsync>( + $"customer/{customerCode}/person", + request, + BaseService.ApiVersion1_2 + ); + } + + public Task>> GetCustomerPersons(string customerCode, Dictionary queryParams) + { + var url = $"customer/{customerCode}/person" + BaseService.CreateUriQuery(queryParams); + return service.GetAsync>>( + url, + BaseService.ApiVersion1_2); + } + + public Task> UpdateCustomerPerson(string customerCode, Guid personId, UpdateCustomerPersonRequest request) + { + return service.PutAsync>( + $"customer/{customerCode}/person/{personId}", + request, + BaseService.ApiVersion1_2); + } + + public Task DeleteCustomerPerson(string customerCode, Guid personId) + { + return service.DeleteAsync($"customer/{customerCode}/person/{personId}", BaseService.ApiVersion1_2); + } +} \ No newline at end of file diff --git a/src/Nexus.Crypto.SDK/Services/ICustomerPersonService.cs b/src/Nexus.Crypto.SDK/Services/ICustomerPersonService.cs new file mode 100644 index 0000000..2191975 --- /dev/null +++ b/src/Nexus.Crypto.SDK/Services/ICustomerPersonService.cs @@ -0,0 +1,12 @@ +using Nexus.Crypto.SDK.Models; +using Nexus.Crypto.SDK.Models.Response; + +namespace Nexus.Crypto.SDK.Services; + +public interface ICustomerPersonService +{ + Task> CreateCustomerPerson(string customerCode, CreateCustomerPersonRequest request); + Task>> GetCustomerPersons(string customerCode, Dictionary queryParams); + Task> UpdateCustomerPerson(string customerCode, Guid personId, UpdateCustomerPersonRequest request); + Task DeleteCustomerPerson(string customerCode, Guid personId); +} \ No newline at end of file