summaryrefslogtreecommitdiff
path: root/Postman/notifications/PostmanNotify.php
blob: 365d708e31aa0054d976c6d2803125691f118c66 (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
<?php
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 );
        }
    }
}