Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="journalNumber"></param>
        /// <param name="voucherNumber"></param>
        public void DeleteVouchers(int journalNumber, int voucherNumber)
        {
            string url = _client.GetUrl("/journals-experimental/{0}/entries/{1}", journalNumber, voucherNumber);

            try
            {
                var response = JsonClient.Delete(url, _client.GetHeaders());
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        public Product Create(Product product)
        {
            string url = Client.GetUrl("/products/");

            try
            {
                var response = JsonClient.Post <Product, Product>(url, product, Client.GetHeaders());
                return(response);
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 3
0
        /// <summary></summary>
        /// <param name="productNumber"></param>
        /// <returns>EcnomicApi.Economic.Objects.Product</returns>
        public Product Get(string productNumber)
        {
            string url = Client.GetUrl("/products/" + productNumber);

            try
            {
                var response = JsonClient.Get <Product>(url, Client.GetHeaders());
                return(response);
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 4
0
        /// <summary></summary>
        /// <returns>EcnomicApi.Economic.Objects.Invoices</returns>
        public Invoices List()
        {
            string url = _client.GetUrl("/invoices/");

            try
            {
                var response = JsonClient.Get <Invoices>(url, _client.GetHeaders());
                return(response);
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="customerNumber"></param>
        /// <returns></returns>
        public CollectionOfContact List(int customerNumber)
        {
            string url = this.Client.GetUrl("/customers/" + customerNumber + "/contacts");

            try
            {
                var response = JsonClient.Get <CollectionOfContact>(url, Client.GetHeaders());
                return(response);
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Delete a draft invoice based in draft invoice number.
        /// </summary>
        /// <param name="invoiceNumber">Draft invoice number.</param>
        /// <returns>True when deleted successfully.</returns>
        public bool DeleteDraft(int invoiceNumber)
        {
            string url = _client.GetUrl("/invoices/drafts/" + invoiceNumber);

            try
            {
                var response = JsonClient.Delete(url, _client.GetHeaders());
                return(response);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 7
0
        /// <summary></summary>
        /// <returns>EcnomicApi.Economic.Objects.CollectionOfProduct</returns>
        public CollectionOfVatZone List()
        {
            string url = this.Client.GetUrl("/vat-zones/");

            try
            {
                var response = JsonClient.Get <CollectionOfVatZone>(url, Client.GetHeaders());
                return(response);
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 8
0
        /// <summary></summary>
        /// <param name="c"></param>
        /// <returns>EcnomicApi.Economic.Objects.CustomerGroup</returns>
        public CustomerGroup Create(CustomerGroup c)
        {
            string url = _client.GetUrl("/customer-groups/");

            // validate
            Validation.ObjectValidation.Validate <CustomerGroup>(c);

            try
            {
                var response = JsonClient.Post <CustomerGroup, CustomerGroup>(url, c, _client.GetHeaders());

                return(response);
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="j"></param>
        /// <returns></returns>
        public Journal Create(Journal j)
        {
            string url = _client.GetUrl("/journals-experimental/");

            // validate
            Validation.ObjectValidation.Validate <Journal>(j);

            try
            {
                var response = JsonClient.Post <Journal, Journal>(url, j, _client.GetHeaders());

                return(response);
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="journalNumber"></param>
        /// <param name="newW"></param>
        public void CreateVouchers(int journalNumber, Vouchers newW)
        {
            string url = _client.GetUrl("/journals-experimental/{0}/vouchers", journalNumber);

            try
            {
                var response = JsonClient.Post <Vouchers, Vouchers>(url, newW, _client.GetHeaders());
            }
            catch (Newtonsoft.Json.JsonSerializationException ex)
            {
                Console.WriteLine("Response serialization issue");
                //throw ex;
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Create a new draft invoice. The method doesn’t also book it, but simply creates the draft.
        /// </summary>
        /// <param name="invoice"></param>
        /// <returns></returns>
        /// <exception cref="EconomicException"></exception>
        public Invoice Create(Invoice invoice)
        {
            string url = _client.GetUrl("/invoices/drafts");

            try
            {
                var response = JsonClient.Post <Invoice, Invoice>(url, invoice, _client.GetHeaders());
                return(response);
            }
            catch (JsonClientException e)
            {
                var errorMessage = JsonConvert.DeserializeObject <ErrorMessage>(e.Message);
                throw new EconomicException(errorMessage, e);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 12
0
        /// <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;
            }
        }
Ejemplo n.º 13
0
        /// <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;
            }
        }
Ejemplo n.º 14
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;
            }
        }
Ejemplo n.º 15
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;
            }
        }
Ejemplo n.º 16
0
        /// <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;
            }
        }
Ejemplo n.º 17
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;
            }
        }
Ejemplo n.º 18
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;
            }
        }
Ejemplo n.º 19
0
        /// <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;
            }
        }
Ejemplo n.º 20
0
        /// <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;
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Books a draft invoice. If the operation is successful, this returns the full booked invoice.
        /// </summary>
        /// <param name="bookInvoiceRequest"></param>
        /// <exception cref="EconomicException"></exception>
        public Invoice Book(BookInvoiceRequest bookInvoiceRequest)
        {
            string url = _client.GetUrl("/invoices/booked/");

            try
            {
                var response = JsonClient.Post <BookInvoiceRequest, Invoice>(url
                                                                             , bookInvoiceRequest
                                                                             , _client.GetHeaders());

                return(response);
            }
            catch (JsonClientException e)
            {
                var errorMessage = JsonConvert.DeserializeObject <ErrorMessage>(e.Message);
                throw new EconomicException(errorMessage, e);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public virtual bool Delete(T obj, int id)
        {
            string url = _client.GetUrl(this.BaseUrl + "/" + id);

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

                throw e;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 23
0
        /// <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;
            }
        }
Ejemplo n.º 24
0
        /// <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;
            }
        }
Ejemplo n.º 25
0
        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;
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="customer"></param>
        /// <returns></returns>
        public bool Delete(Customer customer)
        {
            string url = _client.GetUrl("/customers/" + customer.customerNumber);

            try
            {
                var response = JsonClient.Delete(url, _client.GetHeaders());
                return(response);
            }
            catch (JsonClientException e)
            {
                if (e.StatusCode == System.Net.HttpStatusCode.NotFound)
                {
                    return(false);
                }

                throw _client.CreateException(e);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 27
0
        /// <summary></summary>
        /// <param name="c"></param>
        /// <returns>EcnomicApi.Economic.Objects.Customer</returns>
        public Customer Create(Customer c)
        {
            string url = _client.GetUrl("/customers/");

            // validate
            Validation.ObjectValidation.Validate <Customer>(c);

            try
            {
                var response = JsonClient.Post <Customer, Customer>(url, c, _client.GetHeaders());

                return(response);
            }
            catch (JsonClientException e)
            {
                var errorMessage = JsonConvert.DeserializeObject <ErrorMessage>(e.Message);
                throw new EconomicException(errorMessage, e);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 28
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;
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public virtual T Post(T obj)
        {
            string url = _client.GetUrl(this.BaseUrl + "/");

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

                throw e;
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Ejemplo n.º 30
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;
            }
        }