org.mule.modules.quickbooks.QuickBooksModule.java Source code

Java tutorial

Introduction

Here is the source code for org.mule.modules.quickbooks.QuickBooksModule.java

Source

/**
 * Mule QuickBooks Connector
 *
 * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
 *
 * The software in this package is published under the terms of the CPAL v1.0
 * license, a copy of which has been included with this distribution in the
 * LICENSE.txt file.
 */

/**
 * This file was automatically generated by the Mule Development Kit
 */
package org.mule.modules.quickbooks;

import java.math.BigDecimal;
import java.util.Collections;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.PostConstruct;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;

import org.apache.commons.beanutils.Converter;
import org.apache.commons.lang.Validate;
import org.mule.api.annotations.Configurable;
import org.mule.api.annotations.Module;
import org.mule.api.annotations.Processor;
import org.mule.api.annotations.oauth.OAuth;
import org.mule.api.annotations.oauth.OAuthAccessToken;
import org.mule.api.annotations.oauth.OAuthAccessTokenSecret;
import org.mule.api.annotations.oauth.OAuthConsumerKey;
import org.mule.api.annotations.oauth.OAuthConsumerSecret;
import org.mule.api.annotations.param.Default;
import org.mule.api.annotations.param.Optional;
import org.mule.modules.quickbooks.api.DefaultQuickBooksClient;
import org.mule.modules.quickbooks.api.MapBuilder;
import org.mule.modules.quickbooks.api.QuickBooksClient;
import org.mule.modules.quickbooks.api.Exception.QuickBooksRuntimeException;
import org.mule.modules.quickbooks.schema.Account;
import org.mule.modules.quickbooks.schema.Bill;
import org.mule.modules.quickbooks.schema.BillPayment;
import org.mule.modules.quickbooks.schema.CashPurchase;
import org.mule.modules.quickbooks.schema.Check;
import org.mule.modules.quickbooks.schema.CreditCardCharge;
import org.mule.modules.quickbooks.schema.Customer;
import org.mule.modules.quickbooks.schema.Estimate;
import org.mule.modules.quickbooks.schema.IdType;
import org.mule.modules.quickbooks.schema.Invoice;
import org.mule.modules.quickbooks.schema.Item;
import org.mule.modules.quickbooks.schema.Payment;
import org.mule.modules.quickbooks.schema.PaymentMethod;
import org.mule.modules.quickbooks.schema.SalesReceipt;
import org.mule.modules.quickbooks.schema.SalesTerm;
import org.mule.modules.quickbooks.schema.Vendor;

import ar.com.zauber.commons.mom.CXFStyle;
import ar.com.zauber.commons.mom.MapObjectMapper;

/**
 * QuickBooks software provides an interface that allows you to use forms such as checks, deposit slips and invoices,
 * making the accounting process more comfortable for the average business owner or manager. By using the built-in
 * functions that pertain to your business, you are able to perform your company accounting by simply recording your
 * vendor activities, customer activities, banking transactions, payroll checks and taxes. QuickBooks handles the
 * accounting portion of each transaction behind the scenes.
 *
 * Read more: QuickBooks Accounting Tutorial | eHow.com http://www.ehow.com/way_5462311_quickbooks-accounting-tutorial.html#ixzz1csaydwxl
 * @author MuleSoft, inc.
 */
@Module(name = "quickbooks")
@OAuth(requestTokenUrl = "https://oauth.intuit.com/oauth/v1/get_request_token", accessTokenUrl = "https://oauth.intuit.com/oauth/v1/get_access_token", authorizationUrl = "https://workplace.intuit.com/Connect/Begin")
public class QuickBooksModule {
    /**
     * The realmID, also known as the Company ID, uniquely identifies the data for a company.
     * <p>
     * In QuickBooks Online, the Company ID  appears on the My Account page.
     * In Data Services for QuickBooks Online, the realmID is required in the URL for most calls.
     */
    @Configurable
    private String realmId;

    /**
     * Unique consumer key for the app.  When you create an app on My Developer Center, 
     * Intuit generates the values for the consumer key and secret, and then displays
     * the values on the UI of My Developer Center. You manually copy these values from
     * the UI of My Developer Center and save them in persistent storage.
     */
    @Configurable
    @OAuthConsumerKey
    private String consumerKey;

    /**
     * Unique consumer secret for the app.  When you create an app on My Developer Center, 
     * Intuit generates the values for the consumer key and secret, and then displays
     * the values on the UI of My Developer Center. You manually copy these values from
     * the UI of My Developer Center and save them in persistent storage.
     */
    @Configurable
    @OAuthConsumerSecret
    private String consumerSecret;

    /**
     * Quick-Books client. By default uses DefaultQuickbooksClient class.
     */
    @Configurable
    @Optional
    private QuickBooksClient client;

    private MapObjectMapper mom = new MapObjectMapper("org.mule.modules.quickbooks.schema");

    /**
     * Creates an Account.
     * The Account object represents the accounts that you keep to track your business.
     * Account is a component of a chart of accounts, and is part of a ledger.
     * You can use Account to record the total monetary amount that is allocated for a specific use.
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/Account">Account Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-account}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-account2}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-account3}
     *
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param name User-recognizable name for the account. This name must be unique.
     *             When you create a company, you get some default accounts.
     *             If you want to create an account, you must provide an account name that does not
     *             match the name of any default account.
     * @param desc Optional. User-entered description of the account.
     *             This description helps the book keepers or accountants to decide which journal
     *             entries should be posted to this account.
     * @param subtype Detailed classification of the account that specifies the use of this account.
     *                The accepted values are defined in QboAccountDetailTypeEnum.
     * @param acctNum Optional. User-specified account number that help the user to identify the
     *                account within the chart of accounts and decide what should be posted to the account.
     * @param openingBalance Optional. Opening balance amount when you create a new balance sheet account.
     * @param openingBalanceDate Optional. Date of the opening balance amount when creating a new balance
     *                           sheet account.
     * @param accountParentId Optional. If the account is a subaccount, AccountParentId is used to 
     *                        store the ID of the parent account.
     * @return The created Account.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public Account createAccount(@OAuthAccessToken String accessToken,
            @OAuthAccessTokenSecret String accessTokenSecret, String name, @Optional String desc,
            AccountDetail subtype, @Optional String acctNum, @Optional String openingBalance,
            Date openingBalanceDate, @Optional Map<String, Object> accountParentId) {

        return (Account) client.create(EntityType.ACCOUNT,
                mom.toObject(Account.class,
                        new MapBuilder().with("name", name).with("accountParentId", accountParentId)
                                .with("desc", desc).with("subtype", subtype.toQboAccountDetail().value())
                                .with("acctNum", acctNum).with("openingBalance", openingBalance)
                                .with("openingBalanceDate", openingBalanceDate).build()),
                accessToken, accessTokenSecret);
    }

    /**
     * Creates a Bill.
     * The Bill object represents an expense to the business.
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/Bill">Bill Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-bill}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-bill2}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-bill3}
     * 
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param header Information on the financial transaction of the Bill.
     * @param lines Information about a specific good or service purchased for which the payment is demanded
     *             as a part of the bill. A bill can have multiple lines.
     * @return The created Bill.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public Bill createBill(@OAuthAccessToken String accessToken, @OAuthAccessTokenSecret String accessTokenSecret,
            Map<String, Object> header, List<Map<String, Object>> lines) {
        return (Bill) client.create(EntityType.BILL,
                mom.toObject(Bill.class, new MapBuilder().with("header", header).with("line", lines).build()),
                accessToken, accessTokenSecret);
    }

    /**
     * Creates a BillPayment.
     * BillPayment represents the financial transaction of payment of bills that the business owner receives
     * from a vendor for goods or services purchased from the vendor.
     * QBO supports bill payments through a credit card or a bank account.
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/BillPayment">BillPayment Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-bill-payment}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-bill-payment2}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-bill-payment3}
     *
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param header Header information about the BillPayment.
     * @param lines List of lines. Specifies the line details for the bill payment.
     * @return The created BillPayment.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public BillPayment createBillPayment(@OAuthAccessToken String accessToken,
            @OAuthAccessTokenSecret String accessTokenSecret, Map<String, Object> header,
            List<Map<String, Object>> lines) {
        return (BillPayment) client.create(EntityType.BILLPAYMENT,
                mom.toObject(BillPayment.class,
                        new MapBuilder().with("header", header).with("line", lines).build()),
                accessToken, accessTokenSecret);
    }

    /**
     * Creates a CashPurchase.
     * CashPurchase represents an expense to the business as a cash transaction.
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/CashPurchase">CashPurchase Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-cash-purchase}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-cash-purchase2}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-cash-purchase3}
     *
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param header Information about the financial transaction of the entire CashPurchase.
     * @param lines List of lines. Information about a specific good or service purchased for which 
     *             the payment is demanded as a part of the CashPurchase.
     * @return The created CashPurchase.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public CashPurchase createCashPurchase(@OAuthAccessToken String accessToken,
            @OAuthAccessTokenSecret String accessTokenSecret, Map<String, Object> header,
            List<Map<String, Object>> lines) {
        return (CashPurchase) client.create(EntityType.CASHPURCHASE,
                mom.toObject(CashPurchase.class,
                        new MapBuilder().with("header", header).with("line", lines).build()),
                accessToken, accessTokenSecret);
    }

    /**
     * Creates a Check.
     * The Check object represents an expense to the business paid as a check transaction.
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/Check">Check Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-check}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-check2}
     *
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param header Financial Transaction information that pertains to the entire CheckHeader.
     * @param lines List of lines. Information about a specific good or service purchased for which 
     *             the payment is demanded as a part of the check.
     * @return The created Check.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public Check createCheck(@OAuthAccessToken String accessToken, @OAuthAccessTokenSecret String accessTokenSecret,
            Map<String, Object> header, List<Map<String, Object>> lines) {
        return (Check) client.create(EntityType.CHECK,
                mom.toObject(Check.class, new MapBuilder().with("header", header).with("line", lines).build()),
                accessToken, accessTokenSecret);
    }

    /**
     * Creates a CreditCardCharge.
     * The CreditCardCharge object represents an expense to the business as a credit card charge 
     * transaction. CreditCardCharge must have the total expense equal to the total expense of 
     * line items.
     * 
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/CreditCardCharge">CreditCardCharge Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-credit-card-charge}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-credit-card-charge2}
     *
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param header Financial Transaction information that pertains to the entire CreditCardChargeHeader.
     * @param lines List of lines. Information about a specific good or service purchased for which the 
     *             payment is demanded as a part of the CreditCardCharge purchase.
     * @return The created CreditCardCharge.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public CreditCardCharge createCreditCardCharge(@OAuthAccessToken String accessToken,
            @OAuthAccessTokenSecret String accessTokenSecret, Map<String, Object> header,
            List<Map<String, Object>> lines) {
        return (CreditCardCharge) client.create(EntityType.CREDITCARDCHARGE,
                mom.toObject(CreditCardCharge.class,
                        new MapBuilder().with("header", header).with("line", lines).build()),
                accessToken, accessTokenSecret);
    }

    /**
     * Creates a Customer.
     * The Customer object represents the consumer of the service or the product that your business offers. 
     * QBO allows categorizing the customers in a way that is meaningful to the business.
     *
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/Customer">Customer Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-customer}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-customer2}
     *
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param name Optional. Specifies the full name of the customer. If the Name is specified, then GivenName,
     *             MiddleName, and FamilyName values are ignored.
     * @param givenName Specifies the given name or first name of a person. GivenName is a required field only if 
     *        Name is not sent in the request. If a Name is sent, then the GivenName field is optional.
     * @param middleName Optional. Specifies the middle name of the person. A person can have zero or more middle 
     *                   names.
     * @param familyName Optional. Specifies the family name or the last name of the customer.
     * @param suffix Optional. Suffix appended to the name, Jr., Sr., etc.
     * @param dBAName Optional. Specifies the "Doing Business As" name of the customer.
     * @param showAs Optional. Specifies the name of the vendor to be displayed.
     * @param webSites Valid URI strings. Specifies the customers's Web sites.
     * @param salesTermId Optional. Specifies the default sales term ID that is to be associated with the customer.
     * @param salesTaxCodeId QBO only supports the customers being taxable or not, so if this field is "1", the job 
     *                       is taxable. If the field value is null, the job is not taxable. All other values are 
     *                       invalid.
     * @param emails Optional. Valid email. Specifies the customers's email addresses.
     * @param phones Optional. Specifies the phone numbers of the customer. QBO allows mapping of up to 5 phone 
     *              numbers but only one phone number is permitted for one device type.
     * @param addresses Optional. Specifies the physical addresses.
     * @return The created Customer.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public Customer createCustomer(@OAuthAccessToken String accessToken,
            @OAuthAccessTokenSecret String accessTokenSecret, @Optional String name, @Optional String givenName,
            @Optional String middleName, @Optional String familyName, @Optional String suffix,
            @Optional String dBAName, @Optional String showAs, @Optional List<Map<String, Object>> webSites,
            @Optional Map<String, Object> salesTermId, @Optional String salesTaxCodeId,
            @Optional List<Map<String, Object>> emails, @Optional List<Map<String, Object>> phones,
            @Optional List<Map<String, Object>> addresses) {
        salesTermId = coalesceMap(salesTermId);
        webSites = coalesceList(webSites);
        emails = coalesceList(emails);
        phones = coalesceList(phones);
        addresses = coalesceList(addresses);

        return (Customer) client.create(EntityType.CUSTOMER,
                mom.toObject(Customer.class, new MapBuilder().with("name", name).with("givenName", givenName)
                        .with("middleName", middleName).with("familyName", familyName).with("suffix", suffix)
                        .with("DBAName", dBAName).with("showAs", showAs).with("webSite", webSites)
                        .with("salesTermId", salesTermId).with("salesTaxCodeId", salesTaxCodeId)
                        .with("email", emails).with("phone", phones).with("address", addresses).build()),
                accessToken, accessTokenSecret);
    }

    /**
     * Creates an Estimate.
     * The Estimate object represents a proposal for a financial transaction from a business to a customer 
     * for goods or services proposed to be sold, including proposed pricing. It is also known as quote.
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/Estimate">Estimate Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-estimate}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-estimate2}
     *
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param header Financial transaction information that pertains to the entire Estimate.
     * @param lines Information about a specific good or service for which the estimate is being issued.
     * @return The created Estimate.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public Estimate createEstimate(@OAuthAccessToken String accessToken,
            @OAuthAccessTokenSecret String accessTokenSecret, Map<String, Object> header,
            List<Map<String, Object>> lines) {
        return (Estimate) client.create(EntityType.ESTIMATE,
                mom.toObject(Estimate.class, new MapBuilder().with("header", header).with("line", lines).build()),
                accessToken, accessTokenSecret);
    }

    /**
     * Creates an Invoice.
     * The Invoice object represents an invoice to a customer. Invoice could be based on salesterm 
     * with invoice and due dates for payment. Invoice supports tax, but as of now shipping charges 
     * are not supported. Invoice can be printed and emailed to a customer.
     * 
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/Invoice">Invoice Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-invoice}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-invoice2}
     *
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param header Provides information that pertains to the entire Invoice.
     * @param lines Information about a specific good or service for which the Invoice is being issued.
     * @return The created Invoice.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public Invoice createInvoice(@OAuthAccessToken String accessToken,
            @OAuthAccessTokenSecret String accessTokenSecret, Map<String, Object> header,
            List<Map<String, Object>> lines) {
        return (Invoice) client.create(EntityType.INVOICE,
                mom.toObject(Invoice.class, new MapBuilder().with("header", header).with("line", lines).build()),
                accessToken, accessTokenSecret);
    }

    /**
     * Creates an Item.
     * The Item object represents any product or service that is sold or purchased. Inventory items 
     * are not currently supported.
     * 
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/Item">Item Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-item}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-item2}
     * 
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param name Optional. User recognizable name of the Item.
     * @param unitPrice Optional. Monetary values of the service or product
     * @param desc Optional. User entered description for the item to further describe the details 
     *             of service or product.
     * @param taxable Optional. Indicates whether the item is subject to tax.
     * @param incomeAccount Optional. Income account reference to be associated with the sales item.
     * @param itemParentId Optional. The parent item id of current item.
     * @param itemParentName Optional. Name of parent Item. This field is output only.
     * @param purchaseDesc Optional. User entered purchase description for the item to further describe 
     *                     the details of the purchase.
     * @param purchaseCost Optional. The monetary value of the service or product.
     * @param expenseAccount Optional. Income account reference to be associated with the purchase item.
     * @return The created Item.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public Item createItem(@OAuthAccessToken String accessToken, @OAuthAccessTokenSecret String accessTokenSecret,
            @Optional @Default("") String name, @Optional Map<String, Object> unitPrice, @Optional String desc,
            @Optional @Default("false") Boolean taxable, @Optional Map<String, Object> incomeAccount,
            @Optional Map<String, Object> itemParentId, @Optional String itemParentName,
            @Optional String purchaseDesc, @Optional Map<String, Object> purchaseCost,
            @Optional Map<String, Object> expenseAccount) {
        unitPrice = coalesceMap(unitPrice);
        incomeAccount = coalesceMap(incomeAccount);
        itemParentId = coalesceMap(itemParentId);
        purchaseCost = coalesceMap(purchaseCost);
        expenseAccount = coalesceMap(expenseAccount);

        return (Item) client.create(EntityType.ITEM,
                mom.toObject(Item.class,
                        new MapBuilder().with("name", name).with("unitPrice", unitPrice).with("desc", desc)
                                .with("taxable", taxable).with("incomeAccountRef", incomeAccount)
                                .with("itemParentId", itemParentId).with("itemParentName", itemParentName)
                                .with("purchaseDesc", purchaseDesc).with("purchaseCost", purchaseCost)
                                .with("expenseAccountRef", expenseAccount).build()),
                accessToken, accessTokenSecret);
    }

    /**
     * Creates a Payment.
     * The Payment object  represents the financial transaction that signifies a payment from a customer 
     * for one or more sales transactions.
     * 
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/Payment">Payment Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-payment}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-payment2}
     * 
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param header Information that pertains to the entire payment.
     * @param lines Line details of the receive payment. A receive payment can have multiple lines.
     * @return The created Payment.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public Payment createPayment(@OAuthAccessToken String accessToken,
            @OAuthAccessTokenSecret String accessTokenSecret, Map<String, Object> header,
            List<Map<String, Object>> lines) {
        return (Payment) client.create(EntityType.PAYMENT,
                mom.toObject(Payment.class, new MapBuilder().with("header", header).with("line", lines).build()),
                accessToken, accessTokenSecret);
    }

    /**
     * Creates a PaymentMethod.
     * PaymentMethod represents the method of payment for a transaction. It can be a credit card 
     * payment type or a non-credit card payment type.
     * 
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/PaymentMethod">PaymentMethod Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-payment-method}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-payment-method2}
     *
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param name User recognizable name for the payment method.
     * @param type Type of payment. Specifies if it is a credit card payment type or a 
     *             non-credit card payment type. It must specify either of the following:<br/>
     *             * CREDIT_CARD<br/>
     *             * NON_CREDIT_CARD
     * @return The created PaymentMethod.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public PaymentMethod createPaymentMethod(@OAuthAccessToken String accessToken,
            @OAuthAccessTokenSecret String accessTokenSecret, String name,
            @Optional @Default("NON_CREDIT_CARD") String type) {
        return (PaymentMethod) client.create(EntityType.PAYMENTMETHOD,
                mom.toObject(PaymentMethod.class, new MapBuilder().with("name", name).with("type", type).build()),
                accessToken, accessTokenSecret);
    }

    /**
     * Creates a SalesReceipt.
     * The Payment object  represents the financial transaction that signifies a payment from a customer 
     * for one or more sales transactions.
     * 
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/SalesReceipt">SalesReceipt Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-sales-receipt}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-sales-receipt2}
     *
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param header Groups the elements that are common to the SalesReceipt transaction.
     * @param lines Groups the line items for the sales receipt.
     * @return The created SalesReceipt.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public SalesReceipt createSalesReceipt(@OAuthAccessToken String accessToken,
            @OAuthAccessTokenSecret String accessTokenSecret, Map<String, Object> header,
            List<Map<String, Object>> lines) {
        return (SalesReceipt) client.create(EntityType.SALESRECEIPT,
                mom.toObject(SalesReceipt.class,
                        new MapBuilder().with("header", header).with("line", lines).build()),
                accessToken, accessTokenSecret);
    }

    /**
     * Creates a SalesTerm.
     * The SalesTerm object  represents the terms under which a sale is made. SalesTerm is typically 
     * expressed in the form of days due after the goods are received. There is an optional discount 
     * part of the sales term, where a discount of total amount can automatically be applied if 
     * payment is made within a few days of the stipulated time.
     * 
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/SalesTerm">SalesTerm Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-sales-term}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-sales-term2}
     *
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param name Specifies the user recognizable name for the salesterm.
     * @param dueDays Number of days from the delivery of goods or services till the payment is due.
     *                If DueDays is specified, only DiscountDays and DiscountPercent can be 
     *                additionally specified.
     * @param discountDays Optional. Number of days for which the discount is applicable, if the 
     *                     payment is made within these days. This value is used only when DueDays 
     *                     is specified.
     * @param discountPercent Optional. Percentage of discount that is available against a price, if 
     *                                  paid within the days specified by DiscountDays. This value is 
     *                                  used only when DueDays is specified. 
     * @param dayOfMonthDue Payment must be received by the day of the month specified by DayOfMonthDue. 
     *                      This value is used only when DueDays is not specified.
     * @param dueNextMonthDays Optional. Payment due next month if issued that many days before the 
     *                         DayOfMonthDue. This value is used only when DueDays is not specified.
     * @param discountDayOfMonth Optional. Discount applies if paid before that day of month. This value 
     *                           is used only when DueDays is not specified.
     * @param dateDiscountPercent Optional. Percentage of discount that is available against a price, if 
     *                            paid before DiscountDayofMonth. This value is used only when DueDays is 
     *                            not specified.
     * @return The created SalesTerm.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public SalesTerm createSalesTerm(@OAuthAccessToken String accessToken,
            @OAuthAccessTokenSecret String accessTokenSecret, String name, Integer dueDays,
            @Optional Integer discountDays, @Optional String discountPercent, Integer dayOfMonthDue,
            @Optional Integer dueNextMonthDays, @Optional Integer discountDayOfMonth,
            @Optional String dateDiscountPercent) {

        return (SalesTerm) client.create(EntityType.SALESTERM, mom.toObject(SalesTerm.class,
                new MapBuilder().with("name", name).with("dueDays", dueDays).with("discountDays", discountDays)
                        .with("discountPercent", discountPercent).with("dayOfMonthDue", dayOfMonthDue)
                        .with("dueNextMonthDays", dueNextMonthDays).with("discountDayOfMonth", discountDayOfMonth)
                        .with("dateDiscountPercent", dateDiscountPercent).build()),
                accessToken, accessTokenSecret);
    }

    /**
     * Creates a Vendor.
     * The Vendor object represents the buyer from whom you purchase any service or product 
     * for your organization.
     * 
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/Vendor">Vendor Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-vendor}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:create-vendor2}
     *
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param name Optional. Specifies the full name of the vendor. If the FullName is specified, 
     *             then GivenName, MiddleName, and FamilyName values are ignored.
     * @param givenName Specifies the given name or first name of a person. GivenName is a required 
     *                  field only if Name is not sent in the request. If a Name is sent, then the 
     *                  GivenName field is optional.
     * @param middleName Optional. Specifies the middle name of the vendor. A person can have zero 
     *                   or more middle names.
     * @param familyName Optional. Specifies the family name or the last name of the vendor.
     * @param dBAName Optional. Specifies the "Doing Business As" name of the vendor.
     * @param showAs Optional. Specifies the name of the vendor to be displayed.
     * @param webSites Optional. Valid URI strings. Specifies the vendor's Web site.
     * @param taxIdentifier Optional. Specifies the Tax ID of the person or the organization. This 
     *                      is a Personally Identifiable Information (PII) attribute.
     * @param acctNum Optional. Specifies the account name or the account number that is associated 
     *                with the vendor.
     * @param vendor1099 Optional. Specifies that the Vendor is an independent contractor, someone 
     *                   who is given a 1099-MISC form at the end of the year. The "1099 Vendor" is 
     *                   paid with regular checks, and taxes are not withheld on the vendor's behalf.
     * @param emails Optional. Valid email. Specifies the vendors's email addresses.
     * @param phones Optional. Specifies the phone numbers of the vendor. QBO allows mapping of up to 
     *              5 phone numbers but only one phone number is permitted for one device type.
     * @param addresses Optional. Specifies the physical addresses.
     * @return The created Vendor.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public Vendor createVendor(@OAuthAccessToken String accessToken,
            @OAuthAccessTokenSecret String accessTokenSecret, @Optional String name, @Optional String givenName,
            @Optional String middleName, @Optional String familyName, @Optional String dBAName,
            @Optional String showAs, @Optional List<Map<String, Object>> webSites, @Optional String taxIdentifier,
            @Optional String acctNum, @Optional Boolean vendor1099, @Optional List<Map<String, Object>> emails,
            @Optional List<Map<String, Object>> phones, @Optional List<Map<String, Object>> addresses) {
        webSites = coalesceList(webSites);
        emails = coalesceList(emails);
        phones = coalesceList(phones);
        addresses = coalesceList(addresses);

        return (Vendor) client.create(EntityType.VENDOR,
                mom.toObject(Vendor.class, new MapBuilder().with("name", name).with("givenName", givenName)
                        .with("middleName", middleName).with("familyName", familyName).with("DBAName", dBAName)
                        .with("showAs", showAs).with("webSite", webSites).with("taxIdentifier", taxIdentifier)
                        .with("acctNum", acctNum).with("vendor1099", vendor1099).with("email", emails)
                        .with("phone", phones).with("address", addresses).build()),
                accessToken, accessTokenSecret);
    }

    /**
     * Retrieve objects by ID.
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:get-object}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:get-object2}
     *
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param type EntityType of the object.
     * @param id Id which is assigned by Data Services when the object is created.
     * @return The object.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public Object getObject(@OAuthAccessToken String accessToken, @OAuthAccessTokenSecret String accessTokenSecret,
            EntityType type, Map<String, Object> id) {
        return client.getObject(type, mom.toObject(IdType.class, id), accessToken, accessTokenSecret);
    }

    /**
     * Updates an Account
     * The Account object represents the accounts that you keep to track your business.
     * Account is a component of a chart of accounts, and is part of a ledger.
     * You can use Account to record the total monetary amount that is allocated for a specific use.
     * 
     * Specify all the parameters for the object, not just the new or changed elements.
     * If you omit an element, it is removed from the object by the update operation.
     * 
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/Account">Account Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-account}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-account2}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-account3}
     *
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param id Id which is assigned by Data Services when the object is created.
     * @param syncToken Optional. Integer that indicates how many times the object has been updated.
     *                  Before performing the update, Data Services verifies that the SyncToken in the
     *                  request has the same value as the SyncToken in the Data Service's repository.
     * @param name User-recognizable name for the account. This name must be unique.
     *             When you create a company, you get some default accounts.
     *             If you want to create an account, you must provide an account name that does not
     *             match the name of any default account.
     * @param desc Optional. User-entered description of the account.
     *             This description helps the book keepers or accountants to decide which journal
     *             entries should be posted to this account.
     * @param subtype Detailed classification of the account that specifies the use of this account.
     *                The accepted values are defined in QboAccountDetailTypeEnum.
     * @param acctNum Optional. User-specified account number that help the user to identify the
     *                account within the chart of accounts and decide what should be posted to the account.
     * @param openingBalance Optional. Opening balance amount when you create a new balance sheet account.
     * @param openingBalanceDate Optional. Date of the opening balance amount when creating a new balance
     *                           sheet account.
     * @param accountParentId Optional. If the account is a subaccount, AccountParentId is used to 
     *                        store the ID of the parent account.
     * @return The updated Account.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public Account updateAccount(@OAuthAccessToken String accessToken,
            @OAuthAccessTokenSecret String accessTokenSecret, Map<String, Object> id, @Optional String syncToken,
            String name, @Optional String desc, AccountDetail subtype, @Optional String acctNum,
            @Optional String openingBalance, @Optional Date openingBalanceDate,
            @Optional Map<String, Object> accountParentId) {

        return (Account) client.update(EntityType.ACCOUNT,
                mom.toObject(Account.class,
                        new MapBuilder().with("id", id).with("syncToken", syncToken).with("name", name)
                                .with("accountParentId", accountParentId).with("desc", desc)
                                .with("subtype", subtype.toQboAccountDetail().value()).with("acctNum", acctNum)
                                .with("openingBalance", openingBalance)
                                .with("openingBalanceDate", openingBalanceDate).build()),
                accessToken, accessTokenSecret);
    }

    /**
     * Updates a Bill
     * The Bill object represents an expense to the business. 
     * 
     * Specify all the parameters for the object, not just the new or changed elements.
     * If you omit an element, it is removed from the object by the update operation.
     * 
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/Bill">Bill Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-bill}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-bill2}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-bill3}
     *
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param id Id which is assigned by Data Services when the object is created.
     * @param syncToken Optional. Integer that indicates how many times the object has been updated.
     *                  Before performing the update, Data Services verifies that the SyncToken in the
     *                  request has the same value as the SyncToken in the Data Service's repository.
     * @param header Information on the financial transaction of the Bill.
     * @param lines Information about a specific good or service purchased for which the payment is demanded
     *             as a part of the bill. A bill can have multiple lines.
     * @return The created Bill.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public Bill updateBill(@OAuthAccessToken String accessToken, @OAuthAccessTokenSecret String accessTokenSecret,
            Map<String, Object> id, @Optional String syncToken, Map<String, Object> header,
            List<Map<String, Object>> lines) {
        return (Bill) client.update(
                EntityType.BILL, mom.toObject(Bill.class, new MapBuilder().with("id", id)
                        .with("syncToken", syncToken).with("header", header).with("line", lines).build()),
                accessToken, accessTokenSecret);
    }

    /**
     * Updates a BillPayment
     * BillPayment represents the financial transaction of payment of bills that the business owner receives
     * from a vendor for goods or services purchased from the vendor.
     * QBO supports bill payments through a credit card or a bank account.
     * 
     * Specify all the parameters for the object, not just the new or changed elements.
     * If you omit an element, it is removed from the object by the update operation.
     * 
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/BillPayment">BillPayment Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-bill-payment}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-bill-payment2}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-bill-payment3}
     *
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param id Id which is assigned by Data Services when the object is created.
     * @param syncToken Optional. Integer that indicates how many times the object has been updated.
     *                  Before performing the update, Data Services verifies that the SyncToken in the
     *                  request has the same value as the SyncToken in the Data Service's repository.
     * @param header Header information about the BillPayment.
     * @param lines Specifies the line details for the bill payment. A bill payment can have multiple lines.
     * @return The updated BillPayment.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public BillPayment updateBillPayment(@OAuthAccessToken String accessToken,
            @OAuthAccessTokenSecret String accessTokenSecret, Map<String, Object> id, @Optional String syncToken,
            Map<String, Object> header, List<Map<String, Object>> lines) {
        return (BillPayment) client.update(
                EntityType.BILLPAYMENT, mom.toObject(BillPayment.class, new MapBuilder().with("id", id)
                        .with("syncToken", syncToken).with("header", header).with("line", lines).build()),
                accessToken, accessTokenSecret);
    }

    /**
     * Updates a CashPurchase.
     * CashPurchase represents an expense to the business as a cash transaction.
     * 
     * Specify all the parameters for the object, not just the new or changed elements.
     * If you omit an element, it is removed from the object by the update operation.
     * 
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/CashPurchase">CashPurchase Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-cash-purchase}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-cash-purchase2}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-cash-purchase3}
     *
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param id Id which is assigned by Data Services when the object is created.
     * @param syncToken Optional. Integer that indicates how many times the object has been updated.
     *                  Before performing the update, Data Services verifies that the SyncToken in the
     *                  request has the same value as the SyncToken in the Data Service's repository.
     * @param header Information about the financial transaction of the entire CashPurchase.
     * @param lines List of lines. Information about a specific good or service purchased for which 
     *             the payment is demanded as a part of the CashPurchase.
     * @return The updated CashPurchase.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public CashPurchase updateCashPurchase(@OAuthAccessToken String accessToken,
            @OAuthAccessTokenSecret String accessTokenSecret, Map<String, Object> id, @Optional String syncToken,
            Map<String, Object> header, List<Map<String, Object>> lines) {
        return (CashPurchase) client.update(
                EntityType.CASHPURCHASE, mom.toObject(CashPurchase.class, new MapBuilder().with("id", id)
                        .with("syncToken", syncToken).with("header", header).with("line", lines).build()),
                accessToken, accessTokenSecret);
    }

    /**
     * Updates a Check.
     * The Check object represents an expense to the business paid as a check transaction.
     * 
     * Specify all the parameters for the object, not just the new or changed elements.
     * If you omit an element, it is removed from the object by the update operation.
     * 
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/Check">Check Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-check}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-check2}
     * 
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param id Id which is assigned by Data Services when the object is created.
     * @param syncToken Optional. Integer that indicates how many times the object has been updated.
     *                  Before performing the update, Data Services verifies that the SyncToken in the
     *                  request has the same value as the SyncToken in the Data Service's repository.
     * @param header Financial Transaction information that pertains to the entire CheckHeader.
     * @param lines List of lines. Information about a specific good or service purchased for which 
     *             the payment is demanded as a part of the check.
     * @return The updated Check.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public Check updateCheck(@OAuthAccessToken String accessToken, @OAuthAccessTokenSecret String accessTokenSecret,
            Map<String, Object> id, @Optional String syncToken, Map<String, Object> header,
            List<Map<String, Object>> lines) {
        return (Check) client.update(
                EntityType.CHECK, mom.toObject(Check.class, new MapBuilder().with("id", id)
                        .with("syncToken", syncToken).with("header", header).with("line", lines).build()),
                accessToken, accessTokenSecret);
    }

    /**
     * Updates a CreditCardCharge.
     * The CreditCardCharge object represents an expense to the business as a credit card charge 
     * transaction. CreditCardCharge must have the total expense equal to the total expense of 
     * line items.
     * 
     * Specify all the parameters for the object, not just the new or changed elements.
     * If you omit an element, it is removed from the object by the update operation.
     * 
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/CreditCardCharge">CreditCardCharge Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-credit-card-charge}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-credit-card-charge2}
     * 
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param id Id which is assigned by Data Services when the object is created.
     * @param syncToken Optional. Integer that indicates how many times the object has been updated.
     *                  Before performing the update, Data Services verifies that the SyncToken in the
     *                  request has the same value as the SyncToken in the Data Service's repository.
     * @param header Financial Transaction information that pertains to the entire CreditCardChargeHeader.
     * @param lines List of lines. Information about a specific good or service purchased for which the 
     *             payment is demanded as a part of the CreditCardCharge purchase.
     * @return The updated CreditCardCharge.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public CreditCardCharge updateCreditCardCharge(@OAuthAccessToken String accessToken,
            @OAuthAccessTokenSecret String accessTokenSecret, Map<String, Object> id, @Optional String syncToken,
            Map<String, Object> header, List<Map<String, Object>> lines) {
        return (CreditCardCharge) client.update(
                EntityType.CREDITCARDCHARGE, mom.toObject(CreditCardCharge.class, new MapBuilder().with("id", id)
                        .with("syncToken", syncToken).with("header", header).with("line", lines).build()),
                accessToken, accessTokenSecret);
    }

    /**
     * Updates a Customer.
     * The Customer object represents the consumer of the service or the product that your business offers. 
     * QBO allows categorizing the customers in a way that is meaningful to the business.
     * 
     * Specify all the parameters for the object, not just the new or changed elements.
     * If you omit an element, it is removed from the object by the update operation.
     * 
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/Customer">Customer Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-customer}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-customer2}
     * 
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param id Id which is assigned by Data Services when the object is created.
     * @param syncToken Optional. Integer that indicates how many times the object has been updated.
     *                  Before performing the update, Data Services verifies that the SyncToken in the
     *                  request has the same value as the SyncToken in the Data Service's repository.
     * @param name Optional. Specifies the full name of the customer. If the Name is specified, then GivenName,
     *             MiddleName, and FamilyName values are ignored.
     * @param givenName Specifies the given name or first name of a person. GivenName is a required field only if 
     *        Name is not sent in the request. If a Name is sent, then the GivenName field is optional.
     * @param middleName Optional. Specifies the middle name of the person. A person can have zero or more middle 
     *                   names.
     * @param familyName Optional. Specifies the family name or the last name of the customer.
     * @param suffix Optional. Suffix appended to the name, Jr., Sr., etc.
     * @param dBAName Optional. Specifies the "Doing Business As" name of the customer.
     * @param showAs Optional. Specifies the name of the vendor to be displayed.
     * @param webSites Valid URI strings. Specifies the customers's Web sites.
     * @param salesTermId Optional. Specifies the default sales term ID that is to be associated with the customer.
     * @param salesTaxCodeId QBO only supports the customers being taxable or not, so if this field is "1", the job 
     *                       is taxable. If the field value is null, the job is not taxable. All other values are 
     *                       invalid.
     * @param emails Optional. Valid email. Specifies the customers's email addresses.
     * @param phones Optional. Specifies the phone numbers of the customer. QBO allows mapping of up to 5 phone 
     *              numbers but only one phone number is permitted for one device type.
     * @param addresses Optional. Specifies the physical addresses.
     * @return The updated Customer.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public Customer updateCustomer(@OAuthAccessToken String accessToken,
            @OAuthAccessTokenSecret String accessTokenSecret, Map<String, Object> id, @Optional String syncToken,
            @Optional String name, @Optional String givenName, @Optional String middleName,
            @Optional String familyName, @Optional String suffix, @Optional String dBAName, @Optional String showAs,
            @Optional List<Map<String, Object>> webSites, @Optional Map<String, Object> salesTermId,
            @Optional String salesTaxCodeId, @Optional List<Map<String, Object>> emails,
            @Optional List<Map<String, Object>> phones, @Optional List<Map<String, Object>> addresses) {
        salesTermId = coalesceMap(salesTermId);
        webSites = coalesceList(webSites);
        emails = coalesceList(emails);
        phones = coalesceList(phones);
        addresses = coalesceList(addresses);

        return (Customer) client.update(EntityType.CUSTOMER,
                mom.toObject(Customer.class,
                        new MapBuilder().with("id", id).with("syncToken", syncToken).with("name", name)
                                .with("givenName", givenName).with("middleName", middleName)
                                .with("familyName", familyName).with("suffix", suffix).with("DBAName", dBAName)
                                .with("showAs", showAs).with("webSite", webSites).with("salesTermId", salesTermId)
                                .with("salesTaxCodeId", salesTaxCodeId).with("email", emails).with("phone", phones)
                                .with("address", addresses).build()),
                accessToken, accessTokenSecret);
    }

    /**
     * Updates an Estimate.
     * The Estimate object represents a proposal for a financial transaction from a business to a customer 
     * for goods or services proposed to be sold, including proposed pricing. It is also known as quote.
     * 
     * Specify all the parameters for the object, not just the new or changed elements.
     * If you omit an element, it is removed from the object by the update operation.
     * 
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/Estimate">Estimate Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-estimate}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-estimate2}
     *
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param id Id which is assigned by Data Services when the object is created.
     * @param syncToken Optional. Integer that indicates how many times the object has been updated.
     *                  Before performing the update, Data Services verifies that the SyncToken in the
     *                  request has the same value as the SyncToken in the Data Service's repository.
     * @param header Financial transaction information that pertains to the entire Estimate.
     * @param lines Information about a specific good or service for which the estimate is being issued.
     * @return The updated Estimate.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public Estimate updateEstimate(@OAuthAccessToken String accessToken,
            @OAuthAccessTokenSecret String accessTokenSecret, Map<String, Object> id, @Optional String syncToken,
            Map<String, Object> header, List<Map<String, Object>> lines) {
        return (Estimate) client.update(
                EntityType.ESTIMATE, mom.toObject(Estimate.class, new MapBuilder().with("id", id)
                        .with("syncToken", syncToken).with("header", header).with("line", lines).build()),
                accessToken, accessTokenSecret);
    }

    /**
     * Updates an Invoice.
     * The Invoice object represents an invoice to a customer. Invoice could be based on salesterm 
     * with invoice and due dates for payment. Invoice supports tax, but as of now shipping charges 
     * are not supported. Invoice can be printed and emailed to a customer.
     * 
     * Specify all the parameters for the object, not just the new or changed elements.
     * If you omit an element, it is removed from the object by the update operation.
     * 
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/Invoice">Invoice Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-invoice}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-invoice2}
     *
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param id Id which is assigned by Data Services when the object is created.
     * @param syncToken Optional. Integer that indicates how many times the object has been updated.
     *                  Before performing the update, Data Services verifies that the SyncToken in the
     *                  request has the same value as the SyncToken in the Data Service's repository.
     * @param header Provides information that pertains to the entire Invoice.
     * @param lines Information about a specific good or service for which the Invoice is being issued.
     * @return The updated Invoice.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public Invoice updateInvoice(@OAuthAccessToken String accessToken,
            @OAuthAccessTokenSecret String accessTokenSecret, Map<String, Object> id, @Optional String syncToken,
            Map<String, Object> header, List<Map<String, Object>> lines) {
        return (Invoice) client.update(
                EntityType.INVOICE, mom.toObject(Invoice.class, new MapBuilder().with("id", id)
                        .with("syncToken", syncToken).with("header", header).with("line", lines).build()),
                accessToken, accessTokenSecret);
    }

    /**
     * Updates an Item.
     * The Item object represents any product or service that is sold or purchased. Inventory items 
     * are not currently supported.
     * 
     * Specify all the parameters for the object, not just the new or changed elements.
     * If you omit an element, it is removed from the object by the update operation.
     * 
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/Item">Item Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-item}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-item2}
     *
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param id Id which is assigned by Data Services when the object is created.
     * @param syncToken Optional. Integer that indicates how many times the object has been updated.
     *                  Before performing the update, Data Services verifies that the SyncToken in the
     *                  request has the same value as the SyncToken in the Data Service's repository.
     * @param name Optional. User recognizable name of the Item.
     * @param unitPrice Optional. Monetary values of the service or product
     * @param desc Optional. User entered description for the item to further describe the details 
     *             of service or product.
     * @param taxable Optional. Indicates whether the item is subject to tax.
     * @param incomeAccount Optional. Income account reference to be associated with the sales item.
     * @param itemParentId Optional. The parent item id of current item.
     * @param itemParentName Optional. Name of parent Item. This field is output only.
     * @param purchaseDesc Optional. User entered purchase description for the item to further describe 
     *                     the details of the purchase.
     * @param purchaseCost Optional. The monetary value of the service or product.
     * @param expenseAccount Optional. Income account reference to be associated with the purchase item.
     * @return The updated Item.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public Item updateItem(@OAuthAccessToken String accessToken, @OAuthAccessTokenSecret String accessTokenSecret,
            Map<String, Object> id, @Optional String syncToken, @Optional @Default("") String name,
            @Optional Map<String, Object> unitPrice, @Optional String desc,
            @Optional @Default("false") Boolean taxable, @Optional Map<String, Object> incomeAccount,
            @Optional Map<String, Object> itemParentId, @Optional String itemParentName,
            @Optional String purchaseDesc, @Optional Map<String, Object> purchaseCost,
            @Optional Map<String, Object> expenseAccount) {
        unitPrice = coalesceMap(unitPrice);
        incomeAccount = coalesceMap(incomeAccount);
        itemParentId = coalesceMap(itemParentId);
        purchaseCost = coalesceMap(purchaseCost);
        expenseAccount = coalesceMap(expenseAccount);

        return (Item) client.update(EntityType.ITEM,
                mom.toObject(Item.class, new MapBuilder().with("id", id).with("syncToken", syncToken)
                        .with("name", name).with("unitPrice", unitPrice).with("desc", desc).with("taxable", taxable)
                        .with("incomeAccountRef", incomeAccount).with("itemParentId", itemParentId)
                        .with("itemParentName", itemParentName).with("purchaseDesc", purchaseDesc)
                        .with("purchaseCost", purchaseCost).with("expenseAccountRef", expenseAccount).build()),
                accessToken, accessTokenSecret);
    }

    /**
     * Updates a Payment.
     * The Payment object  represents the financial transaction that signifies a payment from a customer 
     * for one or more sales transactions.
     * 
     * Specify all the parameters for the object, not just the new or changed elements.
     * If you omit an element, it is removed from the object by the update operation.
     * 
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/Payment">Payment Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-payment}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-payment2}
     *
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param id Id which is assigned by Data Services when the object is created.
     * @param syncToken Optional. Integer that indicates how many times the object has been updated.
     *                  Before performing the update, Data Services verifies that the SyncToken in the
     *                  request has the same value as the SyncToken in the Data Service's repository.
     * @param header Information that pertains to the entire payment.
     * @param lines Line details of the receive payment. A receive payment can have multiple lines.
     * @return The updated Payment.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public Payment updatePayment(@OAuthAccessToken String accessToken,
            @OAuthAccessTokenSecret String accessTokenSecret, Map<String, Object> id, @Optional String syncToken,
            Map<String, Object> header, List<Map<String, Object>> lines) {
        return (Payment) client.update(
                EntityType.PAYMENT, mom.toObject(Payment.class, new MapBuilder().with("id", id)
                        .with("syncToken", syncToken).with("header", header).with("line", lines).build()),
                accessToken, accessTokenSecret);
    }

    /**
     * Updates a PaymentMethod.
     * PaymentMethod represents the method of payment for a transaction. It can be a credit card 
     * payment type or a non-credit card payment type.
     * 
     * Specify all the parameters for the object, not just the new or changed elements.
     * If you omit an element, it is removed from the object by the update operation.
     * 
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/PaymentMethod">PaymentMethod Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-payment-method}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-payment-method2}
     *
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param id Id which is assigned by Data Services when the object is created.
     * @param syncToken Optional. Integer that indicates how many times the object has been updated.
     *                  Before performing the update, Data Services verifies that the SyncToken in the
     *                  request has the same value as the SyncToken in the Data Service's repository.
     * @param name User recognizable name for the payment method.
     * @param type Optional. Type of payment. Specifies if it is a credit card payment type or a 
     *             non-credit card payment type.
     * @return The updated PaymentMethod.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public PaymentMethod updatePaymentMethod(@OAuthAccessToken String accessToken,
            @OAuthAccessTokenSecret String accessTokenSecret, Map<String, Object> id, @Optional String syncToken,
            String name, @Optional @Default("NON_CREDIT_CARD") String type) {
        return (PaymentMethod) client.update(
                EntityType.PAYMENTMETHOD, mom.toObject(PaymentMethod.class, new MapBuilder().with("id", id)
                        .with("syncToken", syncToken).with("name", name).with("type", type).build()),
                accessToken, accessTokenSecret);
    }

    /**
     * Updates a SalesReceipt.
     * The Payment object  represents the financial transaction that signifies a payment from a customer 
     * for one or more sales transactions.
     * 
     * Specify all the parameters for the object, not just the new or changed elements.
     * If you omit an element, it is removed from the object by the update operation.
     * 
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/SalesReceipt">SalesReceipt Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-sales-receipt}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-sales-receipt2}
     *
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param id Id which is assigned by Data Services when the object is created.
     * @param syncToken Optional. Integer that indicates how many times the object has been updated.
     *                  Before performing the update, Data Services verifies that the SyncToken in the
     *                  request has the same value as the SyncToken in the Data Service's repository.
     * @param header Groups the elements that are common to the SalesReceipt transaction.
     * @param lines Groups the line items for the sales receipt.
     * @return The updated SalesReceipt.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public SalesReceipt updateSalesReceipt(@OAuthAccessToken String accessToken,
            @OAuthAccessTokenSecret String accessTokenSecret, Map<String, Object> id, @Optional String syncToken,
            Map<String, Object> header, List<Map<String, Object>> lines) {
        return (SalesReceipt) client.update(
                EntityType.SALESRECEIPT, mom.toObject(SalesReceipt.class, new MapBuilder().with("id", id)
                        .with("syncToken", syncToken).with("header", header).with("line", lines).build()),
                accessToken, accessTokenSecret);
    }

    /**
     * Updates a SalesTerm.
     * The SalesTerm object  represents the terms under which a sale is made. SalesTerm is typically 
     * expressed in the form of days due after the goods are received. There is an optional discount 
     * part of the sales term, where a discount of total amount can automatically be applied if 
     * payment is made within a few days of the stipulated time.
     * 
     * Specify all the parameters for the object, not just the new or changed elements.
     * If you omit an element, it is removed from the object by the update operation.
     * 
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/SalesTerm">SalesTerm Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-sales-term}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-sales-term2}
     *
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param id Id which is assigned by Data Services when the object is created.
     * @param syncToken Optional. Integer that indicates how many times the object has been updated.
     *                  Before performing the update, Data Services verifies that the SyncToken in the
     *                  request has the same value as the SyncToken in the Data Service's repository.
     * @param name Specifies the user recognizable name for the salesterm.
     * @param dueDays Number of days from the delivery of goods or services till the payment is due.
     *                If DueDays is specified, only DiscountDays and DiscountPercent can be 
     *                additionally specified.
     * @param discountDays Optional. Number of days for which the discount is applicable, if the 
     *                     payment is made within these days. This value is used only when DueDays 
     *                     is specified.
     * @param discountPercent Optional. Percentage of discount that is available against a price, if 
     *                                  paid within the days specified by DiscountDays. This value is 
     *                                  used only when DueDays is specified. 
     * @param dayOfMonthDue Payment must be received by the day of the month specified by DayOfMonthDue. 
     *                      This value is used only when DueDays is not specified.
     * @param dueNextMonthDays Optional. Payment due next month if issued that many days before the 
     *                         DayOfMonthDue. This value is used only when DueDays is not specified.
     * @param discountDayOfMonth Optional. Discount applies if paid before that day of month. This value 
     *                           is used only when DueDays is not specified.
     * @param dateDiscountPercent Optional. Percentage of discount that is available against a price, if 
     *                            paid before DiscountDayofMonth. This value is used only when DueDays is 
     *                            not specified.
     * @return The updated SalesTerm.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public SalesTerm updateSalesTerm(@OAuthAccessToken String accessToken,
            @OAuthAccessTokenSecret String accessTokenSecret, Map<String, Object> id, @Optional String syncToken,
            String name, Integer dueDays, @Optional Integer discountDays, @Optional String discountPercent,
            Integer dayOfMonthDue, @Optional Integer dueNextMonthDays, @Optional Integer discountDayOfMonth,
            @Optional String dateDiscountPercent) {

        return (SalesTerm) client.update(EntityType.SALESTERM,
                mom.toObject(SalesTerm.class, new MapBuilder().with("id", id).with("syncToken", syncToken)
                        .with("name", name).with("dueDays", dueDays).with("discountDays", discountDays)
                        .with("discountPercent", discountPercent).with("dayOfMonthDue", dayOfMonthDue)
                        .with("dueNextMonthDays", dueNextMonthDays).with("discountDayOfMonth", discountDayOfMonth)
                        .with("dateDiscountPercent", dateDiscountPercent).build()),
                accessToken, accessTokenSecret);
    }

    /**
     * Updates a Vendor.
     * The Vendor object represents the buyer from whom you purchase any service or product 
     * for your organization.
     * 
     * Specify all the parameters for the object, not just the new or changed elements.
     * If you omit an element, it is removed from the object by the update operation.
     * 
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/Vendor">Vendor Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-vendor}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:update-vendor2}
     *
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param id Id which is assigned by Data Services when the object is created.
     * @param syncToken Optional. Integer that indicates how many times the object has been updated.
     *                  Before performing the update, Data Services verifies that the SyncToken in the
     *                  request has the same value as the SyncToken in the Data Service's repository.
     * @param name Optional. Specifies the full name of the vendor. If the FullName is specified, 
     *             then GivenName, MiddleName, and FamilyName values are ignored.
     * @param givenName Specifies the given name or first name of a person. GivenName is a required 
     *                  field only if Name is not sent in the request. If a Name is sent, then the 
     *                  GivenName field is optional.
     * @param middleName Optional. Specifies the middle name of the vendor. A person can have zero 
     *                   or more middle names.
     * @param familyName Optional. Specifies the family name or the last name of the vendor.
     * @param dBAName Optional. Specifies the "Doing Business As" name of the vendor.
     * @param showAs Optional. Specifies the name of the vendor to be displayed.
     * @param webSites Optional. Valid URI strings. Specifies the vendor's Web site.
     * @param taxIdentifier Optional. Specifies the Tax ID of the person or the organization. This 
     *                      is a Personally Identifiable Information (PII) attribute.
     * @param acctNum Optional. Specifies the account name or the account number that is associated 
     *                with the vendor.
     * @param vendor1099 Optional. Specifies that the Vendor is an independent contractor, someone 
     *                   who is given a 1099-MISC form at the end of the year. The "1099 Vendor" is 
     *                   paid with regular checks, and taxes are not withheld on the vendor's behalf.
     * @param emails Optional. Valid email. Specifies the vendors's email addresses.
     * @param phones Optional. Specifies the phone numbers of the vendor. QBO allows mapping of up to 
     *              5 phone numbers but only one phone number is permitted for one device type.
     * @param addresses Optional. Specifies the physical addresses.
     * @return The updated Vendor.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public Vendor updateVendor(@OAuthAccessToken String accessToken,
            @OAuthAccessTokenSecret String accessTokenSecret, Map<String, Object> id, @Optional String syncToken,
            @Optional String name, @Optional String givenName, @Optional String middleName,
            @Optional String familyName, @Optional String dBAName, @Optional String showAs,
            @Optional List<Map<String, Object>> webSites, @Optional String taxIdentifier, @Optional String acctNum,
            @Optional Boolean vendor1099, @Optional List<Map<String, Object>> emails,
            @Optional List<Map<String, Object>> phones, @Optional List<Map<String, Object>> addresses) {
        webSites = coalesceList(webSites);
        emails = coalesceList(emails);
        phones = coalesceList(phones);
        addresses = coalesceList(addresses);

        return (Vendor) client.update(EntityType.VENDOR,
                mom.toObject(Vendor.class,
                        new MapBuilder().with("id", id).with("syncToken", syncToken).with("name", name)
                                .with("givenName", givenName).with("middleName", middleName)
                                .with("familyName", familyName).with("DBAName", dBAName).with("showAs", showAs)
                                .with("webSite", webSites).with("taxIdentifier", taxIdentifier)
                                .with("acctNum", acctNum).with("vendor1099", vendor1099).with("email", emails)
                                .with("phone", phones).with("address", addresses).build()),
                accessToken, accessTokenSecret);
    }

    /**
     * Deletes an object.
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:delete-object}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:delete-object2}
     *
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param type EntityType of the object.
     * @param id Id which is assigned by Data Services when the object is created.
     * @param syncToken Optional. Integer that indicates how many times the object has been updated.
     *                  Before performing the update, Data Services verifies that the SyncToken in the
     *                  request has the same value as the SyncToken in the Data Service's repository.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @Processor
    public void deleteObject(@OAuthAccessToken String accessToken, @OAuthAccessTokenSecret String accessTokenSecret,
            EntityType type, Map<String, Object> id, @Optional String syncToken) {
        client.deleteObject(type, mom.toObject(IdType.class, id), syncToken, accessToken, accessTokenSecret);
    }

    /**
     * Lazily retrieves Objects
     *
     * For details see: 
     * <a href="http://qbsdk.developer.intuit.com/0010_Intuit_Partner_Platform/0050_Data_Services/
     * 0400_QuickBooks_Online/Vendor">Vendor Especification</a>
     * 
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:find-objects}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:find-objects2}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:find-objects3}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:find-objects4}
     * {@sample.xml ../../../doc/mule-module-quick-books.xml.sample quickbooks:find-objects5}
     *
     * @param accessToken the oauth access token
     * @param accessTokenSecret the oauth secret token
     * @param type EntityType of the object.
     * @param queryFilter String with a filter format (see details). Each type of object to be 
     *                    retrieved, has a list of attributes for which it can be filtered (See this 
     *                    list following the link in the details of the documentation of the create
     *                    or update method of that object).
     * @param querySort String with a sort format (see details). Each type of object to be 
     *                    retrieved, has a list of attributes for which it can be sorted (See this 
     *                    list following the link in the details of the documentation of the create
     *                    or update method of that object).
     * @return Iterable of the objects to be retrieved.
     * 
     * @throws QuickBooksRuntimeException when there is a problem with the server. It has a code 
     *         and a message provided by quickbooks about the error.
     */
    @SuppressWarnings("rawtypes")
    @Processor
    public Iterable findObjects(@OAuthAccessToken String accessToken,
            @OAuthAccessTokenSecret String accessTokenSecret, EntityType type, @Optional String queryFilter,
            @Optional String querySort) {
        return client.findObjects(type, queryFilter, querySort, accessToken, accessTokenSecret);
    }

    /**
     * 
     */
    @PostConstruct
    public void init() {
        if (client == null) {
            client = new DefaultQuickBooksClient(realmId, consumerKey, consumerSecret);
        }
        mom.setPropertyStyle(CXFStyle.STYLE);
    }

    /**
     * Sets the realmId. 
     *
     * @param realmId  with the realmId.
     */

    public void setRealmId(String realmId) {
        this.realmId = realmId;
    }

    /**
     * Returns the realmId.
     * 
     * @return  with the realmId.
     */

    public String getRealmId() {
        return realmId;
    }

    /**
     * Returns the consumerKey.
     * 
     * @return  with the consumerKey.
     */

    public String getConsumerKey() {
        return consumerKey;
    }

    /**
     * Sets the consumerKey. 
     *
     * @param consumerKey  with the consumerKey.
     */

    public void setConsumerKey(String consumerKey) {
        this.consumerKey = consumerKey;
    }

    /**
     * Returns the consumerSecret.
     * 
     * @return  with the consumerSecret.
     */

    public String getConsumerSecret() {
        return consumerSecret;
    }

    /**
     * Sets the consumerSecret. 
     *
     * @param consumerSecret  with the consumerSecret.
     */

    public void setConsumerSecret(String consumerSecret) {
        this.consumerSecret = consumerSecret;
    }

    private final DatatypeFactory datatypeFactory;
    {
        mom.registerConverter(new Converter() {

            @SuppressWarnings("rawtypes")
            @Override
            public Object convert(Class arg0, Object arg1) {
                Validate.isTrue(arg0 == XMLGregorianCalendar.class);

                if (arg1 instanceof XMLGregorianCalendar) {
                    return arg1;
                }
                return toGregorianCalendar((Date) arg1);
            }
        }, XMLGregorianCalendar.class);
        mom.registerConverter(new Converter() {
            @SuppressWarnings("rawtypes")
            @Override
            public Object convert(Class type, Object value) {
                Validate.isTrue(type == BigDecimal.class);
                return new BigDecimal(value.toString());
            }

        }, BigDecimal.class);
        try {
            datatypeFactory = DatatypeFactory.newInstance();
        } catch (DatatypeConfigurationException e) {
            throw new AssertionError(e);
        }
    }

    private XMLGregorianCalendar toGregorianCalendar(Date openingBalanceDate) {
        GregorianCalendar cal = new GregorianCalendar();
        cal.setTime(openingBalanceDate);
        return datatypeFactory.newXMLGregorianCalendar(cal);
    }

    @SuppressWarnings("unchecked")
    private <T> List<T> coalesceList(List<T> list) {
        return (List<T>) ((list == null) ? Collections.emptyList() : list);
    }

    private Map<String, Object> coalesceMap(Map<String, Object> map) {
        return ((map == null) ? new HashMap<String, Object>() : map);
    }
}