Copy
using OneKhusa.SDK;
using OneKhusa.SDK.Models.Merchants.MerchantAccounts;
using OneKhusa.SDK.Models.Constants.Shared;
//code omitted for brevity
OneKhusaResponse<List<GetMerchantsResponse>> response = await client
.Merchants
.Accounts
.GetAccountsAsync(new GetMerchantsRequest
{
OrganisationId = "ORG123456789",
IsIncremental = false,
PageNumber = 1,
NumberOfReturnedRows = 20,
SearchBy = SearchFields.AccountName,
SearchText = string.Empty
});
if (response is { IsSuccess: true, Data: not null })
{
foreach (var account in response.Data)
{
Console.WriteLine($"""
OrganisationId: {account.OrganisationId};
MerchantAccountNumber: {account.MerchantAccountNumber};
AccountName: {account.AccountName};
AccountBalance: {account.AccountBalance};
StatusCode: {account.StatusCode};
StatusName: {account.StatusName};
LevelNumber: {account.LevelNumber};
LevelName: {account.LevelName};
CurrencyCode: {account.CurrencyCode};
CapturedBy: {account.CapturedBy};
DateCreated: {account.DateCreated}
""");
}
Console.ReadLine();
return;
}
//it means an error has occurred: RFC7807 compliant error object
Console.WriteLine($"""
Type: {response.Error?.Type};
Title: {response.Error?.Title};
Detail: {response.Error?.Detail};
ErrorCode: {response.Error?.ErrorCode};
Status: {response.Error?.Status};
Instance: {response.Error?.Instance};
Errors: {string.Join(";", response.Error?.Errors ?? [])}
""");
Console.ReadLine();