-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
806 additions
and
93 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
src/NoFrixion.MoneyMoov/Mapping/AccountIdentifierMappers.cs
This file contains 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,46 @@ | ||
// ----------------------------------------------------------------------------- | ||
// Filename: AccountIdentifierMapper.cs | ||
// | ||
// Description: Mapping extensions for AccountIdentifier model | ||
// Author(s): | ||
// [email protected] ([email protected]) | ||
// | ||
// History: | ||
// 16 04 2024 Saurav Maiti Created, Harcourt street, Dublin, Ireland. | ||
// | ||
// License: | ||
// MIT. | ||
// ----------------------------------------------------------------------------- | ||
|
||
using NoFrixion.MoneyMoov.Models; | ||
|
||
namespace NoFrixion.MoneyMoov; | ||
|
||
public static class AccountIdentifierMapper | ||
{ | ||
public static AccountIdentifier ToAccountIdentifier(this AccountIdentifierCreate accountIdentifierCreate, CurrencyTypeEnum currency) | ||
{ | ||
return new AccountIdentifier | ||
{ | ||
AccountNumber = accountIdentifierCreate.AccountNumber, | ||
IBAN = accountIdentifierCreate.IBAN, | ||
BIC = accountIdentifierCreate.BIC, | ||
SortCode = accountIdentifierCreate.SortCode, | ||
BitcoinAddress = accountIdentifierCreate.BitcoinAddress, | ||
Currency = accountIdentifierCreate.Currency ?? currency | ||
}; | ||
} | ||
|
||
public static AccountIdentifierCreate ToAccountIdentifierCreate(this AccountIdentifier accountIdentifier) | ||
{ | ||
return new AccountIdentifierCreate | ||
{ | ||
AccountNumber = accountIdentifier.AccountNumber, | ||
IBAN = accountIdentifier.IBAN, | ||
BIC = accountIdentifier.BIC, | ||
SortCode = accountIdentifier.SortCode, | ||
BitcoinAddress = accountIdentifier.BitcoinAddress, | ||
Currency = accountIdentifier.Currency | ||
}; | ||
} | ||
} |
This file contains 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,44 @@ | ||
// ----------------------------------------------------------------------------- | ||
// Filename: CounterpartyMapper.cs | ||
// | ||
// Description: Mapping extensions for Counterparty model | ||
// Author(s): | ||
// [email protected] ([email protected]) | ||
// | ||
// History: | ||
// 16 04 2024 Saurav Maiti Created, Harcourt street, Dublin, Ireland. | ||
// | ||
// License: | ||
// MIT. | ||
// ----------------------------------------------------------------------------- | ||
|
||
using NoFrixion.MoneyMoov.Models; | ||
|
||
namespace NoFrixion.MoneyMoov; | ||
|
||
public static class CounterpartyMapper | ||
{ | ||
public static Counterparty ToCounterparty(this CounterpartyCreate counterpartyCreate, CurrencyTypeEnum currency) | ||
{ | ||
return new Counterparty | ||
{ | ||
AccountID = counterpartyCreate.AccountID, | ||
Name = counterpartyCreate.Name, | ||
EmailAddress = counterpartyCreate.EmailAddress, | ||
PhoneNumber = counterpartyCreate.PhoneNumber, | ||
Identifier = counterpartyCreate.Identifier?.ToAccountIdentifier(currency) | ||
}; | ||
} | ||
|
||
public static CounterpartyCreate ToCounterpartyCreate(this Counterparty counterparty) | ||
{ | ||
return new CounterpartyCreate | ||
{ | ||
AccountID = counterparty.AccountID, | ||
Name = counterparty.Name, | ||
EmailAddress = counterparty.EmailAddress, | ||
PhoneNumber = counterparty.PhoneNumber, | ||
Identifier = counterparty.Identifier?.ToAccountIdentifierCreate() | ||
}; | ||
} | ||
} |
This file contains 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
146 changes: 146 additions & 0 deletions
146
src/NoFrixion.MoneyMoov/Models/Account/AccountIdentifierCreate.cs
This file contains 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,146 @@ | ||
// ----------------------------------------------------------------------------- | ||
// Filename: AccountIdentifierCreate.cs | ||
// | ||
// Description: Account identifier Create model | ||
// Author(s): | ||
// [email protected] ([email protected]) | ||
// | ||
// History: | ||
// 16 04 2024 Saurav Maiti Created, Harcourt street, Dublin, Ireland. | ||
// | ||
// License: | ||
// MIT. | ||
// ----------------------------------------------------------------------------- | ||
|
||
namespace NoFrixion.MoneyMoov.Models; | ||
|
||
#nullable disable | ||
|
||
public class AccountIdentifierCreate | ||
{ | ||
|
||
/// <summary> | ||
/// The currency for the account. | ||
/// </summary> | ||
public CurrencyTypeEnum? Currency { get; set; } | ||
|
||
/// <summary> | ||
/// The Bank Identifier Code for an IBAN. | ||
/// </summary> | ||
private string _bic; | ||
public string BIC | ||
{ | ||
get => _bic; | ||
set | ||
{ | ||
if (!string.IsNullOrEmpty(value)) | ||
{ | ||
_bic = value.Trim().Replace(" ", string.Empty); | ||
} | ||
else | ||
{ | ||
_bic = value; | ||
} | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// The International Bank Account Number for the identifier. Only applicable | ||
/// for IBAN identifiers. | ||
/// </summary> | ||
private string _iban; | ||
public string IBAN | ||
{ | ||
get => _iban; | ||
set | ||
{ | ||
if (!string.IsNullOrEmpty(value)) | ||
{ | ||
_iban = value.Trim().Replace(" ", string.Empty); | ||
} | ||
else | ||
{ | ||
_iban = value; | ||
} | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// The account Sort Code. Only applicable for SCAN identifiers. | ||
/// </summary> | ||
private string _sortCode; | ||
public string SortCode | ||
{ | ||
get => _sortCode; | ||
set | ||
{ | ||
if (!string.IsNullOrEmpty(value)) | ||
{ | ||
_sortCode = value.Trim().Replace(" ", string.Empty); | ||
} | ||
else | ||
{ | ||
_sortCode = value; | ||
} | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Bank account number. Only applicable for SCAN identifiers. | ||
/// </summary> | ||
private string _accountNumber; | ||
public string AccountNumber | ||
{ | ||
get => _accountNumber; | ||
set | ||
{ | ||
if (!string.IsNullOrEmpty(value)) | ||
{ | ||
_accountNumber = value.Trim().Replace(" ", string.Empty); | ||
} | ||
else | ||
{ | ||
_accountNumber = value; | ||
} | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Bitcoin address destination. | ||
/// </summary> | ||
private string _bitcoinAddress; | ||
public string BitcoinAddress | ||
{ | ||
get => _bitcoinAddress; | ||
set | ||
{ | ||
if (!string.IsNullOrEmpty(value)) | ||
{ | ||
_bitcoinAddress = value.Trim(); | ||
} | ||
else | ||
{ | ||
_bitcoinAddress = value; | ||
} | ||
} | ||
} | ||
|
||
public virtual Dictionary<string, string> ToDictionary(string keyPrefix) | ||
{ | ||
return new Dictionary<string, string> | ||
{ | ||
{ keyPrefix + nameof(Currency), Currency.ToString()}, | ||
{ keyPrefix + nameof(BIC), BIC ?? string.Empty}, | ||
{ keyPrefix + nameof(IBAN), IBAN ?? string.Empty}, | ||
{ keyPrefix + nameof(SortCode), SortCode ?? string.Empty}, | ||
{ keyPrefix + nameof(AccountNumber), AccountNumber ?? string.Empty}, | ||
{ keyPrefix + nameof(BitcoinAddress), BitcoinAddress ?? string.Empty} | ||
}; | ||
} | ||
|
||
/// <summary> | ||
/// Summary of the account identifier's most important properties. | ||
/// </summary> | ||
public string Summary => | ||
$"IBAN: {IBAN}, BIC: {BIC}, SortCode: {SortCode}, AccountNumber: {AccountNumber}, BitcoinAddress: {BitcoinAddress}"; | ||
} |
Oops, something went wrong.