Completed
Push — master ( 158640...6228b6 )
by Carlos
02:38 queued 01:15
created

Client::prepare()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 1
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
ccs 0
cts 8
cp 0
crap 2
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\Payment\Redpack;
13
14
use EasyWeChat\Kernel\Support;
15
use EasyWeChat\Payment\Kernel\BaseClient;
16
17
/**
18
 * Class Client.
19
 *
20
 * @author tianyong90 <[email protected]>
21
 */
22
class Client extends BaseClient
23
{
24
    /**
25
     * Query redpack.
26
     *
27
     * @param array $params
28
     *
29
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
30
     */
31 View Code Duplication
    public function info(array $params)
32
    {
33
        $base = [
34
            'appid' => $this->app['config']->app_id,
35
            'bill_type' => 'MCHT',
36
        ];
37
38
        return $this->safeRequest('mmpaymkttransfers/gethbinfo', array_merge($base, $params));
39
    }
40
41
    /**
42
     * Send normal redpack.
43
     *
44
     * @param array $params
45
     *
46
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
47
     */
48
    public function sendNormal(array $params)
49
    {
50
        $base = [
51
            'total_num' => 1,
52
            'client_ip' => $params['client_ip'] ?? Support\get_server_ip(),
53
            'wxappid' => $this->app['config']->app_id,
54
        ];
55
56
        return $this->safeRequest('mmpaymkttransfers/sendredpack', array_merge($base, $params));
57
    }
58
59
    /**
60
     * Send group redpack.
61
     *
62
     * @param array $params
63
     *
64
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
65
     */
66
    public function sendGroup(array $params)
67
    {
68
        $base = [
69
            'amt_type' => 'ALL_RAND',
70
        ];
71
72
        return $this->safeRequest('mmpaymkttransfers/sendgroupredpack', array_merge($base, $params));
73
    }
74
}
75