ContactLists::createAddContactsRequest()   A
last analyzed

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/quitoque/emarsys-php-client
7
 * @package   emarsys-php-client
8
 * @license   MIT
9
 * @copyright Copyright (c) 2017 Quitoque <[email protected]>
10
 */
11
12
namespace Emarsys\Api;
13
14
use Http\Promise\Promise;
15
use Psr\Http\Message\ResponseInterface;
16
17
/**
18
 * Class ContactLists.
19
 *
20
 * @author Claude Khedhiri <[email protected]>
21
 */
22
class ContactLists extends AbstractApi
23
{
24
    /**
25
     * @param string $listId
26
     * @param array  $contacts
27
     *
28
     * @return ResponseInterface
29
     */
30
    public function addContacts($listId, $contacts)
31
    {
32
        return $this->sendRequest($this->createAddContactsRequest($listId, $contacts));
33
    }
34
35
    /**
36
     * @param string $listId
37
     * @param array  $contacts
38
     *
39
     * @return Promise
40
     */
41
    public function asyncAll($listId, $contacts)
42
    {
43
        return $this->sendAsyncRequest($this->createAddContactsRequest($listId, $contacts));
44
    }
45
46
    /**
47
     * @param string $listId
48
     * @param array  $contacts
49
     *
50
     * @return \Psr\Http\Message\RequestInterface
51
     */
52
    private function createAddContactsRequest($listId, $contacts)
53
    {
54
        return $this->createRequest('POST', "/contactlist/$listId/", $contacts);
55
    }
56
}
57