summaryrefslogtreecommitdiff
path: root/app/Model/Webhook.php
blob: 8c270fb63ef81d035b18a7d9abc87b79b362825d (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 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->post($url, $values);
        }
    }
}