Esempio n. 1
0
 static void Main(string[] args)
 {
     try
     {
         var service = new ZohoBooks();
         service.initialize("{authtoken}", "{organization id}");
         var estimateSettingsApi = service.GetSettingsApi();
         var estimateSettings    = estimateSettingsApi.GetEstimateSettings();
         Console.WriteLine("Auto Generarte:{0},\nIs salesperson Required:{1},\nNotes:{2}\n", estimateSettings.auto_generate, estimateSettings.is_sales_person_required, estimateSettings.notes);
         var updateInfo = new EstimateSettings()
         {
             auto_generate            = false,
             discount_type            = "no_discount",
             is_sales_person_required = false
         };
         var updatedSettings = estimateSettingsApi.UpdateEstimateSettings(updateInfo);
         Console.WriteLine("Auto Generarte:{0},\nIs salesperson Required:{1},\nDiscount:{2}\n", updatedSettings.auto_generate, updatedSettings.is_sales_person_required, updatedSettings.discount_type);
         var notesAndTerms = estimateSettingsApi.GetEstimateNotesAndTerms();
         Console.WriteLine("notes:{0}\nterms:{1}", notesAndTerms.notes, notesAndTerms.terms);
         var updatedInfo = new NotesAndTerms()
         {
             notes = "Thanking for business",
             terms = "terms"
         };
         var updated = estimateSettingsApi.UpdateEstimateNotesAndTerms(updatedInfo);
         Console.WriteLine("notes:{0}\nterms:{1}", updated.notes, updated.terms);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
     Console.ReadKey();
 }
        internal static EstimateSettings getEstimateSettings(System.Net.Http.HttpResponseMessage response)
        {
            var estimateSettings = new EstimateSettings();
            var jsonObj          = JsonConvert.DeserializeObject <Dictionary <string, object> >(response.Content.ReadAsStringAsync().Result);

            if (jsonObj.ContainsKey("estimate_settings"))
            {
                estimateSettings = JsonConvert.DeserializeObject <EstimateSettings>(jsonObj["estimate_settings"].ToString());
            }
            return(estimateSettings);
        }
        /// <summary>
        ///     Update the settings that are configured for estimates.
        /// </summary>
        /// <param name="update_info">
        ///     The update_info is the EstimateSettings object which contains the settings upadation
        ///     information.
        /// </param>
        /// <returns>EstimateSettings object.</returns>
        public EstimateSettings UpdateEstimateSettings(EstimateSettings update_info)
        {
            var url        = baseAddress + "/estimates";
            var json       = JsonConvert.SerializeObject(update_info);
            var jsonstring = new Dictionary <object, object>();

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

            return(EstimateSettingsParser.getEstimateSettings(response));
        }