Skip to content
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
1 change: 1 addition & 0 deletions src/Nexus.Crypto.SDK/INexusAPIService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public interface INexusAPIService
{
IDocumentStoreService DocumentStore { get; }
ICustomerService Customer { get; }
ICustomerPersonService CustomerPerson { get; }
Task<CustomResultHolder<GetLabelPartner>> GetLabelPartner();
Task<CustomResultHolder<GetCurrencies>> GetCurrencies();
Task<CustomResultHolder<GetPrices>> GetPrices(string currency);
Expand Down
171 changes: 171 additions & 0 deletions src/Nexus.Crypto.SDK/Models/CustomerPerson.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
using System.ComponentModel.DataAnnotations;

namespace Nexus.Crypto.SDK.Models;

public class PersonResponse
{
/// <summary>
/// Unique identifier of the person.
/// </summary>
public Guid Id { get; set; }

/// <summary>
/// Unique identifier of the customer linked to this person.
/// </summary>
public string CustomerCode { get; set; }

/// <summary>
/// First name of the person.
/// </summary>
public string? FirstName { get; set; }

/// <summary>
/// Last name of the person.
/// </summary>
public string? LastName { get; set; }

/// <summary>
/// This person is linked to a customer in one or more ways.
/// </summary>
public List<CustomerPersonType> Types { get; set; } = [];

/// <summary>
/// Date of birth of this person.
/// </summary>
public string? DateOfBirth { get; set; }

/// <summary>
/// Country of this person's nationality (ISO 4217).
/// </summary>
Comment thread
AsimaksiAnt marked this conversation as resolved.
public PersonCountry? Nationality { get; set; }

/// <summary>
/// Country of this person's residence (ISO 4217).
/// </summary>
Comment thread
AsimaksiAnt marked this conversation as resolved.
public PersonCountry? ResidenceCountry { get; set; }

/// <summary>
/// Person's ownership percentage of the business
/// </summary>
Comment thread
AsimaksiAnt marked this conversation as resolved.
/// <example>
/// 0.39 represents 39%
/// </example>
public decimal? OwnershipPercentage { get; set; }

/// <summary>
/// Date the person was created.
/// </summary>
public string CreatedOn { get; set; }
Comment thread
raymens marked this conversation as resolved.

/// <summary>
/// User that created the person.
/// </summary>
public string CreatedBy { get; set; }

/// <summary>
/// Date the person was last updated.
/// </summary>
public string? UpdatedOn { get; set; }
Comment thread
raymens marked this conversation as resolved.

/// <summary>
/// User that updated the person last.
/// </summary>
public string? UpdatedBy { get; set; }
}

public class CustomerPersonRequestBase
{
/// <summary>
/// First name of the person.
/// </summary>
[StringLength(100)]
public string? FirstName { get; set; }

/// <summary>
/// Last name of the person.
/// </summary>
[StringLength(100)]
public string? LastName { get; set; }

/// <summary>
/// Person's date of birth (ISO 8601). Date format needs to be: yyyy-MM-dd.
/// </summary>
[RegularExpression(@"^\d{4}-\d{2}-\d{2}$",
ErrorMessage = "The value must be in the exact format: yyyy-MM-dd")]
public string? DateOfBirth { get; set; }

/// <summary>
/// Country code of this person's nationality (ISO 4217).
/// </summary>
Comment thread
AsimaksiAnt marked this conversation as resolved.
/// <example>NL</example>
[StringLength(3, MinimumLength = 2)]
public string? NationalityCountryCode { get; set; }

/// <summary>
/// Country code of this person's residence country (ISO 4217).
/// </summary>
Comment thread
AsimaksiAnt marked this conversation as resolved.
/// <example>NL</example>
[StringLength(3, MinimumLength = 2)]
public string? ResidenceCountryCode { get; set; }

/// <summary>
/// Person's ownership percentage of the business and should be expressed as a decimal fraction.
/// </summary>
Comment thread
AsimaksiAnt marked this conversation as resolved.
/// <example>
/// 0.39 represents 39%
/// </example>
[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
{
/// <summary>
/// This person is linked to a customer in the below way:
/// </summary>
[Required(ErrorMessage = "The Types field is required.")]
[MinLength(1, ErrorMessage = "At least one type must be provided.")]
public List<CustomerPersonType> Types { get; set; } = [];
}

public class UpdateCustomerPersonRequest : CustomerPersonRequestBase
{
/// <summary>
/// Update the way a person is linked to a customer:
/// </summary>
[MinLength(1)]
public List<CustomerPersonType>? Types { get; set; }


/// <summary>
/// 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.
/// </summary>
/// <example>
/// ["FirstName", "Type.UltimateBeneficialOwner", "OwnershipPercentage"]
/// </example>
public string[]? FieldsToClear { get; set; }
}


public enum CustomerPersonType
{
Director,
UltimateBeneficialOwner,
PseudoUltimateBeneficialOwner,
AuthorisedRepresentative
}

public class PersonCountry
{
/// <summary>
/// Code of this country (ISO 4217).
/// </summary>
Comment thread
AsimaksiAnt marked this conversation as resolved.
public string Code { get; set; }

/// <summary>
/// Name of this country.
/// </summary>
public string Name { get; set; }
}
3 changes: 2 additions & 1 deletion src/Nexus.Crypto.SDK/NexusAPIService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Comment thread
AsimaksiAnt marked this conversation as resolved.
public async Task<CustomResultHolder<GetCurrencies>> GetCurrencies()
{
return await GetAsync<CustomResultHolder<GetCurrencies>>("currencies", ApiVersion1_2);
Expand Down
37 changes: 37 additions & 0 deletions src/Nexus.Crypto.SDK/Services/CustomerPersonService.cs
Original file line number Diff line number Diff line change
@@ -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<CustomResultHolder<PersonResponse>> CreateCustomerPerson(string customerCode, CreateCustomerPersonRequest request)
{
return service.PostAsync<CreateCustomerPersonRequest, CustomResultHolder<PersonResponse>>(
$"customer/{customerCode}/person",
request,
BaseService.ApiVersion1_2
);
}
Comment thread
AsimaksiAnt marked this conversation as resolved.

public Task<CustomResultHolder<PagedResult<PersonResponse>>> GetCustomerPersons(string customerCode, Dictionary<string, string> queryParams)
{
var url = $"customer/{customerCode}/person" + BaseService.CreateUriQuery(queryParams);
return service.GetAsync<CustomResultHolder<PagedResult<PersonResponse>>>(
url,
BaseService.ApiVersion1_2);
}

public Task<CustomResultHolder<PersonResponse>> UpdateCustomerPerson(string customerCode, Guid personId, UpdateCustomerPersonRequest request)
{
return service.PutAsync<UpdateCustomerPersonRequest, CustomResultHolder<PersonResponse>>(
$"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);
}
}
12 changes: 12 additions & 0 deletions src/Nexus.Crypto.SDK/Services/ICustomerPersonService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Nexus.Crypto.SDK.Models;
using Nexus.Crypto.SDK.Models.Response;

namespace Nexus.Crypto.SDK.Services;

public interface ICustomerPersonService
{
Task<CustomResultHolder<PersonResponse>> CreateCustomerPerson(string customerCode, CreateCustomerPersonRequest request);
Task<CustomResultHolder<PagedResult<PersonResponse>>> GetCustomerPersons(string customerCode, Dictionary<string, string> queryParams);
Task<CustomResultHolder<PersonResponse>> UpdateCustomerPerson(string customerCode, Guid personId, UpdateCustomerPersonRequest request);
Task DeleteCustomerPerson(string customerCode, Guid personId);
}
Loading