summaryrefslogtreecommitdiff
path: root/app/Model/Webhook.php
blob: dd277bf8da92e204311969f2e22d7f314c5bfaf2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php

namespace Kanboard\Model;

/**
 * Webhook model
 *
 * @package  model
 * @author   Frederic Guillot
 */
class Webhook extends Base
{
    /**
     * Call the external URL
     *
     * @access public
     * @param  array    $values   Event payload
     */
    public function notify(array $values)
    {
        $url = $this->config->get('webhook_url');
        $token = $this->config->get('webhook_token');

        if (! empty($url)) {

            if (strpos($url, '?') !== false) {
                $url .= '&token='.$token;
            }
            else {
                $url .= '?token='.$token;
            }

            return $this->httpClient->postJson($url, $values);
        }
    }
}