/// <summary>
 /// Create a new item.
 /// </summary>
 /// <param name="item_info">The item_info is the LineItem object with name and rate as mandatory attributes.</param>
 /// <returns>LineItem object.</returns>
 public LineItem Create(LineItem item_info)
 {
     string url = baseAddress ;
     var json = JsonConvert.SerializeObject(item_info);
     var jsonstring = new Dictionary<object, object>();
     jsonstring.Add("JSONString", json);
     var response = ZohoHttpClient.post(url, getQueryParameters(jsonstring));
     return ItemParser.getItem(response);
 }
 internal static LineItem getItem(HttpResponseMessage response)
 {
     var item = new LineItem();
     var jsonObj = JsonConvert.DeserializeObject<Dictionary<string, object>>(response.Content.ReadAsStringAsync().Result);
     if (jsonObj.ContainsKey("item"))
     {
         item = JsonConvert.DeserializeObject<LineItem>(jsonObj["item"].ToString());
     }
     return item;
 }
 static void Main(string[] args)
 {
     try
     {
         var service = new ZohoBooks();
         service.initialize("{authtoken}", "{organization id}");
         var itemsApi = service.GetItemsApi();
         var parameters = new Dictionary<object, object>();
         var itemsList = itemsApi.GetItems(parameters);
         var items = itemsList;
         var itemId = items[1].item_id;
         foreach (var item in items)
             Console.WriteLine("Item id:{0},\nName:{1},\ndescription:{2},\nRate:{3}\n", item.item_id, item.name, item.description, item.rate);
         var item1 = itemsApi.Get(itemId);
         Console.WriteLine("Item id:{0},\nName:{1},\ndescription:{2},\nRate:{3}\n", item1.item_id, item1.name, item1.description, item1.rate);
         var newItemInfo = new LineItem()
         {
             name="computer hardware21",
             rate=1500
         };
         var newItem = itemsApi.Create(newItemInfo);
         Console.WriteLine("Item id:{0},\nName:{1},\ndescription:{2},\nRate:{3}\n", newItem.item_id, newItem.name, newItem.description, newItem.rate);
         var updateInfo = new LineItem()
         {
             description = "ram of 1gb"
         };
         var updatedItem = itemsApi.Update(newItem.item_id, updateInfo);
         Console.WriteLine("Item id:{0},\nName:{1},\ndescription:{2},\nRate:{3}\n", updatedItem.item_id, updatedItem.name, updatedItem.description, updatedItem.rate);
         var deleteMsg = itemsApi.Delete(updatedItem.item_id);
         Console.WriteLine(deleteMsg);
         var inactiveMsg = itemsApi.MarkAsInactive(itemId);
         Console.WriteLine(inactiveMsg);
         var activeMsg = itemsApi.MarkAsActive(itemId);
         Console.WriteLine(activeMsg);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
     Console.ReadKey();
 }
 internal static ItemList getItemList(HttpResponseMessage response)
 {
     var itemList = new ItemList();
     var jsonObj = JsonConvert.DeserializeObject<Dictionary<string, object>>(response.Content.ReadAsStringAsync().Result);
     if (jsonObj.ContainsKey("items"))
     {
         var itemsArray = JsonConvert.DeserializeObject<List<object>>(jsonObj["items"].ToString());
         foreach(var itemObj in itemsArray)
         {
             var item = new LineItem();
             item = JsonConvert.DeserializeObject<LineItem>(itemObj.ToString());
             itemList.Add(item);
         }
     }
     if (jsonObj.ContainsKey("page_context"))
     {
         var pageContext = new PageContext();
         pageContext = JsonConvert.DeserializeObject<PageContext>(jsonObj["page_context"].ToString());
         itemList.page_context = pageContext;
     }
     return itemList;
 }