/// <summary> /// Get a list of Transactions pages that satisfy a time-based Transaction query. /// </summary> /// <param name="accountID">Account identifier</param> /// <param name="parameters">The parameters for the request</param> /// <returns></returns> public static async Task <List <ITransaction> > GetTransactionsAsync(string accountID, TransactionsParameters parameters) { var requestParams = ConvertToDictionary(parameters); string type = null; if (parameters.type != null) { type = GetCommaSeparatedString(parameters.type); requestParams.Add("type", type); } string uri = ServerUri(EServer.Account) + "accounts/" + accountID + "/transactions"; var pagesResponse = await MakeRequestAsync <TransactionPagesResponse, TransactionPagesErrorResponse>(uri, "GET", requestParams); var transactions = new List <ITransaction>(); foreach (string page in pagesResponse.pages) { var pageParams = new TransactionsByIdRangeParameters { page = page, type = parameters.type }; transactions.AddRange(await GetTransactionsByIdRangeAsync(accountID, pageParams)); await Task.Delay(parameters.pagingDelayMilliSeconds); // throttle these a bit } return(transactions); }
/// <summary> /// Get a range of Transactions for an Account based on the Transaction IDs /// http://developer.oanda.com/rest-live-v20/transaction-ep/ /// </summary> /// <param name="accountID">Account identifier</param> /// <param name="parameters">The parameters for the request</param> /// <returns></returns> public static async Task <List <ITransaction> > GetTransactionsByIdRangeAsync(string accountID, TransactionsByIdRangeParameters parameters) { string uri = null; TransactionsResponse response = null; if (!string.IsNullOrEmpty(parameters.page)) { uri = parameters.page; response = await MakeRequestAsync <TransactionsResponse>(uri); } else { uri = ServerUri(EServer.Account) + "accounts/" + accountID + "/transactions/idrange"; var requestParams = ConvertToDictionary(parameters); if (parameters.type?.Count > 0) { requestParams.Add("type", GetCommaSeparatedString(parameters.type)); } response = await MakeRequestAsync <TransactionsByIdRangeResponse, TransactionsByIdRangeErrorResponse>(uri, "GET", requestParams); } return(response.transactions); }