DataService::requestHistoricalExport()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Aosmak\Laravel\Layer\Sdk\Services\Subservices;
4
5
use Aosmak\Laravel\Layer\Sdk\Models\ResponseInterface;
6
use Aosmak\Laravel\Layer\Sdk\Services\Subservices\Interfaces\DataServiceInterface;
7
8
/**
9
 * Class DataService
10
 * @package namespace Aosmak\Laravel\Layer\Sdk\Services\Subservices
11
 */
12
class DataService extends BaseService implements DataServiceInterface
13
{
14
    /**
15
     * Register public key
16
     *
17
     * @param string $key public key
18
     *
19
     * @return \Aosmak\Laravel\Layer\Sdk\Models\ResponseInterface
20
     */
21 2
    public function registerPublicKey(string $key): ResponseInterface
22
    {
23
        $data = [
24 2
            'public_key' => $key
25
        ];
26
27 2
        return $this->getRequestService()
28 2
            ->makePutRequest($this->getRouter()->getShortUrl('export_security'), $data);
29
    }
30
31
    /**
32
     * Get public key
33
     *
34
     * @return \Aosmak\Laravel\Layer\Sdk\Models\ResponseInterface
35
     */
36 2
    public function getPublicKey(): ResponseInterface
37
    {
38 2
        return $this->getRequestService()
39 2
            ->makeGetRequest($this->getRouter()->getShortUrl('export_security'));
40
    }
41
42
    /**
43
     * Request historical export
44
     *
45
     * @return \Aosmak\Laravel\Layer\Sdk\Models\ResponseInterface
46
     */
47 2
    public function requestHistoricalExport(): ResponseInterface
48
    {
49 2
        return $this->getRequestService()
50 2
            ->makePostRequest($this->getRouter()->getShortUrl('exports'));
51
    }
52
53
    /**
54
     * Track export status
55
     *
56
     * @param string $exportId export ID
57
     *
58
     * @return \Aosmak\Laravel\Layer\Sdk\Models\ResponseInterface
59
     */
60 2
    public function trackExportStatus(string $exportId): ResponseInterface
61
    {
62 2
        return $this->getRequestService()
63 2
            ->makeGetRequest($this->getRouter()->getShortUrl('exports', $exportId, 'status'));
64
    }
65
66
    /**
67
     * Get exports
68
     *
69
     * @return \Aosmak\Laravel\Layer\Sdk\Models\ResponseInterface
70
     */
71 2
    public function getExports(): ResponseInterface
72
    {
73 2
        return $this->getRequestService()
74 2
            ->makeGetRequest($this->getRouter()->getShortUrl('exports'));
75
    }
76
77
    /**
78
     * Configure scheduled export
79
     *
80
     * @return \Aosmak\Laravel\Layer\Sdk\Models\ResponseInterface
81
     */
82 2
    public function configureScheduledExport(array $data): ResponseInterface
83
    {
84 2
        return $this->getRequestService()
85 2
            ->makePutRequest($this->getRouter()->getShortUrl('export_schedule'), $data);
86
    }
87
88
    /**
89
     * Get export schedule configuration
90
     *
91
     * @return \Aosmak\Laravel\Layer\Sdk\Models\ResponseInterface
92
     */
93 2
    public function getExportScheduleConfiguration(): ResponseInterface
94
    {
95 2
        return $this->getRequestService()
96 2
            ->makeGetRequest($this->getRouter()->getShortUrl('export_schedule'));
97
    }
98
99
    /**
100
     * Delete export
101
     *
102
     * @param string $exportId export ID
103
     *
104
     * @return \Aosmak\Laravel\Layer\Sdk\Models\ResponseInterface
105
     */
106 2
    public function deleteExport(string $exportId): ResponseInterface
107
    {
108 2
        return $this->getRequestService()
109 2
            ->makeDeleteRequest($this->getRouter()->getShortUrl('exports', $exportId));
110
    }
111
}
112