private GetSellerListResponse DeserializeResult(string responseContent) { var result = new GetSellerListResponse(); var serializer = new XmlSerializer(typeof(GetSellerListResponse)); using (var reader = new StringReader(responseContent)) { result = (GetSellerListResponse)serializer.Deserialize(reader); } return(result); }
public async Task <GetSellerListResponse> GetSellerListAsync(DateTime timeFrom, DateTime timeTo, GetSellerListTimeRangeEnum getSellerListTimeRangeEnum, string mark) { var items = new GetSellerListResponse(); var recordsPerPage = this._itemsPerPage; var pageNumber = 1; var hasMoreItems = false; do { var body = this.CreateGetSellerListRequestBody(timeFrom, timeTo, getSellerListTimeRangeEnum, recordsPerPage, pageNumber); var headers = CreateGetSellerListRequestHeadersWithApiCallName(); await ActionPolicies.GetAsync.Do(async() => { var webRequest = await this.CreateEbayStandartPostRequestAsync(this._endPoint, headers, body, mark, CancellationToken.None).ConfigureAwait(false); using (var memStream = await this._webRequestServices.GetResponseStreamAsync(webRequest, mark, CancellationToken.None).ConfigureAwait(false)) { var getSellerListResponse = new EbayGetSallerListResponseParser().Parse(memStream); if (getSellerListResponse != null) { if (getSellerListResponse.Errors != null) { items.Errors = getSellerListResponse.Errors; return; } hasMoreItems = getSellerListResponse.HasMoreItems; if (getSellerListResponse.Items != null) { items.Items.AddRange(getSellerListResponse.Items); } } } }).ConfigureAwait(false); pageNumber++; } while(hasMoreItems); return(items); }
private async Task <List <Item> > ProcessResults(GetSellerListResponse result) { // Filter categories from contentful var categoryFilters = await _contentfulService.GetEbayCategoryFilters(); var includeCategories = categoryFilters.Where(x => x.IncludeOrIgnore).Select(x => x.Category).ToList(); var excludeCategoris = categoryFilters.Where(x => !x.IncludeOrIgnore).Select(x => x.Category).ToList(); foreach (var item in result.ItemArray.Items) { // Hide all items by default item.Hide = true; // Get list of cagtegories var categories = item.PrimaryCategory.CategoryName.Split(':').ToList(); // Show items that are in an include category foreach (var include in includeCategories) { if (categories.Contains(include)) { item.Hide = false; } } // Hide any that are also in an excluded category foreach (var exclude in excludeCategoris) { if (categories.Contains(exclude)) { item.Hide = true; } } } result.ItemArray.Items.RemoveAll(x => x.Hide); return(result.ItemArray.Items); }