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();
 }
 static void Main(string[] args)
 {
     try
     {
         var service = new ZohoBooks();
         service.initialize("{authtoken}", "{organizationId}");
         var creditnoteSettingsApi = service.GetSettingsApi();
         var creditnoteSettings    = creditnoteSettingsApi.GetCreditnoteSettings();
         Console.WriteLine("prefix:{0},\nreferencetxt:{1},\nnotes:{2}", creditnoteSettings.prefix_string, creditnoteSettings.reference_text, creditnoteSettings.notes);
         var updateInfo = new CreditNoteSettings()
         {
             prefix_string  = "cn",
             reference_text = "hari"
         };
         var updatedSettings = creditnoteSettingsApi.UpdateCreditnoteSettings(updateInfo);
         Console.WriteLine("prefix:{0},\nreferencetxt:{1},\nnotes:{2}", updatedSettings.prefix_string, updatedSettings.reference_text, updatedSettings.notes);
         var notesAndTerms = creditnoteSettingsApi.GetCreditnoteNotesAndTerms();
         Console.WriteLine("notes:{0}\nterms:{1}", notesAndTerms.notes, notesAndTerms.terms);
         var updatedInfo = new NotesAndTerms()
         {
             notes = "Thanking for business",
             terms = "terms"
         };
         var updated = creditnoteSettingsApi.UpdateCreditnoteNotesAndTerms(updatedInfo);
         Console.WriteLine("notes:{0}\nterms:{1}", updated.notes, updated.terms);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
     Console.ReadKey();
 }
 static void Main(string[] args)
 {
     try
     {
         var service = new ZohoBooks();
         service.initialize("{authtoken}", "{organizationId}");
         var creditnoteSettingsApi = service.GetSettingsApi();
         var creditnoteSettings = creditnoteSettingsApi.GetCreditnoteSettings();
         Console.WriteLine("prefix:{0},\nreferencetxt:{1},\nnotes:{2}", creditnoteSettings.prefix_string, creditnoteSettings.reference_text, creditnoteSettings.notes);
         var updateInfo = new CreditNoteSettings()
         {
             prefix_string="cn",
             reference_text="hari"
         };
         var updatedSettings = creditnoteSettingsApi.UpdateCreditnoteSettings(updateInfo);
         Console.WriteLine("prefix:{0},\nreferencetxt:{1},\nnotes:{2}", updatedSettings.prefix_string, updatedSettings.reference_text, updatedSettings.notes);
         var notesAndTerms = creditnoteSettingsApi.GetCreditnoteNotesAndTerms();
         Console.WriteLine("notes:{0}\nterms:{1}", notesAndTerms.notes, notesAndTerms.terms);
         var updatedInfo = new NotesAndTerms()
         {
             notes = "Thanking for business",
             terms = "terms"
         };
         var updated = creditnoteSettingsApi.UpdateCreditnoteNotesAndTerms(updatedInfo);
         Console.WriteLine("notes:{0}\nterms:{1}", updated.notes, updated.terms);
     }
     catch(Exception e)
     {
         Console.WriteLine(e.Message);
     }
     Console.ReadKey();
 }
 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();
 }
        static void Main(string[] args)
        {
            try
            {
                var service = new ZohoBooks();
                service.initialize("{authtoken}", "{organization id}");
                RecurringExpensesApi recurringExpensesApi = service.GetRecurringExpensesApi();
                var parameters = new Dictionary<object, object>();
                parameters.Add("recurrence_name_startswith", "h");
                var recurringExpenses = recurringExpensesApi.GetRecurringExpenses(parameters);
                var recExpId = recurringExpenses[0].recurring_expense_id;
                if (recurringExpenses != null)
                    foreach (var recurringExpense in recurringExpenses)
                        Console.WriteLine("{0},{1},{2}", recurringExpense.account_name, recurringExpense.total, recurringExpense.recurrence_name);
                var recurringExpense1 = recurringExpensesApi.Get(recExpId);
                if (recurringExpense1 != null)
                    Console.WriteLine("{0},{1},{2}", recurringExpense1.account_name, recurringExpense1.total, recurringExpense1.recurrence_name);
                var newRecurringExpenseInfo = new RecurringExpense()
                {
                    account_id = "{account id}",
                    paid_through_account_id = "{account id from which going to pay}",
                    recurrence_name = "rec name",
                    start_date = "2014-02-03",
                    recurrence_frequency = "months",
                    repeat_every = 2,
                    amount = 1000,
                };
                var newRecurringExpense = recurringExpensesApi.Create(newRecurringExpenseInfo);
                if (newRecurringExpense != null)
                    Console.WriteLine("{0},{1},{2}", newRecurringExpense.account_name, newRecurringExpense.total, newRecurringExpense.recurrence_name);
                var updateInfo = new RecurringExpense()
                {
                    recurrence_frequency = "weeks",
                    repeat_every = 4,

                };
                var updatedExpense = recurringExpensesApi.Update(recExpId, updateInfo);
                if (updatedExpense != null)
                    Console.WriteLine("{0},{1},{2}", updatedExpense.account_name, updatedExpense.total, updatedExpense.recurrence_name);
                var delRecurringExpense = recurringExpensesApi.Delete(recurringExpenses[3].recurring_expense_id);
                Console.WriteLine(delRecurringExpense);
                var stopRecurringExpense = recurringExpensesApi.Stop(recExpId);
                Console.WriteLine(stopRecurringExpense);
                var resumeRecurringExpense = recurringExpensesApi.Resume(recExpId);
                Console.WriteLine(resumeRecurringExpense);
                var childExpenses = recurringExpensesApi.GetExpensesCreated(recExpId, parameters);
                if (childExpenses != null)
                    foreach (var childExpense in childExpenses)
                        Console.WriteLine("{0},{1},{2}", childExpense.account_name, childExpense.total, childExpense.date);
                var comments = recurringExpensesApi.GetComments(recExpId);
                if (comments != null)
                    foreach (var comment in comments)
                        Console.WriteLine("{0},{1},{2}", comment.comment_id, comment.description, comment.commented_by);
            }
            catch(Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
 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();
 }
 static void Main(string[] args)
 {
     try
     {
         var service = new ZohoBooks();
         service.initialize("{authtoken}", "{organization id}");
         var usersApi   = service.GetUsersApi();
         var parameters = new Dictionary <object, object>();
         parameters.Add("filter_by", "Status.Invited");
         var userslist = usersApi.GetUsers(parameters);
         var users     = userslist;
         var userId    = users[1].user_id;
         foreach (var user in users)
         {
             Console.WriteLine("user id:{0},\nuser name:{1},\nuser role:{2}.\nstatus:{3}\n", user.user_id, user.name, user.user_role, user.status);
         }
         var user1 = usersApi.Get(userId);
         Console.WriteLine("user id:{0},\nuser name:{1},\nuser role:{2}.\nstatus:{3}\n", user1.user_id, user1.name, user1.user_role, user1.status);
         var emails = user1.email_ids;
         foreach (var email in emails)
         {
             Console.WriteLine("{0},{1}", email.email, email.is_selected);
         }
         var currentUser = usersApi.GetCurrentUser();
         Console.WriteLine("user id:{0},\nuser name:{1},\nuser role:{2}.\nstatus:{3}\n", currentUser.user_id, currentUser.name, currentUser.user_role, currentUser.status);
         var emails1 = currentUser.email_ids;
         foreach (var email in emails1)
         {
             Console.WriteLine("{0},{1}", email.email, email.is_selected);
         }
         var newUserInfo = new User()
         {
             name      = "hari",
             email     = "*****@*****.**",
             user_role = "timesheetstaff"
         };
         var newUser = usersApi.Create(newUserInfo);
         Console.WriteLine("New user Info: \n user id:{0},\nuser name:{1},\nuser role:{2}.\nstatus:{3}\n", newUser.user_id, newUser.name, newUser.user_role, newUser.status);
         var updateInfo = new User()
         {
             name  = "user name",
             email = "*****@*****.**"
         };
         var updatedUser = usersApi.Update(newUser.user_id, updateInfo);
         Console.WriteLine("user id:{0},\nuser name:{1},\nuser role:{2}.\nstatus:{3}\n", updatedUser.user_id, updatedUser.name, updatedUser.user_role, updatedUser.status);
         var deleteMsg = usersApi.Delete(updatedUser.user_id);
         Console.WriteLine(deleteMsg);
         var inviteMsg = usersApi.InviteUser(userId);
         Console.WriteLine(inviteMsg);
         var activeMsg = usersApi.MarkAsActive(userId);
         Console.WriteLine(activeMsg);
         var inactiveMsg = usersApi.MarkAsInactive(userId);
         Console.WriteLine(inactiveMsg);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
     Console.ReadKey();
 }
 static void Main(string[] args)
 {
     var service = new ZohoBooks();
     service.initialize("{authtoken}", "{organizationId}");
     var bankAccountsApi = service.GetBankAccountsApi();
     try
     {
         var parameters = new Dictionary<object, object>();
         var bankaccountsList = bankAccountsApi.GetBankAccounts(parameters);
         var bankaccounts = bankaccountsList;
         if (bankaccounts != null)
             foreach (var bankAccount in bankaccounts)
                 Console.WriteLine("{0},{1},{2}", bankAccount.account_id, bankAccount.account_name, bankAccount.balance);
         string accountId = bankaccounts[0].account_id;
        var bankaccount = bankAccountsApi.Get(accountId);
         if(bankaccount!=null)
             Console.WriteLine("{0},{1},{2}", bankaccount.account_number, bankaccount.account_name, bankaccount.balance);
         var newAccountInfo = new BankAccount()
         {
             account_name = "name of account",
             account_type = "bank",
             is_primary_account = true
         };
         var newAccount = bankAccountsApi.Create(newAccountInfo);
         if (newAccount != null)
             Console.WriteLine("{0},{1},{2}", newAccount.is_primary_account, newAccount.account_name, newAccount.balance);
         var updateInfo = new BankAccount()
         {
             account_name = "name of account",
             routing_number = "158987"
         };
         var updatedAccount = bankAccountsApi.Update(accountId, updateInfo);
         if(updatedAccount!=null)
             Console.WriteLine("{0},{1},{2}", updatedAccount.routing_number, updatedAccount.account_name, updatedAccount.balance);
        var delAccount = bankAccountsApi.Delete(bankaccounts[1].account_id);
        Console.WriteLine(delAccount);
        var deactAccount = bankAccountsApi.DeactivateAccount(accountId);
        Console.WriteLine(deactAccount);
        var actAccount = bankAccountsApi.ActivateAccount(accountId);
        Console.WriteLine(actAccount);
        var statement = bankAccountsApi.GetLastImportedStatement(accountId);
       if (statement != null)
       {
           Console.WriteLine("{0},{1},{2}", statement.statement_id, statement.to_date, statement.transactions.Count);
           var transactions = statement.transactions;
           foreach(var transaction in transactions)
           {
               Console.WriteLine("{0},{1},{2}", transaction.debit_or_credit, transaction.amount, transaction.transaction_type);
           }
       }
        var delstatement = bankAccountsApi.DeleteLastImportedStatement(accountId, statement.statement_id);
        Console.WriteLine(delstatement);
     }
     catch(Exception e)
     {
         Console.WriteLine(e.Message);
     }
     Console.ReadKey();
 }
 static void Main(string[] args)
 {
     try
     {
         var service = new ZohoBooks();
         service.initialize("{authtoken}", "{organization id}");
         var organizationApi = service.GetOrganizationsApi();
        var organizationsList = organizationApi.GetOrganizations();
        var organizations = organizationsList;
        var organizationId = organizations[0].organization_id;
         foreach (var organization in organizations)
             Console.WriteLine("Organization Id:{0},\n name:{1},\n contact name:{2},\n email:{3}", organization.organization_id, organization.name, organization.contact_name, organization.email);
         var organization1 = organizationApi.Get(organizationId);
         Console.WriteLine("Organization Id:{0},\n name:{1},\n contact name:{2},\n email:{3}\n addr:{4}\n", organization1.organization_id, organization1.name, organization1.contact_name, organization1.email,organization1.org_address);
         var addr = organization1.address;
         Console.WriteLine("Address:{0},{1},{2}",addr.city,addr.state,addr.country);
         var newOrganizationInfo = new Organization()
         {
             name="org3",
             currency_code="INR",
             time_zone = "IST",
             address=new Address(){country="India"}
         };
         var newOrganization = organizationApi.Create(newOrganizationInfo);
         Console.WriteLine("Organization Id:{0},\n name:{1},\n contact name:{2},\n email:{3}", newOrganization.organization_id, newOrganization.name, newOrganization.contact_name, newOrganization.email);
         var updateInfo = new Organization()
         {
             name="Org2",
             address = new Address()
             {
                 city="city",
                 state="state",
                 country="India"
             },
         };
         var updatedOrg = organizationApi.Upadte(organizationId, updateInfo);
         Console.WriteLine("Organization Id:{0},\n name:{1},\n contact name:{2},\n email:{3}\n addr:{4}\n", updatedOrg.organization_id, updatedOrg.name, updatedOrg.contact_name, updatedOrg.email, updatedOrg.org_address);
         var address = updatedOrg.address;
         Console.WriteLine("Address:{0},{1},{2}", address.city, address.state, address.country);
         var new_address_info = new Address()
         {
             attention="hari",
         };
         var newAddress = organizationApi.AddOrganizationAddress(new_address_info);
         var update_addr_info = new Address()
         {
             attention = "krishna"
         };
         var updatedAddress = organizationApi.UpdateOrganizationAddress(newAddress.organization_address_id, update_addr_info);
     }
     catch(Exception e)
     {
         Console.WriteLine(e.Message);
     }
     Console.ReadKey();
 }
Exemple #10
0
 static void Main(string[] args)
 {
     try
     {
         var service = new ZohoBooks();
         service.initialize("{authtoken}", "{organization id}");
         CustomerPaymentsApi customerpaymentsApi = service.GetCustomerPaymentsApi();
         var parameters = new Dictionary <object, object>();
         parameters.Add("customer_name_startswith", "h");
         var customerpaymentsList = customerpaymentsApi.GetCustomerPayments(parameters);
         var customerpayments     = customerpaymentsList;
         var paymentId            = customerpayments[2].payment_id;
         if (customerpayments != null)
         {
             foreach (var customerpayment in customerpayments)
             {
                 Console.WriteLine("{0},{1},{2}", customerpayment.account_name, customerpayment.amount, customerpayment.customer_name);
             }
         }
         var customerpayment1 = customerpaymentsApi.Get(paymentId);
         if (customerpayment1 != null)
         {
             Console.WriteLine("{0},{1},{2}", customerpayment1.account_name, customerpayment1.amount, customerpayment1.customer_name);
         }
         var customerId     = customerpayment1.customer_id;
         var newPaymentInfo = new CustomerPayment()
         {
             customer_id = customerId,
             date        = "2014-02-03",
             amount      = 1234,
         };
         var newCustomerPayment = customerpaymentsApi.Create(newPaymentInfo);
         if (newCustomerPayment != null)
         {
             Console.WriteLine("{0},{1},{2}", newCustomerPayment.account_name, newCustomerPayment.amount, newCustomerPayment.customer_name);
         }
         var updateInfo = new CustomerPayment()
         {
             amount = 100000,
         };
         var updatedCustomerPayment = customerpaymentsApi.Update(paymentId, updateInfo);
         if (updatedCustomerPayment != null)
         {
             Console.WriteLine("{0},{1},{2}", updatedCustomerPayment.account_name, updatedCustomerPayment.amount, updatedCustomerPayment.customer_name);
         }
         var delcustpayment = customerpaymentsApi.Delete(customerpayments[1].payment_id);
         Console.WriteLine(delcustpayment);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
     Console.ReadKey();
 }
 static void Main(string[] args)
 {
     try
     {
         var service = new ZohoBooks();
         service.initialize("{authtoken}", "{organization id}");
         var usersApi = service.GetUsersApi();
         var parameters = new Dictionary<object, object>();
         parameters.Add("filter_by", "Status.Invited");
         var userslist = usersApi.GetUsers(parameters);
         var users = userslist;
         var userId = users[1].user_id;
         foreach (var user in users)
             Console.WriteLine("user id:{0},\nuser name:{1},\nuser role:{2}.\nstatus:{3}\n", user.user_id, user.name, user.user_role, user.status);
         var user1 = usersApi.Get(userId);
         Console.WriteLine("user id:{0},\nuser name:{1},\nuser role:{2}.\nstatus:{3}\n", user1.user_id, user1.name, user1.user_role, user1.status);
         var emails = user1.email_ids;
         foreach (var email in emails)
             Console.WriteLine("{0},{1}", email.email, email.is_selected);
         var currentUser = usersApi.GetCurrentUser();
         Console.WriteLine("user id:{0},\nuser name:{1},\nuser role:{2}.\nstatus:{3}\n", currentUser.user_id, currentUser.name, currentUser.user_role, currentUser.status);
         var emails1 = currentUser.email_ids;
         foreach (var email in emails1)
             Console.WriteLine("{0},{1}", email.email, email.is_selected);
         var newUserInfo = new User()
         {
             name="hari",
             email="*****@*****.**",
             user_role="timesheetstaff"
         };
         var newUser = usersApi.Create(newUserInfo);
         Console.WriteLine("New user Info: \n user id:{0},\nuser name:{1},\nuser role:{2}.\nstatus:{3}\n", newUser.user_id, newUser.name, newUser.user_role, newUser.status);
         var updateInfo = new User()
         {
             name="user name",
             email="*****@*****.**"
         };
         var updatedUser = usersApi.Update(newUser.user_id, updateInfo);
         Console.WriteLine("user id:{0},\nuser name:{1},\nuser role:{2}.\nstatus:{3}\n", updatedUser.user_id, updatedUser.name, updatedUser.user_role, updatedUser.status);
         var deleteMsg = usersApi.Delete(updatedUser.user_id);
         Console.WriteLine(deleteMsg);
         var inviteMsg = usersApi.InviteUser(userId);
         Console.WriteLine(inviteMsg);
         var activeMsg = usersApi.MarkAsActive(userId);
         Console.WriteLine(activeMsg);
         var inactiveMsg = usersApi.MarkAsInactive(userId);
         Console.WriteLine(inactiveMsg);
     }
     catch(Exception e)
     {
         Console.WriteLine(e.Message);
     }
     Console.ReadKey();
 }
        static void Main(string[] args)
        {
            try
            {
                var service = new ZohoBooks();
                service.initialize("{authtoken}", "{organization id}");
                var vendorPaymentsApi = service.GetVendorPaymentsApi();
                var parameters        = new Dictionary <object, object>();
                parameters.Add("filter_by", "PaymentMode.BankTransfer");
                var vendorpayments  = vendorPaymentsApi.GetVendorPayments(parameters);
                var vendorPaymentId = vendorpayments[1].payment_id;
                if (vendorpayments != null)
                {
                    foreach (var vendorpayment in vendorpayments)
                    {
                        Console.WriteLine("{0},{1},{2}", vendorpayment.payment_id, vendorpayment.vendor_id, vendorpayment.amount);
                    }
                }
                var vendorpayment1 = vendorPaymentsApi.Get(vendorPaymentId);
                if (vendorpayment1 != null)
                {
                    Console.WriteLine("{0},{1},{2}", vendorpayment1.payment_id, vendorpayment1.vendor_id, vendorpayment1.amount);
                }

                var newVendorPaymentInfo = new VendorPayment()
                {
                    vendor_id = "{vendor id}",
                    amount    = 1560,
                };
                var newVendorPayment = vendorPaymentsApi.Create(newVendorPaymentInfo);

                if (newVendorPayment != null)
                {
                    Console.WriteLine("{0},{1},{2}", newVendorPayment.payment_id, newVendorPayment.vendor_id, newVendorPayment.amount);
                }
                var updateinfo = new VendorPayment()
                {
                    amount = 10
                };
                var updatedVendorPayment = vendorPaymentsApi.Update(vendorPaymentId, updateinfo);
                if (updatedVendorPayment != null)
                {
                    Console.WriteLine("{0},{1},{2}", updatedVendorPayment.payment_id, updatedVendorPayment.vendor_id, updatedVendorPayment.amount);
                }
                var delvendorpayments = vendorPaymentsApi.Delete(vendorpayments[3].payment_id);
                Console.WriteLine(delvendorpayments);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
 static void Main(string[] args)
 {
     try
     {
         var service = new ZohoBooks();
         service.initialize("{authtoken}", "{organization id}");
         CustomerPaymentsApi customerpaymentsApi = service.GetCustomerPaymentsApi();
         var parameters = new Dictionary<object, object>();
         parameters.Add("customer_name_startswith", "h");
         var customerpaymentsList = customerpaymentsApi.GetCustomerPayments(parameters);
         var customerpayments = customerpaymentsList;
         var paymentId = customerpayments[2].payment_id;
         if (customerpayments != null)
         {
             foreach (var customerpayment in customerpayments)
                 Console.WriteLine("{0},{1},{2}", customerpayment.account_name, customerpayment.amount, customerpayment.customer_name);
         }
         var customerpayment1 = customerpaymentsApi.Get(paymentId);
         if(customerpayment1!=null)
             Console.WriteLine("{0},{1},{2}", customerpayment1.account_name, customerpayment1.amount, customerpayment1.customer_name);
         var customerId = customerpayment1.customer_id;
         var newPaymentInfo = new CustomerPayment()
         {
             customer_id = customerId,
             date="2014-02-03",
             amount=1234,
         };
         var newCustomerPayment = customerpaymentsApi.Create(newPaymentInfo);
         if(newCustomerPayment!=null)
             Console.WriteLine("{0},{1},{2}", newCustomerPayment.account_name, newCustomerPayment.amount, newCustomerPayment.customer_name);
         var updateInfo = new CustomerPayment()
         {
             amount=100000,
         };
         var updatedCustomerPayment = customerpaymentsApi.Update(paymentId, updateInfo);
         if(updatedCustomerPayment!=null)
             Console.WriteLine("{0},{1},{2}", updatedCustomerPayment.account_name, updatedCustomerPayment.amount, updatedCustomerPayment.customer_name);
         var delcustpayment = customerpaymentsApi.Delete(customerpayments[1].payment_id);
         Console.WriteLine(delcustpayment);
     }
     catch(Exception e)
     {
         Console.WriteLine(e.Message);
     }
     Console.ReadKey();
 }
        static void Main(string[] args)
        {
            try
            {
                var service = new ZohoBooks();
                service.initialize("{authtoken}", "{organization id}");
                var vendorPaymentsApi = service.GetVendorPaymentsApi();
                var parameters = new Dictionary<object, object>();
                parameters.Add("filter_by", "PaymentMode.BankTransfer");
                var vendorpayments = vendorPaymentsApi.GetVendorPayments(parameters);
                var vendorPaymentId = vendorpayments[1].payment_id;
                if (vendorpayments != null)
                    foreach (var vendorpayment in vendorpayments)
                        Console.WriteLine("{0},{1},{2}", vendorpayment.payment_id, vendorpayment.vendor_id, vendorpayment.amount);
                var vendorpayment1 = vendorPaymentsApi.Get(vendorPaymentId);
                if (vendorpayment1 != null)
                    Console.WriteLine("{0},{1},{2}", vendorpayment1.payment_id, vendorpayment1.vendor_id, vendorpayment1.amount);

                var newVendorPaymentInfo = new VendorPayment()
                {
                    vendor_id="{vendor id}",
                    amount = 1560,
                };
                var newVendorPayment = vendorPaymentsApi.Create(newVendorPaymentInfo);

                if (newVendorPayment != null)
                {
                    Console.WriteLine("{0},{1},{2}", newVendorPayment.payment_id, newVendorPayment.vendor_id, newVendorPayment.amount);
                }
                var updateinfo = new VendorPayment()
                 {
                     amount = 10
                 };
                var updatedVendorPayment = vendorPaymentsApi.Update(vendorPaymentId, updateinfo);
                if (updatedVendorPayment != null)
                    Console.WriteLine("{0},{1},{2}", updatedVendorPayment.payment_id, updatedVendorPayment.vendor_id, updatedVendorPayment.amount);
                var delvendorpayments = vendorPaymentsApi.Delete(vendorpayments[3].payment_id);
                Console.WriteLine(delvendorpayments);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
Exemple #15
0
 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();
 }
 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();
 }
 static void Main(string[] args)
 {
     try
     {
         var service = new ZohoBooks();
         service.initialize("{authtoken}", "{organization id}");
         var vendorCreditsApi = service.GetVendorCreditsApi();
         Console.WriteLine("--------------------VendorCreditList--------------");
         var vendorCredits = vendorCreditsApi.GetVendorCredits(null);
         foreach (var tempVendorCredit in vendorCredits)
             Console.WriteLine("Id:{0},Vendor name:{1},Status:{2}",tempVendorCredit.vendor_credit_id,tempVendorCredit.vendor_name,tempVendorCredit.status);
         Console.WriteLine("----------------------------------Specified Vendor Credit-----------------------");
         var vendorCredit = vendorCreditsApi.Get(vendorCredits[0].vendor_credit_id,null);
         Console.WriteLine("Id:{0},Vendor name:{1},Status:{2}", vendorCredit.vendor_credit_id, vendorCredit.vendor_name, vendorCredit.status);
         Console.WriteLine("Line items:");
         var lineitems = vendorCredit.line_items;
         foreach (var tempLineItem in lineitems)
             Console.WriteLine("name:{0},desc:{1},rate:{2}", tempLineItem.name, tempLineItem.description, tempLineItem.rate);
         Console.WriteLine("------------------New Vendor Credit---------");
         var newCreditInfo = new VendorCredit()
         {
             vendor_id=vendorCredit.vendor_id,
             line_items = new List<LineItem>()
             {
                 new LineItem(){
                     item_id=lineitems[0].item_id,
                     rate=360,
                 },
             },
         };
         var newVendorCredit = vendorCreditsApi.Create(newCreditInfo, null);
         Console.WriteLine("Id:{0},Vendor name:{1},Status:{2},amount:{3}", newVendorCredit.vendor_credit_id, newVendorCredit.vendor_name, newVendorCredit.status,newVendorCredit.total);
         Console.WriteLine("-------------------------Update Vendor Credit------------");
         var creditUpdateInfo = new VendorCredit()
         {
             
             line_items = new List<LineItem>()
             {
                 new LineItem(){
                     item_id=lineitems[0].item_id,
                     rate=560,
                 },
             },
         };
         var updatedVendorCredit = vendorCreditsApi.Update(newVendorCredit.vendor_credit_id, creditUpdateInfo);
         Console.WriteLine("Id:{0},Vendor name:{1},Status:{2},amount:{3}", updatedVendorCredit.vendor_credit_id, updatedVendorCredit.vendor_name, updatedVendorCredit.status, updatedVendorCredit.total);
         Console.WriteLine("-----------------------Delete Vendor Credit----------------");
         var deleteVendorcredit = vendorCreditsApi.Delete(updatedVendorCredit.vendor_credit_id);
         Console.WriteLine(deleteVendorcredit);
         Console.WriteLine("------------------Statuses----------------");
         var convertToOpen = vendorCreditsApi.ConvertToOpen(vendorCredits[0].vendor_credit_id);
         Console.WriteLine(convertToOpen);
         var markAsVoid = vendorCreditsApi.MarkAsVoid(vendorCredits[1].vendor_credit_id);
         Console.WriteLine(markAsVoid);
         Console.WriteLine("---------------------------------Bills credited-------------------------------");
         var bills = vendorCreditsApi.GetBillsCredited(vendorCredits[0].vendor_credit_id);
         foreach (var tempBill in bills)
             Console.WriteLine("Bill id:{0},vendor credit bill id:{1},amount:{2}",tempBill.bill_id,tempBill.vendor_credit_bill_id,tempBill.amount);
         var billsToApply = new ApplyToBills()
         {
             bills = new List<Bill>()
             {
                 new Bill(){
                     bill_id=bills[0].bill_id,
                     amount_applied=100
                  },
             }
         };
         var applyCredits = vendorCreditsApi.ApplyCreditsToBill(vendorCredits[0].vendor_credit_id, billsToApply);
         Console.WriteLine(applyCredits);
         var deleteBillsCredited = vendorCreditsApi.DeleteBillsCredited(vendorCredits[0].vendor_credit_id, bills[0].vendor_credit_bill_id);
         Console.WriteLine(deleteBillsCredited);
         Console.WriteLine("------------------------------------Refunds------------------------");
         var allRefunds = vendorCreditsApi.GetRefunds(null);
         foreach (var tempRefund in allRefunds)
             Console.WriteLine("Refund id:{0},vendor name:{1},amount:{2}",tempRefund.vendor_credit_refund_id,tempRefund.vendor_name,tempRefund.amount_fcy);
         var refundsOfCredit = vendorCreditsApi.GetRefundsOfVendorCredit(vendorCredits[0].vendor_credit_id);
         foreach (var tempRefund in refundsOfCredit)
             Console.WriteLine("Refund id:{0},vendor name:{1},amount:{2}", tempRefund.vendor_credit_refund_id, tempRefund.vendor_name, tempRefund.amount_fcy);
         var refund = vendorCreditsApi.GetVendorCreditRefund(vendorCredits[0].vendor_credit_id, refundsOfCredit[0].vendor_credit_refund_id);
         Console.WriteLine("Specified Refund \n Refund id:{0},vendor name:{1},amount:{2}", refund.vendor_credit_refund_id, refund.vendor_name, refund.amount);
         var newRefundInfo = new VendorCreditRefund()
         {
             date="2014-11-25",
             account_id=refund.account_id,
             amount=20
         };
         var newRefund = vendorCreditsApi.AddRefund(vendorCredits[0].vendor_credit_id, newRefundInfo);
         Console.WriteLine("New Refund \n Refund id:{0},vendor name:{1},amount:{2}", newRefund.vendor_credit_refund_id, newRefund.vendor_name, newRefund.amount);
         var updateInfo = new VendorCreditRefund()
         {
             amount = 25
         };
         var updatedRefund = vendorCreditsApi.UpdateRefund(vendorCredits[0].vendor_credit_id, newRefund.vendor_credit_refund_id, updateInfo);
         Console.WriteLine("Updated Refund \n Refund id:{0},vendor name:{1},amount:{2}", updatedRefund.vendor_credit_refund_id, updatedRefund.vendor_name, updatedRefund.amount);
         var deleteRefund = vendorCreditsApi.DeleteRefund(vendorCredits[0].vendor_credit_id, updatedRefund.vendor_credit_refund_id);
         Console.WriteLine(deleteRefund);
         Console.WriteLine("--------------------------Comments-------------------");
         var comments = vendorCreditsApi.GetComments(vendorCredits[0].vendor_credit_id);
         foreach (var comment in comments)
             Console.WriteLine("id:{0},description:{1},commented by:{2}", comment.comment_id, comment.description, comment.commented_by);
         var newCommentInfo = new Comment()
         {
             description="test comment",
         };
         var newComment = vendorCreditsApi.AddComment(vendorCredits[0].vendor_credit_id, newCommentInfo);
         Console.WriteLine("New comment \nid:{0},description:{1},commented by:{2}", newComment.comment_id, newComment.description, newComment.commented_by);
         var deleteComment = vendorCreditsApi.DeleteComment(newComment.vendor_credit_id, newComment.comment_id);
         Console.WriteLine(deleteComment);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
     Console.ReadKey();
 }
Exemple #18
0
        static void Main(string[] args)
        {
            try
            {
                var service = new ZohoBooks();
                service.initialize("{authtoken}", "{organization id}");
                CreditNotesApi creditnoteApi = service.GetCreditNoteApi();

                var parameters = new Dictionary <object, object>();
                parameters.Add("creditnote_number_startswith", "CN");
                parameters.Add("status", "open");
                parameters.Add("total_less_than", "5000");
                var creditnotesList = creditnoteApi.GetCreditnotes(parameters);
                var creditnotes     = creditnotesList;
                var creditnoteId    = creditnotes[0].creditnote_id;
                if (creditnotes != null)
                {
                    foreach (var creditnote in creditnotes)
                    {
                        Console.WriteLine("{0},{1},{2}", creditnote.creditnote_number, creditnote.total_credits_used, creditnote.total);
                    }
                }
                var parameters1 = new Dictionary <object, object>();
                parameters1.Add("print", "false");

                var creditnote1 = creditnoteApi.Get(creditnoteId, parameters1);
                if (creditnote1 != null)
                {
                    Console.WriteLine("{0},{1},{2}", creditnote1.creditnote_number, creditnote1.total_credits_used, creditnote1.total);
                }
                var newCreditnote = new CreditNote()
                {
                    customer_id       = "{customer id}",
                    creditnote_number = "CN-0008",
                    line_items        = new List <LineItem>()
                    {
                        new LineItem()
                        {
                            item_id = "{item id}",

                            name        = "Hard Drive",
                            description = "500GB, USB 2.0 interface 1400 rpm, protective hard case.",
                            unit        = "",
                            rate        = 120.00,
                            quantity    = 1.00,
                        },
                    }
                };
                var parameters2 = new Dictionary <object, object>();
                parameters2.Add("ignore_auto_number_generation", "true");

                var createdCreditnote = creditnoteApi.Create(newCreditnote, parameters2);
                if (createdCreditnote != null)
                {
                    Console.WriteLine("{0},{1},{2}", createdCreditnote.creditnote_number, createdCreditnote.total_credits_used, createdCreditnote.total);
                }
                CreditNote updateInf = new CreditNote()
                {
                    customer_id       = "{customer id}",
                    creditnote_number = "CN-00000",
                };
                var parameters3 = new Dictionary <object, object>();
                parameters3.Add("ignore_auto_number_generation", "true");
                var updatedCreditnote = creditnoteApi.Update(creditnoteId, updateInf, parameters3);
                if (updatedCreditnote != null)
                {
                    Console.WriteLine("{0},{1},{2}", updatedCreditnote.creditnote_number, updatedCreditnote.total_credits_used, updatedCreditnote.total);
                }
                var delstr = creditnoteApi.Delete(creditnotes[2].creditnote_id);
                Console.WriteLine(delstr);
                var convToOpen = creditnoteApi.ConvertToOpen(creditnoteId);
                Console.WriteLine(convToOpen);
                var voidstr = creditnoteApi.ConvertToVoid(creditnoteId);
                Console.WriteLine(voidstr);
                var parameters4 = new Dictionary <object, object>();
                var emaildata   = new EmailNotification()
                {
                    send_from_org_email_id = false,
                    to_mail_ids            = new List <string>()
                    {
                        "*****@*****.**"
                    },

                    subject = "Credit Note from Zillium Inc ",
                    body    = "Dear Customer,           <br><br><br><br>The credit note  is attached with this email.           <br><br><br><br>Credit Note Overview:           \n"
                };
                var emailstr = creditnoteApi.SendEmail(creditnoteId, emaildata, parameters4);
                Console.WriteLine(emailstr);
                var emailhstrs = creditnoteApi.GetEmailHistory(creditnoteId);
                if (emailhstrs != null)
                {
                    foreach (var emailhstr in emailhstrs)
                    {
                        Console.WriteLine("{0},{1},{2}", emailhstr.from, emailhstr.mailhistory_id, emailhstr.to_mail_ids);
                    }
                }
                var parameters5 = new Dictionary <object, object>();
                var emailstmt   = creditnoteApi.GetEmailContent(creditnoteId, parameters5);
                if (emailstmt != null)
                {
                    Console.WriteLine("{0},{1},{2}", emailstmt.body, emailstmt.subject, emailstmt.file_name);
                }
                var addr = new Address()
                {
                    city  = "guntur",
                    state = "AP"
                };
                var upbilladdrstr = creditnoteApi.UpdateBillingAddress(creditnoteId, addr);
                Console.WriteLine(upbilladdrstr);
                var address = new Address()
                {
                    city  = "guntur",
                    state = "AP"
                };
                var upshipp = creditnoteApi.UpdateShippingAddress(creditnoteId, address);
                Console.WriteLine(upshipp);
                var templatesList = creditnoteApi.GetTemplates();
                var templates     = templatesList;
                if (templates != null)
                {
                    foreach (var template in templates)
                    {
                        Console.WriteLine("{0},{1},{2}", template.template_id, template.template_name, template.template_type);
                    }
                }
                var updtemplatestr = creditnoteApi.UpdateTemplate(creditnoteId, templates[0].template_id);
                Console.WriteLine(updtemplatestr);
                var invoicescreditedList = creditnoteApi.GetInvoicesCredited(creditnoteId);
                var invoicescredited     = invoicescreditedList;
                if (invoicescredited != null)
                {
                    foreach (var invoicecredited in invoicescredited)
                    {
                        Console.WriteLine("{0},{1},{2}", invoicecredited.creditnote_invoice_id, invoicecredited.credited_amount, invoicecredited.invoice_id);
                    }
                }
                var applytoinvoice = new ApplyToInvoices()
                {
                    invoices = new List <CreditedInvoice>()
                    {
                        new CreditedInvoice()
                        {
                            invoice_id     = "{invoice id}",
                            amount_applied = 55.00,
                        },
                    }
                };
                var creditedinvoicesInfoList = creditnoteApi.CreditToInvoices(creditnoteId, applytoinvoice);
                var creditedinvoicesInfo     = creditedinvoicesInfoList;
                if (creditedinvoicesInfo != null)
                {
                    foreach (var creditedinvoiceInfo in creditedinvoicesInfo)
                    {
                        Console.WriteLine("{0},{1}", creditedinvoiceInfo.invoice_id, creditedinvoiceInfo.amount_applied);
                    }
                }
                var delcreditinvapplied = creditnoteApi.DeleteInvoiceCredited(creditnoteId, creditedinvoicesInfo[1].creditnote_id);
                Console.WriteLine(delcreditinvapplied);
                var parameters6   = new Dictionary <object, object>();
                var creditrefunds = creditnoteApi.GetCreditnoteRefunds(parameters6);
                if (creditrefunds != null)
                {
                    foreach (var creditrefund in creditrefunds)
                    {
                        Console.WriteLine("{0},{1},{2}", creditrefund.creditnote_refund_id, creditrefund.creditnote_number, creditrefund.amount_bcy);
                    }
                }
                var creditrefundsofcrednote = creditnoteApi.GetRefundsOfCrreditnote(creditnoteId);
                foreach (var creditrefund in creditrefundsofcrednote)
                {
                    Console.WriteLine("{0},{1},{2}", creditrefund.creditnote_refund_id, creditrefund.creditnote_number, creditrefund.amount_bcy);
                }
                var creditnoterefund = creditnoteApi.GetCreditnoteRefund(creditnoteId, creditrefundsofcrednote[0].creditnote_refund_id);
                if (creditnoterefund != null)
                {
                    Console.WriteLine("{0},{1},{2}", creditnoterefund.creditnote_refund_id, creditnoterefund.from_account_name, creditnoterefund.amount);
                }
                var refunddetails = new CreditNote()
                {
                    date            = "2014-01-30",
                    from_account_id = "{account id}",
                    amount          = 10,
                };
                var refundedcredit = creditnoteApi.AddRefund(creditnoteId, refunddetails);
                if (refundedcredit != null)
                {
                    Console.WriteLine("{0},{1},{2}", refundedcredit.creditnote_refund_id, refundedcredit.from_account_name, refundedcredit.amount);
                }
                var creditrefundupdateinfo = new CreditNote()
                {
                    date            = "2014-01-30",
                    from_account_id = "{account id}",
                    amount          = 5,
                };
                var updatedCreditrefund = creditnoteApi.UpdateRefund(creditnoteId, creditrefundsofcrednote[0].creditnote_refund_id, creditrefundupdateinfo);
                if (updatedCreditrefund != null)
                {
                    Console.WriteLine("{0},{1},{2}", updatedCreditrefund.creditnote_refund_id, updatedCreditrefund.from_account_name, updatedCreditrefund.amount);
                }
                var delcrdrefstr = creditnoteApi.DeleteRefund(creditnoteId, creditrefundsofcrednote[1].creditnote_refund_id);
                Console.WriteLine(delcrdrefstr);
                var commentsList = creditnoteApi.GetcreditnoteComments(creditnoteId);
                var comments     = commentsList;
                if (comments != null)
                {
                    foreach (var comment in comments)
                    {
                        Console.WriteLine("{0},{1},{2}", comment.comment_id, comment.description, comment.commented_by);
                    }
                }

                var newcommentinfo = new Comment()
                {
                    description = "nothing"
                };
                var newcomment = creditnoteApi.AddComment(creditnoteId, newcommentinfo);
                if (newcomment != null)
                {
                    Console.WriteLine("{0},{1},{2}", newcomment.comment_id, newcomment.description, newcomment.commented_by);
                }
                var delcommentstr = creditnoteApi.DeleteComment(creditnoteId, comments[1].comment_id);
                Console.WriteLine(delcommentstr);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            try
            {
                var service = new ZohoBooks();
                service.initialize("{authtoken}", "{organization id}");
                SettingsApi settingsApi = service.GetSettingsApi();
                Console.WriteLine("----------------Preferences-------------");
                var preferences   = settingsApi.GetPreferences();
                var autoreminders = preferences.auto_reminders;
                Console.WriteLine("Auto Reminders");
                foreach (var autoreminder in autoreminders)
                {
                    Console.WriteLine("sub:{0},body:{1},notification Type:{2}", autoreminder.subject, autoreminder.body, autoreminder.notification_type);
                }
                var addrFormat = preferences.address_formats;
                Console.WriteLine("cust addrformat:{0},Organisation Format:{1}", addrFormat.customer_address_format, addrFormat.organization_address_format);
                var updateInfo = new Preferences()
                {
                    convert_to_invoice          = false,
                    notify_me_on_online_payment = true,
                    is_show_powered_by          = true,
                    is_estimate_enabled         = false,
                };
                var updateMsg = settingsApi.UpdatePreferences(updateInfo);

                var newUnit = new Unit()
                {
                    unit = "new unit"
                };
                var addUnit = settingsApi.CreateUnit(newUnit);
                Console.WriteLine(addUnit);
                var deleteUnit = settingsApi.DeleteUnit("{Unit id}");
                Console.WriteLine(deleteUnit);
                Console.WriteLine("----------------------------------------------------\n------------------Tax and TaxGroups-----------------");
                var taxeslist = settingsApi.GetTaxes();
                var taxes     = taxeslist;
                var taxId     = taxes[0].tax_id;
                foreach (var tax in taxes)
                {
                    Console.WriteLine("taxId:{0},name:{1},percentage:{2},Type:{3}", tax.tax_id, tax.tax_name, tax.tax_percentage, tax.tax_type);
                }
                var tax1 = settingsApi.GetTax(taxId);
                Console.WriteLine("taxId:{0},name:{1},percentage:{2},Type:{3}", tax1.tax_id, tax1.tax_name, tax1.tax_percentage, tax1.tax_type);
                var newTaxInfo = new Tax()
                {
                    tax_name       = "VAT1",
                    tax_percentage = 5
                };
                var newTax = settingsApi.CreateTax(newTaxInfo);
                Console.WriteLine("taxId:{0},name:{1},percentage:{2},Type:{3}", newTax.tax_id, newTax.tax_name, newTax.tax_percentage, newTax.tax_type);
                var updateInfo1 = new Tax()
                {
                    tax_percentage = 6,
                    tax_type       = "compound_tax",
                };
                var updatedTax = settingsApi.UpdateTax(newTax.tax_id, updateInfo1);
                Console.WriteLine("taxId:{0},name:{1},percentage:{2},Type:{3}", updatedTax.tax_id, updatedTax.tax_name, updatedTax.tax_percentage, updatedTax.tax_type);
                var deletemsg = settingsApi.DeleteTax(updatedTax.tax_id);
                Console.WriteLine(deletemsg);
                var taxgroup = settingsApi.GetTaxGroup("71917000000259007");
                Console.WriteLine("the tax group {0} contains the taxes", taxgroup.tax_group_name);
                var taxes1 = taxgroup.taxes;
                foreach (var tax in taxes1)
                {
                    Console.WriteLine("taxId:{0},name:{1},percentage:{2},Type:{3}", tax.tax_id, tax.tax_name, tax.tax_percentage, tax.tax_type);
                }
                var newTaxGroupInfo = new TaxGroupToCreate()
                {
                    tax_group_name = "purchase",
                    taxes          = taxes[0].tax_id + "," + taxes[2].tax_id,
                };
                var newTaxGroup = settingsApi.CreateTaxGroup(newTaxGroupInfo);
                var taxGroupId  = newTaxGroup.tax_group_id;
                Console.WriteLine("the tax group {0} contains the taxes of tax percentage{1}", newTaxGroup.tax_group_name, newTaxGroup.tax_group_percentage);
                var taxes2 = newTaxGroup.taxes;
                foreach (var tax in taxes2)
                {
                    Console.WriteLine("taxId:{0},name:{1},percentage:{2},Type:{3}", tax.tax_id, tax.tax_name, tax.tax_percentage, tax.tax_type);
                }
                var updateInfo2 = new TaxGroupToCreate()
                {
                    tax_group_name = "purcha",
                    taxes          = taxes[0].tax_id + "," + taxes[2].tax_id,
                };
                var updateTaxGroup = settingsApi.UpdateTaxGroup(taxGroupId, updateInfo2);
                Console.WriteLine("the tax group {0} updated as the taxes of tax percentage{1}", updateTaxGroup.tax_group_name, updateTaxGroup.tax_group_percentage);
                var deleteMsg = settingsApi.DeleteTaxGroup(taxGroupId);
                Console.WriteLine(deleteMsg);
                Console.WriteLine("----------------------------------------------------\n------------------Opening balence-----------------");
                var openingbalence = settingsApi.GetOpeningBalance();
                Console.WriteLine("The accounts in opening balance {0}", openingbalence.opening_balance_id);
                var accounts = openingbalence.accounts;
                foreach (var account in accounts)
                {
                    Console.WriteLine("account id:{3},account name:{0},debit/ccredit:{1},amount:{2}", account.account_name, account.debit_or_credit, account.amount, account.account_id);
                }
                var newOpeningbalanceInfo = new OpeningBalance()
                {
                    date     = "2014-05-06",
                    accounts = new List <Account>()
                    {
                        new Account()
                        {
                            account_id      = "71917000000000379",
                            debit_or_credit = "credit",
                            amount          = 200,
                            currency_id     = "71917000000000099",
                        },
                    }
                };
                var newOpeningbalance = settingsApi.CreateOpeningBalance(newOpeningbalanceInfo);
                Console.WriteLine("The accounts in opening balance {0}", newOpeningbalance.opening_balance_id);
                var accounts1 = newOpeningbalance.accounts;
                foreach (var account in accounts1)
                {
                    Console.WriteLine("account id:{3},account name:{0},debit/ccredit:{1},amount:{2}", account.account_name, account.debit_or_credit, account.amount, account.account_id);
                }
                var updateInfo3 = new OpeningBalance()
                {
                    date     = "2014-05-06",
                    accounts = new List <Account>()
                    {
                        new Account()
                        {
                            account_id      = "71917000000000379",
                            debit_or_credit = "credit",
                            amount          = 400,
                            currency_id     = "71917000000000099",
                        },
                    }
                };
                var updatedOpeningbalance = settingsApi.UpdateOpeningBalance(updateInfo3);
                Console.WriteLine("The accounts in opening balance {0}", updatedOpeningbalance.opening_balance_id);
                var accounts2 = updatedOpeningbalance.accounts;
                foreach (var account in accounts2)
                {
                    Console.WriteLine("account id:{3},account name:{0},debit/ccredit:{1},amount:{2}", account.account_name, account.debit_or_credit, account.amount, account.account_id);
                }
                var delmsg = settingsApi.DeleteOpeningBalance();
                Console.WriteLine(delmsg);
                Console.WriteLine("----------------------------------------------------\n------------------Reminders-----------------");
                var reminders    = settingsApi.GetAutoPaymentReminders();
                var autoRemindId = reminders[1].autoreminder_id;
                foreach (var reminder in reminders)
                {
                    Console.WriteLine("reminder Id:{0}\n is_enable:{1}\nbody:{2}\n", reminder.autoreminder_id, reminder.is_enabled, reminder.body);
                }
                var reminderAndPlaceholder = settingsApi.GetAnAutoPaymentReminder(autoRemindId);
                var reminder1 = reminderAndPlaceholder.autoreminder;
                Console.WriteLine("reminder Id:{0}\n is_enable:{1}\nbody:{2}\n", reminder1.autoreminder_id, reminder1.is_enabled, reminder1.body);
                var placeholder = reminderAndPlaceholder.placeholders;
                Console.WriteLine("placeholders Invoices are");
                var invoices = placeholder.Invoice;
                foreach (var invoice in invoices)
                {
                    Console.WriteLine("name:{0},value:{1}", invoice.name, invoice.value);
                }
                Console.WriteLine("placeholders Customers are");
                var customers = placeholder.Customer;
                foreach (var customer in customers)
                {
                    Console.WriteLine("name:{0},value:{1}", customer.name, customer.value);
                }
                Console.WriteLine("placeholders Organizations are are");
                var organizations = placeholder.Organization;
                foreach (var organization in organizations)
                {
                    Console.WriteLine("name:{0},value:{1}", organization.name, organization.value);
                }
                var reminderenable = settingsApi.EnableAutoReminder(autoRemindId);
                Console.WriteLine(reminderenable);
                var reminderdisable = settingsApi.DisableAutoReminder(autoRemindId);
                Console.WriteLine(reminderdisable);
                var updateInfo4 = new AutoReminder()
                {
                    is_enabled   = true,
                    type         = "days_before_due_date",
                    address_type = "remind_customer_and_cc_me"
                };
                var updateMsg1 = settingsApi.UpdateAnAutoReminder(autoRemindId, updateInfo4);
                Console.WriteLine(updateMsg1);
                var parameters = new Dictionary <object, object>();
                parameters.Add("type", "open_reminder");
                var manualreminders = settingsApi.GetManualReminders(parameters);
                var manualRemindId  = manualreminders[0].manualreminder_id;
                foreach (var manualreminder in manualreminders)
                {
                    Console.WriteLine("reminder Id:{0}\n is_enable:{1}\nbody:{2}\ncc_me:{3}", manualreminder.manualreminder_id, manualreminder.type, manualreminder.body, manualreminder.cc_me);
                }
                var manualreminder1 = settingsApi.GetManualReminder(manualRemindId);
                var reminder2       = manualreminder1.manualreminder;
                Console.WriteLine("reminder Id:{0}\n is_enable:{1}\nbody:{2}\ncc_me:{3}", reminder2.manualreminder_id, reminder2.type, reminder2.body, reminder2.cc_me);
                var placeholder1 = manualreminder1.placeholders;
                Console.WriteLine("placeholders Invoices are");
                var invoices1 = placeholder.Invoice;
                foreach (var invoice in invoices1)
                {
                    Console.WriteLine("name:{0},value:{1}", invoice.name, invoice.value);
                }
                Console.WriteLine("placeholders Customers are");
                var customers1 = placeholder.Customer;
                foreach (var customer in customers1)
                {
                    Console.WriteLine("name:{0},value:{1}", customer.name, customer.value);
                }
                Console.WriteLine("placeholders Organizations are are");
                var organizations1 = placeholder.Organization;
                foreach (var organization in organizations1)
                {
                    Console.WriteLine("name:{0},value:{1}", organization.name, organization.value);
                }
                var updateInfo5 = new ManualReminder()
                {
                    cc_me = true
                };
                var updatedmsg = settingsApi.UpdateManualReminder(manualRemindId, updateInfo5);
                Console.WriteLine(updatedmsg);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            try
            {
                var service = new ZohoBooks();
                service.initialize("{authtoken}", "{organization id}");
                var projectsApi = service.GetProjectsApi();
                var parameters = new Dictionary<object, object>();
                 parameters.Add("filter_by", "Status.Active");
                 var projectsList = projectsApi.GetProjects(null);
                 var projects = projectsList;
                 var projectId = projects[0].project_id;
                 foreach (var project in projects)
                     Console.WriteLine("{0},{1},{2}", project.project_name, project.billing_type, project.status);
                 var project1 = projectsApi.Get(projectId);
                 Console.WriteLine("{0},{1},{2}", project1.project_name, project1.tasks.Count, project1.users.Count);
                 var newPrjctInfo = new Project()
                 {
                     project_name="project-test-1",
                     customer_id = project1.customer_id,
                     billing_type = "fixed_cost_for_project",
                     rate=1000,
                 };
                 var newProject = projectsApi.Create(newPrjctInfo);
                 Console.WriteLine("{0},{1},{2}", newProject.project_name, newProject.billing_type, newProject.status);
                 var updateInfo = new Project()
                 {
                     project_name="project-test-updated",
                 };
                 var updatedprjct = projectsApi.Update(newProject.project_id, updateInfo);
                 Console.WriteLine("{0},{1},{2}", updatedprjct.project_name, updatedprjct.billing_type, updatedprjct.status);
                 var delprjct = projectsApi.Delete(updatedprjct.project_id);
                 Console.WriteLine(delprjct);
                 var inAct = projectsApi.Inactivate(projectId);
                 Console.WriteLine(inAct);
                 var act = projectsApi.Activate(projectId);
                 Console.WriteLine(act);
                 var clonePrjctInfo = new Project()
                 {
                     project_name="clone-test",
                     description="cloned for test"
                 };
                 var clonePrjct = projectsApi.Clone(projectId, clonePrjctInfo);
                 Console.WriteLine("{0},{1},{2}", clonePrjct.project_name, clonePrjct.billing_type, clonePrjct.status);
                 var parameters1 = new Dictionary<object, object>();
                 var taskslist = projectsApi.GetTasks(projectId, parameters1);
                 var tasks = taskslist;
                 var taskId = tasks[0].task_id;
                 foreach (var task in tasks)
                     Console.WriteLine("{0},{1}", task.task_name, task.billed_hours);
                 var task1 = projectsApi.GetATask(projectId, taskId);
                 Console.WriteLine("{0},{1}", task1.task_name, task1.rate);
                 var newTaskInfo = new ProjectTask()
                 {
                     task_name = "task new for test",
                     description = "new task to project",

                 };
                 var newTask = projectsApi.AddATask(projectId, newTaskInfo);
                 Console.WriteLine("{0},{1}", newTask.task_name, newTask.rate);
                 var updateInfo1 = new ProjectTask()
                 {
                     task_name = "ta3",

                 };
                 var updatedTask = projectsApi.UpdateTask(projectId, newTask.task_id, updateInfo1);
                 Console.WriteLine("{0},{1}", updatedTask.task_name, updatedTask.task_id);
                 var delTask = projectsApi.DeleteTask(projectId, updatedTask.task_id);
                 Console.WriteLine(delTask);
                 var usersList = projectsApi.GetUsers(projectId);
                 var users = usersList;
                 var userId = users[0].user_id;
                 foreach (var user in users)
                     Console.WriteLine("{0},{1},{2}", user.user_name, user.user_role, user.rate);
                 var user1 = projectsApi.GetAUser(projectId, userId);
                 Console.WriteLine("{0},{1},{2}", user1.user_name, user1.user_role, user1.rate);
                 var userstoAssign = new UsersToAssign()
                 {
                     users = new List<User>()
                     {
                         new User()
                         {
                             user_id=userId
                         }
                     }
                 };
                 var users1 = projectsApi.AssignUsers(projectId, userstoAssign);
                 foreach (var user in users1)
                     Console.WriteLine("{0},{1},{2}", user.user_name, user.user_role, user.rate);
                 var userInfo = new User()
                 {
                     user_name="name-twst",
                     email="*****@*****.**",
                     user_role="staff"
                 };
                 var user2 = projectsApi.InviteUser(projectId, userInfo);
                Console.WriteLine("{0},{1},{2}", user2.user_name, user2.user_role, user2.rate);
                 var updateInfo2 = new User()
                 {
                     user_name="name",
                     user_role = "admin"
                 };
                 var UpdatedUser = projectsApi.UpdateUser(projectId, user2.user_id, updateInfo2);
                 Console.WriteLine("{0},{1},{2}", UpdatedUser.user_name, UpdatedUser.user_role, UpdatedUser.rate);
                 var deleteUser = projectsApi.DeleteUser(projectId, UpdatedUser.user_id);
                 Console.WriteLine(deleteUser);
                 var parameters2 = new Dictionary<object, object>();
                 var timeEntrieslist = projectsApi.GetTimeEnries(parameters2);
                 var timeEntries = timeEntrieslist;
                 var timeEnteryId = timeEntries[0].time_entry_id;
                 foreach (var timeentry in timeEntries)
                      Console.WriteLine("time entry of id {0} for the project {1} of user {2} of log time:{3}\n",timeentry.time_entry_id,timeentry.project_name,timeentry.user_name,timeentry.log_time);
                  var timeentry1 = projectsApi.GetATimeEntry(timeEnteryId);
                  Console.WriteLine("time entry of id {0} for the project {1} of user {2} of log time:{3}\n", timeentry1.time_entry_id, timeentry1.project_name, timeentry1.user_name, timeentry1.log_time);
                  var newTimeentryInfo = new TimeEntry()
                  {
                      project_id =projectId,
                      task_id = taskId,
                      user_id = userId,
                      log_date="2014-11-13",
                      log_time="06:46"
                  };
                  var newTimeentry = projectsApi.LogTimeEntry(newTimeentryInfo);
                  Console.WriteLine("time entry of id {0} for the project {1} of user {2} of log time:{3}\n", newTimeentry.time_entry_id, newTimeentry.project_name, newTimeentry.user_name, newTimeentry.log_time);
                  var updateInfo3 = new TimeEntry()
                  {
                      project_id = projectId,
                      user_id = userId,
                      log_time="02:00",
                  };
                  var updatedTimeEntry = projectsApi.UpdateTimeEntry(newTimeentry.time_entry_id, updateInfo3);
                  Console.WriteLine("time entry of id {0} for the project {1} of user {2} of log time:{3}\n", updatedTimeEntry.time_entry_id, updatedTimeEntry.project_name, updatedTimeEntry.user_name, updatedTimeEntry.log_time);
                  var deleteMsg = projectsApi.DeleteTimeEntry(updatedTimeEntry.time_entry_id);
                  Console.WriteLine(deleteMsg);
                  var parameters3 = new Dictionary<object, object>();
                  parameters3.Add("time_entry_ids", timeEnteryId+","+updatedTimeEntry.time_entry_id);
                  var deleteEntries = projectsApi.DeleteTimeEntries(parameters3);
                  Console.WriteLine(deleteEntries);
                  var timer = projectsApi.GetTimer();
                  Console.WriteLine("time entry of id {0} for the project {1} of user {2} of log time:{3}\n", timer.time_entry_id, timer.project_name, timer.user_name, timer.log_time);
                 var timerStart = projectsApi.StartTimer(timeEnteryId);
                 Console.WriteLine("time entry of id {0} for the project {1} of user {2} of log time:{3}\n", timerStart.time_entry_id, timerStart.project_name, timerStart.user_name, timerStart.log_time);
                 var stopTimer = projectsApi.StopTimer();
                 Console.WriteLine("time entry of id {0} for the project {1} of user {2} of log time:{3}\n", stopTimer.time_entry_id, stopTimer.project_name, stopTimer.user_name, stopTimer.log_time);
                var commentsList = projectsApi.GetComments(projectId);
                var comments = commentsList;
                foreach (var comment in comments)
                    Console.WriteLine("{0},{1},{2}", comment.comment_id, comment.description, comment.commented_by);
                var newCommentInfo = new Comment()
                {
                    description = "manually added comment",
                };
                var newComment = projectsApi.AddComment(projectId, newCommentInfo);
                Console.WriteLine("{0},{1},{2}", newComment.comment_id, newComment.description, newComment.commented_by);
                var deleteComment = projectsApi.DeleteComment(projectId, newComment.comment_id);
                Console.WriteLine(deleteComment);
                var parameters4 = new Dictionary<object, object>();
                var invoicesList = projectsApi.GetInvoices(projectId, null);
                foreach (var invoice in invoicesList)
                    Console.WriteLine("{0},{1},{2}", invoice.invoice_number, invoice.total, invoice.status);
            }
            catch(Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            try
            {
                var service = new ZohoBooks();
                service.initialize("{authtoken}", "{organizationId}");
                var rulesApi = service.GetBankRulesApi();
                var parameters = new Dictionary<object, object>();
                var accountsApi = service.GetBankAccountsApi();
                var accounts = accountsApi.GetBankAccounts(null);
                var chartOfAccountsApi = service.GetChartOfAccountsApi();
                var chartOfAccounts = chartOfAccountsApi.GetChartOfAcounts(null);
                parameters.Add("account_id", accounts[1].account_id);
                Console.WriteLine("--------------------------Rules List---------------");
                var rules = rulesApi.GetRules(parameters);
                foreach (var tempRule in rules)
                {
                    Console.WriteLine("{0},{1},{2}", tempRule.rule_id, tempRule.rule_name, tempRule.account_name);
                    var tempCriterions = tempRule.criterion;
                    Console.WriteLine("criterions");
                    foreach (var tempCriterion in tempCriterions)
                        Console.WriteLine("{0},{1}", tempCriterion.criteria_id, tempCriterion.value);
                }
                Console.WriteLine("--------------------------------------Specified Rule ----------------------------");
                var rule = rulesApi.Get(rules[0].rule_id);
                Console.WriteLine("{0},{1},{2}", rule.rule_id, rule.rule_name, rule.account_name);

                var ruleInfo = new Rule()
                {
                    rule_name = "hari",
                    target_account_id = accounts[0].account_id,
                    apply_to = "withdrawals",
                    criteria_type = "or",
                    criterion = new List<Criterion>(){
                         new Criterion(){
                             field="payee",
                             comparator="contains",
                             value="9"
                            }
                     },
                    record_as = "expense",
                    account_id = chartOfAccounts[41].account_id
                };
                Console.WriteLine("----------------------------New Rule-----------------------");
                var newRule = rulesApi.Create(ruleInfo);
                Console.WriteLine("{0},{1},{2}", newRule.rule_id, newRule.rule_name, newRule.account_name);
                var newcriterions = newRule.criterion;
                Console.WriteLine("criterions");
                foreach (var criterion in newcriterions)
                    Console.WriteLine("{0},{1}", criterion.criteria_id, criterion.value);
                var updateInfo = new Rule()
                {
                    rule_name = "krishna",
                    apply_to = "withdrawals",
                    criteria_type = "or",
                    criterion = new List<Criterion>(){
                         new Criterion(){
                             field="payee",
                             comparator="contains",
                             value="8"
                            }
                     },
                    record_as = "expense",
                };
                Console.WriteLine("----------------------------Updated Rule----------------------");
                var updatedRule = rulesApi.Update(newRule.rule_id, updateInfo);
                Console.WriteLine("{0},{1},{2}", updatedRule.rule_id, updatedRule.rule_name, updatedRule.account_name);
                var criterions1 = updatedRule.criterion;
                Console.WriteLine("criterions");
                foreach (var criterion in criterions1)
                    Console.WriteLine("{0},{1}", criterion.criteria_id, criterion.value);
                Console.WriteLine("-------------------------------Delete Rule--------------------------------------");
                var delRule = rulesApi.Delete(updatedRule.rule_id);
                Console.WriteLine(delRule);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            try
            {
                var service = new ZohoBooks();
                service.initialize("{authtoken}", "{organization id}");
                RecurringInvoicesApi recinvapi = service.GetRecurringInvoicesApi();
                var paramets = new Dictionary<object, object>();
                paramets.Add("recurrence_name_contains", "r");

                var recinvcs = recinvapi.GetRecurringInvoices(paramets);
                if (recinvcs != null)
                {
                    foreach (var x in recinvcs)
                    {
                        Console.WriteLine("{0},{1},{2}", x.recurrence_name, x.recurring_invoice_id, x.created_time);

                    }
                }
                var recinvId = recinvcs[0].recurring_invoice_id;
                var recinv = recinvapi.Get(recinvId);
                var customerId = recinv.customer_id;
                var templateId = recinv.template_id;
                var itemId = recinv.line_items[0].item_id;
                if (recinv != null)
                    Console.WriteLine("{0},{1},{2}", recinv.recurrence_name, recinv.recurring_invoice_id, recinv.created_time);
                var newRecurInv = new RecurringInvoice()
                {
                    recurrence_name = "Premium2",
                    customer_id = customerId,
                    contact_persons = new List<string> { },
                    template_id = templateId,
                    start_date = "2013-10-03",
                    end_date = "2014-11-04",
                    recurrence_frequency = "months",
                    repeat_every = 1,
                    payment_terms = 15,
                    payment_terms_label = "Net 15",
                    exchange_rate = 1.00,
                    payment_options = new PaymentOptions()
                    {
                        payment_gateways = new List<PaymentGateway>()
                        {

                        }
                    },
                    discount = 0.00,
                    is_discount_before_tax = true,
                    discount_type = "item_level",
                    allow_partial_payments = true,
                    line_items = new List<LineItem>{
                 new LineItem() {
                   item_id=itemId,
                   name="Premium Pla",
                   description="10 GB Space, 300 GB Transfer 100 Email Accounts 10 MySQL Databases",
                   item_order= 1,

                   quantity=1.00,
                   unit="Nos",
                   discount="10.60%",

                 },
               },
                    notes = "Thanks for your business.",
                    terms = "",
                    salesperson_name = "John Michael",
                    shipping_charge = 10.00,
                    adjustment = 2.00,
                    adjustment_description = "Adjustment"

                };
                var createdrecinv = recinvapi.Create(newRecurInv);
                if (createdrecinv != null)
                    Console.WriteLine("{0},{1},{2}", createdrecinv.recurrence_name, createdrecinv.recurring_invoice_id, createdrecinv.created_time);
                var updatInfo = new RecurringInvoice()
                {
                    recurrence_name = "rec name",

                    template_id = templateId,
                    start_date = "2013-10-03",
                    end_date = "2013-11-04",
                    recurrence_frequency = "months",
                    repeat_every = 1,
                    payment_terms = 15,

                    discount = 2.00,
                    is_discount_before_tax = false,
                    discount_type = "item_level",
                    allow_partial_payments = true,

                    salesperson_name = "",
                };
                var updatedinfo = recinvapi.Update(recinvId, updatInfo);
                if (updatedinfo != null)
                {
                    Console.WriteLine("{0},{1},{2}", updatedinfo.recurrence_name, updatedinfo.recurring_invoice_id, updatedinfo.created_time);
                }
                var delresp = recinvapi.Delete(recinvcs[2].recurring_invoice_id);
                Console.WriteLine(delresp);
                var stopres = recinvapi.Stop(recinvId);
                Console.WriteLine(stopres);
                var resumeres = recinvapi.Resume(recinvId);
                Console.WriteLine(resumeres);
                var templatechang = recinvapi.UpdateTemplate(recinvId, templateId);
                Console.WriteLine(templatechang);
                var comments = recinvapi.GetComments(recinvId);
                if (comments != null)
                {
                    foreach (var comment in comments)
                    {
                        Console.WriteLine("{0},{1},{2}", comment.comment_id, comment.description, comment.commented_by_id);
                    }
                }
            }
            catch(Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
Exemple #23
0
        static void Main(string[] args)
        {
            var service = new ZohoBooks();

            service.initialize("{authtoken}", "{organizationId}");
            ContactsApi contactsApi  = service.GetContactsApi();
            var         parameters   = new Dictionary <object, object>();
            var         contactsList = contactsApi.GetContacts(parameters);
            var         contacts     = contactsList;
            var         contactId    = contacts[0].contact_id;

            if (contacts != null)
            {
                foreach (var cont in contacts)
                {
                    Console.WriteLine("{0},{1},{2}", cont.contact_id, cont.contact_name, cont.contact_type);
                }
            }
            var contact = contactsApi.Get(contacts[0].contact_id);

            Console.WriteLine("{0},{1},{2}", contact.contact_id, contact.contact_name, contact.contact_type);
            var contactpers = contact.contact_persons;

            foreach (var per in contactpers)
            {
                Console.WriteLine("{0},{1},{2}", per.contact_person_id, per.email, per.is_primary_contact);
            }
            var newContact = new Contact()
            {
                contact_name        = "name",
                payment_terms       = 15,
                payment_terms_label = "Net 15",
                currency_id         = "{currency id}",
                billing_address     = new Address()
                {
                    address = "4900 Hopyard Rd, Suite 310",
                    city    = "Pleasanton",
                    state   = "CA",
                    zip     = "94588",
                    country = "USA",
                    fax     = "+1-925-924-9600"
                },
                shipping_address = new Address()
                {
                    address = "Suite 125, McMillan Avenue",
                    city    = "San Francisco",
                    state   = "CA",
                    zip     = "94134",
                    country = "USA",
                    fax     = "+1-925-924-9600"
                },
                contact_persons = new List <ContactPerson>()
                {
                    new ContactPerson()
                    {
                        salutation = "Mr.",
                        first_name = "Will",
                        last_name  = "Smith",
                        email      = "*****@*****.**",
                    },
                    new ContactPerson()
                    {
                        salutation = "Mr.",
                        first_name = "Peter",
                        last_name  = "Parker",
                        email      = "*****@*****.**",
                    }
                },

                notes = "Payment option : Through check"
            };
            var contact1 = contactsApi.Create(newContact);

            Console.WriteLine("{0},{1},{2}", contact1.contact_id, contact1.contact_name, contact1.contact_type);
            var contactpersons = contact.contact_persons;

            foreach (var per in contactpersons)
            {
                Console.WriteLine("{0},{1},{2}", per.contact_person_id, per.email, per.is_primary_contact);
            }
            var updateInfo = new Contact()
            {
                payment_terms       = 15,
                payment_terms_label = "Net 15",

                billing_address = new Address()
                {
                    address = "4900 Hopyard Rd, Suite 310",
                    city    = "Pleasanton",
                    state   = "CA",
                    zip     = "94588",
                    country = "USA",
                    fax     = "+1-925-924-9600"
                },
                shipping_address = new Address()
                {
                    address = "Suite 125, McMillan Avenue",
                    city    = "San Francisco",
                    state   = "CA",
                    zip     = "94134",
                    country = "USA",
                    fax     = "+1-925-924-9600"
                },
                contact_persons = new List <ContactPerson>()
                {
                    new ContactPerson()
                    {
                        salutation = "Mr.",
                        first_name = "Will",
                        last_name  = "Smith",
                        email      = "*****@*****.**",
                        phone      = "+1-925-921-9201",
                        mobile     = "+1-4054439562"
                    },
                    new ContactPerson()
                    {
                        salutation = "Mr.",
                        first_name = "Peter",
                        last_name  = "Parker",
                        email      = "*****@*****.**",
                        phone      = "+1-925-929-7211",
                        mobile     = "+1-4054439760"
                    }
                },

                notes = "Payment option : Through check"
            };
            var updatedcontact = contactsApi.Update(contactId, updateInfo);

            Console.WriteLine("{0},{1},{2}", updatedcontact.contact_id, updatedcontact.contact_name, updatedcontact.contact_type);
            var contctpersons = updatedcontact.contact_persons;

            foreach (var per in contctpersons)
            {
                Console.WriteLine("{0},{1},{2}", per.contact_person_id, per.email, per.is_primary_contact);
            }
            var deleteContact = contactsApi.Delete(contacts[1].contact_id);

            Console.WriteLine(deleteContact);
            var inactive = contactsApi.MarkAsInactive(contactId);

            Console.WriteLine(inactive);
            var active = contactsApi.MarkAsActive(contactId);

            Console.WriteLine(active);
            var EnableReminder = contactsApi.EnablePaymentReminder(contactId);

            Console.WriteLine(EnableReminder);
            var disableReminder = contactsApi.DisablePaymentReminder(contactId);

            Console.WriteLine(disableReminder);
            var emailnote = new EmailNotification()
            {
                to_mail_ids = new List <string>()
                {
                    "*****@*****.**",
                },
                subject = "email notify",
                body    = "body of mail"
            };
            var emailstmt = contactsApi.SendEmailStatement(contactId, emailnote, null, null);

            Console.WriteLine(emailstmt);
            parameters.Add("start_date", "2014-03-15");
            parameters.Add("end_date", "2014-04-29");
            var emaildata = contactsApi.GetEmailStatementContent(contactId, parameters);

            Console.WriteLine(emaildata.body);
            var emailnotify = new EmailNotification()
            {
                to_mail_ids = new List <string>()
                {
                    "*****@*****.**",
                },
                subject = "email notify",
                body    = "body of mail"
            };
            var emailcntct = contactsApi.SendEmailStatement(contactId, emailnotify, null, null);

            Console.WriteLine(emailcntct);
            var comments = contactsApi.GetComments(contactId);

            foreach (var comment in comments)
            {
                Console.WriteLine("{0},{1}", comment.comment_id, comment.description);
            }
            var refunds = contactsApi.GetRefunds(contactId);

            foreach (var refund in refunds)
            {
                Console.WriteLine("{0},{1}", refund.refund_mode, refund.amount);
            }
            var track = contactsApi.Track1099(contactId);

            Console.WriteLine(track);
            var untrack = contactsApi.UnTrack1099(contactId);

            Console.WriteLine(untrack);
            var cntctpersnsList = contactsApi.GetContactPersons(contacts[0].contact_id);
            var cntctPersons    = cntctpersnsList;
            var contactPersonId = cntctPersons[0].contact_person_id;

            foreach (var cntctper in cntctPersons)
            {
                Console.WriteLine("{0},{1},{2}", cntctper.contact_person_id, cntctper.last_name, cntctper.first_name);
            }

            var contactperson = contactsApi.GetContactPerson(contacts[0].contact_id, contactPersonId);

            Console.WriteLine("{0},{1},{2}", contactperson.contact_person_id, contactperson.last_name, contactperson.first_name);
            var contactPerInfo = new ContactPerson()
            {
                contact_id = "{contactId}",
                first_name = "hk"
            };
            var newContactPer = contactsApi.CreateContactPerson(contactPerInfo);

            Console.WriteLine("{0},{1},{2}", newContactPer.contact_person_id, newContactPer.last_name, newContactPer.first_name);
            var updateInfo1 = new ContactPerson()
            {
                first_name = "fname"
            };
            var updated = contactsApi.UpdateContactperson(contactPersonId, updateInfo1);

            Console.WriteLine("{0},{1},{2}", updated.contact_person_id, updated.last_name, updated.first_name);
            var deletedmsg = contactsApi.DeleteContactPerson(contactPersonId);

            Console.WriteLine(deletedmsg);

            var makeAsPrimary = contactsApi.MarkAsPrimaryContactPerson(contactPersonId);

            Console.WriteLine(makeAsPrimary);
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            try
            {
                var service = new ZohoBooks();
                service.initialize("{authtoken}", "{organisation id}");
                EstimatesApi estimateApi = service.GetEstimatesApi();
                var parameters = new Dictionary<object, object>();
                 var estimatesList = estimateApi.GetEstimates(parameters);
                 var estimates = estimatesList;
                 var estimateId = estimates[0].estimate_id;
                 var customerId = estimates[0].customer_id;
                 var contactPersns = estimates[0].contact_persons;
                 if (estimates != null)
                     foreach (var estimate in estimates)
                         Console.WriteLine("{0},{1},{2}", estimate.estimate_id, estimate.customer_name, estimate.estimate_number);
                 var parameters1 = new Dictionary<object, object>();
                  parameters1.Add("send",true);
                  var newEstmt = new Estimate()
                  {
                      customer_id = customerId,
                      template_id = "{template id}",
                      reference_number = "QRT-",
                      date = "2014-03-10",
                      expiry_date = "2014-03-24",
                      exchange_rate = 1.0,
                      discount = 0.0,
                      is_discount_before_tax = true,
                      discount_type = "item_level",
                      salesperson_name = "John Michael",
                      line_items = new List<LineItem>()
                          {
                                  new LineItem(){
                                  name="Premium Plan - Web hosting",
                                  description="10 GB Space, 300 GB Transfer 100 Email Accounts 10 MySQL Databases",
                                  rate=2500,
                                  item_order=0,
                                  quantity=1.0,
                                  discount="0.0",

                                  },
                          },
                      notes = "Looking forward for your business.",
                      terms = "Terms and conditions apply.",
                      shipping_charge = 0.0,
                      adjustment = 0.0,
                      adjustment_description = "Adjustment"
                  };
                  var newEstimate = estimateApi.Create(newEstmt, parameters1);
                  if(newEstimate!=null)
                  {
                      Console.WriteLine("The new Estimate is created with the api call for the amount {0} which is having the following properties\n",newEstimate.total);
                      Console.WriteLine("Estimate Id:{0}\n,Estimate number:{1},\n status:{2},\n",newEstimate.estimate_id,newEstimate.estimate_number,newEstimate.status);
                      var billto = newEstimate.billing_address;
                      Console.WriteLine("To:{0},{1},{2},{3},{4}", newEstimate.customer_name, billto.address, billto.city, billto.country, billto.zip);
                      var items = newEstimate.line_items;
                      Console.WriteLine("\n Items details:\n");
                      foreach (var item in items)
                          Console.WriteLine("\n name: {0},\nCost: {1},\n Quantity :{2}", item.name, item.rate, item.quantity);

                  }
                  var parameters2 = new Dictionary<object, object>();
                var updateInfo = new Estimate()
                {

                     reference_number="2197",

               };
                 var updatedEst =estimateApi.Update(estimateId, updateInfo,parameters2);
                if(updatedEst!=null)
                    Console.WriteLine("{0},{1},{2}", updatedEst.estimate_number, updatedEst.reference_number, updatedEst.exchange_rate);
                var delmsg = estimateApi.Delete(estimates[2].estimate_id);
                Console.WriteLine(delmsg);
                var status = estimateApi.MarkAsSent(estimateId);
                Console.WriteLine(status);
                var status1 = estimateApi.MarkAsAccepted(estimateId);
                Console.WriteLine(status);
                var status2 = estimateApi.MarkAsDeclined(estimateId);
                Console.WriteLine(status);
                var emailDetails = new EmailNotification()
                {
                    to_mail_ids = new List<string>(){
                    "*****@*****.**",},
                    subject = "estimate email",
                    body = "est"
                };
                var emailEst = estimateApi.SendEmail(estimateId, emailDetails, new string[] { @"F:\error.png", @"F:\error.png" });
                Console.WriteLine(emailEst);
                var estIds = new Dictionary<object, object>();
                estIds.Add("estimate_ids", estimates[1].estimate_id + "," + estimates[2]);
                var emailests = estimateApi.EmailEstimates(estIds);
                Console.WriteLine(emailests);
                var emailContent = estimateApi.GetEmailContent(estimateId, null);
                Console.WriteLine("{0},{1},{2}", emailContent.body, emailContent.file_name, emailContent.subject);
                var export = estimateApi.BulkExport(estIds);
                Console.WriteLine(export);
                var print = estimateApi.BulkPrint(estIds);
                Console.WriteLine(print);
                var updateinfo3 = new Address()
                {
                    address = "31",
                    city = "chennai"
                };
                var update = estimateApi.UpdateBillingAddress(estimateId, updateinfo3);
                Console.WriteLine(update);
                var updateinfo2 = new Address()
                {
                    state="TamilNadu"
                };
                var shipaddrUpdate = estimateApi.UpdateShippingAddress(estimateId, updateinfo2);
                Console.WriteLine(shipaddrUpdate);
                var estTemplatesList = estimateApi.GetTemplates();
                var templates = estTemplatesList;
                foreach (var estTemplate in templates)
                    Console.WriteLine("{0},{1},{2}", estTemplate.template_id, estTemplate.template_name, estTemplate.template_type);

                var updateTemplate = estimateApi.UpdateTemplate(estimateId, templates[1].template_id);
                Console.WriteLine(updateTemplate);
                var commentsList = estimateApi.GetComments(estimateId);
                var comments = commentsList;
                foreach (var comment in comments)
                    Console.WriteLine("{0},{1},{2}",comment.comment_id,comment.description,comment.commented_by);
                var newCommentInfo = new Comment()
                {
                    description = "added manually"
                };
                var newComment = estimateApi.AddComment(estimateId, newCommentInfo);
                Console.WriteLine(newComment);
                var updateInfo1 = new Comment()
                {
                    description = "edited comment"
                };
                var updated = estimateApi.UpdateComment(estimateId, comments[2].comment_id, updateInfo1);
                Console.WriteLine("{0},{1},{2}", updated.comment_id, updated.description, updated.commented_by);
                var deleteMsg = estimateApi.DeleteComment(estimateId, comments[4].comment_id);
                Console.WriteLine(deleteMsg);
            }
            catch(Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            try
            {
                var service = new ZohoBooks();
                service.initialize("{authtoken}", "{organizationId}");
                var transactionApi = service.GetBankTransactionsApi();
                var accounts       = service.GetBankAccountsApi().GetBankAccounts(null);
                var parameters     = new Dictionary <object, object>();
                parameters.Add("filter_by", "Status.All");
                parameters.Add("account_id", accounts[0].account_id);
                Console.WriteLine("---------------------- All Transactions ----------------------");
                var transactionList = transactionApi.GetTransactions(parameters);
                var transactions    = transactionList;
                foreach (var trans in transactions)
                {
                    Console.WriteLine("{0},{1},{2}", trans.transaction_id, trans.status, trans.amount);
                }

                Console.WriteLine("---------------------- Specified Transaction ----------------------");
                var transaction = transactionApi.Get(transactions[2].transaction_id);
                Console.WriteLine("{0},{1},{2}", transaction.transaction_id, transaction.transaction_type, transaction.amount);

                Console.WriteLine("---------------------- New Transaction ----------------------");
                var newTransactionInfo = new Transaction()
                {
                    transaction_type = "transfer_fund",
                    from_account_id  = accounts[0].account_id,
                    to_account_id    = accounts[2].account_id,
                    amount           = 10
                };
                var newTransaction = transactionApi.Create(newTransactionInfo);
                Console.WriteLine("{0},{1},{2}", newTransaction.transaction_id, newTransaction.transaction_type, newTransaction.amount);

                Console.WriteLine("---------------------- Updated Transaction ----------------------");
                var updateInfo = new Transaction()
                {
                    amount           = 50,
                    currency_id      = transactionList[0].currency_id,
                    date             = "2014-02-06",
                    description      = "",
                    exchange_rate    = 1,
                    from_account_id  = accounts[0].account_id,
                    reference_number = "",
                    to_account_id    = accounts[2].account_id,
                    transaction_type = "transfer_fund"
                };
                var updatedTrans = transactionApi.Update(newTransaction.transaction_id, updateInfo);
                Console.WriteLine("{0},{1},{2}", updatedTrans.transaction_id, updatedTrans.transaction_type, updatedTrans.amount);

                Console.WriteLine("---------------------- Delete Transaction ----------------------");
                var deltrans = transactionApi.Delete(updatedTrans.transaction_id);
                Console.WriteLine(deltrans);
                var parameters1 = new Dictionary <object, object>();
                parameters1.Add("amount_start", "1");
                parameters1.Add("amount_end", "4000");
                parameters1.Add("date_start", "2014-02-01");
                parameters1.Add("date_end", "2014-02-07");

                var matchingtrans = transactionApi.GetMatchingTransactions(transactions[1].transaction_id, parameters1);

                foreach (var matchingTran in matchingtrans)
                {
                    Console.WriteLine("{0},{1},{2}", matchingTran.transaction_id, matchingTran.transaction_type, matchingTran.amount);
                }
                var parameters3 = new Dictionary <object, object>();
                parameters3.Add("account_id", accounts[1].account_id);
                TransactionsToBeMatched transtomatch = new TransactionsToBeMatched()
                {
                    transactions_to_be_matched = new List <Transaction>()
                    {
                        new Transaction()
                        {
                            transaction_id   = transactions[2].transaction_id,
                            transaction_type = "vendor_payment"
                        },
                        new Transaction()
                        {
                            transaction_id   = transactions[3].transaction_id,
                            transaction_type = "transfer_fund"
                        },
                        new Transaction()
                        {
                            transaction_id   = transactions[1].transaction_id,
                            transaction_type = "expense"
                        }
                    }
                };
                var matchtransaction = transactionApi.MatchATransaction(transactions[0].transaction_id, transtomatch);
                Console.WriteLine(matchtransaction);
                var unmatch = transactionApi.UnmatchTransaction(transactions[0].transaction_id);
                Console.WriteLine(unmatch);
                parameters.Add("sort_column", "statement_date");
                var associatedTransObj = transactionApi.GetAssociatedTransactions(transactions[0].transaction_id, null);
                var associatedTrans    = associatedTransObj.associated_transactions;
                Console.WriteLine(associatedTransObj.imported_transaction_id);
                foreach (var asociatedTran in associatedTrans)
                {
                    Console.WriteLine("{0},{1},{2}", asociatedTran.transaction_id, asociatedTran.transaction_type, asociatedTran.amount);
                }
                var exclude = transactionApi.ExcludeATransaction(transactions[0].transaction_id);
                Console.WriteLine(exclude);
                var restore = transactionApi.RestoreATransaction(transactions[0].transaction_id);
                Console.WriteLine(restore);
                var transacInfo = new Transaction()
                {
                    amount           = 4000,
                    date             = "2013-01-29",
                    description      = "Insurance payment",
                    exchange_rate    = 1,
                    from_account_id  = accounts[1].account_id,
                    reference_number = "Ref-9872",
                    to_account_id    = accounts[3].account_id,
                    transaction_type = "expense"
                };
                var catogarise = transactionApi.CategorizeAnUncategorizedTransaction(transactions[0].transaction_id, transacInfo);
                Console.WriteLine(catogarise);
                var creditrefundInfo = new CreditNote()
                {
                    creditnote_id   = "{credit note id}",
                    date            = "2014-02-07",
                    from_account_id = "{account id from which account the transaction is going to be done}",
                    amount          = 4000
                };
                var catogasCred = transactionApi.CategorizeAsCreditNoteRefunds(transactions[0].transaction_id, creditrefundInfo);
                Console.WriteLine(catogasCred);
                var vendordetails = new VendorPayment()
                {
                    vendor_id = "{vendor id}",
                    amount    = 4000,
                    paid_through_account_id = "{account id}"
                };
                var vendorcat = transactionApi.CategorizeAsVendorpayment(transactions[0].transaction_id, vendordetails);
                Console.WriteLine(vendorcat);
                var customerinfo = new CustomerPayment()
                {
                    customer_id = "{customer id}",
                    date        = "2014-02-08",
                    invoices    = new List <Invoice>()
                    {
                        new Invoice()
                        {
                            invoice_id     = "{invoice id}",
                            amount_applied = 4000
                        }
                    },
                    amount = 4000
                };
                var custpaycat = transactionApi.CategorizeAsCustomerPayments(transactions[0].transaction_id, customerinfo, parameters);
                Console.WriteLine(custpaycat);
                var expenseInfo = new Expense()
                {
                    account_id = accounts[3].account_id,
                    date       = "2013-01-29",
                    paid_through_account_id = accounts[4].account_id,
                    project_id       = "",
                    amount           = 4000,
                    tax_id           = "",
                    is_inclusive_tax = false,
                    is_billable      = false,
                    reference_number = "Ref-123",
                    description      = "Insurance payment",
                };
                var catAsExpens = transactionApi.CategorizeAsExpense(transactions[0].transaction_id, expenseInfo, @"F:\error.png");
                Console.WriteLine(catAsExpens);
                var uncatogorise = transactionApi.UncategorizeACategorizedTransaction(transactions[0].transaction_id);
                Console.WriteLine(uncatogorise);
                var vendorCreditsApi = service.GetVendorCreditsApi();
                var vendorCredits    = vendorCreditsApi.GetVendorCredits(null);
                var refundInfo       = new VendorCreditRefund()
                {
                    vendor_credit_id = vendorCredits[0].vendor_credit_id,
                    date             = "2014-11-25",
                };
                var catAsVendorRefund = transactionApi.CategorizeAsVendorCreditRefund(transactions[0].transaction_id, refundInfo);
                Console.WriteLine(catAsVendorRefund);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
Exemple #26
0
        static void Main(string[] args)
        {
            var service = new ZohoBooks();

            service.initialize("{authtoken}", "{organizationId}");
            var bankAccountsApi = service.GetBankAccountsApi();

            try
            {
                var parameters       = new Dictionary <object, object>();
                var bankaccountsList = bankAccountsApi.GetBankAccounts(parameters);
                var bankaccounts     = bankaccountsList;
                if (bankaccounts != null)
                {
                    foreach (var bankAccount in bankaccounts)
                    {
                        Console.WriteLine("{0},{1},{2}", bankAccount.account_id, bankAccount.account_name, bankAccount.balance);
                    }
                }
                string accountId   = bankaccounts[0].account_id;
                var    bankaccount = bankAccountsApi.Get(accountId);
                if (bankaccount != null)
                {
                    Console.WriteLine("{0},{1},{2}", bankaccount.account_number, bankaccount.account_name, bankaccount.balance);
                }
                var newAccountInfo = new BankAccount()
                {
                    account_name       = "name of account",
                    account_type       = "bank",
                    is_primary_account = true
                };
                var newAccount = bankAccountsApi.Create(newAccountInfo);
                if (newAccount != null)
                {
                    Console.WriteLine("{0},{1},{2}", newAccount.is_primary_account, newAccount.account_name, newAccount.balance);
                }
                var updateInfo = new BankAccount()
                {
                    account_name   = "name of account",
                    routing_number = "158987"
                };
                var updatedAccount = bankAccountsApi.Update(accountId, updateInfo);
                if (updatedAccount != null)
                {
                    Console.WriteLine("{0},{1},{2}", updatedAccount.routing_number, updatedAccount.account_name, updatedAccount.balance);
                }
                var delAccount = bankAccountsApi.Delete(bankaccounts[1].account_id);
                Console.WriteLine(delAccount);
                var deactAccount = bankAccountsApi.DeactivateAccount(accountId);
                Console.WriteLine(deactAccount);
                var actAccount = bankAccountsApi.ActivateAccount(accountId);
                Console.WriteLine(actAccount);
                var statement = bankAccountsApi.GetLastImportedStatement(accountId);
                if (statement != null)
                {
                    Console.WriteLine("{0},{1},{2}", statement.statement_id, statement.to_date, statement.transactions.Count);
                    var transactions = statement.transactions;
                    foreach (var transaction in transactions)
                    {
                        Console.WriteLine("{0},{1},{2}", transaction.debit_or_credit, transaction.amount, transaction.transaction_type);
                    }
                }
                var delstatement = bankAccountsApi.DeleteLastImportedStatement(accountId, statement.statement_id);
                Console.WriteLine(delstatement);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            try
            {
                var service = new ZohoBooks();
                service.initialize("{authtoken}", "{organization id}");
                var invoicesApi = service.GetInvoicesApi();
                var parameters = new Dictionary<object, object>();
                var invoicesList = invoicesApi.GetInvoices(parameters);
                var invoices = invoicesList;
                var invoiceId = invoices[1].invoice_id;
                var custId = invoices[0].customer_id;
                var contactId=invoices[0].contact_persons[1];
                 foreach (var invoice in invoices)
                     Console.WriteLine("Id:{0},Name:{1},due date:{2},total:{3}",invoice.invoice_id,invoice.name,invoice.due_date,invoice.total);
                 var parameters1 = new Dictionary<object, object>();
                 var invoice1 = invoicesApi.Get(invoiceId, parameters1);
                 Console.WriteLine("Id:{0},Name:{1},status:{2},total:{3}", invoice1.invoice_id, invoice1.name, invoice1.status, invoice1.total);
                 var newInvoiceInfo = new Invoice()
                 {
                     customer_id = custId,
                     reference_number = "jwqjjkw",
                     payment_terms = 15,
                     payment_terms_label = "Net 15",

                     allow_partial_payments = false,
                     custom_fields = { },
                     exchange_rate = 1,
                     template_id = "{template id}",
                     is_discount_before_tax = true,
                     discount = "",
                     discount_type = "item_level",
                     shipping_charge = 50,
                     adjustment = -100,
                     adjustment_description = " adjustment",
                     salesperson_name = "John Michael"
                 };
                 var parameters8 = new Dictionary<object, object>();
                 var newinvoice = invoicesApi.Create(newInvoiceInfo,parameters8);
                 Console.WriteLine("Id:{0},Name:{1},status:{2},total:{3}", newinvoice.invoice_id, newinvoice.name, newinvoice.status, newinvoice.total);
                 var updateinfo = new Invoice()
                 {
                     salesperson_name="ha",
                 };

                 var updatedInvoice = invoicesApi.Update(invoiceId, updateinfo, parameters8);
                 Console.WriteLine("Id:{0},Name:{1},status:{2},salesPerson:{3}", updatedInvoice.invoice_id, updatedInvoice.name, updatedInvoice.status, updatedInvoice.salesperson_name);
                 var deletemsg = invoicesApi.Delete(invoices[3].invoice_id);
                 Console.WriteLine(deletemsg);
                 var statusMsg = invoicesApi.MarkAsSent(invoiceId);
                 Console.WriteLine(statusMsg);
                 var status = invoicesApi.MarkAsVoid(invoiceId);
                Console.WriteLine(status);
                var statusmsg = invoicesApi.MarkAsDraft(invoiceId);
                Console.WriteLine(statusmsg);
                var emaildata=new EmailNotification(){
                    to_mail_ids=new List<string>(){"*****@*****.**"},
                    subject="invoice mail",
                    body="hi"
                };
                var parameters9 = new Dictionary<object, object>();
                var emailInvoice = invoicesApi.SendEmail(invoiceId, emaildata, new string[] { @"attachment path", @"attachment path" }, parameters9);
                Console.WriteLine(emailInvoice);
                var parameters2 = new Dictionary<object, object>();
                parameters2.Add("invoice_ids", invoices[2].invoice_id+","+invoices[0].invoice_id);
                var contactsToSend=new Contacts(){
                    contacts=new List<Contact>(){
                    new Contact(){
                        contact_id=contactId,
                        email="true",
                        snail_mail=true
                    },
                    }
                };
                var emailInvoices=invoicesApi.EmailInvoices(contactsToSend,parameters2);
                Console.WriteLine(emailInvoices);
                var parameters3 = new Dictionary<object, object>();
                parameters3.Add("invoice_ids", invoices[2].invoice_id + "," + invoices[0].invoice_id);
                var emailcontent = invoicesApi.GetEmailContent(invoiceId, parameters3);
                Console.WriteLine("{0},{1},{2}", emailcontent.body, emailcontent.file_name, emailcontent.gateways_configured);
                var notifydetails = new EmailNotification()
                {
                    to_mail_ids = new List<string>() { "{mail id 1}", "{mail id 2}" },
                    subject="payment reminder",
                    body="dear "
                };
                var parameters4 = new Dictionary<object, object>();

                var remindMsg = invoicesApi.RemindCustomer(invoiceId, notifydetails, parameters4);
                Console.WriteLine(remindMsg);
                var parameters5 = new Dictionary<object, object>();

                parameters5.Add("invoice_ids", invoices[2].invoice_id + "," + invoices[0].invoice_id);
                var bulkReminderMsg = invoicesApi.BulkInvoiceReminder(parameters5);
                Console.WriteLine(bulkReminderMsg);
                var reminderContent = invoicesApi.GetPaymentReminder(invoiceId);
                Console.WriteLine("{0},{1},{2}", reminderContent.body, reminderContent.file_name, reminderContent.gateways_configured);
                var parameters6 = new Dictionary<object, object>();
                parameters6.Add("invoice_ids", invoices[2].invoice_id + "," + invoices[0].invoice_id);
                var bulkExport = invoicesApi.BulkExport(parameters6);
                Console.WriteLine(bulkExport);
                var disableReminderMsg = invoicesApi.DisablePaymentReminder(invoiceId);
                Console.WriteLine(disableReminderMsg);
                var enableReminderMsg = invoicesApi.EnablePaymentReminder(invoiceId);
                Console.WriteLine(enableReminderMsg);
                var writeoff = invoicesApi.WriteoffInvoice(invoiceId);
                Console.WriteLine(writeoff);
                var cancleWriteoff = invoicesApi.CancelWriteoff(invoiceId);
                Console.WriteLine(cancleWriteoff);
                var updateInfo = new Address()
                {
                    address = "addr",
                    is_update_customer = false
                };
                var billingdAddrUpdate = invoicesApi.UpdateBillingAddress(invoiceId, updateInfo);
                Console.WriteLine(billingdAddrUpdate);
                var updateInfo1 = new Address()
                {
                    address = "addr",
                    is_update_customer = false
                };
                var shippingdAddrUpdate = invoicesApi.UpdateShippingAddress(invoiceId, updateInfo);
                Console.WriteLine(shippingdAddrUpdate);
                var invoicetemplatesList = invoicesApi.GetTemplates();
                var invoicetemplates = invoicetemplatesList;
                foreach (var template in invoicetemplates)
                    Console.WriteLine("Templates\n{0},{1},{2}", template.template_id, template.template_name, template.template_type);
                var updateTemplate = invoicesApi.UpdateTemplate(invoiceId, invoicetemplates[0].template_id);
                Console.WriteLine(updateTemplate);
                var invoicePaymentsList = invoicesApi.GetPayments(invoiceId);
                var invoicePayments = invoicePaymentsList;
                var paymentId=invoicePayments[1].payment_id;
                foreach (var payment in invoicePayments)
                    Console.WriteLine("payment:{0},{1},{2}", payment.payment_id, payment.description, payment.invoice_id);
                var appliedCreditsList = invoicesApi.GetCreditsApplied(invoiceId);
                var appliedCredits = appliedCreditsList;
                var creditnoteId=appliedCredits[1].creditnote_id;

                foreach (var credit in appliedCredits)
                    Console.WriteLine("credit note:{0},{1},{2}", credit.creditnote_id, credit.amount_applied, credit.creditnotes_number);
                var creditstoapplly = new UseCredits()
                {

                    apply_creditnotes = new List<CreditNote>()
                     {
                         new CreditNote(){
                             creditnote_id=creditnoteId,
                             amount_applied=40.00
                         }
                     }
                };
                var appliedCredits1 = invoicesApi.AddCredits(invoiceId, creditstoapplly);
                var creditnotes = appliedCredits1.apply_creditnotes;
                foreach(var credit in creditnotes)
                Console.WriteLine("credit note:{0},{1}", credit.creditnote_id, credit.amount_applied);
                var deletePaymentmsg = invoicesApi.DeletePayment(invoiceId,paymentId);
                Console.WriteLine(deletePaymentmsg);
                var deleteAppliedcredit = invoicesApi.DelteAppliedCredit(invoiceId, creditnoteId);
                Console.WriteLine(deleteAppliedcredit);
                var commentsList = invoicesApi.GetComments(invoiceId);
                var comments = commentsList;
                foreach (var comment in comments)
                    Console.WriteLine("{0},{1},{2}", comment.comment_id, comment.description, comment.commented_by);
                var newCommentInfo = new Comment()
                {
                    description = "new comment",
                    show_comment_to_clients = true
                };
                var newComment = invoicesApi.AddComment(invoiceId, newCommentInfo);
                Console.WriteLine(newComment);
                var updateInfo2 = new Comment()
                {
                    description = "updated comment",
                    show_comment_to_clients = true
                };
                var updatedComment = invoicesApi.UpdateComment(invoiceId, comments[1].comment_id, updateInfo2);
                Console.WriteLine("{0},{1},{2}", updatedComment.comment_id, updatedComment.description, updatedComment.commented_by);
                var deleteMsg = invoicesApi.DeleteComment(invoiceId, comments[3].comment_id);
                Console.WriteLine(deleteMsg);
                var attachment = invoicesApi.GetAttachment(invoiceId);
                Console.WriteLine(attachment);
                var parameters7 = new Dictionary<object, object>();
                parameters7.Add("can_send_in_mail",true);
                var attachPreference = invoicesApi.UpdateAttachment(invoiceId, parameters7);
                Console.WriteLine(attachPreference);
                var deleteAttach = invoicesApi.DeleteAttachment(invoiceId);
                Console.WriteLine(deleteAttach);
                var deleteExpenceRecipt = invoicesApi.DeleteExpenseReceipt(invoiceId);
                Console.WriteLine(deleteExpenceRecipt);
            }
            catch(Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            try
            {
                var service = new ZohoBooks();
                service.initialize("{authtoken}", "{organization id}");
                SettingsApi settingsApi = service.GetSettingsApi();
                Console.WriteLine("----------------Preferences-------------");
                var preferences = settingsApi.GetPreferences();
                var autoreminders = preferences.auto_reminders;
                Console.WriteLine("Auto Reminders");
                foreach (var autoreminder in autoreminders)
                    Console.WriteLine("sub:{0},body:{1},notification Type:{2}", autoreminder.subject, autoreminder.body, autoreminder.notification_type);
                var addrFormat = preferences.address_formats;
                Console.WriteLine("cust addrformat:{0},Organisation Format:{1}", addrFormat.customer_address_format, addrFormat.organization_address_format);
                var updateInfo = new Preferences()
                {
                    convert_to_invoice= false,
                    notify_me_on_online_payment=true,
                    is_show_powered_by=true,
                    is_estimate_enabled=false,
                };
                var updateMsg = settingsApi.UpdatePreferences(updateInfo);

                var newUnit = new Unit()
                {
                    unit = "new unit"
                };
                var addUnit = settingsApi.CreateUnit(newUnit);
                Console.WriteLine(addUnit);
                var deleteUnit = settingsApi.DeleteUnit("{Unit id}");
                Console.WriteLine(deleteUnit);
                Console.WriteLine("----------------------------------------------------\n------------------Tax and TaxGroups-----------------");
                var taxeslist = settingsApi.GetTaxes();
                var taxes = taxeslist;
                var taxId = taxes[0].tax_id;
                foreach (var tax in taxes)
                    Console.WriteLine("taxId:{0},name:{1},percentage:{2},Type:{3}", tax.tax_id, tax.tax_name, tax.tax_percentage, tax.tax_type);
                var tax1 = settingsApi.GetTax(taxId);
                Console.WriteLine("taxId:{0},name:{1},percentage:{2},Type:{3}", tax1.tax_id, tax1.tax_name, tax1.tax_percentage, tax1.tax_type);
                var newTaxInfo = new Tax()
                {
                    tax_name="VAT1",
                    tax_percentage=5
                };
                var newTax = settingsApi.CreateTax(newTaxInfo);
                Console.WriteLine("taxId:{0},name:{1},percentage:{2},Type:{3}", newTax.tax_id, newTax.tax_name, newTax.tax_percentage, newTax.tax_type);
                var updateInfo1 = new Tax()
                {
                    tax_percentage=6,
                    tax_type = "compound_tax",

                };
                var updatedTax = settingsApi.UpdateTax(newTax.tax_id, updateInfo1);
                Console.WriteLine("taxId:{0},name:{1},percentage:{2},Type:{3}", updatedTax.tax_id, updatedTax.tax_name, updatedTax.tax_percentage, updatedTax.tax_type);
                var deletemsg = settingsApi.DeleteTax(updatedTax.tax_id);
                Console.WriteLine(deletemsg);
                var taxgroup = settingsApi.GetTaxGroup("71917000000259007");
                Console.WriteLine("the tax group {0} contains the taxes",taxgroup.tax_group_name);
                var taxes1 = taxgroup.taxes;
                foreach(var tax in taxes1)
                    Console.WriteLine("taxId:{0},name:{1},percentage:{2},Type:{3}", tax.tax_id, tax.tax_name, tax.tax_percentage, tax.tax_type);
                var newTaxGroupInfo = new TaxGroupToCreate()
                {
                    tax_group_name="purchase",
                    taxes = taxes[0].tax_id+","+taxes[2].tax_id,
                };
                var newTaxGroup = settingsApi.CreateTaxGroup(newTaxGroupInfo);
                var taxGroupId = newTaxGroup.tax_group_id;
                Console.WriteLine("the tax group {0} contains the taxes of tax percentage{1}", newTaxGroup.tax_group_name,newTaxGroup.tax_group_percentage);
                var taxes2 = newTaxGroup.taxes;
                foreach (var tax in taxes2)
                    Console.WriteLine("taxId:{0},name:{1},percentage:{2},Type:{3}", tax.tax_id, tax.tax_name, tax.tax_percentage, tax.tax_type);
                var updateInfo2 = new TaxGroupToCreate()
                {
                    tax_group_name="purcha",
                    taxes = taxes[0].tax_id + "," + taxes[2].tax_id,
                };
                var updateTaxGroup = settingsApi.UpdateTaxGroup(taxGroupId, updateInfo2);
                Console.WriteLine("the tax group {0} updated as the taxes of tax percentage{1}", updateTaxGroup.tax_group_name, updateTaxGroup.tax_group_percentage);
                var deleteMsg = settingsApi.DeleteTaxGroup(taxGroupId);
                Console.WriteLine(deleteMsg);
                Console.WriteLine("----------------------------------------------------\n------------------Opening balence-----------------");
                var openingbalence = settingsApi.GetOpeningBalance();
                Console.WriteLine("The accounts in opening balance {0}", openingbalence.opening_balance_id);
                var accounts = openingbalence.accounts;
                foreach (var account in accounts)
                    Console.WriteLine("account id:{3},account name:{0},debit/ccredit:{1},amount:{2}", account.account_name, account.debit_or_credit, account.amount,account.account_id);
                var newOpeningbalanceInfo = new OpeningBalance()
                {
                    date="2014-05-06",
                    accounts = new List<Account>()
                    {
                        new Account()
                        {
                            account_id="71917000000000379",
                            debit_or_credit="credit",
                            amount=200,
                            currency_id="71917000000000099",

                         },
                    }
                };
                var newOpeningbalance = settingsApi.CreateOpeningBalance(newOpeningbalanceInfo);
                Console.WriteLine("The accounts in opening balance {0}", newOpeningbalance.opening_balance_id);
                var accounts1 = newOpeningbalance.accounts;
                foreach (var account in accounts1)
                    Console.WriteLine("account id:{3},account name:{0},debit/ccredit:{1},amount:{2}", account.account_name, account.debit_or_credit, account.amount, account.account_id);
               var updateInfo3 = new OpeningBalance()
                {
                    date = "2014-05-06",
                    accounts = new List<Account>()
                    {
                        new Account()
                        {
                            account_id="71917000000000379",
                            debit_or_credit="credit",
                            amount=400,
                            currency_id="71917000000000099",
                        },
                    }
                };
                var updatedOpeningbalance = settingsApi.UpdateOpeningBalance(updateInfo3);
                Console.WriteLine("The accounts in opening balance {0}", updatedOpeningbalance.opening_balance_id);
                var accounts2 = updatedOpeningbalance.accounts;
                foreach (var account in accounts2)
                    Console.WriteLine("account id:{3},account name:{0},debit/ccredit:{1},amount:{2}", account.account_name, account.debit_or_credit, account.amount, account.account_id);
                var delmsg = settingsApi.DeleteOpeningBalance();
                Console.WriteLine(delmsg);
                Console.WriteLine("----------------------------------------------------\n------------------Reminders-----------------");
                var reminders = settingsApi.GetAutoPaymentReminders();
                var autoRemindId = reminders[1].autoreminder_id;
                foreach (var reminder in reminders)
                    Console.WriteLine("reminder Id:{0}\n is_enable:{1}\nbody:{2}\n",reminder.autoreminder_id,reminder.is_enabled,reminder.body);
                var reminderAndPlaceholder = settingsApi.GetAnAutoPaymentReminder(autoRemindId);
                var reminder1 = reminderAndPlaceholder.autoreminder;
                Console.WriteLine("reminder Id:{0}\n is_enable:{1}\nbody:{2}\n", reminder1.autoreminder_id, reminder1.is_enabled, reminder1.body);
                var placeholder = reminderAndPlaceholder.placeholders;
                Console.WriteLine("placeholders Invoices are");
                var invoices = placeholder.Invoice;
                foreach (var invoice in invoices)
                    Console.WriteLine("name:{0},value:{1}", invoice.name, invoice.value);
                Console.WriteLine("placeholders Customers are");
                var customers = placeholder.Customer;
                foreach (var customer in customers)
                    Console.WriteLine("name:{0},value:{1}", customer.name, customer.value);
                Console.WriteLine("placeholders Organizations are are");
                var organizations = placeholder.Organization;
                foreach (var organization in organizations)
                    Console.WriteLine("name:{0},value:{1}", organization.name, organization.value);
                var reminderenable = settingsApi.EnableAutoReminder(autoRemindId);
                Console.WriteLine(reminderenable);
                var reminderdisable = settingsApi.DisableAutoReminder(autoRemindId);
                Console.WriteLine(reminderdisable);
                var updateInfo4 = new AutoReminder()
                {
                    is_enabled = true,
                    type = "days_before_due_date",
                    address_type = "remind_customer_and_cc_me"
                };
                var updateMsg1 = settingsApi.UpdateAnAutoReminder(autoRemindId, updateInfo4);
                Console.WriteLine(updateMsg1);
                var parameters = new Dictionary<object, object>();
                parameters.Add("type", "open_reminder");
                var manualreminders = settingsApi.GetManualReminders(parameters);
                var manualRemindId = manualreminders[0].manualreminder_id;
                foreach(var manualreminder in manualreminders)
                    Console.WriteLine("reminder Id:{0}\n is_enable:{1}\nbody:{2}\ncc_me:{3}", manualreminder.manualreminder_id, manualreminder.type, manualreminder.body,manualreminder.cc_me);
                var manualreminder1 = settingsApi.GetManualReminder(manualRemindId);
                var reminder2 = manualreminder1.manualreminder;
                Console.WriteLine("reminder Id:{0}\n is_enable:{1}\nbody:{2}\ncc_me:{3}", reminder2.manualreminder_id, reminder2.type, reminder2.body, reminder2.cc_me);
                var placeholder1 = manualreminder1.placeholders;
                Console.WriteLine("placeholders Invoices are");
                var invoices1 = placeholder.Invoice;
                foreach (var invoice in invoices1)
                    Console.WriteLine("name:{0},value:{1}", invoice.name, invoice.value);
                Console.WriteLine("placeholders Customers are");
                var customers1 = placeholder.Customer;
                foreach (var customer in customers1)
                    Console.WriteLine("name:{0},value:{1}", customer.name, customer.value);
                Console.WriteLine("placeholders Organizations are are");
                var organizations1 = placeholder.Organization;
                foreach (var organization in organizations1)
                    Console.WriteLine("name:{0},value:{1}", organization.name, organization.value);
                var updateInfo5 = new ManualReminder()
                {
                    cc_me=true
                };
                var updatedmsg = settingsApi.UpdateManualReminder(manualRemindId, updateInfo5);
                Console.WriteLine(updatedmsg);
            }
            catch(Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            var service = new ZohoBooks();
            service.initialize("{authtoken}", "{organizationId}");
            ContactsApi contactsApi = service.GetContactsApi();
            var parameters = new Dictionary<object, object>();
            var contactsList = contactsApi.GetContacts(parameters);
            var contacts=contactsList;
            var contactId = contacts[0].contact_id;
            if(contacts!=null)
            {

                foreach (var cont in contacts)
                    Console.WriteLine("{0},{1},{2}", cont.contact_id, cont.contact_name, cont.contact_type);
            }
            var contact = contactsApi.Get(contacts[0].contact_id);
            Console.WriteLine("{0},{1},{2}", contact.contact_id, contact.contact_name, contact.contact_type);
            var contactpers = contact.contact_persons;
            foreach (var per in contactpers)
                Console.WriteLine("{0},{1},{2}", per.contact_person_id, per.email, per.is_primary_contact);
            var newContact = new Contact()
            {
                contact_name = "name",
                payment_terms = 15,
                payment_terms_label = "Net 15",
                currency_id = "{currency id}",
                billing_address = new Address()
                {
                    address = "4900 Hopyard Rd, Suite 310",
                    city = "Pleasanton",
                    state = "CA",
                    zip = "94588",
                    country = "USA",
                    fax = "+1-925-924-9600"
                },
                shipping_address = new Address()
                {
                    address = "Suite 125, McMillan Avenue",
                    city = "San Francisco",
                    state = "CA",
                    zip = "94134",
                    country = "USA",
                    fax = "+1-925-924-9600"
                },
                contact_persons = new List<ContactPerson>(){
             new ContactPerson(){

             salutation="Mr.",
             first_name="Will",
             last_name="Smith",
             email="*****@*****.**",
               },
               new ContactPerson(){

             salutation="Mr.",
             first_name="Peter",
             last_name="Parker",
             email="*****@*****.**",
               }
             },

                notes = "Payment option : Through check"
            };
            var contact1 = contactsApi.Create(newContact);
            Console.WriteLine("{0},{1},{2}", contact1.contact_id, contact1.contact_name, contact1.contact_type);
            var contactpersons = contact.contact_persons;
            foreach (var per in contactpersons)
                Console.WriteLine("{0},{1},{2}", per.contact_person_id, per.email, per.is_primary_contact);
            var updateInfo = new Contact()
            {

                payment_terms = 15,
                payment_terms_label = "Net 15",

                billing_address = new Address()
                {
                    address = "4900 Hopyard Rd, Suite 310",
                    city = "Pleasanton",
                    state = "CA",
                    zip = "94588",
                    country = "USA",
                    fax = "+1-925-924-9600"
                },
                shipping_address = new Address()
                {
                    address = "Suite 125, McMillan Avenue",
                    city = "San Francisco",
                    state = "CA",
                    zip = "94134",
                    country = "USA",
                    fax = "+1-925-924-9600"
                },
                contact_persons = new List<ContactPerson>(){
             new ContactPerson(){

             salutation="Mr.",
             first_name="Will",
             last_name="Smith",
             email="*****@*****.**",
             phone="+1-925-921-9201",
             mobile="+1-4054439562"
               },
               new ContactPerson(){

             salutation="Mr.",
             first_name="Peter",
             last_name="Parker",
             email="*****@*****.**",
             phone="+1-925-929-7211",
             mobile="+1-4054439760"
               }
             },

                notes = "Payment option : Through check"
            };
            var updatedcontact = contactsApi.Update(contactId, updateInfo);
            Console.WriteLine("{0},{1},{2}", updatedcontact.contact_id, updatedcontact.contact_name, updatedcontact.contact_type);
            var contctpersons = updatedcontact.contact_persons;
            foreach (var per in contctpersons)
                Console.WriteLine("{0},{1},{2}", per.contact_person_id, per.email, per.is_primary_contact);
            var deleteContact = contactsApi.Delete(contacts[1].contact_id);
            Console.WriteLine(deleteContact);
            var inactive = contactsApi.MarkAsInactive(contactId);
            Console.WriteLine(inactive);
            var active = contactsApi.MarkAsActive(contactId);
            Console.WriteLine(active);
            var EnableReminder = contactsApi.EnablePaymentReminder(contactId);
            Console.WriteLine(EnableReminder);
            var disableReminder = contactsApi.DisablePaymentReminder(contactId);
            Console.WriteLine(disableReminder);
            var emailnote = new EmailNotification()
            {
                to_mail_ids =new List<string>(){
                    "*****@*****.**",},
                subject = "email notify",
                body = "body of mail"
            };
            var emailstmt = contactsApi.SendEmailStatement(contactId, emailnote, null, null);
            Console.WriteLine(emailstmt);
            parameters.Add("start_date", "2014-03-15");
            parameters.Add("end_date", "2014-04-29");
            var emaildata = contactsApi.GetEmailStatementContent(contactId, parameters);
            Console.WriteLine(emaildata.body);
            var emailnotify = new EmailNotification()
            {
                to_mail_ids =new List<string>(){
                    "*****@*****.**",},
                subject = "email notify",
                body = "body of mail"
            };
            var emailcntct = contactsApi.SendEmailStatement(contactId, emailnotify,null,null);
            Console.WriteLine(emailcntct);
            var comments = contactsApi.GetComments(contactId);
            foreach (var comment in comments)
                Console.WriteLine("{0},{1}", comment.comment_id, comment.description);
            var refunds = contactsApi.GetRefunds(contactId);
            foreach (var refund in refunds)
                Console.WriteLine("{0},{1}", refund.refund_mode, refund.amount);
            var track = contactsApi.Track1099(contactId);
            Console.WriteLine(track);
            var untrack = contactsApi.UnTrack1099(contactId);
            Console.WriteLine(untrack);
            var cntctpersnsList = contactsApi.GetContactPersons(contacts[0].contact_id);
            var cntctPersons = cntctpersnsList;
            var contactPersonId = cntctPersons[0].contact_person_id;
            foreach (var cntctper in cntctPersons)
                Console.WriteLine("{0},{1},{2}", cntctper.contact_person_id, cntctper.last_name, cntctper.first_name);

            var contactperson = contactsApi.GetContactPerson(contacts[0].contact_id, contactPersonId);
             Console.WriteLine("{0},{1},{2}", contactperson.contact_person_id, contactperson.last_name, contactperson.first_name);
             var contactPerInfo = new ContactPerson()
             {
                 contact_id = "{contactId}",
                 first_name = "hk"
             };
             var newContactPer = contactsApi.CreateContactPerson(contactPerInfo);
             Console.WriteLine("{0},{1},{2}", newContactPer.contact_person_id, newContactPer.last_name, newContactPer.first_name);
             var updateInfo1 = new ContactPerson()
             {

                 first_name = "fname"
             };
             var updated = contactsApi.UpdateContactperson(contactPersonId, updateInfo1);
             Console.WriteLine("{0},{1},{2}", updated.contact_person_id, updated.last_name, updated.first_name);
             var deletedmsg = contactsApi.DeleteContactPerson(contactPersonId);
             Console.WriteLine(deletedmsg);

             var makeAsPrimary = contactsApi.MarkAsPrimaryContactPerson(contactPersonId);
             Console.WriteLine(makeAsPrimary);
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            try
            {
                var service = new ZohoBooks();
                service.initialize("{authtoken}", "{organization id}");
                RecurringInvoicesApi recinvapi = service.GetRecurringInvoicesApi();
                var paramets = new Dictionary <object, object>();
                paramets.Add("recurrence_name_contains", "r");

                var recinvcs = recinvapi.GetRecurringInvoices(paramets);
                if (recinvcs != null)
                {
                    foreach (var x in recinvcs)
                    {
                        Console.WriteLine("{0},{1},{2}", x.recurrence_name, x.recurring_invoice_id, x.created_time);
                    }
                }
                var recinvId   = recinvcs[0].recurring_invoice_id;
                var recinv     = recinvapi.Get(recinvId);
                var customerId = recinv.customer_id;
                var templateId = recinv.template_id;
                var itemId     = recinv.line_items[0].item_id;
                if (recinv != null)
                {
                    Console.WriteLine("{0},{1},{2}", recinv.recurrence_name, recinv.recurring_invoice_id, recinv.created_time);
                }
                var newRecurInv = new RecurringInvoice()
                {
                    recurrence_name      = "Premium2",
                    customer_id          = customerId,
                    contact_persons      = new List <string> {
                    },
                    template_id          = templateId,
                    start_date           = "2013-10-03",
                    end_date             = "2014-11-04",
                    recurrence_frequency = "months",
                    repeat_every         = 1,
                    payment_terms        = 15,
                    payment_terms_label  = "Net 15",
                    exchange_rate        = 1.00,
                    payment_options      = new PaymentOptions()
                    {
                        payment_gateways = new List <PaymentGateway>()
                        {
                        }
                    },
                    discount = 0.00,
                    is_discount_before_tax = true,
                    discount_type          = "item_level",
                    allow_partial_payments = true,
                    line_items             = new List <LineItem> {
                        new LineItem()
                        {
                            item_id     = itemId,
                            name        = "Premium Pla",
                            description = "10 GB Space, 300 GB Transfer 100 Email Accounts 10 MySQL Databases",
                            item_order  = 1,

                            quantity = 1.00,
                            unit     = "Nos",
                            discount = "10.60%",
                        },
                    },
                    notes                  = "Thanks for your business.",
                    terms                  = "",
                    salesperson_name       = "John Michael",
                    shipping_charge        = 10.00,
                    adjustment             = 2.00,
                    adjustment_description = "Adjustment"
                };
                var createdrecinv = recinvapi.Create(newRecurInv);
                if (createdrecinv != null)
                {
                    Console.WriteLine("{0},{1},{2}", createdrecinv.recurrence_name, createdrecinv.recurring_invoice_id, createdrecinv.created_time);
                }
                var updatInfo = new RecurringInvoice()
                {
                    recurrence_name = "rec name",

                    template_id          = templateId,
                    start_date           = "2013-10-03",
                    end_date             = "2013-11-04",
                    recurrence_frequency = "months",
                    repeat_every         = 1,
                    payment_terms        = 15,

                    discount = 2.00,
                    is_discount_before_tax = false,
                    discount_type          = "item_level",
                    allow_partial_payments = true,


                    salesperson_name = "",
                };
                var updatedinfo = recinvapi.Update(recinvId, updatInfo);
                if (updatedinfo != null)
                {
                    Console.WriteLine("{0},{1},{2}", updatedinfo.recurrence_name, updatedinfo.recurring_invoice_id, updatedinfo.created_time);
                }
                var delresp = recinvapi.Delete(recinvcs[2].recurring_invoice_id);
                Console.WriteLine(delresp);
                var stopres = recinvapi.Stop(recinvId);
                Console.WriteLine(stopres);
                var resumeres = recinvapi.Resume(recinvId);
                Console.WriteLine(resumeres);
                var templatechang = recinvapi.UpdateTemplate(recinvId, templateId);
                Console.WriteLine(templatechang);
                var comments = recinvapi.GetComments(recinvId);
                if (comments != null)
                {
                    foreach (var comment in comments)
                    {
                        Console.WriteLine("{0},{1},{2}", comment.comment_id, comment.description, comment.commented_by_id);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            try
            {
                var service = new ZohoBooks();
                service.initialize("{authtoken}", "{organizationId}");
                var chartofAccountApi = service.GetChartOfAccountsApi();
                var parameters = new Dictionary<object, object>();
                parameters.Add("sort_column", "account_name");
                Console.WriteLine("----------------------------List of Accounts-----------------");
                var chartofaccountsList = chartofAccountApi.GetChartOfAcounts(parameters);
                var accounts = chartofaccountsList;
                foreach (var account in accounts)
                    Console.WriteLine("{0},{1},{2}", account.account_id, account.account_name, account.account_type);
                Console.WriteLine("----------------------------Specified Chart of Account-----------------");
                var account1 = chartofAccountApi.Get(accounts[0].account_id);
                Console.WriteLine("{0},{1},{2}", account1.account_id, account1.account_name, account1.account_type);
                var newAccountInfo = new ChartOfAccount()
                {
                    account_name = "account name",
                    account_type = "cost_of_goods_sold"
                };
                Console.WriteLine("----------------------------New Account-----------------");
                var newAccount = chartofAccountApi.Create(newAccountInfo);
                Console.WriteLine("{0},{1},{2}", newAccount.account_id, newAccount.account_name, newAccount.account_type);
                var updateInfo = new ChartOfAccount()
                {
                    account_name = "hari-test",
                };
                Console.WriteLine("----------------------------Updated Account-----------------");
                var updatedAccount = chartofAccountApi.Update(newAccount.account_id, updateInfo);
                Console.WriteLine("{0},{1},{2}", updatedAccount.account_id, updatedAccount.account_name, updatedAccount.account_type);
                Console.WriteLine("----------------------------Delete Account-----------------");
                var delInfo = chartofAccountApi.Delete(updatedAccount.account_id);
                Console.WriteLine(delInfo);
                Console.WriteLine("----------------------------Mark Account as active/inactive-----------------");
                var markasinactive = chartofAccountApi.MarkAsInactive(accounts[16].account_id);
                Console.WriteLine(markasinactive);
                var markasactive = chartofAccountApi.MarkAsActive(accounts[16].account_id);
                Console.WriteLine(markasactive);
                var parameters1 = new Dictionary<object, object>();
                parameters1.Add("account_id", accounts[0].account_id);
                parameters1.Add("date.start", "2014-02-06");
                parameters1.Add("date.end", "2014-02-08");
                parameters1.Add("amount.less_than", 100);
                Console.WriteLine("----------------------------Transactions of Account-----------------");
                var transactionsList = chartofAccountApi.GetTransactions(parameters1);
                var trans = transactionsList;
                foreach (var tran in trans)
                    Console.WriteLine("{0},{1},{2}", tran.transaction_id, tran.payee, tran.payment_mode);
                Console.WriteLine("----------------------------Delete Transaction of Account-----------------");
                var deltran = chartofAccountApi.DeleteATransaction(trans[0].transaction_id);
                Console.WriteLine(deltran);
            }
            catch(Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.ReadKey();
        }
Exemple #32
0
 static void Main(string[] args)
 {
     try
     {
         var service = new ZohoBooks();
         service.initialize("{authtoken}", "{organization id}");
         RecurringExpensesApi recurringExpensesApi = service.GetRecurringExpensesApi();
         var parameters = new Dictionary <object, object>();
         parameters.Add("recurrence_name_startswith", "h");
         var recurringExpenses = recurringExpensesApi.GetRecurringExpenses(parameters);
         var recExpId          = recurringExpenses[0].recurring_expense_id;
         if (recurringExpenses != null)
         {
             foreach (var recurringExpense in recurringExpenses)
             {
                 Console.WriteLine("{0},{1},{2}", recurringExpense.account_name, recurringExpense.total, recurringExpense.recurrence_name);
             }
         }
         var recurringExpense1 = recurringExpensesApi.Get(recExpId);
         if (recurringExpense1 != null)
         {
             Console.WriteLine("{0},{1},{2}", recurringExpense1.account_name, recurringExpense1.total, recurringExpense1.recurrence_name);
         }
         var newRecurringExpenseInfo = new RecurringExpense()
         {
             account_id = "{account id}",
             paid_through_account_id = "{account id from which going to pay}",
             recurrence_name         = "rec name",
             start_date           = "2014-02-03",
             recurrence_frequency = "months",
             repeat_every         = 2,
             amount = 1000,
         };
         var newRecurringExpense = recurringExpensesApi.Create(newRecurringExpenseInfo);
         if (newRecurringExpense != null)
         {
             Console.WriteLine("{0},{1},{2}", newRecurringExpense.account_name, newRecurringExpense.total, newRecurringExpense.recurrence_name);
         }
         var updateInfo = new RecurringExpense()
         {
             recurrence_frequency = "weeks",
             repeat_every         = 4,
         };
         var updatedExpense = recurringExpensesApi.Update(recExpId, updateInfo);
         if (updatedExpense != null)
         {
             Console.WriteLine("{0},{1},{2}", updatedExpense.account_name, updatedExpense.total, updatedExpense.recurrence_name);
         }
         var delRecurringExpense = recurringExpensesApi.Delete(recurringExpenses[3].recurring_expense_id);
         Console.WriteLine(delRecurringExpense);
         var stopRecurringExpense = recurringExpensesApi.Stop(recExpId);
         Console.WriteLine(stopRecurringExpense);
         var resumeRecurringExpense = recurringExpensesApi.Resume(recExpId);
         Console.WriteLine(resumeRecurringExpense);
         var childExpenses = recurringExpensesApi.GetExpensesCreated(recExpId, parameters);
         if (childExpenses != null)
         {
             foreach (var childExpense in childExpenses)
             {
                 Console.WriteLine("{0},{1},{2}", childExpense.account_name, childExpense.total, childExpense.date);
             }
         }
         var comments = recurringExpensesApi.GetComments(recExpId);
         if (comments != null)
         {
             foreach (var comment in comments)
             {
                 Console.WriteLine("{0},{1},{2}", comment.comment_id, comment.description, comment.commented_by);
             }
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
     Console.ReadKey();
 }
        static void Main(string[] args)
        {
            try
            {
                var service = new ZohoBooks();
                service.initialize("{authtoken}", "{organization id}");
                var invoicesApi  = service.GetInvoicesApi();
                var parameters   = new Dictionary <object, object>();
                var invoicesList = invoicesApi.GetInvoices(parameters);
                var invoices     = invoicesList;
                var invoiceId    = invoices[1].invoice_id;
                var custId       = invoices[0].customer_id;
                var contactId    = invoices[0].contact_persons[1];
                foreach (var invoice in invoices)
                {
                    Console.WriteLine("Id:{0},Name:{1},due date:{2},total:{3}", invoice.invoice_id, invoice.name, invoice.due_date, invoice.total);
                }
                var parameters1 = new Dictionary <object, object>();
                var invoice1    = invoicesApi.Get(invoiceId, parameters1);
                Console.WriteLine("Id:{0},Name:{1},status:{2},total:{3}", invoice1.invoice_id, invoice1.name, invoice1.status, invoice1.total);
                var newInvoiceInfo = new Invoice()
                {
                    customer_id         = custId,
                    reference_number    = "jwqjjkw",
                    payment_terms       = 15,
                    payment_terms_label = "Net 15",


                    allow_partial_payments = false,
                    custom_fields          = { },
                    exchange_rate          = 1,
                    template_id            = "{template id}",
                    is_discount_before_tax = true,
                    discount               = "",
                    discount_type          = "item_level",
                    shipping_charge        = 50,
                    adjustment             = -100,
                    adjustment_description = " adjustment",
                    salesperson_name       = "John Michael"
                };
                var parameters8 = new Dictionary <object, object>();
                var newinvoice  = invoicesApi.Create(newInvoiceInfo, parameters8);
                Console.WriteLine("Id:{0},Name:{1},status:{2},total:{3}", newinvoice.invoice_id, newinvoice.name, newinvoice.status, newinvoice.total);
                var updateinfo = new Invoice()
                {
                    salesperson_name = "ha",
                };

                var updatedInvoice = invoicesApi.Update(invoiceId, updateinfo, parameters8);
                Console.WriteLine("Id:{0},Name:{1},status:{2},salesPerson:{3}", updatedInvoice.invoice_id, updatedInvoice.name, updatedInvoice.status, updatedInvoice.salesperson_name);
                var deletemsg = invoicesApi.Delete(invoices[3].invoice_id);
                Console.WriteLine(deletemsg);
                var statusMsg = invoicesApi.MarkAsSent(invoiceId);
                Console.WriteLine(statusMsg);
                var status = invoicesApi.MarkAsVoid(invoiceId);
                Console.WriteLine(status);
                var statusmsg = invoicesApi.MarkAsDraft(invoiceId);
                Console.WriteLine(statusmsg);
                var emaildata = new EmailNotification()
                {
                    to_mail_ids = new List <string>()
                    {
                        "*****@*****.**"
                    },
                    subject = "invoice mail",
                    body    = "hi"
                };
                var parameters9  = new Dictionary <object, object>();
                var emailInvoice = invoicesApi.SendEmail(invoiceId, emaildata, new string[] { @"attachment path", @"attachment path" }, parameters9);
                Console.WriteLine(emailInvoice);
                var parameters2 = new Dictionary <object, object>();
                parameters2.Add("invoice_ids", invoices[2].invoice_id + "," + invoices[0].invoice_id);
                var contactsToSend = new Contacts()
                {
                    contacts = new List <Contact>()
                    {
                        new Contact()
                        {
                            contact_id = contactId,
                            email      = "true",
                            snail_mail = true
                        },
                    }
                };
                var emailInvoices = invoicesApi.EmailInvoices(contactsToSend, parameters2);
                Console.WriteLine(emailInvoices);
                var parameters3 = new Dictionary <object, object>();
                parameters3.Add("invoice_ids", invoices[2].invoice_id + "," + invoices[0].invoice_id);
                var emailcontent = invoicesApi.GetEmailContent(invoiceId, parameters3);
                Console.WriteLine("{0},{1},{2}", emailcontent.body, emailcontent.file_name, emailcontent.gateways_configured);
                var notifydetails = new EmailNotification()
                {
                    to_mail_ids = new List <string>()
                    {
                        "{mail id 1}", "{mail id 2}"
                    },
                    subject = "payment reminder",
                    body    = "dear "
                };
                var parameters4 = new Dictionary <object, object>();

                var remindMsg = invoicesApi.RemindCustomer(invoiceId, notifydetails, parameters4);
                Console.WriteLine(remindMsg);
                var parameters5 = new Dictionary <object, object>();

                parameters5.Add("invoice_ids", invoices[2].invoice_id + "," + invoices[0].invoice_id);
                var bulkReminderMsg = invoicesApi.BulkInvoiceReminder(parameters5);
                Console.WriteLine(bulkReminderMsg);
                var reminderContent = invoicesApi.GetPaymentReminder(invoiceId);
                Console.WriteLine("{0},{1},{2}", reminderContent.body, reminderContent.file_name, reminderContent.gateways_configured);
                var parameters6 = new Dictionary <object, object>();
                parameters6.Add("invoice_ids", invoices[2].invoice_id + "," + invoices[0].invoice_id);
                var bulkExport = invoicesApi.BulkExport(parameters6);
                Console.WriteLine(bulkExport);
                var disableReminderMsg = invoicesApi.DisablePaymentReminder(invoiceId);
                Console.WriteLine(disableReminderMsg);
                var enableReminderMsg = invoicesApi.EnablePaymentReminder(invoiceId);
                Console.WriteLine(enableReminderMsg);
                var writeoff = invoicesApi.WriteoffInvoice(invoiceId);
                Console.WriteLine(writeoff);
                var cancleWriteoff = invoicesApi.CancelWriteoff(invoiceId);
                Console.WriteLine(cancleWriteoff);
                var updateInfo = new Address()
                {
                    address            = "addr",
                    is_update_customer = false
                };
                var billingdAddrUpdate = invoicesApi.UpdateBillingAddress(invoiceId, updateInfo);
                Console.WriteLine(billingdAddrUpdate);
                var updateInfo1 = new Address()
                {
                    address            = "addr",
                    is_update_customer = false
                };
                var shippingdAddrUpdate = invoicesApi.UpdateShippingAddress(invoiceId, updateInfo);
                Console.WriteLine(shippingdAddrUpdate);
                var invoicetemplatesList = invoicesApi.GetTemplates();
                var invoicetemplates     = invoicetemplatesList;
                foreach (var template in invoicetemplates)
                {
                    Console.WriteLine("Templates\n{0},{1},{2}", template.template_id, template.template_name, template.template_type);
                }
                var updateTemplate = invoicesApi.UpdateTemplate(invoiceId, invoicetemplates[0].template_id);
                Console.WriteLine(updateTemplate);
                var invoicePaymentsList = invoicesApi.GetPayments(invoiceId);
                var invoicePayments     = invoicePaymentsList;
                var paymentId           = invoicePayments[1].payment_id;
                foreach (var payment in invoicePayments)
                {
                    Console.WriteLine("payment:{0},{1},{2}", payment.payment_id, payment.description, payment.invoice_id);
                }
                var appliedCreditsList = invoicesApi.GetCreditsApplied(invoiceId);
                var appliedCredits     = appliedCreditsList;
                var creditnoteId       = appliedCredits[1].creditnote_id;

                foreach (var credit in appliedCredits)
                {
                    Console.WriteLine("credit note:{0},{1},{2}", credit.creditnote_id, credit.amount_applied, credit.creditnotes_number);
                }
                var creditstoapplly = new UseCredits()
                {
                    apply_creditnotes = new List <CreditNote>()
                    {
                        new CreditNote()
                        {
                            creditnote_id  = creditnoteId,
                            amount_applied = 40.00
                        }
                    }
                };
                var appliedCredits1 = invoicesApi.AddCredits(invoiceId, creditstoapplly);
                var creditnotes     = appliedCredits1.apply_creditnotes;
                foreach (var credit in creditnotes)
                {
                    Console.WriteLine("credit note:{0},{1}", credit.creditnote_id, credit.amount_applied);
                }
                var deletePaymentmsg = invoicesApi.DeletePayment(invoiceId, paymentId);
                Console.WriteLine(deletePaymentmsg);
                var deleteAppliedcredit = invoicesApi.DelteAppliedCredit(invoiceId, creditnoteId);
                Console.WriteLine(deleteAppliedcredit);
                var commentsList = invoicesApi.GetComments(invoiceId);
                var comments     = commentsList;
                foreach (var comment in comments)
                {
                    Console.WriteLine("{0},{1},{2}", comment.comment_id, comment.description, comment.commented_by);
                }
                var newCommentInfo = new Comment()
                {
                    description             = "new comment",
                    show_comment_to_clients = true
                };
                var newComment = invoicesApi.AddComment(invoiceId, newCommentInfo);
                Console.WriteLine(newComment);
                var updateInfo2 = new Comment()
                {
                    description             = "updated comment",
                    show_comment_to_clients = true
                };
                var updatedComment = invoicesApi.UpdateComment(invoiceId, comments[1].comment_id, updateInfo2);
                Console.WriteLine("{0},{1},{2}", updatedComment.comment_id, updatedComment.description, updatedComment.commented_by);
                var deleteMsg = invoicesApi.DeleteComment(invoiceId, comments[3].comment_id);
                Console.WriteLine(deleteMsg);
                var attachment = invoicesApi.GetAttachment(invoiceId);
                Console.WriteLine(attachment);
                var parameters7 = new Dictionary <object, object>();
                parameters7.Add("can_send_in_mail", true);
                var attachPreference = invoicesApi.UpdateAttachment(invoiceId, parameters7);
                Console.WriteLine(attachPreference);
                var deleteAttach = invoicesApi.DeleteAttachment(invoiceId);
                Console.WriteLine(deleteAttach);
                var deleteExpenceRecipt = invoicesApi.DeleteExpenseReceipt(invoiceId);
                Console.WriteLine(deleteExpenceRecipt);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
Exemple #34
0
 static void Main(string[] args)
 {
     try
     {
         var service = new ZohoBooks();
         service.initialize("{authtoken}", "{organization id}");
         var currenciesApi = service.GetSettingsApi();
         var parameters    = new Dictionary <object, object>();
         parameters.Add("filter_by", "Currencies.ExcludeBaseCurrency");
         var currenciesList = currenciesApi.GetCurrencies(parameters);
         var currencies     = currenciesList;
         var currencyId     = currencies[0].currency_id;
         foreach (var currency in currencies)
         {
             Console.WriteLine("Id:{0},\ncode:{1},\nname:{2},\nsymbol:{3}\nFormat:{4}\n", currency.currency_id, currency.currency_code, currency.currency_name, currency.currency_symbol, currency.currency_format);
         }
         var currency1 = currenciesApi.GetACurrency(currencyId);
         Console.WriteLine("Id:{0},\ncode:{1},\nname:{2},\nsymbol:{3}\nFormat:{4}\n", currency1.currency_id, currency1.currency_code, currency1.currency_name, currency1.currency_symbol, currency1.currency_format);
         var newCurrencyInfo = new Currency()
         {
             currency_code   = "JPY",
             currency_symbol = "%",
             currency_format = "1,234,567.89"
         };
         var newCurrency = currenciesApi.CreateCurrency(newCurrencyInfo);
         Console.WriteLine("Id:{0},\ncode:{1},\nname:{2},\nsymbol:{3}\nFormat:{4}\n", newCurrency.currency_id, newCurrency.currency_code, newCurrency.currency_name, newCurrency.currency_symbol, newCurrency.currency_format);
         var updateInfo = new Currency()
         {
             currency_symbol = "&"
         };
         var updatedCurrncy = currenciesApi.UpdateCurrency(newCurrency.currency_id, updateInfo);
         Console.WriteLine("Id:{0},\ncode:{1},\nname:{2},\nsymbol:{3}\nFormat:{4}\n", updatedCurrncy.currency_id, updatedCurrncy.currency_code, updatedCurrncy.currency_name, updatedCurrncy.currency_symbol, updatedCurrncy.currency_format);
         var deletemsg = currenciesApi.DeleteCurrency(updatedCurrncy.currency_id);
         Console.WriteLine(deletemsg);
         var ErParameters      = new Dictionary <object, object>();
         var exchangeratesList = currenciesApi.GetExchangeRates("71917000000000097", ErParameters);
         var exchangerates     = exchangeratesList;
         var exchangeRateId    = exchangerates[0].exchange_rate_id;
         foreach (var exchangerate in exchangerates)
         {
             Console.WriteLine("ExchangerateId:{0},\ncurrency Id:{1},Currency Code:{2},\nRate:{3}\n", exchangerate.exchange_rate_id, exchangerate.currency_id, exchangerate.currency_code, exchangerate.rate);
         }
         var exchngerate = currenciesApi.GetAnExchangeRate("71917000000000097", exchangeRateId);
         Console.WriteLine("ExchangerateId:{0},\ncurrency Id:{1},\nCurrency Code:{2},\nRate:{3}\n", exchngerate.exchange_rate_id, exchngerate.currency_id, exchngerate.currency_code, exchngerate.rate);
         var newExchangerateInfo = new ExchangeRate()
         {
             effective_date = "2014-05-14",
             rate           = 31,
         };
         var newExchangerate = currenciesApi.CreateAnExchangeRate("71917000000000097", newExchangerateInfo);
         Console.WriteLine("ExchangerateId:{0},\ncurrency Id:{1},\nCurrency Code:{2},\nRate:{3}\n", newExchangerate.exchange_rate_id, newExchangerate.currency_id, newExchangerate.currency_code, newExchangerate.rate);
         var updateinfo = new ExchangeRate()
         {
             rate = 40,
         };
         var updatedExchangerate = currenciesApi.UpdateAnExchangeRate("71917000000000097", newExchangerate.exchange_rate_id, updateinfo);
         Console.WriteLine("ExchangerateId:{0},\ncurrency Id:{1},\nCurrency Code:{2},\nRate:{3}\n", updatedExchangerate.exchange_rate_id, updatedExchangerate.currency_id, updatedExchangerate.currency_code, updatedExchangerate.rate);
         var deleteMsg = currenciesApi.DeleteAnExchangeRate("71917000000000097", updatedExchangerate.exchange_rate_id);
         Console.WriteLine(deleteMsg);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
     Console.ReadKey();
 }
 static void Main(string[] args)
 {
     try
     {
         var service = new ZohoBooks();
         service.initialize("{authtoken}", "{organization id}");
         var projectsApi = service.GetProjectsApi();
         var parameters  = new Dictionary <object, object>();
         parameters.Add("filter_by", "Status.Active");
         var projectsList = projectsApi.GetProjects(null);
         var projects     = projectsList;
         var projectId    = projects[0].project_id;
         foreach (var project in projects)
         {
             Console.WriteLine("{0},{1},{2}", project.project_name, project.billing_type, project.status);
         }
         var project1 = projectsApi.Get(projectId);
         Console.WriteLine("{0},{1},{2}", project1.project_name, project1.tasks.Count, project1.users.Count);
         var newPrjctInfo = new Project()
         {
             project_name = "project-test-1",
             customer_id  = project1.customer_id,
             billing_type = "fixed_cost_for_project",
             rate         = 1000,
         };
         var newProject = projectsApi.Create(newPrjctInfo);
         Console.WriteLine("{0},{1},{2}", newProject.project_name, newProject.billing_type, newProject.status);
         var updateInfo = new Project()
         {
             project_name = "project-test-updated",
         };
         var updatedprjct = projectsApi.Update(newProject.project_id, updateInfo);
         Console.WriteLine("{0},{1},{2}", updatedprjct.project_name, updatedprjct.billing_type, updatedprjct.status);
         var delprjct = projectsApi.Delete(updatedprjct.project_id);
         Console.WriteLine(delprjct);
         var inAct = projectsApi.Inactivate(projectId);
         Console.WriteLine(inAct);
         var act = projectsApi.Activate(projectId);
         Console.WriteLine(act);
         var clonePrjctInfo = new Project()
         {
             project_name = "clone-test",
             description  = "cloned for test"
         };
         var clonePrjct = projectsApi.Clone(projectId, clonePrjctInfo);
         Console.WriteLine("{0},{1},{2}", clonePrjct.project_name, clonePrjct.billing_type, clonePrjct.status);
         var parameters1 = new Dictionary <object, object>();
         var taskslist   = projectsApi.GetTasks(projectId, parameters1);
         var tasks       = taskslist;
         var taskId      = tasks[0].task_id;
         foreach (var task in tasks)
         {
             Console.WriteLine("{0},{1}", task.task_name, task.billed_hours);
         }
         var task1 = projectsApi.GetATask(projectId, taskId);
         Console.WriteLine("{0},{1}", task1.task_name, task1.rate);
         var newTaskInfo = new ProjectTask()
         {
             task_name   = "task new for test",
             description = "new task to project",
         };
         var newTask = projectsApi.AddATask(projectId, newTaskInfo);
         Console.WriteLine("{0},{1}", newTask.task_name, newTask.rate);
         var updateInfo1 = new ProjectTask()
         {
             task_name = "ta3",
         };
         var updatedTask = projectsApi.UpdateTask(projectId, newTask.task_id, updateInfo1);
         Console.WriteLine("{0},{1}", updatedTask.task_name, updatedTask.task_id);
         var delTask = projectsApi.DeleteTask(projectId, updatedTask.task_id);
         Console.WriteLine(delTask);
         var usersList = projectsApi.GetUsers(projectId);
         var users     = usersList;
         var userId    = users[0].user_id;
         foreach (var user in users)
         {
             Console.WriteLine("{0},{1},{2}", user.user_name, user.user_role, user.rate);
         }
         var user1 = projectsApi.GetAUser(projectId, userId);
         Console.WriteLine("{0},{1},{2}", user1.user_name, user1.user_role, user1.rate);
         var userstoAssign = new UsersToAssign()
         {
             users = new List <User>()
             {
                 new User()
                 {
                     user_id = userId
                 }
             }
         };
         var users1 = projectsApi.AssignUsers(projectId, userstoAssign);
         foreach (var user in users1)
         {
             Console.WriteLine("{0},{1},{2}", user.user_name, user.user_role, user.rate);
         }
         var userInfo = new User()
         {
             user_name = "name-twst",
             email     = "*****@*****.**",
             user_role = "staff"
         };
         var user2 = projectsApi.InviteUser(projectId, userInfo);
         Console.WriteLine("{0},{1},{2}", user2.user_name, user2.user_role, user2.rate);
         var updateInfo2 = new User()
         {
             user_name = "name",
             user_role = "admin"
         };
         var UpdatedUser = projectsApi.UpdateUser(projectId, user2.user_id, updateInfo2);
         Console.WriteLine("{0},{1},{2}", UpdatedUser.user_name, UpdatedUser.user_role, UpdatedUser.rate);
         var deleteUser = projectsApi.DeleteUser(projectId, UpdatedUser.user_id);
         Console.WriteLine(deleteUser);
         var parameters2     = new Dictionary <object, object>();
         var timeEntrieslist = projectsApi.GetTimeEnries(parameters2);
         var timeEntries     = timeEntrieslist;
         var timeEnteryId    = timeEntries[0].time_entry_id;
         foreach (var timeentry in timeEntries)
         {
             Console.WriteLine("time entry of id {0} for the project {1} of user {2} of log time:{3}\n", timeentry.time_entry_id, timeentry.project_name, timeentry.user_name, timeentry.log_time);
         }
         var timeentry1 = projectsApi.GetATimeEntry(timeEnteryId);
         Console.WriteLine("time entry of id {0} for the project {1} of user {2} of log time:{3}\n", timeentry1.time_entry_id, timeentry1.project_name, timeentry1.user_name, timeentry1.log_time);
         var newTimeentryInfo = new TimeEntry()
         {
             project_id = projectId,
             task_id    = taskId,
             user_id    = userId,
             log_date   = "2014-11-13",
             log_time   = "06:46"
         };
         var newTimeentry = projectsApi.LogTimeEntry(newTimeentryInfo);
         Console.WriteLine("time entry of id {0} for the project {1} of user {2} of log time:{3}\n", newTimeentry.time_entry_id, newTimeentry.project_name, newTimeentry.user_name, newTimeentry.log_time);
         var updateInfo3 = new TimeEntry()
         {
             project_id = projectId,
             user_id    = userId,
             log_time   = "02:00",
         };
         var updatedTimeEntry = projectsApi.UpdateTimeEntry(newTimeentry.time_entry_id, updateInfo3);
         Console.WriteLine("time entry of id {0} for the project {1} of user {2} of log time:{3}\n", updatedTimeEntry.time_entry_id, updatedTimeEntry.project_name, updatedTimeEntry.user_name, updatedTimeEntry.log_time);
         var deleteMsg = projectsApi.DeleteTimeEntry(updatedTimeEntry.time_entry_id);
         Console.WriteLine(deleteMsg);
         var parameters3 = new Dictionary <object, object>();
         parameters3.Add("time_entry_ids", timeEnteryId + "," + updatedTimeEntry.time_entry_id);
         var deleteEntries = projectsApi.DeleteTimeEntries(parameters3);
         Console.WriteLine(deleteEntries);
         var timer = projectsApi.GetTimer();
         Console.WriteLine("time entry of id {0} for the project {1} of user {2} of log time:{3}\n", timer.time_entry_id, timer.project_name, timer.user_name, timer.log_time);
         var timerStart = projectsApi.StartTimer(timeEnteryId);
         Console.WriteLine("time entry of id {0} for the project {1} of user {2} of log time:{3}\n", timerStart.time_entry_id, timerStart.project_name, timerStart.user_name, timerStart.log_time);
         var stopTimer = projectsApi.StopTimer();
         Console.WriteLine("time entry of id {0} for the project {1} of user {2} of log time:{3}\n", stopTimer.time_entry_id, stopTimer.project_name, stopTimer.user_name, stopTimer.log_time);
         var commentsList = projectsApi.GetComments(projectId);
         var comments     = commentsList;
         foreach (var comment in comments)
         {
             Console.WriteLine("{0},{1},{2}", comment.comment_id, comment.description, comment.commented_by);
         }
         var newCommentInfo = new Comment()
         {
             description = "manually added comment",
         };
         var newComment = projectsApi.AddComment(projectId, newCommentInfo);
         Console.WriteLine("{0},{1},{2}", newComment.comment_id, newComment.description, newComment.commented_by);
         var deleteComment = projectsApi.DeleteComment(projectId, newComment.comment_id);
         Console.WriteLine(deleteComment);
         var parameters4  = new Dictionary <object, object>();
         var invoicesList = projectsApi.GetInvoices(projectId, null);
         foreach (var invoice in invoicesList)
         {
             Console.WriteLine("{0},{1},{2}", invoice.invoice_number, invoice.total, invoice.status);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
     Console.ReadKey();
 }
        static void Main(string[] args)
        {
            try
            {
                var service = new ZohoBooks();
                service.initialize("{authtoken}", "{organization id}");
                var salesOrdersApi = service.GetSalesordersApi();
                Console.WriteLine("------------------ SalesOrders -------------");
                var salesOrders = salesOrdersApi.GetSalesorders(null);
                foreach(var tempSalesOrder in salesOrders)
                    Console.WriteLine("Id:{0},date:{1},customerName:{2},status:{3},Amount:{4}",tempSalesOrder.salesorder_id,tempSalesOrder.date,tempSalesOrder.customer_name,tempSalesOrder.status,tempSalesOrder.total);
                Console.WriteLine("--------------------Specified SalesOrder----------------------");
                var salesOrder = salesOrdersApi.Get(salesOrders[0].salesorder_id,null);
                Console.WriteLine("Id:{0},date:{1},customerName:{2},status:{3},Amount:{4}", salesOrder.salesorder_id, salesOrder.date, salesOrder.customer_name, salesOrder.status, salesOrder.total);
                Console.WriteLine("Line Items");
                var lineitems = salesOrder.line_items;
                foreach(var tempLineitem in lineitems)
                {
                    Console.WriteLine("Id:{0},name:{1},rate:{2}", tempLineitem.line_item_id, tempLineitem.name, tempLineitem.rate);
                }
               Console.WriteLine("--------------------New SalesOrder----------------------");
                var newSalesOrderInfo=new Salesorder()
                {
                    customer_id=salesOrders[0].customer_id,
                    line_items = new List<LineItem> { new LineItem{
                            item_id=lineitems[0].item_id,
                        },
                    },

                };
                var newSalesOrder = salesOrdersApi.Create(newSalesOrderInfo, null);
                Console.WriteLine("Id:{0},date:{1},customerName:{2},status:{3},Amount:{4}", newSalesOrder.salesorder_id, newSalesOrder.date, salesOrder.customer_name, newSalesOrder.status, newSalesOrder.total);
                Console.WriteLine("Line Items");
                var newLineitems = salesOrder.line_items;
                foreach (var tempLineitem in newLineitems)
                {
                    Console.WriteLine("Id:{0},name:{1},rate:{2}", tempLineitem.line_item_id, tempLineitem.name, tempLineitem.rate);
                }
                Console.WriteLine("--------------------Updated SalesOrder----------------------");
                var updateInfo = new Salesorder()
                {
                    line_items = new List<LineItem> { new LineItem{
                            item_id=lineitems[0].item_id,
                            rate=150,
                        },
                    },

                };
                var updatedSalesOrder = salesOrdersApi.Update(newSalesOrder.salesorder_id,updateInfo,null);
                Console.WriteLine("Id:{0},date:{1},customerName:{2},status:{3},Amount:{4}", updatedSalesOrder.salesorder_id, updatedSalesOrder.date, updatedSalesOrder.customer_name, updatedSalesOrder.status, updatedSalesOrder.total);
                Console.WriteLine("Line Items");
                var updatedLineitems = salesOrder.line_items;
                foreach (var tempLineitem in updatedLineitems)
                {
                    Console.WriteLine("Id:{0},name:{1},rate:{2}", tempLineitem.line_item_id, tempLineitem.name, tempLineitem.rate);
                }
                Console.WriteLine("--------------------Delete SalesOrder----------------------");
                var deleteMsg = salesOrdersApi.Delete(updatedSalesOrder.salesorder_id);
                Console.WriteLine(deleteMsg);
                Console.WriteLine("--------------------Mark SalesOrder as Open----------------------");
                var markAsOpen = salesOrdersApi.MarkAsOpen(salesOrders[0].salesorder_id);
                Console.WriteLine(markAsOpen);
                Console.WriteLine("--------------------Mark SalesOrder as Void----------------------");
                var markAsVoid = salesOrdersApi.MarkAsVoid(salesOrders[0].salesorder_id);
                Console.WriteLine(markAsVoid);
                Console.WriteLine("--------------------Email A SalesOrder----------------------");
                var emailDetails = new EmailNotification()
                {
                    to_mail_ids = new List<string>(){"*****@*****.**",},
                    subject="test sub",
                    body="body-test"
                };
                var emailOrder=salesOrdersApi.SendEmail(salesOrders[1].salesorder_id,emailDetails,null);
                Console.WriteLine(emailOrder);
                Console.WriteLine("--------------------Email Content of SalesOrder----------------------");
                var emailData = salesOrdersApi.GetEmailContent(salesOrders[1].salesorder_id, null);
                Console.WriteLine("Body:{0}\nSub:{1}\nTemplate Id{2}",emailData.body,emailData.subject,emailData.emailtemplates[0].email_template_id);
                Console.WriteLine("--------------------Bulk Export----------------------------");
                var salesorderIds = new List<string> { salesOrders[0].salesorder_id,};
                var bulkExport = salesOrdersApi.BulkExportSalesorders(salesorderIds);
                Console.WriteLine(bulkExport);
                Console.WriteLine("--------------------Bulk Print----------------------------");
                var bulkPrint = salesOrdersApi.BulkExportSalesorders(salesorderIds);
                Console.WriteLine(bulkPrint);
                var addr_info = new Address()
                {
                    city="test-city",
                    country="test-country"
                };
                Console.WriteLine("--------------------Update BillingAddress----------------------------");
                var updatedBillingAddr = salesOrdersApi.UpdateBillingAddress(salesOrders[0].salesorder_id, addr_info);
                Console.WriteLine("city:{0},state:{1}",updatedBillingAddr.city,updatedBillingAddr.country);
                Console.WriteLine("--------------------Update ShippingAddress----------------------------");
                var updatedShippingAddr = salesOrdersApi.UpdateShippingAddress(salesOrders[0].salesorder_id, addr_info);
                Console.WriteLine("city:{0},state:{1}", updatedShippingAddr.city, updatedShippingAddr.country);
                Console.WriteLine("---------------------Templates-------------------");
                var templates = salesOrdersApi.GetTemplates();
                foreach (var template in templates)
                    Console.WriteLine("id:{0},name:{1}", template.template_id, template.template_name);
                Console.WriteLine("-----------------------Update Template----------------");
                var updatedTemplate = salesOrdersApi.UpdateTemplate(salesOrders[0].salesorder_id, templates[0].template_id);
                Console.WriteLine(updatedTemplate);
                Console.WriteLine("-------------------------Attachments-----------------");
                var getAttachment = salesOrdersApi.GetAttachment(salesOrders[1].salesorder_id,null);
                Console.WriteLine(getAttachment);
                var addAttachment=salesOrdersApi.AddAttachment(salesOrders[0].salesorder_id,@"C:\Users\hari-2197\Desktop\h.jpg",null);
                Console.WriteLine(addAttachment);
                var attachPreference = new Dictionary<object, object>();
                attachPreference.Add("can_send_in_mail", true);
                var updatedAttachPreference = salesOrdersApi.UpdateAttachmentPreference(salesOrders[0].salesorder_id, attachPreference);
                Console.WriteLine(updatedAttachPreference);
                var delAttachment = salesOrdersApi.DeleteAnAttachment(salesOrders[0].salesorder_id);
                Console.WriteLine(delAttachment);
                Console.WriteLine("-------------------------Comments-----------------");
                var comments = salesOrdersApi.GetComments(salesOrders[0].salesorder_id);
                Console.WriteLine("All Comments");
                foreach (var comment in comments)
                    Console.WriteLine("id:{0},description:{1},commented by:{2}",comment.comment_id,comment.description,comment.commented_by);
                var newCommentInfo=new Comment()
                {
                    description="new test comment",
                };
                var newComment = salesOrdersApi.AddComment(salesOrders[0].salesorder_id, newCommentInfo);
                Console.WriteLine("id:{0},description:{1},commented by:{2}", newComment.comment_id, newComment.description, newComment.commented_by);
                var commentUpdateInfo=new Comment(){
                    description="updated-test"
                };
                var updatedComment = salesOrdersApi.UpdateComment(salesOrders[0].salesorder_id, newComment.comment_id, commentUpdateInfo);
                Console.WriteLine("id:{0},description:{1},commented by:{2}", updatedComment.comment_id, updatedComment.description, updatedComment.commented_by);
                var deleteComment = salesOrdersApi.DeleteComment(salesOrders[0].salesorder_id, updatedComment.comment_id);
                Console.WriteLine(deleteComment);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            try
            {
                var service = new ZohoBooks();
                service.initialize("{authtoken}", "{organization id}");
                CreditNotesApi creditnoteApi = service.GetCreditNoteApi();

                var parameters = new Dictionary<object, object>();
                parameters.Add("creditnote_number_startswith", "CN");
                parameters.Add("status", "open");
                parameters.Add("total_less_than", "5000");
                var creditnotesList = creditnoteApi.GetCreditnotes(parameters);
                var creditnotes = creditnotesList;
                var creditnoteId = creditnotes[0].creditnote_id;
                if (creditnotes != null)
                {
                    foreach (var creditnote in creditnotes)
                        Console.WriteLine("{0},{1},{2}", creditnote.creditnote_number, creditnote.total_credits_used, creditnote.total);
                }
                var parameters1 = new Dictionary<object, object>();
                parameters1.Add("print", "false");

                var creditnote1 = creditnoteApi.Get(creditnoteId, parameters1);
                if (creditnote1 != null)
                    Console.WriteLine("{0},{1},{2}", creditnote1.creditnote_number, creditnote1.total_credits_used, creditnote1.total);
                var newCreditnote = new CreditNote()
                {
                    customer_id = "{customer id}",
                    creditnote_number = "CN-0008",
                    line_items = new List<LineItem>(){
                    new LineItem(){
                      item_id="{item id}",

                      name="Hard Drive",
                      description="500GB, USB 2.0 interface 1400 rpm, protective hard case.",
                      unit="",
                      rate=120.00,
                      quantity= 1.00,

                    },
                }

                };
                var parameters2 = new Dictionary<object, object>();
                parameters2.Add("ignore_auto_number_generation", "true");

                var createdCreditnote = creditnoteApi.Create(newCreditnote, parameters2);
                if (createdCreditnote != null)
                    Console.WriteLine("{0},{1},{2}", createdCreditnote.creditnote_number, createdCreditnote.total_credits_used, createdCreditnote.total);
                CreditNote updateInf = new CreditNote()
                {
                    customer_id = "{customer id}",
                    creditnote_number = "CN-00000",

                };
                var parameters3 = new Dictionary<object, object>();
                parameters3.Add("ignore_auto_number_generation", "true");
                var updatedCreditnote = creditnoteApi.Update(creditnoteId, updateInf, parameters3);
                if (updatedCreditnote != null)
                    Console.WriteLine("{0},{1},{2}", updatedCreditnote.creditnote_number, updatedCreditnote.total_credits_used, updatedCreditnote.total);
                var delstr = creditnoteApi.Delete(creditnotes[2].creditnote_id);
                Console.WriteLine(delstr);
                var convToOpen = creditnoteApi.ConvertToOpen(creditnoteId);
                Console.WriteLine(convToOpen);
                var voidstr = creditnoteApi.ConvertToVoid(creditnoteId);
                Console.WriteLine(voidstr);
                var parameters4 = new Dictionary<object, object>();
                var emaildata = new EmailNotification()
                {

                    send_from_org_email_id = false,
                    to_mail_ids = new List<string>(){
                    "*****@*****.**"
                  },

                    subject = "Credit Note from Zillium Inc ",
                    body = "Dear Customer,           <br><br><br><br>The credit note  is attached with this email.           <br><br><br><br>Credit Note Overview:           \n"

                };
                var emailstr = creditnoteApi.SendEmail(creditnoteId, emaildata, parameters4);
                Console.WriteLine(emailstr);
                var emailhstrs = creditnoteApi.GetEmailHistory(creditnoteId);
                if (emailhstrs != null)
                    foreach (var emailhstr in emailhstrs)
                        Console.WriteLine("{0},{1},{2}", emailhstr.from, emailhstr.mailhistory_id, emailhstr.to_mail_ids);
                var parameters5 = new Dictionary<object, object>();
                var emailstmt = creditnoteApi.GetEmailContent(creditnoteId, parameters5);
                if (emailstmt != null)
                {
                    Console.WriteLine("{0},{1},{2}", emailstmt.body, emailstmt.subject, emailstmt.file_name);
                }
                var addr = new Address()
                {
                    city = "guntur",
                    state = "AP"
                };
                var upbilladdrstr = creditnoteApi.UpdateBillingAddress(creditnoteId, addr);
                Console.WriteLine(upbilladdrstr);
                var address = new Address()
                {
                    city = "guntur",
                    state = "AP"
                };
                var upshipp = creditnoteApi.UpdateShippingAddress(creditnoteId, address);
                Console.WriteLine(upshipp);
                var templatesList = creditnoteApi.GetTemplates();
                var templates = templatesList;
                if (templates != null)
                    foreach (var template in templates)
                        Console.WriteLine("{0},{1},{2}", template.template_id, template.template_name, template.template_type);
                var updtemplatestr = creditnoteApi.UpdateTemplate(creditnoteId, templates[0].template_id);
                Console.WriteLine(updtemplatestr);
                var invoicescreditedList = creditnoteApi.GetInvoicesCredited(creditnoteId);
                var invoicescredited = invoicescreditedList;
                if (invoicescredited != null)
                    foreach (var invoicecredited in invoicescredited)
                        Console.WriteLine("{0},{1},{2}", invoicecredited.creditnote_invoice_id, invoicecredited.credited_amount, invoicecredited.invoice_id);
                var applytoinvoice = new ApplyToInvoices()
                {
                    invoices = new List<CreditedInvoice>(){
                    new CreditedInvoice(){
                        invoice_id="{invoice id}",
                        amount_applied=55.00,
                    },
                }
                };
                var creditedinvoicesInfoList = creditnoteApi.CreditToInvoices(creditnoteId, applytoinvoice);
                var creditedinvoicesInfo = creditedinvoicesInfoList;
                if (creditedinvoicesInfo != null)
                    foreach (var creditedinvoiceInfo in creditedinvoicesInfo)
                        Console.WriteLine("{0},{1}", creditedinvoiceInfo.invoice_id, creditedinvoiceInfo.amount_applied);
                var delcreditinvapplied = creditnoteApi.DeleteInvoiceCredited(creditnoteId, creditedinvoicesInfo[1].creditnote_id);
                Console.WriteLine(delcreditinvapplied);
                var parameters6 = new Dictionary<object, object>();
                var creditrefunds = creditnoteApi.GetCreditnoteRefunds(parameters6);
                if (creditrefunds != null)
                    foreach (var creditrefund in creditrefunds)
                        Console.WriteLine("{0},{1},{2}", creditrefund.creditnote_refund_id, creditrefund.creditnote_number, creditrefund.amount_bcy);
                var creditrefundsofcrednote = creditnoteApi.GetRefundsOfCrreditnote(creditnoteId);
                foreach (var creditrefund in creditrefundsofcrednote)
                    Console.WriteLine("{0},{1},{2}", creditrefund.creditnote_refund_id, creditrefund.creditnote_number, creditrefund.amount_bcy);
                var creditnoterefund = creditnoteApi.GetCreditnoteRefund(creditnoteId, creditrefundsofcrednote[0].creditnote_refund_id);
                if (creditnoterefund != null)
                    Console.WriteLine("{0},{1},{2}", creditnoterefund.creditnote_refund_id, creditnoterefund.from_account_name, creditnoterefund.amount);
                var refunddetails = new CreditNote()
                {
                    date = "2014-01-30",
                    from_account_id = "{account id}",
                    amount = 10,
                };
                var refundedcredit = creditnoteApi.AddRefund(creditnoteId, refunddetails);
                if (refundedcredit != null)
                    Console.WriteLine("{0},{1},{2}", refundedcredit.creditnote_refund_id, refundedcredit.from_account_name, refundedcredit.amount);
                var creditrefundupdateinfo = new CreditNote()
                {
                    date = "2014-01-30",
                    from_account_id = "{account id}",
                    amount = 5,
                };
                var updatedCreditrefund = creditnoteApi.UpdateRefund(creditnoteId, creditrefundsofcrednote[0].creditnote_refund_id, creditrefundupdateinfo);
                if (updatedCreditrefund != null)
                    Console.WriteLine("{0},{1},{2}", updatedCreditrefund.creditnote_refund_id, updatedCreditrefund.from_account_name, updatedCreditrefund.amount);
                var delcrdrefstr = creditnoteApi.DeleteRefund(creditnoteId, creditrefundsofcrednote[1].creditnote_refund_id);
                Console.WriteLine(delcrdrefstr);
                var commentsList = creditnoteApi.GetcreditnoteComments(creditnoteId);
                var comments = commentsList;
                if (comments != null)
                    foreach (var comment in comments)
                        Console.WriteLine("{0},{1},{2}", comment.comment_id, comment.description, comment.commented_by);

                var newcommentinfo = new Comment()
                {
                    description = "nothing"
                };
                var newcomment = creditnoteApi.AddComment(creditnoteId, newcommentinfo);
                if (newcomment != null)
                    Console.WriteLine("{0},{1},{2}", newcomment.comment_id, newcomment.description, newcomment.commented_by);
                var delcommentstr = creditnoteApi.DeleteComment(creditnoteId, comments[1].comment_id);
                Console.WriteLine(delcommentstr);
            }
            catch(Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
Exemple #38
0
        static void Main(string[] args)
        {
            try
            {
                var service = new ZohoBooks();
                service.initialize("{authtoken}", "{organisation id}");
                var expensesApi  = service.GetExpensesApi();
                var parameters2  = new Dictionary <object, object>();
                var expensesList = expensesApi.GetExpenses(parameters2);
                var expenses     = expensesList;
                var expenseId    = expenses[1].expense_id;
                var accountId    = expenses[0].account_id;
                var paidAccId    = expenses[0].paid_through_account_id;
                if (expenses != null)
                {
                    foreach (var expense in expenses)
                    {
                        Console.WriteLine("{0},{1},{2}", expense.expense_id, expense.total, expense.account_name);
                    }
                }
                var parameters = new Dictionary <object, object>();
                var receiptstr = expensesApi.GetReceipt(expenseId, parameters);
                Console.WriteLine(receiptstr);
                var delreceipt = expensesApi.DeleteReceipt(expenseId);
                Console.WriteLine(delreceipt);
                var addreceipt = expensesApi.AddReceipt(expenseId, @"attachment path");
                Console.WriteLine(addreceipt);

                var expense1 = expensesApi.Get(expenseId);
                Console.WriteLine("{0},{1},{2}", expense1.expense_id, expense1.total, expense1.account_name);
                var newExpenseInfo = new Expense()
                {
                    account_id = accountId,
                    paid_through_account_id = paidAccId,
                    amount = 24567.00
                };
                var newExpense = expensesApi.Create(newExpenseInfo, @"C:\Users\....\.png");
                if (newExpense != null)
                {
                    Console.WriteLine("{0},{1},{2}", newExpense.expense_id, newExpense.total, newExpense.account_name);
                }
                var updateInfo = new Expense
                {
                    amount = 2456
                };
                var updatedExpense = expensesApi.Update(expenseId, updateInfo, @"attachment path");
                if (updatedExpense != null)
                {
                    Console.WriteLine("{0},{1},{2}", updatedExpense.expense_id, updatedExpense.total, updatedExpense.account_name);
                }
                var delexpense = expensesApi.Delete(expenses[3].expense_id);
                Console.WriteLine(delexpense);
                var commentsList = expensesApi.GetComments(expenseId);
                var comments     = commentsList;
                if (comments != null)
                {
                    foreach (var comment in comments)
                    {
                        Console.WriteLine("{0},{1},{2}", comment.comment_id, comment.description, comment.commented_by);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.ReadKey();
        }
 static void Main(string[] args)
 {
     try
     {
         var service = new ZohoBooks();
         service.initialize("{authtoken}", "{organization id}");
         var salesOrdersApi = service.GetSalesordersApi();
         Console.WriteLine("------------------ SalesOrders -------------");
         var salesOrders = salesOrdersApi.GetSalesorders(null);
         foreach (var tempSalesOrder in salesOrders)
         {
             Console.WriteLine("Id:{0},date:{1},customerName:{2},status:{3},Amount:{4}", tempSalesOrder.salesorder_id, tempSalesOrder.date, tempSalesOrder.customer_name, tempSalesOrder.status, tempSalesOrder.total);
         }
         Console.WriteLine("--------------------Specified SalesOrder----------------------");
         var salesOrder = salesOrdersApi.Get(salesOrders[0].salesorder_id, null);
         Console.WriteLine("Id:{0},date:{1},customerName:{2},status:{3},Amount:{4}", salesOrder.salesorder_id, salesOrder.date, salesOrder.customer_name, salesOrder.status, salesOrder.total);
         Console.WriteLine("Line Items");
         var lineitems = salesOrder.line_items;
         foreach (var tempLineitem in lineitems)
         {
             Console.WriteLine("Id:{0},name:{1},rate:{2}", tempLineitem.line_item_id, tempLineitem.name, tempLineitem.rate);
         }
         Console.WriteLine("--------------------New SalesOrder----------------------");
         var newSalesOrderInfo = new Salesorder()
         {
             customer_id = salesOrders[0].customer_id,
             line_items  = new List <LineItem> {
                 new LineItem {
                     item_id = lineitems[0].item_id,
                 },
             },
         };
         var newSalesOrder = salesOrdersApi.Create(newSalesOrderInfo, null);
         Console.WriteLine("Id:{0},date:{1},customerName:{2},status:{3},Amount:{4}", newSalesOrder.salesorder_id, newSalesOrder.date, salesOrder.customer_name, newSalesOrder.status, newSalesOrder.total);
         Console.WriteLine("Line Items");
         var newLineitems = salesOrder.line_items;
         foreach (var tempLineitem in newLineitems)
         {
             Console.WriteLine("Id:{0},name:{1},rate:{2}", tempLineitem.line_item_id, tempLineitem.name, tempLineitem.rate);
         }
         Console.WriteLine("--------------------Updated SalesOrder----------------------");
         var updateInfo = new Salesorder()
         {
             line_items = new List <LineItem> {
                 new LineItem {
                     item_id = lineitems[0].item_id,
                     rate    = 150,
                 },
             },
         };
         var updatedSalesOrder = salesOrdersApi.Update(newSalesOrder.salesorder_id, updateInfo, null);
         Console.WriteLine("Id:{0},date:{1},customerName:{2},status:{3},Amount:{4}", updatedSalesOrder.salesorder_id, updatedSalesOrder.date, updatedSalesOrder.customer_name, updatedSalesOrder.status, updatedSalesOrder.total);
         Console.WriteLine("Line Items");
         var updatedLineitems = salesOrder.line_items;
         foreach (var tempLineitem in updatedLineitems)
         {
             Console.WriteLine("Id:{0},name:{1},rate:{2}", tempLineitem.line_item_id, tempLineitem.name, tempLineitem.rate);
         }
         Console.WriteLine("--------------------Delete SalesOrder----------------------");
         var deleteMsg = salesOrdersApi.Delete(updatedSalesOrder.salesorder_id);
         Console.WriteLine(deleteMsg);
         Console.WriteLine("--------------------Mark SalesOrder as Open----------------------");
         var markAsOpen = salesOrdersApi.MarkAsOpen(salesOrders[0].salesorder_id);
         Console.WriteLine(markAsOpen);
         Console.WriteLine("--------------------Mark SalesOrder as Void----------------------");
         var markAsVoid = salesOrdersApi.MarkAsVoid(salesOrders[0].salesorder_id);
         Console.WriteLine(markAsVoid);
         Console.WriteLine("--------------------Email A SalesOrder----------------------");
         var emailDetails = new EmailNotification()
         {
             to_mail_ids = new List <string>()
             {
                 "*****@*****.**",
             },
             subject = "test sub",
             body    = "body-test"
         };
         var emailOrder = salesOrdersApi.SendEmail(salesOrders[1].salesorder_id, emailDetails, null);
         Console.WriteLine(emailOrder);
         Console.WriteLine("--------------------Email Content of SalesOrder----------------------");
         var emailData = salesOrdersApi.GetEmailContent(salesOrders[1].salesorder_id, null);
         Console.WriteLine("Body:{0}\nSub:{1}\nTemplate Id{2}", emailData.body, emailData.subject, emailData.emailtemplates[0].email_template_id);
         Console.WriteLine("--------------------Bulk Export----------------------------");
         var salesorderIds = new List <string> {
             salesOrders[0].salesorder_id,
         };
         var bulkExport = salesOrdersApi.BulkExportSalesorders(salesorderIds);
         Console.WriteLine(bulkExport);
         Console.WriteLine("--------------------Bulk Print----------------------------");
         var bulkPrint = salesOrdersApi.BulkExportSalesorders(salesorderIds);
         Console.WriteLine(bulkPrint);
         var addr_info = new Address()
         {
             city    = "test-city",
             country = "test-country"
         };
         Console.WriteLine("--------------------Update BillingAddress----------------------------");
         var updatedBillingAddr = salesOrdersApi.UpdateBillingAddress(salesOrders[0].salesorder_id, addr_info);
         Console.WriteLine("city:{0},state:{1}", updatedBillingAddr.city, updatedBillingAddr.country);
         Console.WriteLine("--------------------Update ShippingAddress----------------------------");
         var updatedShippingAddr = salesOrdersApi.UpdateShippingAddress(salesOrders[0].salesorder_id, addr_info);
         Console.WriteLine("city:{0},state:{1}", updatedShippingAddr.city, updatedShippingAddr.country);
         Console.WriteLine("---------------------Templates-------------------");
         var templates = salesOrdersApi.GetTemplates();
         foreach (var template in templates)
         {
             Console.WriteLine("id:{0},name:{1}", template.template_id, template.template_name);
         }
         Console.WriteLine("-----------------------Update Template----------------");
         var updatedTemplate = salesOrdersApi.UpdateTemplate(salesOrders[0].salesorder_id, templates[0].template_id);
         Console.WriteLine(updatedTemplate);
         Console.WriteLine("-------------------------Attachments-----------------");
         var getAttachment = salesOrdersApi.GetAttachment(salesOrders[1].salesorder_id, null);
         Console.WriteLine(getAttachment);
         var addAttachment = salesOrdersApi.AddAttachment(salesOrders[0].salesorder_id, @"C:\Users\hari-2197\Desktop\h.jpg", null);
         Console.WriteLine(addAttachment);
         var attachPreference = new Dictionary <object, object>();
         attachPreference.Add("can_send_in_mail", true);
         var updatedAttachPreference = salesOrdersApi.UpdateAttachmentPreference(salesOrders[0].salesorder_id, attachPreference);
         Console.WriteLine(updatedAttachPreference);
         var delAttachment = salesOrdersApi.DeleteAnAttachment(salesOrders[0].salesorder_id);
         Console.WriteLine(delAttachment);
         Console.WriteLine("-------------------------Comments-----------------");
         var comments = salesOrdersApi.GetComments(salesOrders[0].salesorder_id);
         Console.WriteLine("All Comments");
         foreach (var comment in comments)
         {
             Console.WriteLine("id:{0},description:{1},commented by:{2}", comment.comment_id, comment.description, comment.commented_by);
         }
         var newCommentInfo = new Comment()
         {
             description = "new test comment",
         };
         var newComment = salesOrdersApi.AddComment(salesOrders[0].salesorder_id, newCommentInfo);
         Console.WriteLine("id:{0},description:{1},commented by:{2}", newComment.comment_id, newComment.description, newComment.commented_by);
         var commentUpdateInfo = new Comment()
         {
             description = "updated-test"
         };
         var updatedComment = salesOrdersApi.UpdateComment(salesOrders[0].salesorder_id, newComment.comment_id, commentUpdateInfo);
         Console.WriteLine("id:{0},description:{1},commented by:{2}", updatedComment.comment_id, updatedComment.description, updatedComment.commented_by);
         var deleteComment = salesOrdersApi.DeleteComment(salesOrders[0].salesorder_id, updatedComment.comment_id);
         Console.WriteLine(deleteComment);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
     Console.ReadKey();
 }
 static void Main(string[] args)
 {
     try
     {
         var service = new ZohoBooks();
         service.initialize("{authtoken}", "{organization id}");
         var purchaseordersApi = service.GetPurchaseordersApi();
         Console.WriteLine("------------------------All Orders-----------");
         var purchaseorders = purchaseordersApi.GetPurchaseorders(null);
         foreach (var tempOrder in purchaseorders)
         {
             Console.WriteLine("order id:{0},vendor name:{1},status:{2}", tempOrder.purchaseorder_id, tempOrder.vendor_name, tempOrder.status);
         }
         Console.WriteLine("-------------Specified order-------------------");
         var purchaseorder = purchaseordersApi.Get(purchaseorders[0].purchaseorder_id, null);
         Console.WriteLine("order id:{0},vendor name:{1},status:{2}", purchaseorder.purchaseorder_id, purchaseorder.vendor_name, purchaseorder.status);
         Console.WriteLine("line items");
         var lineitems = purchaseorder.line_items;
         foreach (var tempitem in lineitems)
         {
             Console.WriteLine("item id:{0},description:{1},rate:{2}", tempitem.item_id, tempitem.description, tempitem.rate);
         }
         Console.WriteLine("-------------New Purchaseorder--------------------");
         var newOrderInfo = new Purchaseorder()
         {
             vendor_id  = purchaseorder.vendor_id,
             line_items = new List <LineItem>()
             {
                 new LineItem()
                 {
                     item_id = lineitems[0].item_id,
                     rate    = 250,
                 },
             }
         };
         var newPurchaseOrder = purchaseordersApi.Create(newOrderInfo, null, @"C:\Users\hari-2197\Desktop\h.jpg");
         Console.WriteLine("order id:{0},vendor name:{1},status:{2},total:{3}", newPurchaseOrder.purchaseorder_id, newPurchaseOrder.vendor_name, newPurchaseOrder.status, newPurchaseOrder.total);
         Console.WriteLine("line items");
         var newOredrlineitems = newPurchaseOrder.line_items;
         foreach (var tempitem in newOredrlineitems)
         {
             Console.WriteLine("item id:{0},description:{1},rate:{2}", tempitem.item_id, tempitem.description, tempitem.rate);
         }
         Console.WriteLine("--------------------update order--------------");
         var updateInfo = new Purchaseorder()
         {
             line_items = new List <LineItem>()
             {
                 new LineItem()
                 {
                     item_id = lineitems[0].item_id,
                     rate    = 300,
                 },
             }
         };
         var updatedOrder = purchaseordersApi.Update(newPurchaseOrder.purchaseorder_id, updateInfo, null, null);
         Console.WriteLine("order id:{0},vendor name:{1},status:{2},total:{3}", updatedOrder.purchaseorder_id, updatedOrder.vendor_name, updatedOrder.status, updatedOrder.total);
         Console.WriteLine("---------------Delete Order------------------");
         var deleteOrder = purchaseordersApi.Delete(updatedOrder.purchaseorder_id);
         Console.WriteLine(deleteOrder);
         Console.WriteLine("---------------Mark Order as open------------------");
         var markAsOpen = purchaseordersApi.MarkAsOpen(purchaseorders[0].purchaseorder_id);
         Console.WriteLine(markAsOpen);
         Console.WriteLine("---------------Mark Order as billed------------------");
         var markAsBilled = purchaseordersApi.MarkAsBilled(purchaseorders[0].purchaseorder_id);
         Console.WriteLine(markAsBilled);
         Console.WriteLine("---------------Cancel purchaseOrder ------------------");
         var cancelOrder = purchaseordersApi.CancelPurchaseorder(purchaseorders[0].purchaseorder_id);
         Console.WriteLine(cancelOrder);
         Console.WriteLine("---------------Email Purchase Order------------------");
         var emailDetails = new EmailNotification()
         {
             to_mail_ids = new List <string>()
             {
                 "*****@*****.**"
             },
             subject = "test-sub",
             body    = "test-body"
         };
         var emailOrder = purchaseordersApi.SendEmail(purchaseorders[1].purchaseorder_id, emailDetails, null);
         Console.WriteLine(emailOrder);
         Console.WriteLine("---------------Email content of Purchase Order------------------");
         var emailContent = purchaseordersApi.GetEmailContent(purchaseorders[1].purchaseorder_id, null);
         Console.WriteLine("Subject:{0},\n Body:{1}", emailContent.subject, emailContent.body);
         Console.WriteLine("---------------Update Billing Address------------------");
         var updateAddressInfo = new Address()
         {
             city  = "test-city",
             state = "test-state",
         };
         var updatedAddress = purchaseordersApi.UpdateBillingAddress(purchaseorders[1].purchaseorder_id, updateAddressInfo);
         Console.WriteLine("city:{0},state:{1}", updatedAddress.city, updatedAddress.state);
         Console.WriteLine("---------------List and update template------------------");
         var templates = purchaseordersApi.GetTemplates();
         foreach (var template in templates)
         {
             Console.WriteLine("name:{0},type:{1}", template.template_name, template.template_type);
         }
         var updateTemplate = purchaseordersApi.UpdateTemplate(purchaseorders[1].purchaseorder_id, templates[0].template_id);
         Console.WriteLine(updateTemplate);
         Console.WriteLine("-------------------Attachments----------------");
         var getAttachment = purchaseordersApi.GetAttachment(purchaseorders[0].purchaseorder_id, null);
         Console.WriteLine(getAttachment);
         var addAttachment = purchaseordersApi.AddAttachment(purchaseorders[2].purchaseorder_id, @"C:\Users\hari-2197\Desktop\h.jpg");
         Console.WriteLine(addAttachment);
         var attachPreferences = new Dictionary <object, object>();
         attachPreferences.Add("can_send_in_mail", true);
         var updateAttachPreference = purchaseordersApi.UpdateAttachmentPreference(purchaseorders[2].purchaseorder_id, attachPreferences);
         Console.WriteLine(updateAttachPreference);
         var deleteAttachment = purchaseordersApi.DeleteAnAttachment(purchaseorders[2].purchaseorder_id);
         Console.WriteLine(deleteAttachment);
         Console.WriteLine("--------------------------Comments -----------------------");
         var comments = purchaseordersApi.GetComments(purchaseorders[0].purchaseorder_id);
         foreach (var comment in comments)
         {
             Console.WriteLine("comment id:{0},description:{1},commented by:{2}", comment.comment_id, comment.description, comment.commented_by);
         }
         var newCommentInfo = new Comment()
         {
             description = "test comment",
         };
         var newComment = purchaseordersApi.AddComment(purchaseorders[0].purchaseorder_id, newCommentInfo);
         Console.WriteLine("comment id:{0},description:{1},commented by:{2}", newComment.comment_id, newComment.description, newComment.commented_by);
         var commentUpdateInfo = new Comment()
         {
             description = "updated for test",
         };
         var updatedComment = purchaseordersApi.UpdateComment(purchaseorders[0].purchaseorder_id, newComment.comment_id, commentUpdateInfo);
         Console.WriteLine("comment id:{0},description:{1},commented by:{2}", updatedComment.comment_id, updatedComment.description, updatedComment.commented_by);
         var deleteComment = purchaseordersApi.DeleteComment(purchaseorders[0].purchaseorder_id, updatedComment.comment_id);
         Console.WriteLine(deleteComment);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
     Console.ReadKey();
 }
 static void Main(string[] args)
 {
     try
     {
         var service = new ZohoBooks();
         service.initialize("{authtoken}", "{organization id}");
         var currenciesApi = service.GetSettingsApi();
         var parameters = new Dictionary<object, object>();
        parameters.Add("filter_by", "Currencies.ExcludeBaseCurrency");
         var currenciesList = currenciesApi.GetCurrencies(parameters);
         var currencies = currenciesList;
         var currencyId = currencies[0].currency_id;
         foreach (var currency in currencies)
             Console.WriteLine("Id:{0},\ncode:{1},\nname:{2},\nsymbol:{3}\nFormat:{4}\n", currency.currency_id, currency.currency_code, currency.currency_name, currency.currency_symbol, currency.currency_format);
         var currency1 = currenciesApi.GetACurrency(currencyId);
         Console.WriteLine("Id:{0},\ncode:{1},\nname:{2},\nsymbol:{3}\nFormat:{4}\n", currency1.currency_id, currency1.currency_code, currency1.currency_name, currency1.currency_symbol, currency1.currency_format);
         var newCurrencyInfo = new Currency()
         {
             currency_code = "JPY",
             currency_symbol = "%",
             currency_format = "1,234,567.89"
         };
         var newCurrency = currenciesApi.CreateCurrency(newCurrencyInfo);
         Console.WriteLine("Id:{0},\ncode:{1},\nname:{2},\nsymbol:{3}\nFormat:{4}\n", newCurrency.currency_id, newCurrency.currency_code, newCurrency.currency_name, newCurrency.currency_symbol, newCurrency.currency_format);
         var updateInfo = new Currency()
         {
             currency_symbol = "&"
         };
         var updatedCurrncy = currenciesApi.UpdateCurrency(newCurrency.currency_id, updateInfo);
         Console.WriteLine("Id:{0},\ncode:{1},\nname:{2},\nsymbol:{3}\nFormat:{4}\n", updatedCurrncy.currency_id, updatedCurrncy.currency_code, updatedCurrncy.currency_name, updatedCurrncy.currency_symbol, updatedCurrncy.currency_format);
         var deletemsg = currenciesApi.DeleteCurrency(updatedCurrncy.currency_id);
         Console.WriteLine(deletemsg);
         var ErParameters = new Dictionary<object, object>();
         var exchangeratesList = currenciesApi.GetExchangeRates("71917000000000097", ErParameters);
         var exchangerates = exchangeratesList;
         var exchangeRateId = exchangerates[0].exchange_rate_id;
         foreach (var exchangerate in exchangerates)
             Console.WriteLine("ExchangerateId:{0},\ncurrency Id:{1},Currency Code:{2},\nRate:{3}\n",exchangerate.exchange_rate_id,exchangerate.currency_id,exchangerate.currency_code,exchangerate.rate);
         var exchngerate = currenciesApi.GetAnExchangeRate("71917000000000097", exchangeRateId);
         Console.WriteLine("ExchangerateId:{0},\ncurrency Id:{1},\nCurrency Code:{2},\nRate:{3}\n", exchngerate.exchange_rate_id, exchngerate.currency_id, exchngerate.currency_code, exchngerate.rate);
         var newExchangerateInfo = new ExchangeRate()
         {
             effective_date="2014-05-14",
             rate=31,
         };
         var newExchangerate = currenciesApi.CreateAnExchangeRate("71917000000000097", newExchangerateInfo);
         Console.WriteLine("ExchangerateId:{0},\ncurrency Id:{1},\nCurrency Code:{2},\nRate:{3}\n", newExchangerate.exchange_rate_id, newExchangerate.currency_id, newExchangerate.currency_code, newExchangerate.rate);
         var updateinfo = new ExchangeRate()
         {
             rate = 40,
         };
         var updatedExchangerate = currenciesApi.UpdateAnExchangeRate("71917000000000097", newExchangerate.exchange_rate_id, updateinfo);
         Console.WriteLine("ExchangerateId:{0},\ncurrency Id:{1},\nCurrency Code:{2},\nRate:{3}\n", updatedExchangerate.exchange_rate_id, updatedExchangerate.currency_id, updatedExchangerate.currency_code, updatedExchangerate.rate);
         var deleteMsg = currenciesApi.DeleteAnExchangeRate("71917000000000097", updatedExchangerate.exchange_rate_id);
         Console.WriteLine(deleteMsg);
     }
     catch(Exception e)
     {
         Console.WriteLine(e.Message);
     }
     Console.ReadKey();
 }
        static void Main(string[] args)
        {
            try
            {
                var service = new ZohoBooks();
                service.initialize("{authtoken}", "{organizationId}");
                var rulesApi           = service.GetBankRulesApi();
                var parameters         = new Dictionary <object, object>();
                var accountsApi        = service.GetBankAccountsApi();
                var accounts           = accountsApi.GetBankAccounts(null);
                var chartOfAccountsApi = service.GetChartOfAccountsApi();
                var chartOfAccounts    = chartOfAccountsApi.GetChartOfAcounts(null);
                parameters.Add("account_id", accounts[1].account_id);
                Console.WriteLine("--------------------------Rules List---------------");
                var rules = rulesApi.GetRules(parameters);
                foreach (var tempRule in rules)
                {
                    Console.WriteLine("{0},{1},{2}", tempRule.rule_id, tempRule.rule_name, tempRule.account_name);
                    var tempCriterions = tempRule.criterion;
                    Console.WriteLine("criterions");
                    foreach (var tempCriterion in tempCriterions)
                    {
                        Console.WriteLine("{0},{1}", tempCriterion.criteria_id, tempCriterion.value);
                    }
                }
                Console.WriteLine("--------------------------------------Specified Rule ----------------------------");
                var rule = rulesApi.Get(rules[0].rule_id);
                Console.WriteLine("{0},{1},{2}", rule.rule_id, rule.rule_name, rule.account_name);

                var ruleInfo = new Rule()
                {
                    rule_name         = "hari",
                    target_account_id = accounts[0].account_id,
                    apply_to          = "withdrawals",
                    criteria_type     = "or",
                    criterion         = new List <Criterion>()
                    {
                        new Criterion()
                        {
                            field      = "payee",
                            comparator = "contains",
                            value      = "9"
                        }
                    },
                    record_as  = "expense",
                    account_id = chartOfAccounts[41].account_id
                };
                Console.WriteLine("----------------------------New Rule-----------------------");
                var newRule = rulesApi.Create(ruleInfo);
                Console.WriteLine("{0},{1},{2}", newRule.rule_id, newRule.rule_name, newRule.account_name);
                var newcriterions = newRule.criterion;
                Console.WriteLine("criterions");
                foreach (var criterion in newcriterions)
                {
                    Console.WriteLine("{0},{1}", criterion.criteria_id, criterion.value);
                }
                var updateInfo = new Rule()
                {
                    rule_name     = "krishna",
                    apply_to      = "withdrawals",
                    criteria_type = "or",
                    criterion     = new List <Criterion>()
                    {
                        new Criterion()
                        {
                            field      = "payee",
                            comparator = "contains",
                            value      = "8"
                        }
                    },
                    record_as = "expense",
                };
                Console.WriteLine("----------------------------Updated Rule----------------------");
                var updatedRule = rulesApi.Update(newRule.rule_id, updateInfo);
                Console.WriteLine("{0},{1},{2}", updatedRule.rule_id, updatedRule.rule_name, updatedRule.account_name);
                var criterions1 = updatedRule.criterion;
                Console.WriteLine("criterions");
                foreach (var criterion in criterions1)
                {
                    Console.WriteLine("{0},{1}", criterion.criteria_id, criterion.value);
                }
                Console.WriteLine("-------------------------------Delete Rule--------------------------------------");
                var delRule = rulesApi.Delete(updatedRule.rule_id);
                Console.WriteLine(delRule);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            try
            {
                var service = new ZohoBooks();
                service.initialize("{authtoken}", "{organizationId}");
                var transactionApi = service.GetBankTransactionsApi();
                var accounts = service.GetBankAccountsApi().GetBankAccounts(null);
                var parameters = new Dictionary<object, object>();
                 parameters.Add("filter_by", "Status.All");
                 parameters.Add("account_id", accounts[0].account_id);
                 Console.WriteLine("---------------------- All Transactions ----------------------");
                 var transactionList = transactionApi.GetTransactions(parameters);
                 var transactions = transactionList;
                 foreach (var trans in transactions)
                     Console.WriteLine("{0},{1},{2}", trans.transaction_id, trans.status, trans.amount);

                Console.WriteLine("---------------------- Specified Transaction ----------------------");
                var transaction = transactionApi.Get(transactions[2].transaction_id);
                 Console.WriteLine("{0},{1},{2}", transaction.transaction_id, transaction.transaction_type, transaction.amount);

                 Console.WriteLine("---------------------- New Transaction ----------------------");
                 var newTransactionInfo = new Transaction()
                 {
                     transaction_type = "transfer_fund",
                     from_account_id = accounts[0].account_id,
                     to_account_id = accounts[2].account_id,
                     amount=10
                 };
                 var newTransaction = transactionApi.Create(newTransactionInfo);
                 Console.WriteLine("{0},{1},{2}", newTransaction.transaction_id, newTransaction.transaction_type, newTransaction.amount);

                 Console.WriteLine("---------------------- Updated Transaction ----------------------");
                 var updateInfo = new Transaction()
                  {
                         amount=50,
                         currency_id=transactionList[0].currency_id,
                         date="2014-02-06",
                         description="",
                         exchange_rate=1,
                         from_account_id = accounts[0].account_id,
                         reference_number= "",
                         to_account_id = accounts[2].account_id,
                         transaction_type = "transfer_fund"
                 };
                 var updatedTrans = transactionApi.Update(newTransaction.transaction_id, updateInfo);
                 Console.WriteLine("{0},{1},{2}", updatedTrans.transaction_id, updatedTrans.transaction_type, updatedTrans.amount);

                 Console.WriteLine("---------------------- Delete Transaction ----------------------");
                 var deltrans = transactionApi.Delete(updatedTrans.transaction_id);
                 Console.WriteLine(deltrans);
                var parameters1 = new Dictionary<object, object>();
                 parameters1.Add("amount_start", "1");
                 parameters1.Add("amount_end", "4000");
                 parameters1.Add("date_start", "2014-02-01");
                 parameters1.Add("date_end", "2014-02-07");

                 var matchingtrans = transactionApi.GetMatchingTransactions(transactions[1].transaction_id, parameters1);

                 foreach(var matchingTran in matchingtrans)
                     Console.WriteLine("{0},{1},{2}", matchingTran.transaction_id, matchingTran.transaction_type, matchingTran.amount);
                var parameters3=new Dictionary<object,object>();
                 parameters3.Add("account_id", accounts[1].account_id);
                 TransactionsToBeMatched transtomatch = new TransactionsToBeMatched()
                 {
                     transactions_to_be_matched = new List<Transaction>(){
                         new Transaction()
                         {
                             transaction_id=transactions[2].transaction_id,
                             transaction_type="vendor_payment"
                         },
                         new Transaction()
                         {
                             transaction_id=transactions[3].transaction_id,
                             transaction_type="transfer_fund"
                         },
                         new Transaction()
                         {
                             transaction_id=transactions[1].transaction_id,
                             transaction_type="expense"
                         }
                     }
                 };
                 var matchtransaction = transactionApi.MatchATransaction(transactions[0].transaction_id, transtomatch);
                 Console.WriteLine(matchtransaction);
                 var unmatch = transactionApi.UnmatchTransaction(transactions[0].transaction_id);
                 Console.WriteLine(unmatch);
                 parameters.Add("sort_column", "statement_date");
                 var associatedTransObj = transactionApi.GetAssociatedTransactions(transactions[0].transaction_id, null);
                 var associatedTrans = associatedTransObj.associated_transactions;
                 Console.WriteLine(associatedTransObj.imported_transaction_id);
                 foreach (var asociatedTran in associatedTrans)
                     Console.WriteLine("{0},{1},{2}", asociatedTran.transaction_id, asociatedTran.transaction_type, asociatedTran.amount);
                 var exclude = transactionApi.ExcludeATransaction(transactions[0].transaction_id);
                 Console.WriteLine(exclude);
                 var restore = transactionApi.RestoreATransaction(transactions[0].transaction_id);
                 Console.WriteLine(restore);
                 var transacInfo=new Transaction()
                 {
                         amount=4000,
                         date="2013-01-29",
                         description="Insurance payment",
                         exchange_rate=1,
                         from_account_id = accounts[1].account_id,
                         reference_number="Ref-9872",
                         to_account_id = accounts[3].account_id,
                         transaction_type = "expense"
                 };
                 var catogarise = transactionApi.CategorizeAnUncategorizedTransaction(transactions[0].transaction_id, transacInfo);
                 Console.WriteLine(catogarise);
                 var creditrefundInfo = new CreditNote()
                 {
                     creditnote_id = "{credit note id}",
                     date="2014-02-07",
                     from_account_id = "{account id from which account the transaction is going to be done}",
                     amount=4000
                 };
                 var catogasCred = transactionApi.CategorizeAsCreditNoteRefunds(transactions[0].transaction_id, creditrefundInfo);
                 Console.WriteLine(catogasCred);
                 var vendordetails = new VendorPayment()
                 {
                     vendor_id = "{vendor id}",
                     amount=4000,
                     paid_through_account_id = "{account id}"
                 };
                 var vendorcat = transactionApi.CategorizeAsVendorpayment(transactions[0].transaction_id, vendordetails);
                 Console.WriteLine(vendorcat);
                 var customerinfo = new CustomerPayment()
                 {
                     customer_id = "{customer id}",
                     date="2014-02-08",
                     invoices = new List<Invoice>()
                     {
                         new Invoice(){
                             invoice_id="{invoice id}",
                             amount_applied=4000
                            }
                     },
                     amount=4000
                 };
                 var custpaycat = transactionApi.CategorizeAsCustomerPayments(transactions[0].transaction_id, customerinfo, parameters);
                 Console.WriteLine(custpaycat);
                 var expenseInfo=new Expense()
                 {
                     account_id=accounts[3].account_id,
                     date="2013-01-29",
                     paid_through_account_id = accounts[4].account_id,
                     project_id= "",
                     amount=4000,
                     tax_id="",
                     is_inclusive_tax=false,
                     is_billable=false,
                     reference_number="Ref-123",
                     description="Insurance payment",
                 };
                 var catAsExpens = transactionApi.CategorizeAsExpense(transactions[0].transaction_id, expenseInfo, @"F:\error.png");
                 Console.WriteLine(catAsExpens);
                 var uncatogorise = transactionApi.UncategorizeACategorizedTransaction(transactions[0].transaction_id);
                 Console.WriteLine(uncatogorise);
                 var vendorCreditsApi = service.GetVendorCreditsApi();
                 var vendorCredits = vendorCreditsApi.GetVendorCredits(null);
                 var refundInfo = new VendorCreditRefund()
                 {
                     vendor_credit_id=vendorCredits[0].vendor_credit_id,
                     date="2014-11-25",

                 };
                 var catAsVendorRefund = transactionApi.CategorizeAsVendorCreditRefund(transactions[0].transaction_id, refundInfo);
                 Console.WriteLine(catAsVendorRefund);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
Exemple #44
0
        static void Main(string[] args)
        {
            try
            {
                var service = new ZohoBooks();
                service.initialize("{authtoken}", "{organisation id}");
                EstimatesApi estimateApi   = service.GetEstimatesApi();
                var          parameters    = new Dictionary <object, object>();
                var          estimatesList = estimateApi.GetEstimates(parameters);
                var          estimates     = estimatesList;
                var          estimateId    = estimates[0].estimate_id;
                var          customerId    = estimates[0].customer_id;
                var          contactPersns = estimates[0].contact_persons;
                if (estimates != null)
                {
                    foreach (var estimate in estimates)
                    {
                        Console.WriteLine("{0},{1},{2}", estimate.estimate_id, estimate.customer_name, estimate.estimate_number);
                    }
                }
                var parameters1 = new Dictionary <object, object>();
                parameters1.Add("send", true);
                var newEstmt = new Estimate()
                {
                    customer_id            = customerId,
                    template_id            = "{template id}",
                    reference_number       = "QRT-",
                    date                   = "2014-03-10",
                    expiry_date            = "2014-03-24",
                    exchange_rate          = 1.0,
                    discount               = 0.0,
                    is_discount_before_tax = true,
                    discount_type          = "item_level",
                    salesperson_name       = "John Michael",
                    line_items             = new List <LineItem>()
                    {
                        new LineItem()
                        {
                            name        = "Premium Plan - Web hosting",
                            description = "10 GB Space, 300 GB Transfer 100 Email Accounts 10 MySQL Databases",
                            rate        = 2500,
                            item_order  = 0,
                            quantity    = 1.0,
                            discount    = "0.0",
                        },
                    },
                    notes                  = "Looking forward for your business.",
                    terms                  = "Terms and conditions apply.",
                    shipping_charge        = 0.0,
                    adjustment             = 0.0,
                    adjustment_description = "Adjustment"
                };
                var newEstimate = estimateApi.Create(newEstmt, parameters1);
                if (newEstimate != null)
                {
                    Console.WriteLine("The new Estimate is created with the api call for the amount {0} which is having the following properties\n", newEstimate.total);
                    Console.WriteLine("Estimate Id:{0}\n,Estimate number:{1},\n status:{2},\n", newEstimate.estimate_id, newEstimate.estimate_number, newEstimate.status);
                    var billto = newEstimate.billing_address;
                    Console.WriteLine("To:{0},{1},{2},{3},{4}", newEstimate.customer_name, billto.address, billto.city, billto.country, billto.zip);
                    var items = newEstimate.line_items;
                    Console.WriteLine("\n Items details:\n");
                    foreach (var item in items)
                    {
                        Console.WriteLine("\n name: {0},\nCost: {1},\n Quantity :{2}", item.name, item.rate, item.quantity);
                    }
                }
                var parameters2 = new Dictionary <object, object>();
                var updateInfo  = new Estimate()
                {
                    reference_number = "2197",
                };
                var updatedEst = estimateApi.Update(estimateId, updateInfo, parameters2);
                if (updatedEst != null)
                {
                    Console.WriteLine("{0},{1},{2}", updatedEst.estimate_number, updatedEst.reference_number, updatedEst.exchange_rate);
                }
                var delmsg = estimateApi.Delete(estimates[2].estimate_id);
                Console.WriteLine(delmsg);
                var status = estimateApi.MarkAsSent(estimateId);
                Console.WriteLine(status);
                var status1 = estimateApi.MarkAsAccepted(estimateId);
                Console.WriteLine(status);
                var status2 = estimateApi.MarkAsDeclined(estimateId);
                Console.WriteLine(status);
                var emailDetails = new EmailNotification()
                {
                    to_mail_ids = new List <string>()
                    {
                        "*****@*****.**",
                    },
                    subject = "estimate email",
                    body    = "est"
                };
                var emailEst = estimateApi.SendEmail(estimateId, emailDetails, new string[] { @"F:\error.png", @"F:\error.png" });
                Console.WriteLine(emailEst);
                var estIds = new Dictionary <object, object>();
                estIds.Add("estimate_ids", estimates[1].estimate_id + "," + estimates[2]);
                var emailests = estimateApi.EmailEstimates(estIds);
                Console.WriteLine(emailests);
                var emailContent = estimateApi.GetEmailContent(estimateId, null);
                Console.WriteLine("{0},{1},{2}", emailContent.body, emailContent.file_name, emailContent.subject);
                var export = estimateApi.BulkExport(estIds);
                Console.WriteLine(export);
                var print = estimateApi.BulkPrint(estIds);
                Console.WriteLine(print);
                var updateinfo3 = new Address()
                {
                    address = "31",
                    city    = "chennai"
                };
                var update = estimateApi.UpdateBillingAddress(estimateId, updateinfo3);
                Console.WriteLine(update);
                var updateinfo2 = new Address()
                {
                    state = "TamilNadu"
                };
                var shipaddrUpdate = estimateApi.UpdateShippingAddress(estimateId, updateinfo2);
                Console.WriteLine(shipaddrUpdate);
                var estTemplatesList = estimateApi.GetTemplates();
                var templates        = estTemplatesList;
                foreach (var estTemplate in templates)
                {
                    Console.WriteLine("{0},{1},{2}", estTemplate.template_id, estTemplate.template_name, estTemplate.template_type);
                }

                var updateTemplate = estimateApi.UpdateTemplate(estimateId, templates[1].template_id);
                Console.WriteLine(updateTemplate);
                var commentsList = estimateApi.GetComments(estimateId);
                var comments     = commentsList;
                foreach (var comment in comments)
                {
                    Console.WriteLine("{0},{1},{2}", comment.comment_id, comment.description, comment.commented_by);
                }
                var newCommentInfo = new Comment()
                {
                    description = "added manually"
                };
                var newComment = estimateApi.AddComment(estimateId, newCommentInfo);
                Console.WriteLine(newComment);
                var updateInfo1 = new Comment()
                {
                    description = "edited comment"
                };
                var updated = estimateApi.UpdateComment(estimateId, comments[2].comment_id, updateInfo1);
                Console.WriteLine("{0},{1},{2}", updated.comment_id, updated.description, updated.commented_by);
                var deleteMsg = estimateApi.DeleteComment(estimateId, comments[4].comment_id);
                Console.WriteLine(deleteMsg);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
        static void Main(string[] args)
        {
            try
            {
                var service = new ZohoBooks();
                service.initialize("{authtoken}", "{organizationId}");
                var chartofAccountApi = service.GetChartOfAccountsApi();
                var parameters        = new Dictionary <object, object>();
                parameters.Add("sort_column", "account_name");
                Console.WriteLine("----------------------------List of Accounts-----------------");
                var chartofaccountsList = chartofAccountApi.GetChartOfAcounts(parameters);
                var accounts            = chartofaccountsList;
                foreach (var account in accounts)
                {
                    Console.WriteLine("{0},{1},{2}", account.account_id, account.account_name, account.account_type);
                }
                Console.WriteLine("----------------------------Specified Chart of Account-----------------");
                var account1 = chartofAccountApi.Get(accounts[0].account_id);
                Console.WriteLine("{0},{1},{2}", account1.account_id, account1.account_name, account1.account_type);
                var newAccountInfo = new ChartOfAccount()
                {
                    account_name = "account name",
                    account_type = "cost_of_goods_sold"
                };
                Console.WriteLine("----------------------------New Account-----------------");
                var newAccount = chartofAccountApi.Create(newAccountInfo);
                Console.WriteLine("{0},{1},{2}", newAccount.account_id, newAccount.account_name, newAccount.account_type);
                var updateInfo = new ChartOfAccount()
                {
                    account_name = "hari-test",
                };
                Console.WriteLine("----------------------------Updated Account-----------------");
                var updatedAccount = chartofAccountApi.Update(newAccount.account_id, updateInfo);
                Console.WriteLine("{0},{1},{2}", updatedAccount.account_id, updatedAccount.account_name, updatedAccount.account_type);
                Console.WriteLine("----------------------------Delete Account-----------------");
                var delInfo = chartofAccountApi.Delete(updatedAccount.account_id);
                Console.WriteLine(delInfo);
                Console.WriteLine("----------------------------Mark Account as active/inactive-----------------");
                var markasinactive = chartofAccountApi.MarkAsInactive(accounts[16].account_id);
                Console.WriteLine(markasinactive);
                var markasactive = chartofAccountApi.MarkAsActive(accounts[16].account_id);
                Console.WriteLine(markasactive);
                var parameters1 = new Dictionary <object, object>();
                parameters1.Add("account_id", accounts[0].account_id);
                parameters1.Add("date.start", "2014-02-06");
                parameters1.Add("date.end", "2014-02-08");
                parameters1.Add("amount.less_than", 100);
                Console.WriteLine("----------------------------Transactions of Account-----------------");
                var transactionsList = chartofAccountApi.GetTransactions(parameters1);
                var trans            = transactionsList;
                foreach (var tran in trans)
                {
                    Console.WriteLine("{0},{1},{2}", tran.transaction_id, tran.payee, tran.payment_mode);
                }
                Console.WriteLine("----------------------------Delete Transaction of Account-----------------");
                var deltran = chartofAccountApi.DeleteATransaction(trans[0].transaction_id);
                Console.WriteLine(deltran);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }

            Console.ReadKey();
        }
 static void Main(string[] args)
 {
     try
     {
         var service = new ZohoBooks();
         service.initialize("{authtoken}", "{organization id}");
         var purchaseordersApi = service.GetPurchaseordersApi();
         Console.WriteLine("------------------------All Orders-----------");
         var purchaseorders = purchaseordersApi.GetPurchaseorders(null);
         foreach (var tempOrder in purchaseorders)
             Console.WriteLine("order id:{0},vendor name:{1},status:{2}",tempOrder.purchaseorder_id,tempOrder.vendor_name,tempOrder.status);
         Console.WriteLine("-------------Specified order-------------------");
         var purchaseorder = purchaseordersApi.Get(purchaseorders[0].purchaseorder_id,null);
         Console.WriteLine("order id:{0},vendor name:{1},status:{2}", purchaseorder.purchaseorder_id, purchaseorder.vendor_name, purchaseorder.status);
         Console.WriteLine("line items");
         var lineitems = purchaseorder.line_items;
         foreach (var tempitem in lineitems)
             Console.WriteLine("item id:{0},description:{1},rate:{2}",tempitem.item_id,tempitem.description,tempitem.rate);
         Console.WriteLine("-------------New Purchaseorder--------------------");
         var newOrderInfo = new Purchaseorder()
         {
             vendor_id=purchaseorder.vendor_id,
             line_items=new List<LineItem>()
             {
                 new LineItem(){
                     item_id=lineitems[0].item_id,
                     rate=250,
             },
             }
         };
         var newPurchaseOrder = purchaseordersApi.Create(newOrderInfo, null, @"C:\Users\hari-2197\Desktop\h.jpg");
         Console.WriteLine("order id:{0},vendor name:{1},status:{2},total:{3}", newPurchaseOrder.purchaseorder_id, newPurchaseOrder.vendor_name, newPurchaseOrder.status,newPurchaseOrder.total);
         Console.WriteLine("line items");
         var newOredrlineitems = newPurchaseOrder.line_items;
         foreach (var tempitem in newOredrlineitems)
             Console.WriteLine("item id:{0},description:{1},rate:{2}", tempitem.item_id, tempitem.description, tempitem.rate);
         Console.WriteLine("--------------------update order--------------");
         var updateInfo = new Purchaseorder()
         {
             line_items=new List<LineItem>()
             {
                 new LineItem(){
                     item_id=lineitems[0].item_id,
                     rate=300,
                 },
             }
         };
         var updatedOrder = purchaseordersApi.Update(newPurchaseOrder.purchaseorder_id, updateInfo, null,null);
         Console.WriteLine("order id:{0},vendor name:{1},status:{2},total:{3}", updatedOrder.purchaseorder_id, updatedOrder.vendor_name, updatedOrder.status, updatedOrder.total);
         Console.WriteLine("---------------Delete Order------------------");
         var deleteOrder = purchaseordersApi.Delete(updatedOrder.purchaseorder_id);
         Console.WriteLine(deleteOrder);
         Console.WriteLine("---------------Mark Order as open------------------");
         var markAsOpen = purchaseordersApi.MarkAsOpen(purchaseorders[0].purchaseorder_id);
         Console.WriteLine(markAsOpen);
         Console.WriteLine("---------------Mark Order as billed------------------");
         var markAsBilled = purchaseordersApi.MarkAsBilled(purchaseorders[0].purchaseorder_id);
         Console.WriteLine(markAsBilled);
         Console.WriteLine("---------------Cancel purchaseOrder ------------------");
         var cancelOrder = purchaseordersApi.CancelPurchaseorder(purchaseorders[0].purchaseorder_id);
         Console.WriteLine(cancelOrder);
         Console.WriteLine("---------------Email Purchase Order------------------");
         var emailDetails = new EmailNotification()
         {
             to_mail_ids = new List<string>() { "*****@*****.**"},
             subject="test-sub",
             body="test-body"
         };
         var emailOrder = purchaseordersApi.SendEmail(purchaseorders[1].purchaseorder_id, emailDetails, null);
         Console.WriteLine(emailOrder);
         Console.WriteLine("---------------Email content of Purchase Order------------------");
         var emailContent = purchaseordersApi.GetEmailContent(purchaseorders[1].purchaseorder_id, null);
         Console.WriteLine("Subject:{0},\n Body:{1}", emailContent.subject, emailContent.body);
         Console.WriteLine("---------------Update Billing Address------------------");
         var updateAddressInfo = new Address()
         {
             city="test-city",
             state="test-state",
         };
         var updatedAddress = purchaseordersApi.UpdateBillingAddress(purchaseorders[1].purchaseorder_id, updateAddressInfo);
         Console.WriteLine("city:{0},state:{1}",updatedAddress.city,updatedAddress.state);
         Console.WriteLine("---------------List and update template------------------");
         var templates = purchaseordersApi.GetTemplates();
         foreach (var template in templates)
             Console.WriteLine("name:{0},type:{1}", template.template_name, template.template_type);
         var updateTemplate = purchaseordersApi.UpdateTemplate(purchaseorders[1].purchaseorder_id, templates[0].template_id);
         Console.WriteLine(updateTemplate);
         Console.WriteLine("-------------------Attachments----------------");
         var getAttachment = purchaseordersApi.GetAttachment(purchaseorders[0].purchaseorder_id, null);
         Console.WriteLine(getAttachment);
         var addAttachment = purchaseordersApi.AddAttachment(purchaseorders[2].purchaseorder_id, @"C:\Users\hari-2197\Desktop\h.jpg");
         Console.WriteLine(addAttachment);
         var attachPreferences=new Dictionary<object,object>();
         attachPreferences.Add("can_send_in_mail",true);
         var updateAttachPreference=purchaseordersApi.UpdateAttachmentPreference(purchaseorders[2].purchaseorder_id,attachPreferences);
         Console.WriteLine(updateAttachPreference);
         var deleteAttachment = purchaseordersApi.DeleteAnAttachment(purchaseorders[2].purchaseorder_id);
         Console.WriteLine(deleteAttachment);
         Console.WriteLine("--------------------------Comments -----------------------");
         var comments = purchaseordersApi.GetComments(purchaseorders[0].purchaseorder_id);
         foreach (var comment in comments)
             Console.WriteLine("comment id:{0},description:{1},commented by:{2}", comment.comment_id, comment.description, comment.commented_by);
         var newCommentInfo = new Comment()
         {
             description="test comment",
         };
         var newComment = purchaseordersApi.AddComment(purchaseorders[0].purchaseorder_id, newCommentInfo);
         Console.WriteLine("comment id:{0},description:{1},commented by:{2}", newComment.comment_id, newComment.description, newComment.commented_by);
         var commentUpdateInfo = new Comment()
         {
             description="updated for test",
         };
         var updatedComment = purchaseordersApi.UpdateComment(purchaseorders[0].purchaseorder_id, newComment.comment_id, commentUpdateInfo);
         Console.WriteLine("comment id:{0},description:{1},commented by:{2}", updatedComment.comment_id, updatedComment.description, updatedComment.commented_by);
         var deleteComment = purchaseordersApi.DeleteComment(purchaseorders[0].purchaseorder_id, updatedComment.comment_id);
         Console.WriteLine(deleteComment);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
     Console.ReadKey();
 }
        static void Main(string[] args)
        {
            try
            {
                var service = new ZohoBooks();
                service.initialize("{authtoken}", "{organization id}");
                var journalsApi = service.GetJournalsApi();
                var parameters = new Dictionary<object, object>();
                parameters.Add("filter_by", "JournalDate.All");
                Console.WriteLine("---------------Journals List--------------------");
                var journalsList = journalsApi.GetJournals(parameters);
                var journals = journalsList;

                foreach(var journal in journals)
                {
                    Console.WriteLine("{0},{1},{2}",journal.journal_id,journal.notes,journal.total);
                }
                var journalId = journals[0].journal_id;
                var accountsApi = service.GetChartOfAccountsApi();
                var accountId = accountsApi.GetChartOfAcounts(null)[0].account_id;
                Console.WriteLine("---------------Specified Journal--------------------");
                var journal1 = journalsApi.Get(journalId);
                Console.WriteLine("{0},{1},{2}", journal1.journal_id, journal1.notes, journal1.total);
                var lineitems = journal1.line_items;
                foreach(var lineitem in lineitems)
                {
                    Console.WriteLine("{0},{1},{2}",lineitem.account_id,lineitem.amount,lineitem.line_id);
                }
                var newJournalInfo = new Journal()
                {
                    journal_date="2014-02-10",
                    line_items = new List<LineItem>()
                    {
                        new LineItem(){
                            account_id=accountId,
                            debit_or_credit="credit",
                            amount=150
                        },
                        new LineItem(){
                            account_id=accountId,
                            debit_or_credit="debit",
                            amount=150
                        }
                    }
                };

                Console.WriteLine("---------------New Journal--------------------");
                var newJournal = journalsApi.Create(newJournalInfo);
                Console.WriteLine("{0},{1},{2}", newJournal.journal_id, newJournal.notes, newJournal.total);
                var lineitems1 = newJournal.line_items;
                foreach (var lineitem in lineitems1)
                {
                    Console.WriteLine("{0},{1},{2}", lineitem.account_id, lineitem.amount, lineitem.line_id);
                }
                var updateInfo = new Journal()
                {
                    journal_date = "2014-11-10",
                    line_items = new List<LineItem>()
                    {
                        new LineItem(){
                            account_id=accountId,
                            debit_or_credit="debit",
                            amount=130
                        },
                        new LineItem(){
                            account_id=accountId,
                            debit_or_credit="credit",
                            amount=130
                        }
                    },
                   notes="hari"
                };
                Console.WriteLine("---------------Updated Journal--------------------");
                var updatedJournal = journalsApi.Update(newJournal.journal_id, updateInfo);
                Console.WriteLine("{0},{1},{2}", updatedJournal.journal_id, updatedJournal.notes, updatedJournal.total);
                Console.WriteLine("---------------Delete Journal--------------------");
                var deljournal = journalsApi.Delete(updatedJournal.journal_id);
                Console.WriteLine(deljournal);
            }
            catch(Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
 static void Main(string[] args)
 {
     try
     {
         var service = new ZohoBooks();
         service.initialize("{authtoken}", "{organization id}");
         var organizationApi   = service.GetOrganizationsApi();
         var organizationsList = organizationApi.GetOrganizations();
         var organizations     = organizationsList;
         var organizationId    = organizations[0].organization_id;
         foreach (var organization in organizations)
         {
             Console.WriteLine("Organization Id:{0},\n name:{1},\n contact name:{2},\n email:{3}", organization.organization_id, organization.name, organization.contact_name, organization.email);
         }
         var organization1 = organizationApi.Get(organizationId);
         Console.WriteLine("Organization Id:{0},\n name:{1},\n contact name:{2},\n email:{3}\n addr:{4}\n", organization1.organization_id, organization1.name, organization1.contact_name, organization1.email, organization1.org_address);
         var addr = organization1.address;
         Console.WriteLine("Address:{0},{1},{2}", addr.city, addr.state, addr.country);
         var newOrganizationInfo = new Organization()
         {
             name          = "org3",
             currency_code = "INR",
             time_zone     = "IST",
             address       = new Address()
             {
                 country = "India"
             }
         };
         var newOrganization = organizationApi.Create(newOrganizationInfo);
         Console.WriteLine("Organization Id:{0},\n name:{1},\n contact name:{2},\n email:{3}", newOrganization.organization_id, newOrganization.name, newOrganization.contact_name, newOrganization.email);
         var updateInfo = new Organization()
         {
             name    = "Org2",
             address = new Address()
             {
                 city    = "city",
                 state   = "state",
                 country = "India"
             },
         };
         var updatedOrg = organizationApi.Upadte(organizationId, updateInfo);
         Console.WriteLine("Organization Id:{0},\n name:{1},\n contact name:{2},\n email:{3}\n addr:{4}\n", updatedOrg.organization_id, updatedOrg.name, updatedOrg.contact_name, updatedOrg.email, updatedOrg.org_address);
         var address = updatedOrg.address;
         Console.WriteLine("Address:{0},{1},{2}", address.city, address.state, address.country);
         var new_address_info = new Address()
         {
             attention = "hari",
         };
         var newAddress       = organizationApi.AddOrganizationAddress(new_address_info);
         var update_addr_info = new Address()
         {
             attention = "krishna"
         };
         var updatedAddress = organizationApi.UpdateOrganizationAddress(newAddress.organization_address_id, update_addr_info);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
     Console.ReadKey();
 }
        static void Main(string[] args)
        {
            try
            {
                var service = new ZohoBooks();
                service.initialize("{authtoken}", "{organization id}");
                var journalsApi = service.GetJournalsApi();
                var parameters  = new Dictionary <object, object>();
                parameters.Add("filter_by", "JournalDate.All");
                Console.WriteLine("---------------Journals List--------------------");
                var journalsList = journalsApi.GetJournals(parameters);
                var journals     = journalsList;

                foreach (var journal in journals)
                {
                    Console.WriteLine("{0},{1},{2}", journal.journal_id, journal.notes, journal.total);
                }
                var journalId   = journals[0].journal_id;
                var accountsApi = service.GetChartOfAccountsApi();
                var accountId   = accountsApi.GetChartOfAcounts(null)[0].account_id;
                Console.WriteLine("---------------Specified Journal--------------------");
                var journal1 = journalsApi.Get(journalId);
                Console.WriteLine("{0},{1},{2}", journal1.journal_id, journal1.notes, journal1.total);
                var lineitems = journal1.line_items;
                foreach (var lineitem in lineitems)
                {
                    Console.WriteLine("{0},{1},{2}", lineitem.account_id, lineitem.amount, lineitem.line_id);
                }
                var newJournalInfo = new Journal()
                {
                    journal_date = "2014-02-10",
                    line_items   = new List <LineItem>()
                    {
                        new LineItem()
                        {
                            account_id      = accountId,
                            debit_or_credit = "credit",
                            amount          = 150
                        },
                        new LineItem()
                        {
                            account_id      = accountId,
                            debit_or_credit = "debit",
                            amount          = 150
                        }
                    }
                };

                Console.WriteLine("---------------New Journal--------------------");
                var newJournal = journalsApi.Create(newJournalInfo);
                Console.WriteLine("{0},{1},{2}", newJournal.journal_id, newJournal.notes, newJournal.total);
                var lineitems1 = newJournal.line_items;
                foreach (var lineitem in lineitems1)
                {
                    Console.WriteLine("{0},{1},{2}", lineitem.account_id, lineitem.amount, lineitem.line_id);
                }
                var updateInfo = new Journal()
                {
                    journal_date = "2014-11-10",
                    line_items   = new List <LineItem>()
                    {
                        new LineItem()
                        {
                            account_id      = accountId,
                            debit_or_credit = "debit",
                            amount          = 130
                        },
                        new LineItem()
                        {
                            account_id      = accountId,
                            debit_or_credit = "credit",
                            amount          = 130
                        }
                    },
                    notes = "hari"
                };
                Console.WriteLine("---------------Updated Journal--------------------");
                var updatedJournal = journalsApi.Update(newJournal.journal_id, updateInfo);
                Console.WriteLine("{0},{1},{2}", updatedJournal.journal_id, updatedJournal.notes, updatedJournal.total);
                Console.WriteLine("---------------Delete Journal--------------------");
                var deljournal = journalsApi.Delete(updatedJournal.journal_id);
                Console.WriteLine(deljournal);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadKey();
        }
Exemple #50
0
 static void Main(string[] args)
 {
     try
     {
         var service = new ZohoBooks();
         service.initialize("{authtoken}", "{organizationId}");
         var baseCurrencyAdjustmentApi = service.GetBaseCurrencyAdjustmentsApi();
         var parameters = new Dictionary <object, object>();
         parameters.Add("filter_by", "Date.All");
         var baseCurrencyAdjustmentsList = baseCurrencyAdjustmentApi.GetBaseCurrencyAdjustments(parameters);
         var adjustments = baseCurrencyAdjustmentsList;
         Console.WriteLine("------------------Adjustment List---------------------");
         foreach (var adjustment in adjustments)
         {
             Console.WriteLine("{0},{1},{2}", adjustment.base_currency_adjustment_id, adjustment.currency_code, adjustment.exchange_rate);
         }
         var baseAdjust = baseCurrencyAdjustmentApi.Get(adjustments[0].base_currency_adjustment_id);
         Console.WriteLine("----------------specific Adjustment----------------");
         Console.WriteLine("{0},{1},{2}", baseAdjust.base_currency_adjustment_id, baseAdjust.currency_code, baseAdjust.exchange_rate);
         var accounts = baseAdjust.accounts;
         foreach (var account in accounts)
         {
             Console.WriteLine("{0},{1},{2}", account.account_name, account.adjusted_balance, account.gain_or_loss_formatted);
         }
         var parameters1 = new Dictionary <object, object>();
         parameters1.Add("currency_id", adjustments[0].currency_id);
         parameters1.Add("adjustment_date", adjustments[0].adjustment_date);
         parameters1.Add("exchange_rate", adjustments[0].exchange_rate);
         parameters1.Add("notes", adjustments[0].notes);
         var baseAdjust1 = baseCurrencyAdjustmentApi.GetBaseCurrencyAdjustmentAccounts(parameters1);
         Console.WriteLine("----------------specific Adjustment accounts----------------");
         Console.WriteLine("{0},{1},{2}", baseAdjust.base_currency_adjustment_id, baseAdjust.currency_code, baseAdjust.exchange_rate);
         var accounts1 = baseAdjust.accounts;
         foreach (var account in accounts1)
         {
             Console.WriteLine("{0},{1},{2}", account.account_name, account.adjusted_balance, account.gain_or_loss_formatted);
         }
         var parameters2 = new Dictionary <object, object>();
         parameters2.Add("account_ids", accounts1[0].account_id);
         var newAdjustInfo = new BaseCurrencyAdjustment()
         {
             currency_id     = baseAdjust1.currency_id,
             adjustment_date = "2014-11-14",
             exchange_rate   = 35,
             notes           = "notes",
         };
         var newAdjust = baseCurrencyAdjustmentApi.Create(newAdjustInfo, parameters2);
         Console.WriteLine("----------------New Adjustment----------------");
         Console.WriteLine("{0},{1},{2}", newAdjust.base_currency_adjustment_id, newAdjust.currency_code, newAdjust.exchange_rate);
         var accounts2 = newAdjust.accounts;
         foreach (var account in accounts2)
         {
             Console.WriteLine("{0},{1},{2}", account.account_name, account.adjusted_balance, account.gain_or_loss_formatted);
         }
         var deleteMsg = baseCurrencyAdjustmentApi.Delete(newAdjust.base_currency_adjustment_id);
         Console.WriteLine("----------------Delete Adjustment----------------");
         Console.WriteLine(deleteMsg);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
     Console.ReadKey();
 }