<?php

require_once '../QuickBooks.php';
$Customer = new QuickBooks_Object_Customer();
$Customer->setFullName('web:Keith Palmer');
print 'FullName: ' . $Customer->getFullName() . "\n";
print 'Name: ' . $Customer->getName() . "\n";
print 'Parent: ' . $Customer->getParentName() . "\n";
print "\n";
print $Customer->asQBXML(QUICKBOOKS_ADD_CUSTOMER);
//	desktop editions via the Web Connector)
if ($API->usingRealtime()) {
    print 'Our real-time response from QuickBooks Online Edition was: ';
    print_r($return);
}
exit;
// You can also create QuickBooks_Object_* instances and send them directly to
//	QBOE via the API as show below. The API takes care of transforming those
//	objects to valid qbXML requests for you.
$name = 'Keith Palmer (' . mt_rand() . ')';
$Customer = new QuickBooks_Object_Customer();
$Customer->setName($name);
$Customer->setShipAddress('134 Stonemill Road', '', '', '', '', 'Storrs', 'CT', '', '06268');
// Just a demo showing how to generate the raw qbXML request
print 'Here is the qbXML request we\'re about to send to QuickBooks Online Edition: ' . "\n";
print $Customer->asQBXML('CustomerAdd');
// Send the request to QuickBooks
$API->addCustomer($Customer, '_add_customer_callback', 15);
// This is our callback function, this will get called when the customer is added successfully
function _add_customer_callback($method, $action, $ID, &$err, $qbxml, $Customer, $qbres)
{
    print 'Customer #' . $ID . ' looks like this within QuickBooks Online Edition: ' . "\n";
    print_r($Customer);
}
// Here's a demo of querying for customers with a specific name:
$name = 'Keith Palmer Jr.';
// Here's how to fetch that customer by name
$API->getCustomerByName($name, '_get_customer_callback', 15);
function _get_customer_callback($method, $action, $ID, &$err, $qbxml, $Iterator, $qbres)
{
    print 'This is customer #' . $ID . ' we fetched: ' . "\n";