Ejemplo n.º 1
0
$customer = $client->getCustomer(1);
$customer->setFirstName("John");
$customer->setLastName("Appleseed");
// Update emails. This example can be used for other customer
// entries as well (social profiles, websites, chats, phones)
// ~~~~~
foreach ($customer->getEmails() as $email) {
    if ($email->getValue() === '*****@*****.**') {
        // Update an email
        $email->setValue("*****@*****.**");
    } else {
        if ($email->getValue === '*****@*****.**') {
            // Delete an email be prefixing the id with a minus sign
            $email->setId(-1);
        }
    }
}
// Add a new email
$newEmail = new \HelpScout\model\customer\EmailEntry();
$newEmail->setValue("*****@*****.**");
$newEmail->setLocation("home");
$emails = $customer->getEmails();
$emails[] = $newEmail;
$customer->setEmails($emails);
// Update address
// ~~~~~
$customer->getAddress()->setLines("100 Maple St", "Suite 22");
$customer->getAddress()->setCity("Los Angeles");
$customer->getAddress()->setState("CA");
$customer->getAddress()->setPostalCode("90210");
$client->updateCustomer($customer);
Ejemplo n.º 2
0
 $address->setCountry("US");
 $customer->setAddress($address);
 // Phones
 // ~~~~~
 $phoneWork = new \HelpScout\model\customer\PhoneEntry();
 $phoneWork->setValue("800-555-1212");
 $phoneWork->setLocation("work");
 $phoneHome = new \HelpScout\model\customer\PhoneEntry();
 $phoneHome->setValue("800-123-1234");
 $phoneHome->setLocation("home");
 $customer->setPhones(array($phoneWork, $phoneHome));
 // Emails: at least one email is required
 $emailHome = new \HelpScout\model\customer\EmailEntry();
 $emailHome->setValue("*****@*****.**");
 $emailHome->setLocation("home");
 $emailWork = new \HelpScout\model\customer\EmailEntry();
 $emailWork->setValue("*****@*****.**");
 $emailWork->setLocation("work");
 $customer->setEmails(array($emailWork, $emailHome));
 // Social Profiles
 $facebook = new \HelpScout\model\customer\SocialProfileEntry();
 $facebook->setValue("https://facebook.com/john.appleseed");
 $facebook->setType("facebook");
 $twitter = new \HelpScout\model\customer\SocialProfileEntry();
 $twitter->setValue("https://twitter.com/johnappleseed");
 $twitter->setType("twitter");
 $customer->setSocialProfiles(array($facebook, $twitter));
 // Chats
 // ~~~~~
 $chatAim = new \HelpScout\model\customer\ChatEntry();
 $chatAim->setValue("jappleseed");
$address->setCountry('US');
$customer->setAddress($address);
// Phones
// ~~~~~
$phoneWork = new \HelpScout\model\customer\PhoneEntry();
$phoneWork->setValue('800-555-1212');
$phoneWork->setLocation('work');
$phoneHome = new \HelpScout\model\customer\PhoneEntry();
$phoneHome->setValue('800-123-1234');
$phoneHome->setLocation('home');
$customer->setPhones(array($phoneWork, $phoneHome));
// Emails: at least one email is required
$emailHome = new \HelpScout\model\customer\EmailEntry();
$emailHome->setValue('*****@*****.**');
$emailHome->setLocation('home');
$emailWork = new \HelpScout\model\customer\EmailEntry();
$emailWork->setValue('*****@*****.**');
$emailWork->setLocation('work');
$customer->setEmails(array($emailWork, $emailHome));
// Social Profiles
$facebook = new \HelpScout\model\customer\SocialProfileEntry();
$facebook->setValue('https://facebook.com/john.appleseed');
$facebook->setType('facebook');
$twitter = new \HelpScout\model\customer\SocialProfileEntry();
$twitter->setValue('https://twitter.com/johnappleseed');
$twitter->setType('twitter');
$customer->setSocialProfiles(array($facebook, $twitter));
// Chats
// ~~~~~
$chatAim = new \HelpScout\model\customer\ChatEntry();
$chatAim->setValue('jappleseed');
$client = ApiClient::getInstance();
$client->setKey('example-key');
$customer = $client->getCustomer(1);
$customer->setFirstName('John');
$customer->setLastName('Appleseed');
// Update emails. This example can be used for other customer
// entries as well (social profiles, websites, chats, phones)
// ~~~~~
foreach ($customer->getEmails() as $email) {
    if ($email->getValue() === '*****@*****.**') {
        // Update an email
        $email->setValue('*****@*****.**');
    } elseif ($email->getValue === '*****@*****.**') {
        // Delete an email be prefixing the id with a minus sign
        $email->setId(-1);
    }
}
// Add a new email
$newEmail = new \HelpScout\model\customer\EmailEntry();
$newEmail->setValue('*****@*****.**');
$newEmail->setLocation('home');
$emails = $customer->getEmails();
$emails[] = $newEmail;
$customer->setEmails($emails);
// Update address
// ~~~~~
$customer->getAddress()->setLines('100 Maple St', 'Suite 22');
$customer->getAddress()->setCity('Los Angeles');
$customer->getAddress()->setState('CA');
$customer->getAddress()->setPostalCode('90210');
$client->updateCustomer($customer);