示例#1
0
 static void Main(string[] args)
 {
     try
     {
         var service = new ZohoBooks();
         service.initialize("{authtoken}", "{organization id}");
         var invoiceSettingsApi = service.GetSettingsApi();
         var invoiceSettings    = invoiceSettingsApi.GetInvoiceSettings();
         Console.WriteLine("auto_generate:{0},\nis_sales_person_required:{1},\nis_shipping_charge_required:{2},\nnotes:{3}", invoiceSettings.auto_generate, invoiceSettings.is_sales_person_required, invoiceSettings.is_shipping_charge_required, invoiceSettings.notes);
         var updateInfo = new InvoiceSettings()
         {
             auto_generate = false,
             notes         = "from hari"
         };
         var updatedSettings = invoiceSettingsApi.UpdateInvoiceSettings(updateInfo);
         Console.WriteLine("auto_generate:{0},\nis_sales_person_required:{1},\nis_shipping_charge_required:{2},\nnotes:{3}", updatedSettings.auto_generate, updatedSettings.is_sales_person_required, updatedSettings.is_shipping_charge_required, updatedSettings.notes);
         var notesAndTerms = invoiceSettingsApi.GetInvoiceNotesAndTerms();
         Console.WriteLine("notes:{0}\nterms:{1}", notesAndTerms.notes, notesAndTerms.terms);
         var updatedInfo = new NotesAndTerms()
         {
             notes = "Thanking for business",
             terms = "terms"
         };
         var updated = invoiceSettingsApi.UpdateInvoiceNotesAndTerms(updatedInfo);
         Console.WriteLine("notes:{0}\nterms:{1}", updated.notes, updated.terms);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
     Console.ReadKey();
 }
        internal static InvoiceSettings getInvoiceSettings(HttpResponseMessage response)
        {
            var invoiceSettings = new InvoiceSettings();
            var jsonObj         = JsonConvert.DeserializeObject <Dictionary <string, object> >(response.Content.ReadAsStringAsync().Result);

            if (jsonObj.ContainsKey("invoice_settings"))
            {
                invoiceSettings = JsonConvert.DeserializeObject <InvoiceSettings>(jsonObj["invoice_settings"].ToString());
            }
            return(invoiceSettings);
        }
        /// <summary>
        ///     Update the settings information for invoices.
        /// </summary>
        /// <param name="update_info">
        ///     The update_info is the InvoiceSettings object which is having the settings updation
        ///     information.
        /// </param>
        /// <returns>InvoiceSettings object.</returns>
        public InvoiceSettings UpdateInvoiceSettings(InvoiceSettings update_info)
        {
            var url        = baseAddress + "/invoices";
            var json       = JsonConvert.SerializeObject(update_info);
            var jsonstring = new Dictionary <object, object>();

            jsonstring.Add("JSONString", json);
            var response = ZohoHttpClient.put(url, getQueryParameters(jsonstring));

            return(InvoiceSettingsParser.getInvoiceSettings(response));
        }
        /// <summary>
        /// Loads settings from .dat file. If loaded fails or file doesn't exsists creates new file
        /// </summary>
        private InvoiceSettings LoadInvoiceSettings()
        {
            InvoiceSettings loadedSettings = null;

            if (null != SettingsSerializer)
            {
                loadedSettings =
                    SettingsSerializer.DeserializeObject(InvoiceSettingsSerializationPath) as InvoiceSettings;
            }

            return(loadedSettings);
        }
        private void InitializeInvoiceSettings()
        {
            InvoiceSettings loadedSettings = LoadInvoiceSettings();

            if (null != loadedSettings)
            {
                InvSettings = loadedSettings;
            }
            else //Loading settings failed, create new settings
            {
                InvSettings = new InvoiceSettings();
            }
        }
示例#6
0
        public void Invoice_Click()
        {
            InvoiceSettings invoiceSettingsView = new InvoiceSettings();

            invoiceSettingsView.Show();
        }