Completed
Push — master ( 22e19d...e5f34e )
by Claude
07:09
created

ExternalEvents::asyncTrigger()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 2
crap 2
1
<?php
2
3
/*
4
 * A php library for using the Emarsys API.
5
 *
6
 * @link      https://github.com/ck-developer/emarsys-php-client
7
 * @package   authy
8
 * @license   MIT
9
 * @copyright Copyright (c) 2017 Claude Khedhiri <[email protected]>
10
 */
11
12
namespace Emarsys\Api;
13
14
use Http\Promise\Promise;
15
use Psr\Http\Message\ResponseInterface;
16
17
/**
18
 * Class Events
19
 *
20
 * @author Claude Khedhiri <[email protected]>
21
 */
22
class ExternalEvents extends AbstractApi
23
{
24
    /**
25
     * @param $eventId
26
     *
27
     * @return ResponseInterface
28
     */
29
    public function create($eventId)
30
    {
31
        return $this->sendRequest($this->createCreateRequest($eventId));
32
    }
33
34
    /**
35
     * @param $eventId
36
     *
37
     * @return Promise
38
     */
39
    public function asyncCreate($eventId)
40
    {
41
        return $this->sendAsyncRequest($this->createCreateRequest($eventId));
42
    }
43
44
    /**
45
     * @param int $eventId
46
     * @param array $data
47
     *
48
     * @return \Psr\Http\Message\RequestInterface
49
     */
50
    private function createCreateRequest($eventId, $data = array())
51
    {
52
        return $this->createRequest('POST', "/event/$eventId/trigger", $data);
53
    }
54
55
    /**
56
     * @param int $eventId
57
     * @param array $data
58
     *
59
     * @return ResponseInterface
60
     */
61
    public function trigger($eventId, $data = array())
62
    {
63
        return $this->sendRequest($this->createTriggerRequest($eventId, $data));
64
    }
65
66
    /**
67
     * @param int $eventId
68
     * @param array $data
69
     *
70
     * @return Promise
71
     */
72
    public function asyncTrigger($eventId, $data = array())
73
    {
74
        return $this->sendAsyncRequest($this->createTriggerRequest($eventId, $data));
75
    }
76
77
    /**
78
     * @param int $eventId
79
     * @param array $data
80
     *
81
     * @return \Psr\Http\Message\RequestInterface
82
     */
83
    private function createTriggerRequest($eventId, $data = array())
84
    {
85
        return $this->createRequest('POST', "/event/$eventId/trigger", $data);
86
    }
87
}
88