Completed
Push — master ( ea387f...58422b )
by Joachim
02:07
created

Plugin::getSiteInfo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 0
cts 11
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 1
crap 2
1
<?php
2
namespace Loevgaard\Dandomain\Api\Endpoint;
3
    
4
use Assert\Assert;
5
    
6
/**
7
 * @see http://4221117.shop53.dandomain.dk/admin/webapi/Endpoints/v1_0/PluginService.svc
8
 */
9
class Plugin extends Endpoint
10
{
11
    /**
12
     * @see https://shoppartner.dandomain.dk/dokumentation/app-developer/
13
     *
14
     * @param int $appId
15
     * @return array
16
     */
17
    public function getSiteInfo(int $appId) : array
18
    {
19
        Assert::that($appId)->greaterThan(0, 'The $appId has to be positive');
20
        return (array)$this->master->doRequest(
21
            'GET',
22
            sprintf(
23
                '/admin/WEBAPI/Endpoints/v1_0/PluginService/{KEY}/SiteInfo/%s',
24
                $appId
25
            )
26
        );
27
    }
28
    
29
    /**
30
     * @see https://shoppartner.dandomain.dk/dokumentation/app-developer/
31
     *
32
     * @param int $appId
33
     * @param array\stdClass $body
34
     * @return array
35
     */
36
    public function updateAppScripts(int $appId, $body) : array
37
    {
38
        Assert::that($appId)->greaterThan(0, 'The $appId has to be positive');
39
        return (array)$this->master->doRequest(
40
            'POST',
41
            sprintf(
42
                '/admin/WEBAPI/Endpoints/v1_0/PluginService/{KEY}/%s/SetAppScript',
43
                $appId
44
            ),
45
            $body
46
        );
47
    }
48
49
    /**
50
     * @see https://shoppartner.dandomain.dk/dokumentation/app-developer/
51
     *
52
     * @param int $appId
53
     * @param int $pageType
54
     * @return boolean
55
     */
56
    public function deleteAppScripts(int $appId, int $pageType) : bool
57
    {
58
        Assert::that($appId)->greaterThan(0, 'The $appId has to be positive');
59
        return (bool)$this->master->doRequest(
60
            'DELETE',
61
            sprintf(
62
                '/admin/WEBAPI/Endpoints/v1_0/PluginService/{KEY}/DeleteAppScriptForPage?appId=%s&pageType=%s',
63
                $appId,
64
                $pageType
65
            )
66
        );
67
    }
68
}
69