Exemple #1
0
        public async Task <RootObject> GetOrdersAsync(DateTime updatedFrom, DateTime updatedTo, PagingModel page, Mark mark = null)
        {
            var parameters = new SearchCriteria()
            {
                filter_groups = new List <FilterGroup>()
                {
                    new FilterGroup()
                    {
                        filters = new List <Filter>()
                        {
                            new Filter("updated_at", updatedFrom.ToRestParameterString(), Filter.ConditionType.From)
                        }
                    },
                    new FilterGroup()
                    {
                        filters = new List <Filter>()
                        {
                            new Filter("updated_at", updatedTo.ToRestParameterString(), Filter.ConditionType.To)
                        }
                    }
                },
                current_page = page.CurrentPage,
                page_size    = page.ItemsPerPage,
            };

            var webRequest = ( WebRequest )WebRequest.Create()
                             .Method(MagentoWebRequestMethod.Get)
                             .Path(MagentoServicePath.CreateOrdersServicePath())
                             .Parameters(parameters)
                             .AuthToken(this.Token)
                             .Url(this.Url);

            return(await ActionPolicies.RepeatOnChannelProblemAsync.Get(async() =>
            {
                using (var v = await webRequest.RunAsync(mark).ConfigureAwait(false))
                {
                    return JsonConvert.DeserializeObject <RootObject>(new StreamReader(v, Encoding.UTF8).ReadToEnd());
                }
            }).ConfigureAwait(false));
        }
Exemple #2
0
        public async Task <RootObject> GetOrdersAsync(IEnumerable <string> ids, PagingModel page)
        {
            var idsList = ids as IList <string> ?? ids.ToList();

            if (ids == null || !idsList.Any())
            {
                return(default(RootObject));
            }

            var parameters = new SearchCriteria()
            {
                filter_groups = new List <FilterGroup>()
                {
                    new FilterGroup()
                    {
                        filters = new List <Filter>()
                        {
                            new Filter("increment_id", string.Join(",", idsList), Filter.ConditionType.In)
                        }
                    }
                },
                current_page = page.CurrentPage,
                page_size    = page.ItemsPerPage,
            };

            var webRequest = ( WebRequest )WebRequest.Create()
                             .Method(MagentoWebRequestMethod.Get)
                             .Path(MagentoServicePath.CreateOrdersServicePath())
                             .Parameters(parameters)
                             .AuthToken(this.Token)
                             .Url(this.Url);

            return(await ActionPolicies.RepeatOnChannelProblemAsync.Get(async() =>
            {
                using (var v = await webRequest.RunAsync(Mark.CreateNew()).ConfigureAwait(false))
                {
                    return JsonConvert.DeserializeObject <RootObject>(new StreamReader(v, Encoding.UTF8).ReadToEnd());
                }
            }));
        }