Test Setup Failed
Pull Request — master (#1764)
by
unknown
02:37
created

Client   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 37
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A get() 0 24 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\Fundflow;
13
14
use EasyWeChat\Kernel\Http\StreamResponse;
15
use EasyWeChat\Payment\Kernel\BaseClient;
16
17
class Client extends BaseClient
18
{
19
    /**
20
     * Download fundflow history as a table file
21
     *
22
     * @param string $date
23
     * @param string $type
24
     * @param array $options
25
     * @return array|\EasyWeChat\Kernel\Http\Response|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
26
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
27
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
28
     * @throws \GuzzleHttp\Exception\GuzzleException
29
     */
30
    public function get(string $date, string $type = 'Basic', $options = [])
31
    {
32
33
        $params   = [
34
            'appid' => $this->app['config']->app_id,
35
            'bill_date' => $date,
36
            'account_type' => $type,
37
            'sign_type' => 'HMAC-SHA256',
38
            'nonce_str' => uniqid('micro'),
39
        ];
40
        $options  = array_merge(
41
            [
42
                'cert' => $this->app['config']->get('cert_path'),
43
                'ssl_key' => $this->app['config']->get('key_path'),
44
            ],
45
            $options
46
        );
47
        $response = $this->requestRaw('pay/downloadfundflow', $params, 'post', $options);
48
49
        if (0 === strpos($response->getBody()->getContents(), '<xml>')) {
50
            return $this->castResponseToType($response, $this->app['config']->get('response_type'));
51
        }
52
53
        return StreamResponse::buildFromPsrResponse($response);
54
    }
55
}
56