Хочу реализовать программу для получения баланса и последних платежей с QIWI. Использую библиотеку QiwiApi, но столкнулся с проблемой что не совсем понимаю как правильно передать параметр Source[].
Метод который нужен:
public static async Task<PaymentHistoryResponse> PaymentHistoryAsync(string walletId, int rows, Operation operation, Source[] sources, DateTime? startDate = null, DateTime? endDate = null, DateTime? nextTxnDate = null, long? nextTxnId = null)
{
if (!Initialized) throw new NotInitializedException();
if (!ValidatePhoneNumber(walletId)) throw new ArgumentException("Invalid wallet id.");
var query = new Dictionary<string, object>
{
{"rows", rows },
{"operation", operation.ToString() }
};
for (int i = 0; i < sources.Length; i++)
query.Add("source[" + i + "]", sources[i].ToString());
if (startDate != null && endDate != null)
{
query.Add("startDate", startDate.Value.ToString("s") + "Z");
query.Add("endDate", endDate.Value.ToString("s") + "Z");
}
if(nextTxnDate != null && nextTxnId != null)
{
query.Add("nextTxnDate", nextTxnDate.Value.ToString("s") + "Z");
query.Add("nextTxnId", nextTxnId);
}
var response = await ApiCallAsync("payment-history/v1/persons/" + walletId + "/payments", query);
if (response.IsSuccessStatusCode)
{
var data = JsonConvert.DeserializeObject<PaymentHistoryResponse>(await response.Content.ReadAsStringAsync());
return data;
}
switch ((int)response.StatusCode)
{
case 401: throw new UnauthorizedException();
case 404: throw new TransactionNotFoundException();
}
response.EnsureSuccessStatusCode();
return null;
}
Класс Source:
public enum Source
{
/// <summary>
/// Russian Ruble Qiwi Wallet.
/// </summary>
QW_RUB,
/// <summary>
/// United States Dollar Qiwi Wallet.
/// </summary>
QW_USD,
/// <summary>
/// Euro Qiwi Wallet.
/// </summary>
QW_EUR,
/// <summary>
/// Binded card.
/// </summary>
CARD,
/// <summary>
/// Mobile phone balance.
/// </summary>
MK
}