Skip to content

Commit 3963d45

Browse files
authored
Merge pull request #10 from complycube/rc/1.1.6
Rc/1.1.6
2 parents a170c56 + ca375d7 commit 3963d45

17 files changed

Lines changed: 952 additions & 470 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ coverage_html
1414

1515
# PHPUnit
1616
.phpunit.cache
17+
.phpunit.result.cache
1718

1819
# Build data
1920
/build/

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.1.5
1+
1.1.6

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"php": ">=7.4",
2121
"caseyamcl/guzzle_retry_middleware": "^2.8.0",
2222
"guzzlehttp/guzzle": "^7.5.0",
23-
"nesbot/carbon": "^2.72.6"
23+
"nesbot/carbon": "^3.8.4"
2424
},
2525
"require-dev": {
2626
"friendsofphp/php-cs-fixer": "^3.16.0",

composer.lock

Lines changed: 701 additions & 440 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/ApiClient.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
class ApiClient
1616
{
17-
/** @var integer */
18-
const VERSION = '1.1.5';
17+
/** @var string */
18+
const VERSION = '1.1.6';
1919

2020
/** @var string ComplyCube API key from developer dashboard */
2121
private string $apiKey;
@@ -26,10 +26,16 @@ class ApiClient
2626
/** @var ClientInterface Guzzle Http Client used to make requests */
2727
public ?ClientInterface $httpClient;
2828

29-
public static function randomJitter($numRequests, $response): float
29+
public static function randomJitter(int $numRequests, mixed $response): float
3030
{
31-
return (float) rand(0, $numRequests ** 1.5);
31+
if ($numRequests <= 0) {
32+
return 0.0;
33+
}
34+
$max = (int) ceil($numRequests ** 1.5);
35+
$max = max(1, $max);
36+
return (float) random_int(0, $max);
3237
}
38+
3339
/**
3440
* Create instance of ComplyCube API client
3541
*

lib/ComplyCubeClient.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use ComplyCube\Resources\TeamMemberApi;
2020
use ComplyCube\Resources\TokenApi;
2121
use ComplyCube\Resources\WebhookApi;
22+
use ComplyCube\Resources\WorkflowSessionApi;
2223

2324
class ComplyCubeClient
2425
{
@@ -39,6 +40,7 @@ class ComplyCubeClient
3940
private ?FlowSessionApi $flowSessionApi;
4041
private ?CompanyApi $companyApi;
4142
private ?CustomListApi $customListApi;
43+
private ?WorkflowSessionApi $workflowSessionApi;
4244

4345
/**
4446
* Create a ComplyCubeClient API Client Instance for the provided
@@ -293,4 +295,17 @@ public function customLists(): CustomListApi
293295
}
294296
return $this->customListApi;
295297
}
298+
299+
/**
300+
* The workflow sessions API allows you to run and retrieve workflow sessions. You can retrieve a specific workflow sessions as well as a list of all your client's workflow sessions.
301+
*
302+
* @return WorkflowSessionApi
303+
*/
304+
public function workflowSessions(): WorkflowSessionApi
305+
{
306+
if (empty($this->workflowSessionApi)) {
307+
$this->workflowSessionApi = new WorkflowSessionApi($this->apiClient);
308+
}
309+
return $this->workflowSessionApi;
310+
}
296311
}

lib/Model/ComplyCubeCollection.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@
33
namespace ComplyCube\Model;
44

55
use Iterator;
6+
use Countable;
67
use stdClass;
78

8-
class ComplyCubeCollection extends Model implements Iterator
9+
class ComplyCubeCollection extends Model implements Iterator, Countable
910
{
1011
public int $page;
1112
public int $pageSize;
1213
public int $totalItems;
1314
public int $pages;
14-
public ?array $items;
15+
public ?array $items = null;
1516
private int $position;
1617
private string $model;
1718

@@ -38,7 +39,8 @@ public function load(stdClass $response): void
3839
? $response->pages
3940
: 0;
4041

41-
if (property_exists($response, "items")) {
42+
if (property_exists($response, "items") && is_iterable($response->items)) {
43+
$this->items = [];
4244
foreach ($response->items as $item) {
4345
$this->items[] = new $this->model($item);
4446
}
@@ -49,6 +51,11 @@ public function load(stdClass $response): void
4951
$this->rewind();
5052
}
5153

54+
public function count(): int
55+
{
56+
return is_array($this->items) ? count($this->items) : 0;
57+
}
58+
5259
public function jsonSerialize(): mixed
5360
{
5461
return array_filter(

lib/Model/FlowSession.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ class FlowSession extends Model
88
{
99
public ?string $clientId;
1010
public ?array $checkTypes;
11+
public ?string $workflowTemplateId;
1112
public ?string $successUrl;
1213
public ?string $cancelUrl;
1314
public ?bool $enableMonitoring;
1415
public ?string $language;
1516
public ?string $theme;
1617
public ?string $redirectUrl;
18+
public ?bool $shortUrl;
1719

1820
public function load(stdClass $response): void
1921
{

lib/Model/WorkflowSession.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace ComplyCube\Model;
4+
5+
use stdClass;
6+
7+
class WorkflowSession extends Model
8+
{
9+
public ?string $id;
10+
public ?string $clientId;
11+
public ?string $entityName;
12+
public ?string $status;
13+
public ?bool $workflowTemplateId;
14+
public ?string $workflowTemplateName;
15+
public ?string $workflowTemplateDescription;
16+
public ?string $workflowId;
17+
public ?int $workflowVersion;
18+
public ?string $workflowDescription;
19+
public ?array $compliancePolicies;
20+
public ?string $outcome;
21+
public ?array $allRelatedChecks;
22+
public ?array $policyAssurance;
23+
public ?array $tasks;
24+
public ?string $lastCompletedTaskId;
25+
public ?string $createdAt;
26+
public ?string $completedAt;
27+
public ?string $updatedAt;
28+
29+
public function load(stdClass $response): void
30+
{
31+
parent::load($response);
32+
}
33+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace ComplyCube\Resources;
4+
5+
use ComplyCube\ApiClient;
6+
use ComplyCube\ApiResource;
7+
use ComplyCube\ResourceActions\GetResource;
8+
use ComplyCube\ResourceActions\ListResource;
9+
10+
class WorkflowSessionApi extends ApiResource
11+
{
12+
const ENDPOINT = "workflowSessions";
13+
14+
use GetResource,
15+
ListResource;
16+
17+
public function __construct(ApiClient $apiClient)
18+
{
19+
parent::__construct($apiClient, "\ComplyCube\Model\WorkflowSession");
20+
}
21+
22+
/**
23+
* Complete the workflow session.
24+
*
25+
* @param string $workflowSessionId being completed.
26+
*/
27+
public function complete(string $workflowSessionId)
28+
{
29+
$response = $this->apiClient->post(
30+
$this::ENDPOINT . "/" . $workflowSessionId . "/complete",
31+
[]
32+
);
33+
return $response;
34+
}
35+
}

0 commit comments

Comments
 (0)