Passed
Push — master ( be2d4f...7625ce )
by frey
01:09 queued 11s
created

Client::update()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 9
rs 10
cc 1
nc 1
nop 3
1
<?php
2
3
namespace Freyo\ApiGateway\API;
4
5
use Freyo\ApiGateway\Kernel\TencentCloudClient;
6
7
class Client extends TencentCloudClient
8
{
9
    /**
10
     * @return string
11
     */
12
    protected function getBaseUri()
13
    {
14
        return 'https://apigateway.api.qcloud.com/v2/';
15
    }
16
17
    /**
18
     * @param $apiId
19
     * @param $serviceId
20
     *
21
     * @return array|\Freyo\ApiGateway\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
22
     * @throws \Freyo\ApiGateway\Kernel\Exceptions\InvalidConfigException
23
     */
24
    public function get($apiId, $serviceId)
25
    {
26
        $params = [
27
            'Action' => 'DescribeApi',
28
            'serviceId' => $serviceId,
29
            'apiId' => $apiId,
30
        ];
31
32
        return $this->httpPost('index.php', $params);
33
    }
34
35
    /**
36
     * @param $apiId
37
     * @param $serviceId
38
     *
39
     * @return array|\Freyo\ApiGateway\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
40
     * @throws \Freyo\ApiGateway\Kernel\Exceptions\InvalidConfigException
41
     */
42
    public function delete($apiId, $serviceId)
43
    {
44
        $params = [
45
            'Action' => 'DeleteApi',
46
            'serviceId' => $serviceId,
47
            'apiId' => $apiId,
48
        ];
49
50
        return $this->httpPost('index.php', $params);
51
    }
52
53
    /**
54
     * @param $serviceId
55
     * @param $attributes
56
     *
57
     * @return array|\Freyo\ApiGateway\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
58
     * @throws \Freyo\ApiGateway\Kernel\Exceptions\InvalidConfigException
59
     */
60
    public function create($serviceId, array $attributes)
61
    {
62
        $params = [
63
            'Action' => 'CreateApi',
64
            'serviceId' => $serviceId,
65
        ];
66
67
        return $this->httpPost('index.php', $params + $attributes);
68
    }
69
70
    /**
71
     * @param $apiId
72
     * @param $serviceId
73
     * @param $attributes
74
     *
75
     * @return array|\Freyo\ApiGateway\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
76
     * @throws \Freyo\ApiGateway\Kernel\Exceptions\InvalidConfigException
77
     */
78
    public function update($apiId, $serviceId, array $attributes)
79
    {
80
        $params = [
81
            'Action' => 'ModifyApi',
82
            'serviceId' => $serviceId,
83
            'apiId' => $apiId,
84
        ];
85
86
        return $this->httpPost('index.php', $params + $attributes);
87
    }
88
}