Completed
Push — master ( aaae62...4e6ad6 )
by Carlos
01:44
created

Client::getTemplates()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
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\MiniProgram\TemplateMessage;
13
14
use EasyWeChat\OfficialAccount\TemplateMessage\Client as BaseClient;
15
16
/**
17
 * Class Client.
18
 *
19
 * @author mingyoung <[email protected]>
20
 */
21
class Client extends BaseClient
22
{
23
    const API_SEND = 'cgi-bin/message/wxopen/template/send';
24
25
    /**
26
     * {@inheritdoc}.
27
     */
28
    protected $message = [
29
        'touser' => '',
30
        'template_id' => '',
31
        'page' => '',
32
        'form_id' => '',
33
        'data' => [],
34
        'emphasis_keyword' => '',
35
    ];
36
37
    /**
38
     * {@inheritdoc}.
39
     */
40
    protected $required = ['touser', 'template_id', 'form_id'];
41
42
    /**
43
     * @param int $offset
44
     * @param int $count
45
     *
46
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
47
     */
48
    public function list(int $offset, int $count)
49
    {
50
        return $this->httpPostJson('cgi-bin/wxopen/template/library/list', compact('offset', 'count'));
51
    }
52
53
    /**
54
     * @param string $id
55
     *
56
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
57
     */
58
    public function get(string $id)
59
    {
60
        return $this->httpPostJson('cgi-bin/wxopen/template/library/get', compact('id'));
61
    }
62
63
    /**
64
     * @param string $id
65
     * @param array  $keyword
66
     *
67
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
68
     */
69
    public function add(string $id, array $keyword)
70
    {
71
        return $this->httpPostJson('cgi-bin/wxopen/template/add', [
72
            'id' => $id,
73
            'keyword_id_list' => $keyword,
74
        ]);
75
    }
76
77
    /**
78
     * @param string $templateId
79
     *
80
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
81
     */
82
    public function delete(string $templateId)
83
    {
84
        return $this->httpPostJson('cgi-bin/wxopen/template/del', [
85
            'template_id' => $templateId,
86
        ]);
87
    }
88
89
    /**
90
     * @param int $offset
91
     * @param int $count
92
     *
93
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
94
     */
95
    public function getTemplates(int $offset, int $count)
96
    {
97
        return $this->httpPostJson('cgi-bin/wxopen/template/list', compact('offset', 'count'));
98
    }
99
}
100