Endpoints which enumerate objects support time-based and cursor-based pagination.
Ejemplo n.º 1
0
        /// <summary>
        /// Returns a list of transactions on the user’s account.
        /// </summary>
        /// <param name="accountId">The account to retrieve transactions from.</param>
        /// <param name="expand">Can be merchant.</param>
        /// <param name="paginationOptions">This endpoint can be paginated.</param>
        public async Task<IList<Transaction>> GetTransactionsAsync(string accountId, string expand = null, PaginationOptions paginationOptions = null)
        {
            if (accountId == null) throw new ArgumentNullException(nameof(accountId));

            var sb = new StringBuilder($"transactions?account_id={accountId}{paginationOptions}");
            if (expand != null)
            {
                sb.Append($"&expand[]={expand}");
            }

            HttpResponseMessage response = await _httpClient.GetAsync(sb.ToString());
            string body = await response.Content.ReadAsStringAsync();

            if (!response.IsSuccessStatusCode)
            {
                throw MondoException.CreateFromApiResponse(response, body);
            }

            return JsonConvert.DeserializeObject<ListTransactionsResponse>(body).Transactions;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns a list of transactions on the user’s account.
        /// </summary>
        /// <param name="accountId">The account to retrieve transactions from.</param>
        /// <param name="expand">Can be merchant.</param>
        /// <param name="paginationOptions">This endpoint can be paginated.</param>
        public async Task <IList <Transaction> > GetTransactionsAsync(string accountId, string expand = null, PaginationOptions paginationOptions = null)
        {
            if (accountId == null)
            {
                throw new ArgumentNullException(nameof(accountId));
            }

            var sb = new StringBuilder($"transactions?account_id={accountId}{paginationOptions}");

            if (expand != null)
            {
                sb.Append($"&expand[]={expand}");
            }

            HttpResponseMessage response = await _httpClient.GetAsync(sb.ToString());

            string body = await response.Content.ReadAsStringAsync();

            if (!response.IsSuccessStatusCode)
            {
                throw MondoException.CreateFromApiResponse(response, body);
            }

            return(JsonConvert.DeserializeObject <ListTransactionsResponse>(body).Transactions);
        }