-
Notifications
You must be signed in to change notification settings - Fork 0
NXC-267: Add customer person methods #14
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -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> | ||
| public PersonCountry? Nationality { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Country of this person's residence (ISO 4217). | ||
| /// </summary> | ||
|
AsimaksiAnt marked this conversation as resolved.
|
||
| public PersonCountry? ResidenceCountry { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Person's ownership percentage of the business | ||
| /// </summary> | ||
|
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; } | ||
|
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; } | ||
|
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> | ||
|
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> | ||
|
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> | ||
|
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> | ||
|
AsimaksiAnt marked this conversation as resolved.
|
||
| public string Code { get; set; } | ||
|
|
||
| /// <summary> | ||
| /// Name of this country. | ||
| /// </summary> | ||
| public string Name { get; set; } | ||
| } | ||
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -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 | ||
| ); | ||
| } | ||
|
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); | ||
| } | ||
| } | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -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); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.