summaryrefslogtreecommitdiff
path: root/app/Model/Webhook.php
blob: 7c17e61e602d67cd639a801db6790b51f6915047 (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
<?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);
        }
    }
}