/// <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; } }
/// <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; } }
/// <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; } }
/// <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; } }
/// <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; } }
/// <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; } }
/// <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; } }
/// <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; } }