implement TwingleSync.singlesync

This commit is contained in:
Marc Michalsky forumZFD 2020-12-10 15:20:29 +01:00
parent 8ed58aa625
commit 12b941e01d
Signed by untrusted user who does not match committer: marc.koch
GPG key ID: 12406554CFB028B9
3 changed files with 155 additions and 18 deletions

View file

@ -25,7 +25,7 @@ class CRM_TwingleCampaign_BAO_TwingleApiCall {
*
* @throws API_Exception
*/
public function __construct($apiKey, int $limit = 20) {
public function __construct($apiKey, int $limit) {
$this->apiKey = $apiKey;
$this->limit = $limit;
@ -116,7 +116,7 @@ class CRM_TwingleCampaign_BAO_TwingleApiCall {
*
* @return array
*/
public function getEvent(int $projectId, $eventId = NULL) {
public function getEvent($projectId, $eventId = NULL) {
$result = [];
$url = empty($eventId)
@ -140,9 +140,12 @@ class CRM_TwingleCampaign_BAO_TwingleApiCall {
$response = $this->curlGet($url, $params);
$finished = ($eventId) || count($response['data']) < $this->limit;
$offset = $offset + $this->limit;
if ($response['data']) {
if ($response['data'] && !$eventId) {
$result = array_merge($result, $response['data']);
}
else {
$result = $response;
}
}
return $result;
}