Skip to content

Commit ffb5657

Browse files
authored
added changes for getclickwraps method (#103)
1 parent bb7ea1d commit ffb5657

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

src/Controllers/Examples/Click/EG002ActivateClickwrap.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,22 @@ public function __construct()
2020
{
2121
parent::__construct();
2222
# Step 1. Get available inactive clickwraps
23-
$inactiveClickwraps = ActivateClickwrapService::getInactiveClickwraps(
23+
$inactiveClickwraps = ActivateClickwrapService::getClickwrapsByStatus(
2424
$this->routerService,
2525
$this->clientService,
2626
$this->args,
27-
$this::EG
27+
$this::EG,
28+
"inactive"
2829
);
29-
parent::controller(['clickwraps' => $inactiveClickwraps]);
30+
31+
$draftClickwraps = ActivateClickwrapService::getClickwrapsByStatus(
32+
$this->routerService,
33+
$this->clientService,
34+
$this->args,
35+
$this::EG,
36+
"draft"
37+
);
38+
parent::controller(['clickwraps' => array_merge($inactiveClickwraps, $draftClickwraps)]);
3039
}
3140

3241
/**

src/Services/Examples/Click/ActivateClickwrapService.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,19 @@ public static function activateClickwrap(array $args, ClickApiClientService $cli
4141
return $response;
4242
}
4343

44-
public static function getInactiveClickwraps(
44+
public static function getClickwrapsByStatus(
4545
RouterService $routerService,
4646
ClickApiClientService $clientService,
4747
array $args,
48-
string $eg
48+
string $eg,
49+
string $status
4950
): array {
5051
$minimum_buffer_min = 3;
5152
if ($routerService->ds_token_ok($minimum_buffer_min)) {
5253
try {
5354
$apiClient = $clientService->accountsApi();
5455
$options = new GetClickwrapsOptions();
55-
$options -> setStatus('inactive');
56+
$options -> setStatus($status);
5657
return $apiClient->getClickwraps($args['account_id'], $options)['clickwraps'];
5758
} catch (ApiException $e) {
5859
error_log($e);

src/Services/Examples/Click/EmbedClickwrapService.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public static function getClickwraps(
8282
}
8383

8484

85-
return [ $activeClickwraps, $anyClickwraps];
85+
return [ $activeClickwraps, $anyClickwraps];
8686
} catch (ApiException $e) {
8787
error_log($e);
8888
return [];

0 commit comments

Comments
 (0)