Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="bookInvoiceRequest"></param>
        /// <returns></returns>
        /// <exception cref="EconomicException"></exception>
        public Invoice BookWithNumber(BookInvoiceRequest bookInvoiceRequest)
        {
            if (!bookInvoiceRequest.bookWithNumber.HasValue)
            {
                throw new ArgumentNullException("Book with number method, MUST have a book with number");
            }

            string url = _client.GetUrl("/invoices/booked/" + bookInvoiceRequest.bookWithNumber);

            try
            {
                var response = JsonClient.Put <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;
            }
        }