private async Task <IEnumerable <SellbriteOrder> > GetOrdersByPageAsync(DateTime startDateUtc, DateTime endDateUtc, int page, int limit, CancellationToken token) { var mark = Mark.CreateNew(); var orders = new List <SellbriteOrder>(); var url = string.Format("{0}?min_ordered_at={1}&max_ordered_at={2}&page={3}&limit={4}", SellbriteEndPoint.OrdersUrl, startDateUtc.FromUtcToRFC3339(), endDateUtc.FromUtcToRFC3339(), page, limit); try { SellbriteLogger.LogStarted(this.CreateMethodCallInfo(url, mark, additionalInfo: this.AdditionalLogInfo())); var response = await base.GetAsync <Order[]>(url, token, mark).ConfigureAwait(false); if (response.Length != 0) { orders.AddRange(response.Select(o => o.ToSvOrder())); } SellbriteLogger.LogEnd(this.CreateMethodCallInfo(url, mark, methodResult: orders.ToJson(), additionalInfo: this.AdditionalLogInfo())); } catch (Exception ex) { var sellbriteException = new SellbriteException(this.CreateMethodCallInfo(url, mark, additionalInfo: this.AdditionalLogInfo()), ex); SellbriteLogger.LogTraceException(sellbriteException); throw sellbriteException; } return(orders); }
private async Task <IEnumerable <SellbriteProduct> > GetProductsByPageAsync(DateTime startDateUtc, DateTime endDateUtc, int page, int limit, CancellationToken token) { var mark = Mark.CreateNew(); var products = new List <SellbriteProduct>(); var url = string.Format("{0}?min_modified_at={1}&max_modified_at={2}&page={3}&limit={4}", SellbriteEndPoint.ProductsUrl, startDateUtc.FromUtcToRFC3339(), endDateUtc.FromUtcToRFC3339(), page, limit); try { SellbriteLogger.LogStarted(this.CreateMethodCallInfo(url, mark, additionalInfo: this.AdditionalLogInfo())); var response = await base.GetAsync(url, token).ConfigureAwait(false); products = JsonConvert.DeserializeObject <IEnumerable <Product> >(response).Select(p => p.ToSvProduct()).ToList(); SellbriteLogger.LogEnd(this.CreateMethodCallInfo(url, mark, methodResult: products.ToJson(), additionalInfo: this.AdditionalLogInfo())); } catch (Exception ex) { var sellbriteException = new SellbriteException(this.CreateMethodCallInfo(url, mark, additionalInfo: this.AdditionalLogInfo()), ex); SellbriteLogger.LogTraceException(sellbriteException); throw sellbriteException; } return(products); }