Skip to content

Commit 15785ad

Browse files
committed
Further examples with webhooks
1 parent 3d0cb0a commit 15785ad

File tree

3 files changed

+89
-0
lines changed

3 files changed

+89
-0
lines changed

examples/get_webhook.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
namespace Webhooks\Wrapper;
3+
4+
use http\Exception\RuntimeException;
5+
6+
set_include_path('..');
7+
8+
require "vendor/autoload.php";
9+
10+
require ".config";
11+
12+
$client = new Trello\Client();
13+
$client->authenticate($key, $token, Trello\Client::AUTH_URL_CLIENT_ID);
14+
15+
$trello = new Trello($client);
16+
17+
$webhook = new Webhook($trello);
18+
$webhook->setToken($getWebhookToken);
19+
20+
$webhook->pullFromService();
21+
22+
$webhook->setService(null);
23+
print_r($webhook);

examples/run_webhook.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?php
2+
namespace Webhooks\Wrapper;
3+
4+
use http\Exception\RuntimeException;
5+
6+
set_include_path('..');
7+
8+
require "vendor/autoload.php";
9+
10+
require ".config";
11+
12+
$client = new Trello\Client();
13+
$client->authenticate($key, $token, Trello\Client::AUTH_URL_CLIENT_ID);
14+
15+
$trello = new Trello($client);
16+
17+
$webhook = new Webhook($trello);
18+
$webhook->setModel($updateWebhookModelId);
19+
20+
$action = new Action("action_move_card_from_list_to_list");
21+
$action->setName('Returns the string \'Executed\'');
22+
$action->addArgument('return', 'Executed');
23+
$action->setFunction(function($return, $data, $action) {
24+
print_r($data);
25+
if ($action->getWebhook()->getModel() == $data->listBefore->id) {
26+
return 'Moved away';
27+
}
28+
if ($action->getWebhook()->getModel() == $data->listAfter->id) {
29+
return 'Moved here';
30+
}
31+
return $return;
32+
});
33+
34+
$webhook->setAction($action);
35+
36+
echo $webhook->run($runWebhookJson);

examples/update_webhook.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
namespace Webhooks\Wrapper;
3+
4+
use http\Exception\RuntimeException;
5+
6+
set_include_path('..');
7+
8+
require "vendor/autoload.php";
9+
10+
require ".config";
11+
12+
$client = new Trello\Client();
13+
$client->authenticate($key, $token, Trello\Client::AUTH_URL_CLIENT_ID);
14+
15+
$trello = new Trello($client);
16+
17+
$webhook = new Webhook($trello);
18+
$webhook->setToken($getWebhookToken);
19+
20+
$webhook->pullFromService();
21+
22+
$webhook->setUrl($updateWebhookNewUrl . $webhook->getId());
23+
$webhook->setModel($updateWebhookModelId);
24+
25+
$webhook->pushToService();
26+
27+
$webhook->pullFromService();
28+
29+
$webhook->setService(null);
30+
print_r($webhook);

0 commit comments

Comments
 (0)