public IEnumerable <SalesProduct> GetSalesProducts() { var uri = new Uri($"{this.rootUri}/products/sales-products", UriKind.RelativeOrAbsolute); var response = this.restClient.Get( CancellationToken.None, uri, new Dictionary <string, string>(), DefaultHeaders.JsonGetHeaders()).Result; if (response.StatusCode != HttpStatusCode.OK) { throw new ProxyException($"Error trying to get sales products"); } var json = new JsonSerializer(); var results = json.Deserialize <IEnumerable <SalesProductResource> >(response.Value); return(results.Select(p => new SalesProduct(p.Name) { Id = p.Id, Description = p.Description, ProductRange = p.ProductRange == null ? null : new ProductRange(p.ProductRange.Name) { Id = p.ProductRange.Id }, PhasedOutOn = string.IsNullOrEmpty(p.PhasedOutOn) ? (DateTime?)null : DateTime.Parse(p.PhasedOutOn) })); }
public IEnumerable <SalesArticle> GetByDiscountFamily(string discountFamily, bool includePhasedOut = false) { var uri = new Uri($"{this.rootUri}/linnapps-api/sales-articles", UriKind.RelativeOrAbsolute); var response = this.restClient.Get( CancellationToken.None, uri, new Dictionary <string, string>(), DefaultHeaders.JsonGetHeaders()).Result; if (response.StatusCode != HttpStatusCode.OK) { throw new ProxyException($"Error trying to get sales articles"); } var json = new JsonSerializer(); var resources = json.Deserialize <IEnumerable <SalesArticleExternalResource> >(response.Value); return(resources .Where(a => a.DiscountFamily == discountFamily && a.PhaseOutDate.HasValue == includePhasedOut) .Select(r => new SalesArticle { ArticleNumber = r.ArticleNumber, InvoiceDescription = r.InvoiceDescription, EanCode = r.EanCode, CartonType = r.CartonType })); }
public IEnumerable <Carton> GetCartons() { var uri = new Uri($"{this.rootUri}/products/cartons", UriKind.RelativeOrAbsolute); var response = this.restClient.Get( CancellationToken.None, uri, new Dictionary <string, string>(), DefaultHeaders.JsonGetHeaders()).Result; if (response.StatusCode != HttpStatusCode.OK) { throw new ProxyException($"Error trying to get cartons"); } var json = new JsonSerializer(); return(json.Deserialize <IEnumerable <Carton> >(response.Value)); }
public IEnumerable <ProductionTriggerLevel> GetAll() { var uri = new Uri( $"{this.rootUri}/production/maintenance/production-trigger-levels", UriKind.RelativeOrAbsolute); var response = this.restClient.Get( CancellationToken.None, uri, new Dictionary <string, string>(), DefaultHeaders.JsonGetHeaders()).Result; if (response.StatusCode != HttpStatusCode.OK) { throw new ProxyException($"Error trying to receive production trigger levels"); } var json = new JsonSerializer(); return(json.Deserialize <IEnumerable <ProductionTriggerLevel> >(response.Value)); }
public IEnumerable <SalesArticle> Search(string searchTerm) { var uri = new Uri( $"{this.rootUri}/linnapps-api/sales-articles/search?searchTerm={searchTerm}", UriKind.RelativeOrAbsolute); var response = this.restClient.Get( CancellationToken.None, uri, new Dictionary <string, string>(), DefaultHeaders.JsonGetHeaders()).Result; if (response.StatusCode != HttpStatusCode.OK) { throw new ProxyException($"Error trying to execute search"); } var json = new JsonSerializer(); return(json.Deserialize <IEnumerable <SalesArticle> >(response.Value).Take(20)); }
public IEnumerable <ProductRange> GetProductRanges() { var uri = new Uri($"{this.rootUri}/products/product-ranges", UriKind.RelativeOrAbsolute); var response = this.restClient.Get( CancellationToken.None, uri, new Dictionary <string, string>(), DefaultHeaders.JsonGetHeaders()).Result; if (response.StatusCode != HttpStatusCode.OK) { throw new ProxyException($"Error trying to get product ranges"); } var json = new JsonSerializer(); var results = json.Deserialize <IEnumerable <ProductRangeResource> >(response.Value); return(results.Select(p => new ProductRange(p.Name) { Id = p.Id, Description = p.Description, PhasedOutOn = p.PhasedOutOn })); }
public IEnumerable <SalesPart> GetWEEESalesParts() { var uri = new Uri($"{this.rootUri}/products/sales-parts/weee-parts", UriKind.RelativeOrAbsolute); var response = this.restClient.Get( CancellationToken.None, uri, new Dictionary <string, string>(), DefaultHeaders.JsonGetHeaders()).Result; if (response.StatusCode != HttpStatusCode.OK) { throw new ProxyException($"Error trying to get sales products"); } var json = new JsonSerializer(); var results = json.Deserialize <IEnumerable <SalesPartResource> >(response.Value); return(results.Select( p => new SalesPart() { Description = p.Description, Name = p.Name, DimensionOver50Cm = p.DimensionOver50Cm, MainsCablesPerProduct = p.MainsCablesPerProduct, NettWeight = p.NettWeight, PackagingFoamNettWeight = p.PackagingFoamNettWeight, PackagingNettWeight = p.PackagingNettWeight, WeeeCategory = p.WeeeCategory, WeeeProduct = p.WeeeProduct, RootProduct = p.RootProduct == null ? null : new RootProduct { Name = p.RootProduct.Name, Description = p.RootProduct.Description } })); }