Test Failed
Push — master ( db9bda...7e2f15 )
by James
05:19
created

MessagingService::getService()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: james
5
 * Date: 26/07/2018
6
 * Time: 15:57
7
 */
8
9
namespace CwsOps\LivePerson\Services;
10
11
/**
12
 * Class MessagingService
13
 * @package CwsOps\LivePerson\Services
14
 * @author James Parker <[email protected]>
15
 */
16
class MessagingService extends AbstractService
17
{
18
19
    /**
20
     * Retrieves engagement activity-related metrics at the account, skill, or agent level
21
     * @see https://developers.liveperson.com/data-messaging-operations-messaging-conversation.html
22
     *
23
     * @param int $timeFrame The time range in minutes max value is 1440 minutes (24 hours)
24
     * @param array $agents an array of agents to get data for, this can be left empty to return data for all agents
25
     * @param array $skillIds an array of skills to filter by, this can be left empty to get data for all skills.
26
     * @param int|null $interval the interval to filter at.
27
     *
28
     * @throws \CwsOps\LivePerson\Rest\BuilderLockedException
29
     */
30
    public function conversation(int $timeFrame = 60, array $agents = [], array $skillIds = [], int $interval = null)
31
    {
32
        $this->urlBuilder = $this->request->buildUrl($this->getDomain())
33
            ->setService($this->getService())
34
            ->setAccount($this->config->getAccountId())
35
            ->setAction('msgconversation')
36
            ->hasQueryParam(true)
37
            ->addQueryParam('timeframe', $timeFrame);
38
39
40
        if (0 !== count($agents)) {
41
            $this->urlBuilder->addQueryParam('agentIds', $this->arrayToList($agents));
42
43
        } else {
44
            $this->urlBuilder->addQueryParam('agentIds', 'all');
45
        }
46
47
        if (0 !== count($skillIds)) {
48
            $this->urlBuilder->addQueryParam('skillIds', $this->arrayToList($skillIds));
49
        } else {
50
            $this->urlBuilder->addQueryParam('skillsIds', 'all');
51
        }
52
53
54
        if (null !== $interval) {
55
            $this->urlBuilder->addQueryParam('interval', $interval);
56
        }
57
58
        $payload = [];
59
60
        $this->urlBuilder->build();
61
62
        $this->handle($payload);
63
    }
64
65
66
    /**
67
     * Should provide the Live person domain id, this service will query against
68
     *
69
     * @return string
70
     */
71
    protected function getDomain(): string
72
    {
73
        return 'leDataReporting';
74
    }
75
76
    /**
77
     * Should provide the Live Person service the service will query against.
78
     *
79
     * @return string
80
     */
81
    protected function getService(): string
82
    {
83
        return 'operations';
84
    }
85
}