-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Related work items: #211425, #229536, #229740, #229910, #231234, #231346
- Loading branch information
Showing
19 changed files
with
421 additions
and
261 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
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 |
---|---|---|
|
@@ -13,7 +13,8 @@ class ResponseMediator | |
private static $passableStatusCodes = [ | ||
200, | ||
201, | ||
202 | ||
202, | ||
204 | ||
]; | ||
|
||
/** | ||
|
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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Dotdigital\V3\Models; | ||
|
||
use Dotdigital\V3\Models\InsightData\Record; | ||
use Dotdigital\V3\Models\InsightData\RecordsCollection; | ||
|
||
class InsightData extends AbstractSingletonModel | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected string $collectionName; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected string $collectionScope; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected string $collectionType; | ||
|
||
/** | ||
* @var RecordsCollection | ||
*/ | ||
protected RecordsCollection $records; | ||
|
||
/** | ||
* @param $data | ||
* @return void | ||
* @throws \Exception | ||
*/ | ||
public function setRecords($data) | ||
{ | ||
$recordsCollection = new RecordsCollection(); | ||
foreach ($data as $array) { | ||
$record = new Record($array); | ||
$recordsCollection->add($record); | ||
} | ||
$this->records = $recordsCollection; | ||
} | ||
} |
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,18 @@ | ||
<?php | ||
|
||
namespace Dotdigital\V3\Models\InsightData; | ||
|
||
use Dotdigital\V3\Models\AbstractSingletonModel; | ||
|
||
class ContactIdentity extends AbstractSingletonModel | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected string $identifier; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected string $value; | ||
} |
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,34 @@ | ||
<?php | ||
|
||
namespace Dotdigital\V3\Models\InsightData; | ||
|
||
use Dotdigital\V3\Models\AbstractSingletonModel; | ||
use Dotdigital\V3\Models\InsightData\ContactIdentity; | ||
|
||
class Record extends AbstractSingletonModel | ||
{ | ||
/** | ||
* @var ContactIdentity|null | ||
*/ | ||
protected ?ContactIdentity $contactIdentity; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected string $key; | ||
|
||
/** | ||
* @var array | ||
*/ | ||
protected array $json; | ||
|
||
/** | ||
* @param array $data | ||
* @return void | ||
* @throws \Exception | ||
*/ | ||
public function setContactIdentity(array $data) | ||
{ | ||
$this->contactIdentity = new ContactIdentity($data); | ||
} | ||
} |
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,9 @@ | ||
<?php | ||
|
||
namespace Dotdigital\V3\Models\InsightData; | ||
|
||
use Dotdigital\V3\Models\Collection; | ||
|
||
class RecordsCollection extends Collection | ||
{ | ||
} |
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,54 @@ | ||
<?php | ||
|
||
namespace Dotdigital\V3\Resources; | ||
|
||
use Dotdigital\Exception\ResponseValidationException; | ||
use Dotdigital\Resources\AbstractResource; | ||
use Dotdigital\V3\Models\AbstractSingletonModel; | ||
use Dotdigital\V3\Models\InsightData as InsightDataModel; | ||
use Http\Client\Exception; | ||
|
||
class InsightData extends AbstractResource | ||
{ | ||
public const RESOURCE_BASE = '/insightData/v3'; | ||
|
||
/** | ||
* @param InsightDataModel $insightData | ||
* @return string | ||
* @throws \Dotdigital\Exception\ResponseValidationException | ||
* @throws \Http\Client\Exception | ||
*/ | ||
public function import(InsightDataModel $insightData): string | ||
{ | ||
return $this->put( | ||
sprintf('%s/%s', self::RESOURCE_BASE, 'import'), | ||
json_decode(json_encode($insightData), true) | ||
); | ||
} | ||
|
||
/** | ||
* @param string $collectionName | ||
* @param string $recordId | ||
* @param array $insightData | ||
* | ||
* @return string | ||
* @throws ResponseValidationException | ||
* @throws Exception | ||
*/ | ||
public function createOrUpdateAccountCollectionRecord( | ||
string $collectionName, | ||
string $recordId, | ||
array $insightData | ||
): string { | ||
return $this->put( | ||
sprintf( | ||
'%s/%s/%s/%s/', | ||
self::RESOURCE_BASE, | ||
'account', | ||
$collectionName, | ||
$recordId | ||
), | ||
$insightData | ||
); | ||
} | ||
} |
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
Oops, something went wrong.