/// <summary></summary>
        /// <param name="options"></param>
        /// <returns>EcnomicApi.Economic.Objects.CollectionOfProduct</returns>
        public CollectionOfProduct List(ViewOptions options = null)
        {
            string url = this.Client.GetUrl("/products/");

            if (options != null)
            {
                options.AppendTo(ref url);
            }

            try
            {
                var response = JsonClient.Get <CollectionOfProduct>(url, Client.GetHeaders());
                return(response);
            }
            catch
            {
                throw;
            }
        }
Exemple #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="journalNumber"></param>
        /// <param name="skippages"></param>
        /// <param name="pagesize"></param>
        /// <returns></returns>
        public CollectionOfVouchers ListVouchers(int journalNumber, int skippages = -1, int pagesize = 20)
        {
            if (pagesize > 1000)
            {
                throw new ArgumentOutOfRangeException("Maximum pagesize is 1.000");
            }

            string url = _client.GetUrl("/journals-experimental/" + journalNumber + "/vouchers?pagesize=" + pagesize);

            try
            {
                var response = JsonClient.Get <CollectionOfVouchers>(url, _client.GetHeaders());
                return(response);
            }
            catch
            {
                throw;
            }
        }
Exemple #3
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public CollectionOfLayout ListLayouts()
        {
            string url = _client.GetUrl("/layouts/");

            try
            {
                var response = JsonClient.Get <CollectionOfLayout>(url, _client.GetHeaders());
                return(response);
            }
            catch (JsonClientException e)
            {
                var errorMessage = JsonConvert.DeserializeObject <ErrorMessage>(e.Message);
                throw new EconomicException(errorMessage, e);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemple #4
0
        /// <summary></summary>
        /// <param name="invoiceNumber"></param>
        /// <returns>EcnomicApi.Economic.Objects.Invoice</returns>
        public Invoice GetDraft(int invoiceNumber)
        {
            string url = _client.GetUrl("/invoices/drafts/" + invoiceNumber);

            try
            {
                var response = JsonClient.Get <Invoice>(url, _client.GetHeaders());
                return(response);
            }
            catch (JsonClientException e)
            {
                var errorMessage = JsonConvert.DeserializeObject <ErrorMessage>(e.Message);
                throw new EconomicException(errorMessage, e);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        /// <summary></summary>
        /// <param name="pagesize"></param>
        /// <param name="skippages"></param>
        /// <returns>EcnomicApi.Economic.Objects.CollectionOfCustomer</returns>
        public CollectionOfCustomer List(int skippages = -1, int pagesize = 20)
        {
            if (pagesize > 1000)
            {
                throw new ArgumentOutOfRangeException("Maximum pagesize is 1.000");
            }

            string url = _client.GetUrl("/customers/?pagesize=" + pagesize);

            try
            {
                var response = JsonClient.Get <CollectionOfCustomer>(url, _client.GetHeaders());
                return(response);
            }
            catch
            {
                throw;
            }
        }
Exemple #6
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public Self Self()
        {
            string url = GetUrl("/self/");

            try
            {
                var response = JsonClient.Get <Self>(url, GetHeaders());
                return(response);
            }
            catch (JsonClientException e)
            {
                var errorMessage = JsonConvert.DeserializeObject <ErrorMessage>(e.Message);
                throw new EconomicException(errorMessage, e);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        /// <summary></summary>
        /// <param name="productNumber"></param>
        /// <returns>EcnomicApi.Economic.Objects.CollectionOfProductPricing</returns>
        public CollectionOf <ProductPricing> GetCurrencySpecificSalesPrices(string productNumber)
        {
            if (string.IsNullOrEmpty(productNumber))
            {
                throw new ArgumentNullException("ProductNumber");
            }

            string url = Client.GetUrl("/products/{0}/pricing/currency-specific-sales-prices", productNumber);

            try
            {
                var response = JsonClient.Get <CollectionOf <ProductPricing> >(url, Client.GetHeaders());
                return(response);
            }
            catch
            {
                throw;
            }
        }
        /// <summary></summary>
        /// <param name="filters"></param>
        /// <param name="filter"></param>
        /// <returns>EcnomicApi.Economic.Objects.CollectionOfProduct</returns>
        public CollectionOfProduct Find(FilterPart[] filters, FilterEnum filter)
        {
            if (filters == null)
            {
                throw new ArgumentNullException();
            }

            string query = Helpers.CollectFilters(filters, filter);

            string url = Client.GetUrl("/products/?filter=" + query);

            try
            {
                var response = JsonClient.Get <CollectionOfProduct>(url, Client.GetHeaders());
                return(response);
            }
            catch
            {
                throw;
            }
        }
        /// <summary></summary>
        internal RT Retrieve <RT>(string url)
        {
            try
            {
                var response = JsonClient.Get <RT>(url, _client.GetHeaders());
                return(response);
            }
            catch (JsonClientException e)
            {
                if (e.StatusCode == System.Net.HttpStatusCode.NotFound)
                {
                    throw e;
                }

                throw e;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemple #10
0
        /// <summary></summary>
        /// <param name="productNumber"></param>
        /// <param name="currencyCode"></param>
        /// <returns>EcnomicApi.Economic.Objects.ProductPricing</returns>
        public ProductPricing GetCurrencySpecificSalesPrice(string productNumber, string currencyCode)
        {
            if (string.IsNullOrEmpty(currencyCode))
            {
                throw new ArgumentNullException("CurrencyCode");
            }
            if (string.IsNullOrEmpty(productNumber))
            {
                throw new ArgumentNullException("ProductNumber");
            }

            string url = Client.GetUrl("/products/{0}/pricing/currency-specific-sales-prices/{1}", productNumber, currencyCode);

            try
            {
                var response = JsonClient.Get <ProductPricing>(url, Client.GetHeaders());
                return(response);
            }
            catch
            {
                throw;
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        public CollectionOfCustomer Find(string query)
        {
            string url = _client.GetUrl("/customers/?filter=" + query);

            try
            {
                var response = JsonClient.Get <CollectionOfCustomer>(url, _client.GetHeaders());
                return(response);
            }
            catch (JsonClientException e)
            {
                if (e.StatusCode == System.Net.HttpStatusCode.NotFound)
                {
                    return(null);
                }

                throw e;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public virtual GenericCollectionOf <T> List()
        {
            string url = _client.GetUrl(this.BaseUrl + "/");

            try
            {
                var response = JsonClient.Get <GenericCollectionOf <T> >(url, _client.GetHeaders());
                return(response);
            }
            catch (JsonClientException e)
            {
                if (e.StatusCode == System.Net.HttpStatusCode.NotFound)
                {
                    throw e;
                }

                throw e;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="customerNumber"></param>
        /// <returns></returns>
        public Customer Get(int customerNumber)
        {
            string url = _client.GetUrl("/customers/" + customerNumber);

            try
            {
                var response = JsonClient.Get <Customer>(url, _client.GetHeaders());
                return(response);
            }
            catch (JsonClientException e)
            {
                if (e.StatusCode == System.Net.HttpStatusCode.NotFound)
                {
                    return(null);
                }

                throw e;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        public InvoiceLine TemplateInvoiceLine(Customer customer)
        {
            string url = _client.GetUrl("/customers/" + customer.customerNumber + "/templates/invoiceline");

            try
            {
                var response = JsonClient.Get <InvoiceLine>(url, _client.GetHeaders());
                return(response);
            }
            catch (JsonClientException e)
            {
                if (e.StatusCode == System.Net.HttpStatusCode.NotFound)
                {
                    return(null);
                }

                throw e;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemple #15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="journalNumber"></param>
        /// <returns></returns>
        public Journal Get(int journalNumber)
        {
            string url = _client.GetUrl("/journals-experimental/" + journalNumber);

            try
            {
                var response = JsonClient.Get <Journal>(url, _client.GetHeaders());
                return(response);
            }
            catch (JsonClientException e)
            {
                if (e.StatusCode == System.Net.HttpStatusCode.NotFound)
                {
                    return(null);
                }

                throw e;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemple #16
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        public CollectionOfInvoice ListBooked(ViewOptions options = null)
        {
            string url = _client.GetUrl("/invoices/booked?sort=-bookedInvoiceNumber");

            if (options != null)
            {
                options.AppendTo(ref url);
            }

            try
            {
                var response = JsonClient.Get <CollectionOfInvoice>(url, _client.GetHeaders());
                return(response);
            }
            catch (JsonClientException e)
            {
                var errorMessage = JsonConvert.DeserializeObject <ErrorMessage>(e.Message);
                throw new EconomicException(errorMessage, e);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemple #17
0
        public CollectionOfCustomer ListCustomers(int customerGroupNumber, int skippages = -1, int pagesize = 20)
        {
            if (customerGroupNumber == 0)
            {
                throw new ArgumentNullException();
            }

            if (pagesize > 1000)
            {
                throw new ArgumentOutOfRangeException("Maximum pagesize is 1.000");
            }

            string url = _client.GetUrl("/customer-groups/{0}/customers?pagesize={1}", customerGroupNumber, pagesize);

            try
            {
                var response = JsonClient.Get <CollectionOfCustomer>(url, _client.GetHeaders());
                return(response);
            }
            catch
            {
                throw;
            }
        }