CallTrackingService::patchCallTracking()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
rs 9.8666
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Yproximite\Api\Service;
5
6
use Yproximite\Api\Model\CallTracking\CallTracking;
7
use Yproximite\Api\Message\CallTracking\CallTrackingPatchMessage;
8
use Yproximite\Api\Message\CallTracking\CallTrackingPostMessage;
9
10
/**
11
 * Class CallTrackingService
12
 */
13 View Code Duplication
class CallTrackingService extends AbstractService implements ServiceInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
14
{
15
    /**
16
     * @param CallTrackingPostMessage $message
17
     *
18
     * @return CallTracking
19
     */
20
    public function postCallTracking(CallTrackingPostMessage $message): CallTracking
21
    {
22
        $path = sprintf('sites/%d/call_trackings', $message->getSiteId());
23
        $data = ['api_call_tracking' => $message->build()];
24
25
        $response = $this->getClient()->sendRequest('POST', $path, $data);
26
27
        /** @var CallTracking $model */
28
        $model = $this->getModelFactory()->create(CallTracking::class, $response);
29
30
        return $model;
31
    }
32
33
    /**
34
     * @param CallTrackingPatchMessage $message
35
     *
36
     * @return CallTracking
37
     */
38
    public function patchCallTracking(CallTrackingPatchMessage $message): CallTracking
39
    {
40
        $path = sprintf('sites/%d/call_trackings/update', $message->getSiteId());
41
        $data = ['api_call_tracking_edit' => $message->build()];
42
43
        $response = $this->getClient()->sendRequest('PATCH', $path, $data);
44
45
        /** @var CallTracking $model */
46
        $model = $this->getModelFactory()->create(CallTracking::class, $response);
47
48
        return $model;
49
    }
50
}
51