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

namespace Model;

/**
 * Webhook model
 *
 * @package  model
 * @author   Frederic Guillot
 */
class Webhook extends Base
{
    /**
     * Call the external URL
     *
     * @access public
     * @param  string   $url    URL to call
     * @param  array    $task   Task data
     */
    public function notify($url, array $task)
    {
        $token = $this->config->get('webhook_token');

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

        return $this->httpClient->post($url, $task);
    }
}