summaryrefslogtreecommitdiff
path: root/Postman/notifications/PostmanNotify.php
blob: 7654ecb33ac24678913a369d793c3c960ea88442 (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
37
38
39
40
41
42
<?php
if ( ! defined( 'ABSPATH' ) ) {
    exit; // Exit if accessed directly
}
require_once 'INotify.php';
require_once 'PostmanMailNotify.php';
require_once 'PostmanPushoverNotify.php';
require_once 'PostmanSlackNotify.php';

class PostmanNotify {
    private $notify;

    public function __construct( Postman_Notify $notify ) {
        $this->notify = $notify;
    }

    public function send( $message, $log ) {
        $this->notify->send_message( $message );
    }

    public function push_to_chrome($message) {
        $push_chrome = PostmanOptions::getInstance()->useChromeExtension();

        if ( $push_chrome ) {
            $uid = PostmanOptions::getInstance()->getNotificationChromeUid();

            if ( empty( $uid ) ) {
                return;
            }

            $url = 'https://postmansmtp.com/chrome/' . $uid;

            $args = array(
                'body' => array(
                    'message' => $message
                )
            );

            $response = wp_remote_post( $url , $args );
        }
    }
}