Test Failed
Push — master ( 9974f0...c8f7ff )
by Carlos
03:53
created

Client   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 95
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 95
rs 10
c 0
b 0
f 0
wmc 8

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getWaybill() 0 3 1
A listProviders() 0 3 1
A getBalance() 0 5 1
A deleteWaybill() 0 3 1
A bindPrinter() 0 5 1
A getWaybillTrack() 0 3 1
A createWaybill() 0 3 1
A unbindPrinter() 0 5 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\MiniProgram\Express;
13
14
use EasyWeChat\Kernel\BaseClient;
15
16
/**
17
 * Class Client.
18
 *
19
 * @author kehuanhuan <[email protected]>
20
 */
21
class Client extends BaseClient
22
{
23
    /**
24
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
25
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
26
     */
27
    public function listProviders()
28
    {
29
        return $this->httpGet('cgi-bin/express/business/delivery/getall');
30
    }
31
32
    /**
33
     * @param array $params
34
     *
35
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
36
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
37
     */
38
    public function createWaybill(array $params = [])
39
    {
40
        return $this->httpPostJson('cgi-bin/express/business/order/add', $params);
41
    }
42
43
    /**
44
     * @param array $params
45
     *
46
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
47
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
48
     */
49
    public function deleteWaybill(array $params = [])
50
    {
51
        return $this->httpPostJson('cgi-bin/express/business/order/cancel', $params);
52
    }
53
54
    /**
55
     * @param array $params
56
     *
57
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
58
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
59
     */
60
    public function getWaybill(array $params = [])
61
    {
62
        return $this->httpPostJson('cgi-bin/express/business/order/get', $params);
63
    }
64
65
    /**
66
     * @param array $params
67
     *
68
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
69
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
70
     */
71
    public function getWaybillTrack(array $params = [])
72
    {
73
        return $this->httpPostJson('cgi-bin/express/business/path/get', $params);
74
    }
75
76
    /**
77
     * @param string $deliveryId
78
     * @param string $bizId
79
     *
80
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
81
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
82
     */
83
    public function getBalance(string $deliveryId, string $bizId)
84
    {
85
        return $this->httpPostJson('cgi-bin/express/business/quota/get', [
86
            'delivery_id' => $deliveryId,
87
            'biz_id' => $bizId,
88
        ]);
89
    }
90
91
    /**
92
     * @param string $openid
93
     *
94
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
95
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
96
     */
97
    public function bindPrinter(string $openid)
98
    {
99
        return $this->httpPostJson('cgi-bin/express/business/printer/update', [
100
            'update_type' => 'bind',
101
            'openid' => $openid,
102
        ]);
103
    }
104
105
    /**
106
     * @param string $openid
107
     *
108
     * @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
109
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
110
     */
111
    public function unbindPrinter(string $openid)
112
    {
113
        return $this->httpPostJson('cgi-bin/express/business/printer/update', [
114
            'update_type' => 'unbind',
115
            'openid' => $openid,
116
        ]);
117
    }
118
}
119