Application.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /*
  3. * This file is part of the overtrue/wechat.
  4. *
  5. * (c) overtrue <i@overtrue.me>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. namespace EasyWeChat\OpenWork;
  11. use EasyWeChat\Kernel\ServiceContainer;
  12. use EasyWeChat\OpenWork\Work\Application as Work;
  13. /**
  14. * Application.
  15. *
  16. * @author xiaomin <keacefull@gmail.com>
  17. *
  18. * @property \EasyWeChat\OpenWork\Server\Guard $server
  19. * @property \EasyWeChat\OpenWork\Corp\Client $corp
  20. * @property \EasyWeChat\OpenWork\Provider\Client $provider
  21. * @property \EasyWeChat\OpenWork\SuiteAuth\AccessToken $suite_access_token
  22. * @property \EasyWeChat\OpenWork\Auth\AccessToken $provider_access_token
  23. * @property \EasyWeChat\OpenWork\SuiteAuth\SuiteTicket $suite_ticket
  24. * @property \EasyWeChat\OpenWork\MiniProgram\Auth\Client $mini_program
  25. */
  26. class Application extends ServiceContainer
  27. {
  28. /**
  29. * @var array
  30. */
  31. protected $providers = [
  32. Auth\ServiceProvider::class,
  33. SuiteAuth\ServiceProvider::class,
  34. Server\ServiceProvider::class,
  35. Corp\ServiceProvider::class,
  36. Provider\ServiceProvider::class,
  37. MiniProgram\ServiceProvider::class,
  38. ];
  39. /**
  40. * @var array
  41. */
  42. protected $defaultConfig = [
  43. // http://docs.guzzlephp.org/en/stable/request-options.html
  44. 'http' => [
  45. 'base_uri' => 'https://qyapi.weixin.qq.com/',
  46. ],
  47. ];
  48. /**
  49. * Creates the miniProgram application.
  50. *
  51. * @return \EasyWeChat\Work\MiniProgram\Application
  52. */
  53. public function miniProgram(): \EasyWeChat\Work\MiniProgram\Application
  54. {
  55. return new \EasyWeChat\Work\MiniProgram\Application($this->getConfig());
  56. }
  57. /**
  58. * @param string $authCorpId 企业 corp_id
  59. * @param string $permanentCode 企业永久授权码
  60. *
  61. * @return Work
  62. */
  63. public function work(string $authCorpId, string $permanentCode): Work
  64. {
  65. return new Work($authCorpId, $permanentCode, $this);
  66. }
  67. /**
  68. * @param string $method
  69. * @param array $arguments
  70. *
  71. * @return mixed
  72. */
  73. public function __call($method, $arguments)
  74. {
  75. return $this['base']->$method(...$arguments);
  76. }
  77. }