Completed
Push — master ( e11452...671033 )
by Carlos
03:12
created

Client::session()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 8
ccs 4
cts 4
cp 1
crap 1
rs 10
c 1
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\OpenWork\MiniProgram;
13
14
use EasyWeChat\Kernel\BaseClient;
15
use EasyWeChat\Kernel\ServiceContainer;
16
17
/**
18
 * Class Client.
19
 */
20
class Client extends BaseClient
21
{
22
    /**
23
     * Client constructor.
24
     *
25
     * @param \EasyWeChat\Kernel\ServiceContainer $app
26
     */
27 2
    public function __construct(ServiceContainer $app)
28
    {
29 2
        parent::__construct($app, $app['suite_access_token']);
30 2
    }
31
32
    /**
33
     * Get session info by code.
34
     *
35
     * @param string $code
36
     *
37
     * @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
38
     *
39
     * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
40
     */
41 1
    public function session(string $code)
42
    {
43
        $params = [
44 1
            'js_code' => $code,
45 1
            'grant_type' => 'authorization_code',
46
        ];
47
48 1
        return $this->httpGet('cgi-bin/service/miniprogram/jscode2session', $params);
49
    }
50
}
51