-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from Talentify/feature/add-delete-method
Feature - Add delete customer method
- Loading branch information
Showing
2 changed files
with
79 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace CIO\Request\Track\Customer; | ||
|
||
use CIO\Entity\Customer\Customer; | ||
use CIO\Entity\EntityInterface; | ||
use CIO\Entity\RequestMethod; | ||
use CIO\Request\Track\TrackBaseRequest; | ||
|
||
class DeleteCustomer extends TrackBaseRequest | ||
{ | ||
/** | ||
* @var \CIO\Entity\Customer\Customer | ||
*/ | ||
private $customer; | ||
|
||
public function __construct(EntityInterface $customer) | ||
{ | ||
assert($customer instanceof Customer); | ||
$this->customer = $customer; | ||
} | ||
|
||
public function getEndpoint() : string | ||
{ | ||
return sprintf('/api/v1/customers/%s', $this->customer->getIdentifier()); | ||
} | ||
|
||
public function getMethod() : RequestMethod | ||
{ | ||
return RequestMethod::DELETE(); | ||
} | ||
|
||
public function getBody() : array | ||
{ | ||
return []; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace CIO\Request\Track\Customer; | ||
|
||
use CIO\CustomerIoClient; | ||
use CIO\Entity\AccountRegion; | ||
use CIO\Entity\Customer\Customer; | ||
use CIO\Entity\Customer\Identifier; | ||
use CIO\Request\Track\Customer\AddOrUpdateCustomer; | ||
use Helpers\RequestTestCase; | ||
use Helpers\TestClient; | ||
|
||
class DeleteCustomerTest extends RequestTestCase | ||
{ | ||
public function testDeleteCustomerRequest() : void | ||
{ | ||
$httpTestClient = new TestClient(); | ||
|
||
$client = new CustomerIoClient( | ||
['token' => 'token'], | ||
AccountRegion::US(), | ||
$httpTestClient | ||
); | ||
|
||
$request = new DeleteCustomer( | ||
new Customer( | ||
new Identifier("123") | ||
) | ||
); | ||
|
||
$client->execute($request); | ||
|
||
$executedRequest = $httpTestClient->getRequestsExecuted()[0]; | ||
|
||
$this->assertEquals('https://track.customer.io/api/v1/customers/123', $executedRequest['uri']); | ||
$this->assertEquals('DELETE', $executedRequest['method']); | ||
} | ||
} |