Completed
Pull Request — master (#1003)
by Keal
01:55
created

Client   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 1
dl 0
loc 54
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getDrafts() 0 4 1
A createFromDraft() 0 8 1
A list() 0 4 1
A delete() 0 8 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
    public function getDrafts()
29
    {
30
        return $this->httpGet('wxa/gettemplatedraftlist');
31
    }
32
33
    /**
34
     * 将草稿箱的草稿选为小程序代码模版.
35
     *
36
     * @param int $draftId
37
     *
38
     * @return mixed
39
     */
40
    public function createFromDraft(int $draftId)
41
    {
42
        $params = [
43
            'draft_id' => $draftId,
44
        ];
45
46
        return $this->httpPostJson('wxa/addtotemplate', $params);
47
    }
48
49
    /**
50
     * 获取代码模版库中的所有小程序代码模版.
51
     *
52
     * @return mixed
53
     */
54
    public function list()
55
    {
56
        return $this->httpGet('wxa/gettemplatelist');
57
    }
58
59
    /**
60
     * 删除指定小程序代码模版.
61
     *
62
     * @param $templateId
63
     *
64
     * @return mixed
65
     */
66
    public function delete($templateId)
67
    {
68
        $params = [
69
            'template_id' => $templateId,
70
        ];
71
72
        return $this->httpPostJson('wxa/deletetemplate', $params);
73
    }
74
}
75