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; |
13
|
|
|
|
14
|
|
|
use EasyWeChat\Kernel\ServiceContainer; |
15
|
|
|
use EasyWeChat\OpenWork\Work\Application as Work; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* Application. |
19
|
|
|
* |
20
|
|
|
* @author xiaomin <[email protected]> |
21
|
|
|
* |
22
|
|
|
* @property \EasyWeChat\OpenWork\Server\Guard $server |
23
|
|
|
* @property \EasyWeChat\OpenWork\Corp\Client $corp |
24
|
|
|
* @property \EasyWeChat\OpenWork\Provider\Client $provider |
25
|
|
|
* @property \EasyWeChat\OpenWork\SuiteAuth\AccessToken $suite_access_token |
26
|
|
|
* @property \EasyWeChat\OpenWork\Auth\AccessToken $provider_access_token |
27
|
|
|
* @property \EasyWeChat\OpenWork\SuiteAuth\SuiteTicket $suite_ticket |
28
|
|
|
* @property \EasyWeChat\OpenWork\MiniProgram\Auth\Client $mini_program |
29
|
|
|
*/ |
30
|
|
|
class Application extends ServiceContainer |
31
|
|
|
{ |
32
|
|
|
/** |
33
|
|
|
* @var array |
34
|
|
|
*/ |
35
|
|
|
protected $providers = [ |
36
|
|
|
Auth\ServiceProvider::class, |
37
|
|
|
SuiteAuth\ServiceProvider::class, |
38
|
|
|
Server\ServiceProvider::class, |
39
|
|
|
Corp\ServiceProvider::class, |
40
|
|
|
Provider\ServiceProvider::class, |
41
|
|
|
MiniProgram\ServiceProvider::class, |
42
|
|
|
]; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var array |
46
|
|
|
*/ |
47
|
|
|
protected $defaultConfig = [ |
48
|
|
|
// http://docs.guzzlephp.org/en/stable/request-options.html |
49
|
|
|
'http' => [ |
50
|
|
|
'base_uri' => 'https://qyapi.weixin.qq.com/', |
51
|
|
|
], |
52
|
|
|
]; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Creates the miniProgram application. |
56
|
|
|
* |
57
|
|
|
* @return \EasyWeChat\Work\MiniProgram\Application |
58
|
|
|
*/ |
59
|
|
|
public function miniProgram(): \EasyWeChat\Work\MiniProgram\Application |
60
|
|
|
{ |
61
|
|
|
return new \EasyWeChat\Work\MiniProgram\Application($this->getConfig()); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @param string $authCorpId 企业 corp_id |
66
|
|
|
* @param string $permanentCode 企业永久授权码 |
67
|
|
|
* |
68
|
|
|
* @return Work |
69
|
|
|
*/ |
70
|
1 |
|
public function work(string $authCorpId, string $permanentCode): Work |
71
|
|
|
{ |
72
|
1 |
|
return new Work($authCorpId, $permanentCode, $this); |
73
|
|
|
} |
74
|
|
|
|
75
|
|
|
/** |
76
|
|
|
* @param string $method |
77
|
|
|
* @param array $arguments |
78
|
|
|
* |
79
|
|
|
* @return mixed |
80
|
|
|
*/ |
81
|
1 |
|
public function __call($method, $arguments) |
82
|
|
|
{ |
83
|
1 |
|
return $this['base']->$method(...$arguments); |
84
|
|
|
} |
85
|
|
|
} |
86
|
|
|
|