-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creating Customer with Conversation or Thread (#120)
* Customer id and email now included in extraction * No longer including empty array values for extracted Customers * Now using generic Customer extraction for easier Customer creation * Updating method name * Added example for how to create a Customer * Removing null values
- Loading branch information
Showing
11 changed files
with
47 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,10 +4,22 @@ | |
|
||
use HelpScout\Api\ApiClientFactory; | ||
use HelpScout\Api\Customers\CustomerFilters; | ||
use HelpScout\Api\Customers\Customer; | ||
use HelpScout\Api\Customers\Entry\Email; | ||
|
||
$client = ApiClientFactory::createClient(); | ||
$client = $client->useClientCredentials($appId, $appSecret); | ||
|
||
// Create Customer | ||
$customer = new Customer(); | ||
$customer->setFirstName('John'); | ||
$customer->setLastName('Smith'); | ||
$customer->addEmail(new Email([ | ||
'email' => "[email protected]", | ||
'type' => 'work', | ||
])); | ||
$client->customers()->create($customer); | ||
|
||
// GET customers | ||
$customer = $client->customers()->get(161694345); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -247,42 +247,51 @@ public function testExtract() | |
$customer->setLocation('US'); | ||
$customer->setOrganization('Sesame Street'); | ||
$customer->setPhotoType('unknown'); | ||
$customer->setPhotoUrl(''); | ||
$customer->setPhotoUrl('https://photos.me'); | ||
$customer->setBackground('Big yellow bird'); | ||
$customer->setAge('52'); | ||
|
||
$this->assertSame([ | ||
'id' => 12, | ||
'firstName' => 'Big', | ||
'lastName' => 'Bird', | ||
'gender' => 'unknown', | ||
'jobTitle' => 'Entertainer', | ||
'location' => 'US', | ||
'organization' => 'Sesame Street', | ||
'photoType' => 'unknown', | ||
'photoUrl' => '', | ||
'photoUrl' => 'https://photos.me', | ||
'background' => 'Big yellow bird', | ||
'age' => '52', | ||
], $customer->extract()); | ||
} | ||
|
||
public function testExtractNewEntity() | ||
/** | ||
* Commonly in v2 of the API we see scenarios where if a "Customer" has an email or id it'll use the existing | ||
* Customer associated with those, otherwise it'll create a new Customer. When extracting a Customer it'll | ||
* most likely be used for Creating something, so including email as a primary attribute this cleaner. | ||
*/ | ||
public function testExtractsEmailAsAttribute() | ||
{ | ||
$customer = new Customer(); | ||
|
||
$this->assertSame([ | ||
'firstName' => null, | ||
'lastName' => null, | ||
'gender' => null, | ||
'jobTitle' => null, | ||
'location' => null, | ||
'organization' => null, | ||
'photoType' => null, | ||
'photoUrl' => null, | ||
'background' => null, | ||
'age' => null, | ||
$email = new Email(); | ||
$email->setValue('[email protected]'); | ||
|
||
$customer->addEmail($email); | ||
|
||
$this->assertArraySubset([ | ||
'email' => '[email protected]', | ||
], $customer->extract()); | ||
} | ||
|
||
public function testExtractNewEntity() | ||
{ | ||
$customer = new Customer(); | ||
|
||
$this->assertSame([], $customer->extract()); | ||
} | ||
|
||
public function testAddChat() | ||
{ | ||
$customer = new Customer(); | ||
|