-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #237 from Mangopay/feature/add-virtual-accounts-an…
…d-event-types Check DTOs for VirtualAccounts
- Loading branch information
Showing
18 changed files
with
366 additions
and
2 deletions.
There are no files selected for viewing
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,68 @@ | ||
using System.Threading.Tasks; | ||
using NUnit.Framework; | ||
|
||
namespace MangoPay.SDK.Tests | ||
{ | ||
[TestFixture] | ||
public class ApiVirtualAccountsTest : BaseTest | ||
{ | ||
[Test] | ||
public async Task Test_VirtualAccounts_Create() | ||
{ | ||
var wallet = await GetJohnsWallet(); | ||
var virtualAccount = await GetJohnsVirtualAccount(); | ||
|
||
Assert.IsNotNull(virtualAccount); | ||
Assert.AreEqual(virtualAccount.WalletId, wallet.Id); | ||
} | ||
|
||
[Test] | ||
public async Task Test_VirtualAccounts_Get() | ||
{ | ||
var virtualAccount = await GetJohnsVirtualAccount(); | ||
var wallet = await GetJohnsWallet(); | ||
|
||
var fetchedVirtualAccount = await Api.VirtualAccounts.GetAsync(wallet.Id, virtualAccount.Id); | ||
|
||
Assert.IsNotNull(fetchedVirtualAccount); | ||
Assert.AreEqual(fetchedVirtualAccount.Id, virtualAccount.Id); | ||
} | ||
|
||
[Test] | ||
public async Task Test_VirtualAccounts_GetAll() | ||
{ | ||
var virtualAccount = await GetJohnsVirtualAccount(); | ||
var wallet = await GetJohnsWallet(); | ||
|
||
var virtualAccounts = await Api.VirtualAccounts.GetAllAsync(wallet.Id); | ||
|
||
Assert.IsNotNull(virtualAccounts); | ||
Assert.AreEqual(1, virtualAccounts.Count); | ||
Assert.AreEqual(virtualAccount.Id, virtualAccounts[0].Id); | ||
} | ||
|
||
[Test] | ||
public async Task Test_VirtualAccounts_GetAvailabilities() | ||
{ | ||
var availabilities = await Api.VirtualAccounts.GetAvailabilitiesAsync(); | ||
|
||
Assert.IsNotNull(availabilities); | ||
Assert.IsTrue(availabilities.Collection.GetType().IsArray); | ||
Assert.IsTrue(availabilities.UserOwned.GetType().IsArray); | ||
Assert.IsNotEmpty(availabilities.Collection); | ||
Assert.IsNotEmpty(availabilities.UserOwned); | ||
} | ||
|
||
[Test] | ||
public async Task Test_VirtualAccounts_Deactivate() | ||
{ | ||
var virtualAccount = await GetJohnsVirtualAccount(); | ||
var wallet = await GetJohnsWallet(); | ||
var deactivatedVirtualAccount = await Api.VirtualAccounts.DeactivateAsync(wallet.Id, virtualAccount.Id); | ||
|
||
Assert.AreEqual(virtualAccount.Id, deactivatedVirtualAccount.Id); | ||
Assert.IsFalse(deactivatedVirtualAccount.Active); | ||
Assert.AreEqual("CLOSED", deactivatedVirtualAccount.Status); | ||
} | ||
} | ||
} |
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
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
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,58 @@ | ||
using System.Threading.Tasks; | ||
using MangoPay.SDK.Core.Enumerations; | ||
using MangoPay.SDK.Entities; | ||
using MangoPay.SDK.Entities.GET; | ||
using MangoPay.SDK.Entities.POST; | ||
using MangoPay.SDK.Entities.PUT; | ||
|
||
namespace MangoPay.SDK.Core.APIs | ||
{ | ||
/// <summary>API for VirtualAccounts</summary> | ||
public class ApiVirtualAccounts : ApiBase | ||
{ | ||
/// <summary>Instantiates new ApiVirtualAccounts object.</summary> | ||
/// <param name="root">Root/parent instance that holds the OAuthToken and Configuration instance.</param> | ||
public ApiVirtualAccounts(MangoPayApi root) : base(root) { } | ||
|
||
public async Task<VirtualAccountDTO> CreateAsync(string walletId, VirtualAccountPostDTO virtualAccount, string idempotentKey = null) | ||
{ | ||
return await this.CreateObjectAsync<VirtualAccountDTO, VirtualAccountPostDTO>(MethodKey.VirtualAccountCreate, virtualAccount, idempotentKey, entitiesId: walletId); | ||
} | ||
|
||
/// <summary>Gets given VirtualAccount associated with wallet</summary> | ||
/// <param name="walletId">Wallet identifier.</param> | ||
/// <param name="virtualAccountId">Virtual Account identifier.</param> | ||
/// <returns>VirtualAccount Object</returns> | ||
public async Task<VirtualAccountDTO> GetAsync(string walletId, string virtualAccountId) | ||
{ | ||
return await this.GetObjectAsync<VirtualAccountDTO>(MethodKey.VirtualAccountGet, entitiesId: new[] { walletId, virtualAccountId }); | ||
} | ||
|
||
/// <summary>Gets all VirtualAccounts associated with wallet</summary> | ||
/// <param name="walletId">Wallet identifier.</param> | ||
/// <param name="pagination">Pagination.</param> | ||
/// <param name="filter">Filter.</param> | ||
/// <param name="sort">Sort.</param> | ||
/// <returns>All related Virtual Account Object</returns> | ||
public async Task<ListPaginated<VirtualAccountDTO>> GetAllAsync(string walletId, Pagination pagination = null, FilterTransactions filter = null, Sort sort = null) | ||
{ | ||
return await this.GetListAsync<VirtualAccountDTO>(MethodKey.VirtualAccountGetAll, pagination, sort, filter?.GetValues(), entitiesId: walletId); | ||
} | ||
|
||
/// <summary>Deactivates given VirtualAccount</summary> | ||
/// <param name="walletId">Wallet identifier.</param> | ||
/// <param name="virtualAccountId">Virtual Account identifier.</param> | ||
/// <returns>Deactivated VirtualAccount Object</returns> | ||
public async Task<VirtualAccountDTO> DeactivateAsync(string walletId, string virtualAccountId) | ||
{ | ||
return await this.UpdateObjectAsync<VirtualAccountDTO, VirtualAccountPutDTO>(methodKey: MethodKey.VirtualAccountDeactivate, entity: new VirtualAccountPutDTO(), entitiesId: new[] { walletId, virtualAccountId }); | ||
} | ||
|
||
/// <summary>Gets all virtual account availabilities.</summary> | ||
/// <returns>VirtualAccountAvailabilities Object</returns> | ||
public async Task<VirtualAccountAvailabilitiesDTO> GetAvailabilitiesAsync() | ||
{ | ||
return await this.GetObjectAsync<VirtualAccountAvailabilitiesDTO>(MethodKey.VirtualAccountGetAvailabilities); | ||
} | ||
} | ||
} |
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
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
17 changes: 17 additions & 0 deletions
17
MangoPay.SDK/Entities/GET/VirtualAccountAvailabilitiesDTO.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,17 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace MangoPay.SDK.Entities.GET | ||
{ | ||
public class VirtualAccountAvailabilitiesDTO : EntityBase | ||
{ | ||
public VirtualAccountAvailabilitiesDTO() | ||
{ | ||
Collection = new List<VirtualAccountAvailability>(); | ||
UserOwned = new List<VirtualAccountAvailability>(); | ||
} | ||
|
||
public List<VirtualAccountAvailability> Collection; | ||
|
||
public List<VirtualAccountAvailability> UserOwned; | ||
} | ||
} |
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,27 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace MangoPay.SDK.Entities.GET | ||
{ | ||
public class VirtualAccountDTO : EntityBase | ||
{ | ||
public string WalletId { get; set; } | ||
|
||
public string CreditedUserId { get; set; } | ||
|
||
public string VirtualAccountPurpose { get; set; } | ||
|
||
public string Country { get; set; } | ||
|
||
public string Status { get; set; } | ||
|
||
public bool Active { get; set; } | ||
|
||
public string AccountOwner { get; set; } | ||
|
||
public LocalAccountDetails LocalAccountDetails { get; set; } | ||
|
||
public List<InternationalAccountDetails> InternationalAccountDetails { get; set; } | ||
|
||
public VirtualAccountCapabilities Capabilities { get; set; } | ||
} | ||
} |
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,9 @@ | ||
namespace MangoPay.SDK.Entities | ||
{ | ||
public class InternationalAccount | ||
{ | ||
public string IBAN { get; set; } | ||
|
||
public string BIC { get; set; } | ||
} | ||
} |
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,9 @@ | ||
namespace MangoPay.SDK.Entities | ||
{ | ||
public class InternationalAccountDetails | ||
{ | ||
public VirtualAccountAddress Address { get; set; } | ||
|
||
public InternationalAccount Account { get; set; } | ||
} | ||
} |
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,9 @@ | ||
namespace MangoPay.SDK.Entities | ||
{ | ||
public class LocalAccount | ||
{ | ||
public string AccountNumber { get; set; } | ||
|
||
public string SortCode { get; set; } | ||
} | ||
} |
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,9 @@ | ||
namespace MangoPay.SDK.Entities | ||
{ | ||
public class LocalAccountDetails | ||
{ | ||
public VirtualAccountAddress Address { get; set; } | ||
|
||
public LocalAccount Account { get; set; } | ||
} | ||
} |
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,32 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace MangoPay.SDK.Entities.POST | ||
{ | ||
public class VirtualAccountPostDTO : EntityPostBase | ||
{ | ||
public VirtualAccountPostDTO() | ||
{ | ||
|
||
} | ||
|
||
public string WalletId { get; set; } | ||
|
||
public string CreditedUserId { get; set; } | ||
|
||
public string VirtualAccountPurpose { get; set; } | ||
|
||
public string Country { get; set; } | ||
|
||
public string Status { get; set; } | ||
|
||
public bool Active { get; set; } | ||
|
||
public string AccountOwner { get; set; } | ||
|
||
public LocalAccountDetails LocalAccountDetails { get; set; } | ||
|
||
public List<InternationalAccountDetails> InternationalAccountDetails { get; set; } | ||
|
||
public VirtualAccountCapabilities Capabilities { get; set; } | ||
} | ||
} |
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,7 @@ | ||
namespace MangoPay.SDK.Entities.PUT | ||
{ | ||
public class VirtualAccountPutDTO : EntityPutBase | ||
{ | ||
|
||
} | ||
} |
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,29 @@ | ||
namespace MangoPay.SDK.Entities | ||
{ | ||
public class VirtualAccountAddress | ||
{ | ||
public VirtualAccountAddress( | ||
string streetName, | ||
string postCode, | ||
string townName, | ||
string countrySubDivision, | ||
string country) | ||
{ | ||
StreetName = streetName; | ||
PostCode = postCode; | ||
TownName = townName; | ||
CountrySubDivision = countrySubDivision; | ||
Country = country; | ||
} | ||
|
||
private string StreetName { get; set; } | ||
|
||
private string PostCode { get; set; } | ||
|
||
private string TownName { get; set; } | ||
|
||
private string CountrySubDivision { get; set; } | ||
|
||
private string Country { get; set; } | ||
} | ||
} |
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,27 @@ | ||
using System.Collections.Generic; | ||
using MangoPay.SDK.Core.Enumerations; | ||
|
||
namespace MangoPay.SDK.Entities | ||
{ | ||
public class VirtualAccountAvailability | ||
{ | ||
|
||
public VirtualAccountAvailability() | ||
{ | ||
Currencies = new List<CurrencyIso>(); | ||
} | ||
|
||
public VirtualAccountAvailability(string country, bool available) | ||
{ | ||
Country = country; | ||
Available = available; | ||
Currencies = new List<CurrencyIso>(); | ||
} | ||
|
||
private string Country { get; set; } | ||
|
||
private bool Available { get; set; } | ||
|
||
public List<CurrencyIso> Currencies; | ||
} | ||
} |
Oops, something went wrong.