GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( bf3942...03b34a )
by Andre
03:54
created

ContactApi   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 120
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 2
Metric Value
eloc 22
c 3
b 0
f 2
dl 0
loc 120
rs 10
wmc 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 3 1
A updateListStatus() 0 3 1
A delete() 0 3 1
A update() 0 3 1
A upsert() 0 3 1
A listPerPage() 0 11 1
A __construct() 0 8 1
A all() 0 4 1
A create() 0 3 1
A tagContact() 0 3 1
1
<?php
2
declare(strict_types=1);
3
/**
4
 */
5
6
namespace CommerceLeague\ActiveCampaignApi\Api;
7
8
use CommerceLeague\ActiveCampaignApi\Client\CommonResourceClientInterface;
9
use CommerceLeague\ActiveCampaignApi\Paginator\PageFactoryInterface;
10
use CommerceLeague\ActiveCampaignApi\Paginator\PageInterface;
11
use CommerceLeague\ActiveCampaignApi\Paginator\ResourceCursorFactoryInterface;
12
use CommerceLeague\ActiveCampaignApi\Paginator\ResourceCursorInterface;
13
14
/**
15
 * Class ContactApi
16
 */
17
class ContactApi implements ContactApiResourceInterface
18
{
19
20
    /**
21
     * @var CommonResourceClientInterface
22
     */
23
    private $resourceClient;
24
25
    /**
26
     * @var PageFactoryInterface
27
     */
28
    private $pageFactory;
29
30
    /**
31
     * @var ResourceCursorFactoryInterface
32
     */
33
    private $cursorFactory;
34
35
    /**
36
     * @param CommonResourceClientInterface  $resourceClient
37
     * @param PageFactoryInterface           $pageFactory
38
     * @param ResourceCursorFactoryInterface $cursorFactory
39
     */
40
    public function __construct(
41
        CommonResourceClientInterface $resourceClient,
42
        PageFactoryInterface $pageFactory,
43
        ResourceCursorFactoryInterface $cursorFactory
44
    ) {
45
        $this->resourceClient = $resourceClient;
46
        $this->pageFactory    = $pageFactory;
47
        $this->cursorFactory  = $cursorFactory;
48
    }
49
50
    /**
51
     * @inheritDoc
52
     */
53
    public function get(int $id): array
54
    {
55
        return $this->resourceClient->getResource('api/3/contacts/%s', [$id]);
56
    }
57
58
    /**
59
     * @inheritDoc
60
     */
61
    public function listPerPage(int $limit = 100, int $offset = 0, array $queryParameters = []): PageInterface
62
    {
63
        $response = $this->resourceClient->getResources(
64
            'api/3/contacts',
65
            [],
66
            $limit,
67
            $offset,
68
            $queryParameters
69
        );
70
71
        return $this->pageFactory->createPage($this, $response['contacts'], $response['meta']);
72
    }
73
74
    /**
75
     * @inheritDoc
76
     */
77
    public function all(int $limit = 100, array $queryParameters = []): ResourceCursorInterface
78
    {
79
        $firstPage = $this->listPerPage($limit, 0, $queryParameters);
80
        return $this->cursorFactory->createCursor($limit, $firstPage);
81
    }
82
83
    /**
84
     * @inheritDoc
85
     */
86
    public function create(array $data): array
87
    {
88
        return $this->resourceClient->createResource('api/3/contacts', [], $data);
89
    }
90
91
    /**
92
     * @inheritDoc
93
     */
94
    public function update(int $id, array $data = []): array
95
    {
96
        return $this->resourceClient->updateResource('api/3/contacts/%s', [$id], $data);
97
    }
98
99
    /**
100
     * @inheritDoc
101
     */
102
    public function upsert(array $data = []): array
103
    {
104
        return $this->resourceClient->upsertResource('api/3/contact/sync', [], $data);
105
    }
106
107
    /**
108
     * @inheritDoc
109
     */
110
    public function delete(int $id): bool
111
    {
112
        return $this->resourceClient->deleteResource('api/3/contacts/%s', [$id]);
113
    }
114
115
    /**
116
     * Update list status for a contact
117
     *
118
     * @param array $data
119
     *
120
     * @return array
121
     */
122
    public function updateListStatus(array $data): array
123
    {
124
        return $this->resourceClient->createResource('api/3/contactList', [], $data);
125
    }
126
127
    /**
128
     * Add a Tag to a contact
129
     *
130
     * @param array $data
131
     *
132
     * @return array
133
     */
134
    public function tagContact(array $data): array
135
    {
136
        return $this->resourceClient->createResource('api/3/contactTags', [], $data);
137
    }
138
}
139