Client   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 64
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A list() 0 3 1
A delete() 0 7 1
A getDrafts() 0 3 1
A createFromDraft() 0 7 1
1
<?php
2
3
/*
4
 * This file is part of the overtrue/wechat.
5
 *
6
 * (c) overtrue <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace EasyWeChat\OpenPlatform\CodeTemplate;
13
14
use EasyWeChat\Kernel\BaseClient;
15
16
/**
17
 * Class Client.
18
 *
19
 * @author caikeal <[email protected]>
20
 */
21
class Client extends BaseClient
22
{
23
    /**
24
     * 获取草稿箱内的所有临时代码草稿
25
     *
26
     * @return mixed
27
     *
28
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
29
     * @throws \GuzzleHttp\Exception\GuzzleException
30
     */
31 1
    public function getDrafts()
32
    {
33 1
        return $this->httpGet('wxa/gettemplatedraftlist');
34
    }
35
36
    /**
37
     * 将草稿箱的草稿选为小程序代码模版.
38
     *
39
     * @param int $draftId
40
     *
41
     * @return mixed
42
     *
43
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
44
     * @throws \GuzzleHttp\Exception\GuzzleException
45
     */
46 1
    public function createFromDraft(int $draftId)
47
    {
48
        $params = [
49 1
            'draft_id' => $draftId,
50
        ];
51
52 1
        return $this->httpPostJson('wxa/addtotemplate', $params);
53
    }
54
55
    /**
56
     * 获取代码模版库中的所有小程序代码模版.
57
     *
58
     * @return mixed
59
     *
60
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
61
     * @throws \GuzzleHttp\Exception\GuzzleException
62
     */
63 1
    public function list()
64
    {
65 1
        return $this->httpGet('wxa/gettemplatelist');
66
    }
67
68
    /**
69
     * 删除指定小程序代码模版.
70
     *
71
     * @param string $templateId
72
     *
73
     * @return mixed
74
     *
75
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
76
     * @throws \GuzzleHttp\Exception\GuzzleException
77
     */
78 1
    public function delete($templateId)
79
    {
80
        $params = [
81 1
            'template_id' => $templateId,
82
        ];
83
84 1
        return $this->httpPostJson('wxa/deletetemplate', $params);
85
    }
86
}
87