init
- 框架初始化 - 安装插件 - 修复PHP8.4报错
This commit is contained in:
63
vendor/overtrue/wechat/src/Work/Agent/Client.php
vendored
Normal file
63
vendor/overtrue/wechat/src/Work/Agent/Client.php
vendored
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\Agent;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* This is WeWork Agent Client.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Get agent.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function get(?int $agentId)
|
||||
{
|
||||
$params = [
|
||||
'agentid' => $agentId,
|
||||
];
|
||||
|
||||
return $this->httpGet('cgi-bin/agent/get', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set agent.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function set(?int $agentId, ?array $attributes)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/agent/set', array_merge(['agentid' => $agentId], $attributes));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get agent list.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function list()
|
||||
{
|
||||
return $this->httpGet('cgi-bin/agent/list');
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/Work/Agent/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/Work/Agent/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\Agent;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['agent'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
105
vendor/overtrue/wechat/src/Work/Application.php
vendored
Normal file
105
vendor/overtrue/wechat/src/Work/Application.php
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work;
|
||||
|
||||
use EasyWeChat\Kernel\ServiceContainer;
|
||||
use EasyWeChat\Work\MiniProgram\Application as MiniProgram;
|
||||
|
||||
/**
|
||||
* Application.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*
|
||||
* @property \EasyWeChat\Work\OA\Client $oa
|
||||
* @property \EasyWeChat\Work\Auth\AccessToken $access_token
|
||||
* @property \EasyWeChat\Work\Agent\Client $agent
|
||||
* @property \EasyWeChat\Work\Department\Client $department
|
||||
* @property \EasyWeChat\Work\Media\Client $media
|
||||
* @property \EasyWeChat\Work\Menu\Client $menu
|
||||
* @property \EasyWeChat\Work\Message\Client $message
|
||||
* @property \EasyWeChat\Work\Message\Messenger $messenger
|
||||
* @property \EasyWeChat\Work\User\Client $user
|
||||
* @property \EasyWeChat\Work\User\TagClient $tag
|
||||
* @property \EasyWeChat\Work\Server\Guard $server
|
||||
* @property \EasyWeChat\Work\Jssdk\Client $jssdk
|
||||
* @property \Overtrue\Socialite\Providers\WeWorkProvider $oauth
|
||||
* @property \EasyWeChat\Work\Invoice\Client $invoice
|
||||
* @property \EasyWeChat\Work\Chat\Client $chat
|
||||
* @property \EasyWeChat\Work\ExternalContact\Client $external_contact
|
||||
* @property \EasyWeChat\Work\ExternalContact\ContactWayClient $contact_way
|
||||
* @property \EasyWeChat\Work\ExternalContact\StatisticsClient $external_contact_statistics
|
||||
* @property \EasyWeChat\Work\ExternalContact\MessageClient $external_contact_message
|
||||
* @property \EasyWeChat\Work\GroupRobot\Client $group_robot
|
||||
* @property \EasyWeChat\Work\GroupRobot\Messenger $group_robot_messenger
|
||||
* @property \EasyWeChat\Work\Calendar\Client $calendar
|
||||
* @property \EasyWeChat\Work\Schedule\Client $schedule
|
||||
* @property \EasyWeChat\Work\MsgAudit\Client $msg_audit
|
||||
* @property \EasyWeChat\Work\ExternalContact\SchoolClient $school
|
||||
*
|
||||
* @method mixed getCallbackIp()
|
||||
*/
|
||||
class Application extends ServiceContainer
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $providers = [
|
||||
OA\ServiceProvider::class,
|
||||
Auth\ServiceProvider::class,
|
||||
Base\ServiceProvider::class,
|
||||
Menu\ServiceProvider::class,
|
||||
OAuth\ServiceProvider::class,
|
||||
User\ServiceProvider::class,
|
||||
Agent\ServiceProvider::class,
|
||||
Media\ServiceProvider::class,
|
||||
Message\ServiceProvider::class,
|
||||
Department\ServiceProvider::class,
|
||||
Server\ServiceProvider::class,
|
||||
Jssdk\ServiceProvider::class,
|
||||
Invoice\ServiceProvider::class,
|
||||
Chat\ServiceProvider::class,
|
||||
ExternalContact\ServiceProvider::class,
|
||||
GroupRobot\ServiceProvider::class,
|
||||
Calendar\ServiceProvider::class,
|
||||
Schedule\ServiceProvider::class,
|
||||
MsgAudit\ServiceProvider::class,
|
||||
];
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $defaultConfig = [
|
||||
// http://docs.guzzlephp.org/en/stable/request-options.html
|
||||
'http' => [
|
||||
'base_uri' => 'https://qyapi.weixin.qq.com/',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* Creates the miniProgram application.
|
||||
*/
|
||||
public function miniProgram(): MiniProgram
|
||||
{
|
||||
return new MiniProgram($this->getConfig());
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
* @param array $arguments
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $arguments)
|
||||
{
|
||||
return $this['base']->$method(...$arguments);
|
||||
}
|
||||
}
|
||||
43
vendor/overtrue/wechat/src/Work/Auth/AccessToken.php
vendored
Normal file
43
vendor/overtrue/wechat/src/Work/Auth/AccessToken.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\Auth;
|
||||
|
||||
use EasyWeChat\Kernel\AccessToken as BaseAccessToken;
|
||||
|
||||
/**
|
||||
* Class AccessToken.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class AccessToken extends BaseAccessToken
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $endpointToGetToken = 'cgi-bin/gettoken';
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $safeSeconds = 0;
|
||||
|
||||
/**
|
||||
* Credential for get token.
|
||||
*/
|
||||
protected function getCredentials(): array
|
||||
{
|
||||
return [
|
||||
'corpid' => $this->app['config']['corp_id'],
|
||||
'corpsecret' => $this->app['config']['secret'],
|
||||
];
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/Work/Auth/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/Work/Auth/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\Auth;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
isset($app['access_token']) || $app['access_token'] = function ($app) {
|
||||
return new AccessToken($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
34
vendor/overtrue/wechat/src/Work/Base/Client.php
vendored
Normal file
34
vendor/overtrue/wechat/src/Work/Base/Client.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\Base;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Get callback ip.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function getCallbackIp()
|
||||
{
|
||||
return $this->httpGet('cgi-bin/getcallbackip');
|
||||
}
|
||||
}
|
||||
30
vendor/overtrue/wechat/src/Work/Base/ServiceProvider.php
vendored
Normal file
30
vendor/overtrue/wechat/src/Work/Base/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\Base;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['base'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
78
vendor/overtrue/wechat/src/Work/Calendar/Client.php
vendored
Normal file
78
vendor/overtrue/wechat/src/Work/Calendar/Client.php
vendored
Normal file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\Calendar;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author her-cat <i@her-cat.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Add a calendar.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function add(?array $calendar)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/oa/calendar/add', compact('calendar'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the calendar.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function update(?string $id, ?array $calendar)
|
||||
{
|
||||
$calendar += ['cal_id' => $id];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/oa/calendar/update', compact('calendar'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get one or more calendars.
|
||||
*
|
||||
* @param string|array $ids
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function get($ids)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/oa/calendar/get', ['cal_id_list' => (array) $ids]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a calendar.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function delete(?string $id)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/oa/calendar/del', ['cal_id' => $id]);
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/Work/Calendar/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/Work/Calendar/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\Calendar;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author her-cat <i@her-cat.com>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['calendar'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
73
vendor/overtrue/wechat/src/Work/Chat/Client.php
vendored
Normal file
73
vendor/overtrue/wechat/src/Work/Chat/Client.php
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\Chat;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author XiaolonY <xiaolony@hotmail.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Get chat.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function get(?string $chatId)
|
||||
{
|
||||
return $this->httpGet('cgi-bin/appchat/get', ['chatid' => $chatId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create chat.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function create(?array $data)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/appchat/create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update chat.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function update(?string $chatId, ?array $data)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/appchat/update', array_merge(['chatid' => $chatId], $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function send(?array $message)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/appchat/send', $message);
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/Work/Chat/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/Work/Chat/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\Chat;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author XiaolonY <xiaolony@hotmail.com>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['chat'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
76
vendor/overtrue/wechat/src/Work/Department/Client.php
vendored
Normal file
76
vendor/overtrue/wechat/src/Work/Department/Client.php
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\Department;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* This is WeWork Department Client.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Create a department.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function create(?array $data)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/department/create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a department.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function update(?int $id, ?array $data)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/department/update', array_merge(compact('id'), $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a department.
|
||||
*
|
||||
* @param int $id
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function delete($id)
|
||||
{
|
||||
return $this->httpGet('cgi-bin/department/delete', compact('id'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get department lists.
|
||||
*
|
||||
* @param int|null $id
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function list($id = null)
|
||||
{
|
||||
return $this->httpGet('cgi-bin/department/list', compact('id'));
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/Work/Department/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/Work/Department/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\Department;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['department'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
266
vendor/overtrue/wechat/src/Work/ExternalContact/Client.php
vendored
Normal file
266
vendor/overtrue/wechat/src/Work/ExternalContact/Client.php
vendored
Normal file
@@ -0,0 +1,266 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\ExternalContact;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* 获取配置了客户联系功能的成员列表.
|
||||
*
|
||||
* @see https://work.weixin.qq.com/api/doc#90000/90135/91554
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function getFollowUsers()
|
||||
{
|
||||
return $this->httpGet('cgi-bin/externalcontact/get_follow_user_list');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取外部联系人列表.
|
||||
*
|
||||
* @see https://work.weixin.qq.com/api/doc#90000/90135/91555
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function list(?string $userId)
|
||||
{
|
||||
return $this->httpGet('cgi-bin/externalcontact/list', [
|
||||
'userid' => $userId,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取外部联系人详情.
|
||||
*
|
||||
* @see https://work.weixin.qq.com/api/doc#90000/90135/91556
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function get(?string $externalUserId)
|
||||
{
|
||||
return $this->httpGet('cgi-bin/externalcontact/get', [
|
||||
'external_userid' => $externalUserId,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量获取外部联系人详情.
|
||||
*
|
||||
* @see https://work.weixin.qq.com/api/doc/90000/90135/92994
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function batchGetUsers(?array $data)
|
||||
{
|
||||
return $this->httpPostJson(
|
||||
'cgi-bin/externalcontact/batch/get_by_user',
|
||||
$data
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改客户备注信息.
|
||||
*
|
||||
* @see https://work.weixin.qq.com/api/doc/90000/90135/92115
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function remark(?array $data)
|
||||
{
|
||||
return $this->httpPostJson(
|
||||
'cgi-bin/externalcontact/remark',
|
||||
$data
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取离职成员的客户列表.
|
||||
*
|
||||
* @see https://work.weixin.qq.com/api/doc#90000/90135/91563
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getUnassigned(?int $pageId = 0, ?int $pageSize = 1000)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/externalcontact/get_unassigned_list', [
|
||||
'page_id' => $pageId,
|
||||
'page_size' => $pageSize,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 离职成员的外部联系人再分配.
|
||||
*
|
||||
* @see https://work.weixin.qq.com/api/doc#90000/90135/91564
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function transfer(?string $externalUserId, ?string $handoverUserId, ?string $takeoverUserId)
|
||||
{
|
||||
$params = [
|
||||
'external_userid' => $externalUserId,
|
||||
'handover_userid' => $handoverUserId,
|
||||
'takeover_userid' => $takeoverUserId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/externalcontact/transfer', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客户群列表.
|
||||
*
|
||||
* @see https://work.weixin.qq.com/api/doc/90000/90135/92120
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getGroupChats(?array $params)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/externalcontact/groupchat/list', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取客户群详情.
|
||||
*
|
||||
* @see https://work.weixin.qq.com/api/doc/90000/90135/92122
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getGroupChat(?string $chatId, ?int $needName = 0)
|
||||
{
|
||||
$params = [
|
||||
'chat_id' => $chatId,
|
||||
'need_name' => $needName,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/externalcontact/groupchat/get', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取企业标签库.
|
||||
*
|
||||
* @see https://work.weixin.qq.com/api/doc/90000/90135/92117#获取企业标签库
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getCorpTags(?array $tagIds = [])
|
||||
{
|
||||
$params = [
|
||||
'tag_id' => $tagIds,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/externalcontact/get_corp_tag_list', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加企业客户标签.
|
||||
*
|
||||
* @see https://work.weixin.qq.com/api/doc/90000/90135/92117#添加企业客户标签
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function addCorpTag(?array $params)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/externalcontact/add_corp_tag', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑企业客户标签.
|
||||
*
|
||||
* @see https://work.weixin.qq.com/api/doc/90000/90135/92117#编辑企业客户标签
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function updateCorpTag(?string $id, ?string $name, ?int $order = 1)
|
||||
{
|
||||
$params = [
|
||||
'id' => $id,
|
||||
'name' => $name,
|
||||
'order' => $order,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/externalcontact/edit_corp_tag', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除企业客户标签.
|
||||
*
|
||||
* @see https://work.weixin.qq.com/api/doc/90000/90135/92117#删除企业客户标签
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function deleteCorpTag(?array $tagId, ?array $groupId)
|
||||
{
|
||||
$params = [
|
||||
'tag_id' => $tagId,
|
||||
'group_id' => $groupId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/externalcontact/del_corp_tag', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑客户企业标签.
|
||||
*
|
||||
* @see https://work.weixin.qq.com/api/doc/90000/90135/92118
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function markTags(?array $params)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/externalcontact/mark_tag', $params);
|
||||
}
|
||||
}
|
||||
87
vendor/overtrue/wechat/src/Work/ExternalContact/ContactWayClient.php
vendored
Normal file
87
vendor/overtrue/wechat/src/Work/ExternalContact/ContactWayClient.php
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\ExternalContact;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class ContactWayClient.
|
||||
*
|
||||
* @author milkmeowo <milkmeowo@gmail.com>
|
||||
*/
|
||||
class ContactWayClient extends BaseClient
|
||||
{
|
||||
/**
|
||||
* 配置客户联系「联系我」方式.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function create(?int $type, ?int $scene, ?array $config = [])
|
||||
{
|
||||
$params = array_merge([
|
||||
'type' => $type,
|
||||
'scene' => $scene,
|
||||
], $config);
|
||||
|
||||
return $this->httpPostJson('cgi-bin/externalcontact/add_contact_way', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取企业已配置的「联系我」方式.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function get(?string $configId)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/externalcontact/get_contact_way', [
|
||||
'config_id' => $configId,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新企业已配置的「联系我」方式.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function update(?string $configId, ?array $config = [])
|
||||
{
|
||||
$params = array_merge([
|
||||
'config_id' => $configId,
|
||||
], $config);
|
||||
|
||||
return $this->httpPostJson('cgi-bin/externalcontact/update_contact_way', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除企业已配置的「联系我」方式.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function delete(?string $configId)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/externalcontact/del_contact_way', [
|
||||
'config_id' => $configId,
|
||||
]);
|
||||
}
|
||||
}
|
||||
171
vendor/overtrue/wechat/src/Work/ExternalContact/MessageClient.php
vendored
Normal file
171
vendor/overtrue/wechat/src/Work/ExternalContact/MessageClient.php
vendored
Normal file
@@ -0,0 +1,171 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\ExternalContact;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Class MessageClient.
|
||||
*
|
||||
* @author milkmeowo <milkmeowo@gmail.com>
|
||||
*/
|
||||
class MessageClient extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Required attributes.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $required = ['media_id', 'title', 'url', 'pic_media_id', 'appid', 'page'];
|
||||
|
||||
protected $textMessage = [
|
||||
'content' => '',
|
||||
];
|
||||
|
||||
protected $imageMessage = [
|
||||
'media_id' => '',
|
||||
];
|
||||
|
||||
protected $linkMessage = [
|
||||
'title' => '',
|
||||
'picurl' => '',
|
||||
'desc' => '',
|
||||
'url' => '',
|
||||
];
|
||||
|
||||
protected $miniprogramMessage = [
|
||||
'title' => '',
|
||||
'pic_media_id' => '',
|
||||
'appid' => '',
|
||||
'page' => '',
|
||||
];
|
||||
|
||||
/**
|
||||
* 添加企业群发消息模板
|
||||
*
|
||||
* @see https://work.weixin.qq.com/api/doc#90000/90135/91560
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function submit(?array $msg)
|
||||
{
|
||||
$params = $this->formatMessage($msg);
|
||||
|
||||
return $this->httpPostJson('cgi-bin/externalcontact/add_msg_template', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取企业群发消息发送结果.
|
||||
*
|
||||
* @see https://work.weixin.qq.com/api/doc#90000/90135/91561
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function get(?string $msgId)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/externalcontact/get_group_msg_result', [
|
||||
'msgid' => $msgId,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送新客户欢迎语.
|
||||
*
|
||||
* @see https://work.weixin.qq.com/api/doc#90000/90135/91688
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function sendWelcome(?string $welcomeCode, ?array $msg)
|
||||
{
|
||||
$formattedMsg = $this->formatMessage($msg);
|
||||
|
||||
$params = array_merge($formattedMsg, [
|
||||
'welcome_code' => $welcomeCode,
|
||||
]);
|
||||
|
||||
return $this->httpPostJson('cgi-bin/externalcontact/send_welcome_msg', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
protected function formatMessage(?array $data = [])
|
||||
{
|
||||
$params = $data;
|
||||
|
||||
if (!empty($params['text'])) {
|
||||
$params['text'] = $this->formatFields($params['text'], $this->textMessage);
|
||||
}
|
||||
|
||||
if (!empty($params['image'])) {
|
||||
$params['image'] = $this->formatFields($params['image'], $this->imageMessage);
|
||||
}
|
||||
|
||||
if (!empty($params['link'])) {
|
||||
$params['link'] = $this->formatFields($params['link'], $this->linkMessage);
|
||||
}
|
||||
|
||||
if (!empty($params['miniprogram'])) {
|
||||
$params['miniprogram'] = $this->formatFields($params['miniprogram'], $this->miniprogramMessage);
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
protected function formatFields(?array $data = [], ?array $default = [])
|
||||
{
|
||||
$params = array_merge($default, $data);
|
||||
foreach ($params as $key => $value) {
|
||||
if (in_array($key, $this->required, true) && empty($value) && empty($default[$key])) {
|
||||
throw new InvalidArgumentException(sprintf('Attribute "%s" can not be empty!', $key));
|
||||
}
|
||||
|
||||
$params[$key] = empty($value) ? $default[$key] : $value;
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 企业发表内容到客户的朋友圈
|
||||
*
|
||||
* @see https://developer.work.weixin.qq.com/document/path/95094
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function moments(?array $msg)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/externalcontact/add_moment_task', $msg);
|
||||
}
|
||||
}
|
||||
454
vendor/overtrue/wechat/src/Work/ExternalContact/SchoolClient.php
vendored
Normal file
454
vendor/overtrue/wechat/src/Work/ExternalContact/SchoolClient.php
vendored
Normal file
@@ -0,0 +1,454 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\ExternalContact;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author MillsGuo <millsguo@gmail.com>
|
||||
*/
|
||||
class SchoolClient extends BaseClient
|
||||
{
|
||||
/**
|
||||
* 创建部门
|
||||
* @see https://work.weixin.qq.com/api/doc/90000/90135/92340
|
||||
* @param string $name
|
||||
* @param int $parentId
|
||||
* @param int $type
|
||||
* @param int $standardGrade
|
||||
* @param int $registerYear
|
||||
* @param int $order
|
||||
* @param array $departmentAdmins [['userid':'139','type':1],['userid':'1399','type':2]]
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function createDepartment(?string $name, ?int $parentId, ?int $type, ?int $standardGrade, ?int $registerYear, ?int $order, ?array $departmentAdmins)
|
||||
{
|
||||
$params = [
|
||||
'name' => $name,
|
||||
'parentid' => $parentId,
|
||||
'type' => $type,
|
||||
'standard_grade' => $standardGrade,
|
||||
'register_year' => $registerYear,
|
||||
'order' => $order,
|
||||
'department_admins' => $departmentAdmins
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/school/department/create', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新部门
|
||||
* @see https://work.weixin.qq.com/api/doc/90000/90135/92341
|
||||
* @param int $id
|
||||
* @param string $name
|
||||
* @param int $parentId
|
||||
* @param int $type
|
||||
* @param int $standardGrade
|
||||
* @param int $registerYear
|
||||
* @param int $order
|
||||
* @param array $departmentAdmins [['op':0,'userid':'139','type':1],['op':1,'userid':'1399','type':2]] OP=0表示新增或更新,OP=1表示删除管理员
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function updateDepartment(?int $id, ?string $name, ?int $parentId, ?int $type, ?int $standardGrade, ?int $registerYear, ?int $order, ?array $departmentAdmins)
|
||||
{
|
||||
$params = [
|
||||
'id' => $id,
|
||||
'name' => $name,
|
||||
'parentid' => $parentId,
|
||||
'type' => $type,
|
||||
'standard_grade' => $standardGrade,
|
||||
'register_year' => $registerYear,
|
||||
'order' => $order,
|
||||
'department_admins' => $departmentAdmins
|
||||
];
|
||||
$params = $this->filterNullValue($params);
|
||||
|
||||
return $this->httpPostJson('cgi-bin/school/department/update', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除部门
|
||||
* @see https://work.weixin.qq.com/api/doc/90000/90135/92342
|
||||
* @param int $id
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function deleteDepartment(?int $id)
|
||||
{
|
||||
return $this->httpGet('cgi-bin/school/department/delete', [
|
||||
'id' => $id
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门列表
|
||||
* @see https://work.weixin.qq.com/api/doc/90000/90135/92343
|
||||
* @param int $id 如果ID为0,则获取全量组织架构
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function getDepartments(?int $id)
|
||||
{
|
||||
if ($id > 0) {
|
||||
$params = [
|
||||
'id' => $id
|
||||
];
|
||||
} else {
|
||||
$params = [];
|
||||
}
|
||||
|
||||
return $this->httpGet('cgi-bin/school/department/list', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建学生
|
||||
* @see https://work.weixin.qq.com/api/doc/90000/90135/92325
|
||||
* @param string $userId
|
||||
* @param string $name
|
||||
* @param array $department
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function createStudent(?string $userId, ?string $name, ?array $department)
|
||||
{
|
||||
$params = [
|
||||
'student_userid' => $userId,
|
||||
'name' => $name,
|
||||
'department' => $department
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/school/user/create_student', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除学生
|
||||
* @see https://work.weixin.qq.com/api/doc/90000/90135/92326
|
||||
* @param string $userId
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function deleteStudent(?string $userId)
|
||||
{
|
||||
return $this->httpGet('cgi-bin/school/user/delete_student', [
|
||||
'userid' => $userId
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新学生
|
||||
* @see https://work.weixin.qq.com/api/doc/90000/90135/92327
|
||||
* @param string $userId
|
||||
* @param string $name
|
||||
* @param string $newUserId
|
||||
* @param array $department
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function updateStudent(?string $userId, ?string $name, ?string $newUserId, ?array $department)
|
||||
{
|
||||
$params = [
|
||||
'student_userid' => $userId
|
||||
];
|
||||
if (!empty($name)) {
|
||||
$params['name'] = $name;
|
||||
}
|
||||
if (!empty($newUserId)) {
|
||||
$params['new_student_userid'] = $newUserId;
|
||||
}
|
||||
if (!empty($department)) {
|
||||
$params['department'] = $department;
|
||||
}
|
||||
|
||||
return $this->httpPostJson('cgi-bin/school/user/update_student', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量创建学生,学生最多100个
|
||||
* @see https://work.weixin.qq.com/api/doc/90000/90135/92328
|
||||
* @param array $students 学生格式:[[student_userid:'','name':'','department':[1,2]],['student_userid':'','name':'','department':[1,2]]]
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function batchCreateStudents(?array $students)
|
||||
{
|
||||
$params = [
|
||||
'students' => $students
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/school/user/batch_create_student', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除学生,每次最多100个学生
|
||||
* @see https://work.weixin.qq.com/api/doc/90000/90135/92329
|
||||
* @param array $useridList 学生USERID,格式:['zhangsan','lisi']
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function batchDeleteStudents(?array $useridList)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/school/user/batch_delete_student', [
|
||||
'useridlist' => $useridList
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量更新学生,每次最多100个
|
||||
* @see https://open.work.weixin.qq.com/api/doc/90001/90143/92042
|
||||
* @param array $students 格式:[['student_userid':'lisi','new_student_userid':'lisi2','name':'','department':[1,2]],.....]
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function batchUpdateStudents(?array $students)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/school/user/batch_update_student', [
|
||||
'students' => $students
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建家长
|
||||
* @see https://open.work.weixin.qq.com/api/doc/90001/90143/92077
|
||||
* @param string $userId
|
||||
* @param string $mobile
|
||||
* @param bool $toInvite
|
||||
* @param array $children
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function createParent(?string $userId, ?string $mobile, bool $toInvite, ?array $children)
|
||||
{
|
||||
$params = [
|
||||
'parent_userid' => $userId,
|
||||
'mobile' => $mobile,
|
||||
'to_invite' => $toInvite,
|
||||
'children' => $children
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/school/user/create_parent', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除家长
|
||||
* @see https://open.work.weixin.qq.com/api/doc/90001/90143/92079
|
||||
* @param string $userId
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function deleteParent(?string $userId)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/school/user/delete_parent', [
|
||||
'userid' => $userId
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新家长
|
||||
* @see https://open.work.weixin.qq.com/api/doc/90001/90143/92081
|
||||
* @param string $userId
|
||||
* @param string $mobile
|
||||
* @param string $newUserId
|
||||
* @param array $children 格式:[['student_userid':'','relation':''],[]]
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function updateParent(?string $userId, ?string $mobile, ?string $newUserId, ?array $children)
|
||||
{
|
||||
$params = [
|
||||
'parent_userid' => $userId
|
||||
];
|
||||
if (!empty($newUserId)) {
|
||||
$params['new_parent_userid'] = $newUserId;
|
||||
}
|
||||
if (!empty($mobile)) {
|
||||
$params['mobile'] = $mobile;
|
||||
}
|
||||
if (!empty($children)) {
|
||||
$params['children'] = $children;
|
||||
}
|
||||
|
||||
return $this->httpPostJson('cgi-bin/school/user/update_parent', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量创建家长 每次最多100个
|
||||
* @see https://open.work.weixin.qq.com/api/doc/90001/90143/92078
|
||||
* @param array $parents [['parent_userid':'','mobile':'','to_invite':true,'children':['student_userid':'','relation':'']],.....]
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function batchCreateParents(?array $parents)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/school/user/batch_create_parent', [
|
||||
'parents' => $parents
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除家长,每次最多100个
|
||||
* @see https://open.work.weixin.qq.com/api/doc/90001/90143/92080
|
||||
* @param array $userIdList 格式:['chang','lisi']
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function batchDeleteParents(?array $userIdList)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/school/user/batch_delete_parent', [
|
||||
'useridlist' => $userIdList
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量更新家长,每次最多100个
|
||||
* @see https://open.work.weixin.qq.com/api/doc/90001/90143/92082
|
||||
* @param array $parents 格式:[['parent_userid':'','new_parent_userid':'','mobile':'','children':[['student_userid':'','relation':''],...]],.....]
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function batchUpdateParents(?array $parents)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/school/user/batch_update_parent', [
|
||||
'parents' => $parents
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取学生或家长
|
||||
* @see https://open.work.weixin.qq.com/api/doc/90001/90143/92038
|
||||
* @param string $userId 学生或家长的userid
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function getUser(?string $userId)
|
||||
{
|
||||
return $this->httpGet('cgi-bin/school/user/get', [
|
||||
'userid' => $userId
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门成员详情
|
||||
* @see https://open.work.weixin.qq.com/api/doc/90001/90143/92038
|
||||
* @param int $departmentId
|
||||
* @param bool $fetchChild
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function getStudents(?int $departmentId, bool $fetchChild)
|
||||
{
|
||||
$params = [
|
||||
'department_id' => $departmentId
|
||||
];
|
||||
if ($fetchChild) {
|
||||
$params['fetch_child'] = 1;
|
||||
} else {
|
||||
$params['fetch_child'] = 0;
|
||||
}
|
||||
|
||||
return $this->httpGet('cgi-bin/school/user/list', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取学校通知二维码
|
||||
* @see https://open.work.weixin.qq.com/api/doc/90001/90143/92197
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function getSubscribeQrCode()
|
||||
{
|
||||
return $this->httpGet('cgi-bin/externalcontact/get_subscribe_qr_code');
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置关注学校通知的模式
|
||||
* @see https://open.work.weixin.qq.com/api/doc/90001/90143/92290
|
||||
* @param int $mode 关注模式,1可扫码填写资料加入,2禁止扫码填写资料加入
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function setSubscribeMode(?int $mode)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/externalcontact/set_subscribe_mode', [
|
||||
'subscribe_mode' => $mode
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取关注学校通知的模式
|
||||
* @see https://open.work.weixin.qq.com/api/doc/90001/90143/92290
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function getSubscribeMode()
|
||||
{
|
||||
return $this->httpGet('cgi-bin/externalcontact/get_subscribe_mode');
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置【老师可查看班级】的模式
|
||||
* @see https://open.work.weixin.qq.com/api/doc/90001/90143/92652
|
||||
* @param int $mode
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function setTeacherViewMode(?int $mode)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/school/set_teacher_view_mode', [
|
||||
'view_mode' => $mode
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取【老师可查看班级】的模式
|
||||
* @see https://open.work.weixin.qq.com/api/doc/90001/90143/92652
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function getTeacherViewMode()
|
||||
{
|
||||
return $this->httpGet('cgi-bin/school/get_teacher_view_mode');
|
||||
}
|
||||
|
||||
/**
|
||||
* 外部联系人OPENID转换
|
||||
* @param string $userId
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function convertOpenid(?string $userId)
|
||||
{
|
||||
return $this->httpGet('cgi-bin/externalcontact/convert_to_openid', [
|
||||
'external_userid' => $userId
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 过滤数组中值为NULL的键
|
||||
* @param array $data
|
||||
* @return array
|
||||
*/
|
||||
protected function filterNullValue(?array $data)
|
||||
{
|
||||
$returnData = [];
|
||||
foreach ($data as $key => $value) {
|
||||
if ($value !== null) {
|
||||
$returnData[$key] = trim($value);
|
||||
}
|
||||
}
|
||||
|
||||
return $returnData;
|
||||
}
|
||||
}
|
||||
49
vendor/overtrue/wechat/src/Work/ExternalContact/ServiceProvider.php
vendored
Normal file
49
vendor/overtrue/wechat/src/Work/ExternalContact/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\ExternalContact;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['external_contact'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
|
||||
$app['contact_way'] = function ($app) {
|
||||
return new ContactWayClient($app);
|
||||
};
|
||||
|
||||
$app['external_contact_statistics'] = function ($app) {
|
||||
return new StatisticsClient($app);
|
||||
};
|
||||
|
||||
$app['external_contact_message'] = function ($app) {
|
||||
return new MessageClient($app);
|
||||
};
|
||||
|
||||
$app['school'] = function ($app) {
|
||||
return new SchoolClient($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
43
vendor/overtrue/wechat/src/Work/ExternalContact/StatisticsClient.php
vendored
Normal file
43
vendor/overtrue/wechat/src/Work/ExternalContact/StatisticsClient.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\ExternalContact;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class StatisticsClient.
|
||||
*
|
||||
* @author milkmeowo <milkmeowo@gmail.com>
|
||||
*/
|
||||
class StatisticsClient extends BaseClient
|
||||
{
|
||||
/**
|
||||
* 获取员工行为数据.
|
||||
*
|
||||
* @see https://work.weixin.qq.com/api/doc#90000/90135/91580
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function userBehavior(?array $userIds, ?string $from, ?string $to)
|
||||
{
|
||||
$params = [
|
||||
'userid' => $userIds,
|
||||
'start_time' => $from,
|
||||
'end_time' => $to,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/externalcontact/get_user_behavior_data', $params);
|
||||
}
|
||||
}
|
||||
48
vendor/overtrue/wechat/src/Work/GroupRobot/Client.php
vendored
Normal file
48
vendor/overtrue/wechat/src/Work/GroupRobot/Client.php
vendored
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\GroupRobot;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
use EasyWeChat\Work\GroupRobot\Messages\Message;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author her-cat <i@her-cat.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* @param string|Message $message
|
||||
*
|
||||
* @return Messenger
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
public function message($message)
|
||||
{
|
||||
return (new Messenger($this))->message($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function send(?string $key, ?array $message)
|
||||
{
|
||||
$this->accessToken = null;
|
||||
|
||||
return $this->httpPostJson('cgi-bin/webhook/send', $message, ['key' => $key]);
|
||||
}
|
||||
}
|
||||
38
vendor/overtrue/wechat/src/Work/GroupRobot/Messages/Image.php
vendored
Normal file
38
vendor/overtrue/wechat/src/Work/GroupRobot/Messages/Image.php
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\GroupRobot\Messages;
|
||||
|
||||
/**
|
||||
* Class Image.
|
||||
*
|
||||
* @author her-cat <i@her-cat.com>
|
||||
*/
|
||||
class Image extends Message
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $type = 'image';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $properties = ['base64', 'md5'];
|
||||
|
||||
/**
|
||||
* Image constructor.
|
||||
*/
|
||||
public function __construct(?string $base64, ?string $md5)
|
||||
{
|
||||
parent::__construct(compact('base64', 'md5'));
|
||||
}
|
||||
}
|
||||
38
vendor/overtrue/wechat/src/Work/GroupRobot/Messages/Markdown.php
vendored
Normal file
38
vendor/overtrue/wechat/src/Work/GroupRobot/Messages/Markdown.php
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\GroupRobot\Messages;
|
||||
|
||||
/**
|
||||
* Class Markdown.
|
||||
*
|
||||
* @author her-cat <i@her-cat.com>
|
||||
*/
|
||||
class Markdown extends Message
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $type = 'markdown';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $properties = ['content'];
|
||||
|
||||
/**
|
||||
* Markdown constructor.
|
||||
*/
|
||||
public function __construct(?string $content)
|
||||
{
|
||||
parent::__construct(compact('content'));
|
||||
}
|
||||
}
|
||||
23
vendor/overtrue/wechat/src/Work/GroupRobot/Messages/Message.php
vendored
Normal file
23
vendor/overtrue/wechat/src/Work/GroupRobot/Messages/Message.php
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\GroupRobot\Messages;
|
||||
|
||||
use EasyWeChat\Kernel\Messages\Message as BaseMessage;
|
||||
|
||||
/**
|
||||
* Class Message.
|
||||
*
|
||||
* @author her-cat <i@her-cat.com>
|
||||
*/
|
||||
class Message extends BaseMessage
|
||||
{
|
||||
}
|
||||
47
vendor/overtrue/wechat/src/Work/GroupRobot/Messages/News.php
vendored
Normal file
47
vendor/overtrue/wechat/src/Work/GroupRobot/Messages/News.php
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\GroupRobot\Messages;
|
||||
|
||||
/**
|
||||
* Class News.
|
||||
*
|
||||
* @author her-cat <i@her-cat.com>
|
||||
*/
|
||||
class News extends Message
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $type = 'news';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $properties = ['items'];
|
||||
|
||||
/**
|
||||
* News constructor.
|
||||
*/
|
||||
public function __construct(?array $items = [])
|
||||
{
|
||||
parent::__construct(compact('items'));
|
||||
}
|
||||
|
||||
public function propertiesToArray(?array $data, ?array $aliases = []): array
|
||||
{
|
||||
return ['articles' => array_map(function ($item) {
|
||||
if ($item instanceof NewsItem) {
|
||||
return $item->toJsonArray();
|
||||
}
|
||||
}, $this->get('items'))];
|
||||
}
|
||||
}
|
||||
45
vendor/overtrue/wechat/src/Work/GroupRobot/Messages/NewsItem.php
vendored
Normal file
45
vendor/overtrue/wechat/src/Work/GroupRobot/Messages/NewsItem.php
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\GroupRobot\Messages;
|
||||
|
||||
/**
|
||||
* Class NewsItem.
|
||||
*
|
||||
* @author her-cat <i@her-cat.com>
|
||||
*/
|
||||
class NewsItem extends Message
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $type = 'news';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $properties = [
|
||||
'title',
|
||||
'description',
|
||||
'url',
|
||||
'image',
|
||||
];
|
||||
|
||||
public function toJsonArray()
|
||||
{
|
||||
return [
|
||||
'title' => $this->get('title'),
|
||||
'description' => $this->get('description'),
|
||||
'url' => $this->get('url'),
|
||||
'picurl' => $this->get('image'),
|
||||
];
|
||||
}
|
||||
}
|
||||
69
vendor/overtrue/wechat/src/Work/GroupRobot/Messages/Text.php
vendored
Normal file
69
vendor/overtrue/wechat/src/Work/GroupRobot/Messages/Text.php
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\GroupRobot\Messages;
|
||||
|
||||
/**
|
||||
* Class Text.
|
||||
*
|
||||
* @author her-cat <i@her-cat.com>
|
||||
*/
|
||||
class Text extends Message
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $type = 'text';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $properties = ['content', 'mentioned_list', 'mentioned_mobile_list'];
|
||||
|
||||
/**
|
||||
* Text constructor.
|
||||
*
|
||||
* @param string|array $userIds
|
||||
* @param string|array $mobiles
|
||||
*/
|
||||
public function __construct(?string $content, $userIds = [], $mobiles = [])
|
||||
{
|
||||
parent::__construct([
|
||||
'content' => $content,
|
||||
'mentioned_list' => (array) $userIds,
|
||||
'mentioned_mobile_list' => (array) $mobiles,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $userIds
|
||||
*
|
||||
* @return Text
|
||||
*/
|
||||
public function mention($userIds)
|
||||
{
|
||||
$this->set('mentioned_list', (array) $userIds);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $mobiles
|
||||
*
|
||||
* @return Text
|
||||
*/
|
||||
public function mentionByMobile($mobiles)
|
||||
{
|
||||
$this->set('mentioned_mobile_list', (array) $mobiles);
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
125
vendor/overtrue/wechat/src/Work/GroupRobot/Messenger.php
vendored
Normal file
125
vendor/overtrue/wechat/src/Work/GroupRobot/Messenger.php
vendored
Normal file
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\GroupRobot;
|
||||
|
||||
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
|
||||
use EasyWeChat\Kernel\Exceptions\InvalidConfigException;
|
||||
use EasyWeChat\Kernel\Exceptions\RuntimeException;
|
||||
use EasyWeChat\Work\GroupRobot\Messages\Message;
|
||||
use EasyWeChat\Work\GroupRobot\Messages\Text;
|
||||
|
||||
/**
|
||||
* Class Messenger.
|
||||
*
|
||||
* @author her-cat <i@her-cat.com>
|
||||
*/
|
||||
class Messenger
|
||||
{
|
||||
/**
|
||||
* @var Client
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* @var Message|null
|
||||
*/
|
||||
protected $message;
|
||||
|
||||
/**
|
||||
* @var string|null
|
||||
*/
|
||||
protected $groupKey;
|
||||
|
||||
/**
|
||||
* Messenger constructor.
|
||||
*/
|
||||
public function __construct(Client $client)
|
||||
{
|
||||
$this->client = $client;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|Message $message
|
||||
*
|
||||
* @return Messenger
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function message($message)
|
||||
{
|
||||
if (is_string($message) || is_numeric($message)) {
|
||||
$message = new Text($message);
|
||||
}
|
||||
|
||||
if (!($message instanceof Message)) {
|
||||
throw new InvalidArgumentException('Invalid message.');
|
||||
}
|
||||
|
||||
$this->message = $message;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Messenger
|
||||
*/
|
||||
public function toGroup(?string $groupKey)
|
||||
{
|
||||
$this->groupKey = $groupKey;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|Message|null $message
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws InvalidArgumentException
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function send($message = null)
|
||||
{
|
||||
if ($message) {
|
||||
$this->message($message);
|
||||
}
|
||||
|
||||
if (empty($this->message)) {
|
||||
throw new RuntimeException('No message to send.');
|
||||
}
|
||||
|
||||
if (is_null($this->groupKey)) {
|
||||
throw new RuntimeException('No group key specified.');
|
||||
}
|
||||
|
||||
$message = $this->message->transformForJsonRequest();
|
||||
|
||||
return $this->client->send($this->groupKey, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $property
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __get($property)
|
||||
{
|
||||
if (property_exists($this, $property)) {
|
||||
return $this->$property;
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException(sprintf('No property named "%s"', $property));
|
||||
}
|
||||
}
|
||||
37
vendor/overtrue/wechat/src/Work/GroupRobot/ServiceProvider.php
vendored
Normal file
37
vendor/overtrue/wechat/src/Work/GroupRobot/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\GroupRobot;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author her-cat <i@her-cat.com>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['group_robot'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
|
||||
$app['group_robot_messenger'] = function ($app) {
|
||||
return new Messenger($app['group_robot']);
|
||||
};
|
||||
}
|
||||
}
|
||||
87
vendor/overtrue/wechat/src/Work/Invoice/Client.php
vendored
Normal file
87
vendor/overtrue/wechat/src/Work/Invoice/Client.php
vendored
Normal file
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\Invoice;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function get(?string $cardId, ?string $encryptCode)
|
||||
{
|
||||
$params = [
|
||||
'card_id' => $cardId,
|
||||
'encrypt_code' => $encryptCode,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/card/invoice/reimburse/getinvoiceinfo', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function select(?array $invoices)
|
||||
{
|
||||
$params = [
|
||||
'item_list' => $invoices,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/card/invoice/reimburse/getinvoiceinfobatch', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function update(?string $cardId, ?string $encryptCode, ?string $status)
|
||||
{
|
||||
$params = [
|
||||
'card_id' => $cardId,
|
||||
'encrypt_code' => $encryptCode,
|
||||
'reimburse_status' => $status,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/card/invoice/reimburse/updateinvoicestatus', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function batchUpdate(?array $invoices, ?string $openid, ?string $status)
|
||||
{
|
||||
$params = [
|
||||
'openid' => $openid,
|
||||
'reimburse_status' => $status,
|
||||
'invoice_list' => $invoices,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/card/invoice/reimburse/updatestatusbatch', $params);
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/Work/Invoice/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/Work/Invoice/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\Invoice;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['invoice'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
186
vendor/overtrue/wechat/src/Work/Jssdk/Client.php
vendored
Normal file
186
vendor/overtrue/wechat/src/Work/Jssdk/Client.php
vendored
Normal file
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\Jssdk;
|
||||
|
||||
use EasyWeChat\BasicService\Jssdk\Client as BaseClient;
|
||||
use EasyWeChat\Kernel\Exceptions\RuntimeException;
|
||||
use EasyWeChat\Kernel\Support;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
protected $ticketEndpoint = 'cgi-bin/get_jsapi_ticket';
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getAppId()
|
||||
{
|
||||
return $this->app['config']->get('corp_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getAgentId()
|
||||
{
|
||||
return $this->app['config']->get('agent_id');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $apis
|
||||
* @param $agentId
|
||||
* @param bool $debug
|
||||
* @param bool $beta
|
||||
* @param array $openTagList
|
||||
* @param string|null $url
|
||||
*
|
||||
* @return array|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
*/
|
||||
public function getAgentConfigArray(?array $apis, $agentId, bool $debug = false, bool $beta = false, ?array $openTagList = [], ?string $url = null)
|
||||
{
|
||||
return $this->buildAgentConfig($apis, $agentId, $debug, $beta, false, $openTagList, $url);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $jsApiList
|
||||
* @param $agentId
|
||||
* @param bool $debug
|
||||
* @param bool $beta
|
||||
* @param bool $json
|
||||
* @param array $openTagList
|
||||
* @param string|null $url
|
||||
*
|
||||
* @return array|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
*/
|
||||
public function buildAgentConfig(?array $jsApiList, $agentId, bool $debug = false, bool $beta = false, bool $json = true, ?array $openTagList = [], ?string $url = null)
|
||||
{
|
||||
$config = array_merge(compact('debug', 'beta', 'jsApiList', 'openTagList'), $this->agentConfigSignature($agentId, $url));
|
||||
|
||||
return $json ? json_encode($config) : $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $agentId
|
||||
* @param string|null $url
|
||||
* @param string|null $nonce
|
||||
* @param null $timestamp
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
*/
|
||||
protected function agentConfigSignature($agentId, ?string $url = null, ?string $nonce = null, $timestamp = null): array
|
||||
{
|
||||
$url = $url ?: $this->getUrl();
|
||||
$nonce = $nonce ?: Support\Str::quickRandom(10);
|
||||
$timestamp = $timestamp ?: time();
|
||||
|
||||
return [
|
||||
'corpid' => $this->getAppId(),
|
||||
'agentid' => $agentId,
|
||||
'nonceStr' => $nonce,
|
||||
'timestamp' => $timestamp,
|
||||
'url' => $url,
|
||||
'signature' => $this->getTicketSignature($this->getAgentTicket()['ticket'], $nonce, $timestamp, $url),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get js ticket.
|
||||
*
|
||||
* @param bool $refresh
|
||||
* @param string $type
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
*/
|
||||
public function getTicket(bool $refresh = false, ?string $type = 'config'): array
|
||||
{
|
||||
$cacheKey = sprintf('easywechat.work.jssdk.ticket.%s.%s', $type, $this->getAppId());
|
||||
|
||||
if (!$refresh && $this->getCache()->has($cacheKey)) {
|
||||
return $this->getCache()->get($cacheKey);
|
||||
}
|
||||
|
||||
/** @var array<string, mixed> $result */
|
||||
$result = $this->castResponseToType(
|
||||
$this->requestRaw($this->ticketEndpoint, 'GET'),
|
||||
'array'
|
||||
);
|
||||
|
||||
$this->getCache()->set($cacheKey, $result, $result['expires_in'] - 500);
|
||||
|
||||
if (!$this->getCache()->has($cacheKey)) {
|
||||
throw new RuntimeException('Failed to cache jssdk ticket.');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|mixed|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws RuntimeException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
*/
|
||||
public function getAgentTicket(bool $refresh = false, ?string $type = 'agent_config')
|
||||
{
|
||||
$cacheKey = sprintf('easywechat.work.jssdk.ticket.%s.%s.%s', $type, $this->getAppId(), $this->getAgentId());
|
||||
|
||||
if (!$refresh && $this->getCache()->has($cacheKey)) {
|
||||
return $this->getCache()->get($cacheKey);
|
||||
}
|
||||
|
||||
/** @var array<string, mixed> $result */
|
||||
$result = $this->castResponseToType(
|
||||
$this->requestRaw('cgi-bin/ticket/get', 'GET', ['query' => ['type' => $type]]),
|
||||
'array'
|
||||
);
|
||||
|
||||
$this->getCache()->set($cacheKey, $result, $result['expires_in'] - 500);
|
||||
|
||||
if (!$this->getCache()->has($cacheKey)) {
|
||||
throw new RuntimeException('Failed to cache jssdk ticket.');
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/Work/Jssdk/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/Work/Jssdk/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\Jssdk;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['jssdk'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
135
vendor/overtrue/wechat/src/Work/Media/Client.php
vendored
Normal file
135
vendor/overtrue/wechat/src/Work/Media/Client.php
vendored
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\Media;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
use EasyWeChat\Kernel\Http\StreamResponse;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Get media.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Http\Response|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function get(?string $mediaId)
|
||||
{
|
||||
$response = $this->requestRaw('cgi-bin/media/get', 'GET', [
|
||||
'query' => [
|
||||
'media_id' => $mediaId,
|
||||
],
|
||||
]);
|
||||
|
||||
if (false !== stripos($response->getHeaderLine('Content-Type'), 'text/plain')) {
|
||||
return $this->castResponseToType($response, $this->app['config']->get('response_type'));
|
||||
}
|
||||
|
||||
return StreamResponse::buildFromPsrResponse($response);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload Image.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function uploadImage(?string $path)
|
||||
{
|
||||
return $this->upload('image', $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload Voice.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function uploadVoice(?string $path)
|
||||
{
|
||||
return $this->upload('voice', $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload Video.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function uploadVideo(?string $path)
|
||||
{
|
||||
return $this->upload('video', $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload File.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function uploadFile(?string $path)
|
||||
{
|
||||
return $this->upload('file', $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload Attachment Resources
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function uploadAttachmentResources(?string $path, ?string $mediaType = 'image', ?int $attachmentType = 1)
|
||||
{
|
||||
return $this->uploadAttachment($path, $mediaType, $attachmentType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload media.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function upload(?string $type, ?string $path)
|
||||
{
|
||||
$files = [
|
||||
'media' => $path,
|
||||
];
|
||||
|
||||
return $this->httpUpload('cgi-bin/media/upload', $files, [], compact('type'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload media
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function uploadAttachment(?string $path, ?string $mediaType, ?int $attachmentType)
|
||||
{
|
||||
$files = [
|
||||
'media' => $path,
|
||||
];
|
||||
|
||||
$query = [
|
||||
'media_type' => $mediaType,
|
||||
'attachment_type' => $attachmentType,
|
||||
];
|
||||
|
||||
return $this->httpUpload('cgi-bin/media/upload_attachment', $files, [], $query);
|
||||
}
|
||||
}
|
||||
28
vendor/overtrue/wechat/src/Work/Media/ServiceProvider.php
vendored
Normal file
28
vendor/overtrue/wechat/src/Work/Media/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\Media;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['media'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
59
vendor/overtrue/wechat/src/Work/Menu/Client.php
vendored
Normal file
59
vendor/overtrue/wechat/src/Work/Menu/Client.php
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\Menu;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Get menu.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
return $this->httpGet('cgi-bin/menu/get', ['agentid' => $this->app['config']['agent_id']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create menu for the given agent.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function create(?array $data)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/menu/create', $data, ['agentid' => $this->app['config']['agent_id']]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete menu.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
return $this->httpGet('cgi-bin/menu/delete', ['agentid' => $this->app['config']['agent_id']]);
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/Work/Menu/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/Work/Menu/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\Menu;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['menu'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
59
vendor/overtrue/wechat/src/Work/Message/Client.php
vendored
Normal file
59
vendor/overtrue/wechat/src/Work/Message/Client.php
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\Message;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
use EasyWeChat\Kernel\Messages\Message;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* @param string|\EasyWeChat\Kernel\Messages\Message $message
|
||||
*
|
||||
* @return \EasyWeChat\Work\Message\Messenger
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
public function message($message)
|
||||
{
|
||||
return (new Messenger($this))->message($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function send(?array $message)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/message/send', $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $msgid
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function recall(?string $msgid)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/message/recall', ['msgid' => $msgid]);
|
||||
}
|
||||
}
|
||||
217
vendor/overtrue/wechat/src/Work/Message/Messenger.php
vendored
Normal file
217
vendor/overtrue/wechat/src/Work/Message/Messenger.php
vendored
Normal file
@@ -0,0 +1,217 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\Message;
|
||||
|
||||
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
|
||||
use EasyWeChat\Kernel\Exceptions\RuntimeException;
|
||||
use EasyWeChat\Kernel\Messages\Message;
|
||||
use EasyWeChat\Kernel\Messages\Text;
|
||||
|
||||
/**
|
||||
* Class MessageBuilder.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class Messenger
|
||||
{
|
||||
/**
|
||||
* @var \EasyWeChat\Kernel\Messages\Message;
|
||||
*/
|
||||
protected $message;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $to = ['touser' => '@all'];
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $agentId;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
protected $secretive = false;
|
||||
|
||||
/**
|
||||
* @var \EasyWeChat\Work\Message\Client
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* MessageBuilder constructor.
|
||||
*
|
||||
* @param \EasyWeChat\Work\Message\Client $client
|
||||
*/
|
||||
public function __construct(Client $client)
|
||||
{
|
||||
$this->client = $client;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set message to send.
|
||||
*
|
||||
* @param string|Message $message
|
||||
*
|
||||
* @return \EasyWeChat\Work\Message\Messenger
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
public function message($message)
|
||||
{
|
||||
if (is_string($message) || is_numeric($message)) {
|
||||
$message = new Text($message);
|
||||
}
|
||||
|
||||
if (!($message instanceof Message)) {
|
||||
throw new InvalidArgumentException('Invalid message.');
|
||||
}
|
||||
|
||||
$this->message = $message;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \EasyWeChat\Work\Message\Messenger
|
||||
*/
|
||||
public function ofAgent(?int $agentId)
|
||||
{
|
||||
$this->agentId = $agentId;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string $userIds
|
||||
*
|
||||
* @return \EasyWeChat\Work\Message\Messenger
|
||||
*/
|
||||
public function toUser($userIds)
|
||||
{
|
||||
return $this->setRecipients($userIds, 'touser');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string $partyIds
|
||||
*
|
||||
* @return \EasyWeChat\Work\Message\Messenger
|
||||
*/
|
||||
public function toParty($partyIds)
|
||||
{
|
||||
return $this->setRecipients($partyIds, 'toparty');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string $tagIds
|
||||
*
|
||||
* @return \EasyWeChat\Work\Message\Messenger
|
||||
*/
|
||||
public function toTag($tagIds)
|
||||
{
|
||||
return $this->setRecipients($tagIds, 'totag');
|
||||
}
|
||||
|
||||
/**
|
||||
* Keep secret.
|
||||
*
|
||||
* @return \EasyWeChat\Work\Message\Messenger
|
||||
*/
|
||||
public function secretive()
|
||||
{
|
||||
$this->secretive = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array|string $ids
|
||||
*
|
||||
* @return \EasyWeChat\Work\Message\Messenger
|
||||
*/
|
||||
protected function setRecipients($ids, ?string $key): self
|
||||
{
|
||||
if (is_array($ids)) {
|
||||
$ids = implode('|', $ids);
|
||||
}
|
||||
|
||||
$this->to = [$key => $ids];
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \EasyWeChat\Kernel\Messages\Message|string|null $message
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
public function send($message = null)
|
||||
{
|
||||
if ($message) {
|
||||
$this->message($message);
|
||||
}
|
||||
|
||||
if (empty($this->message)) {
|
||||
throw new RuntimeException('No message to send.');
|
||||
}
|
||||
|
||||
if (is_null($this->agentId)) {
|
||||
throw new RuntimeException('No agentid specified.');
|
||||
}
|
||||
|
||||
$message = $this->message->transformForJsonRequest(array_merge([
|
||||
'agentid' => $this->agentId,
|
||||
'safe' => intval($this->secretive),
|
||||
], $this->to));
|
||||
|
||||
$this->secretive = false;
|
||||
|
||||
return $this->client->send($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $msgid
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function recall(?string $msgid)
|
||||
{
|
||||
if (empty($msgid)) {
|
||||
throw new RuntimeException('No msgid specified.');
|
||||
}
|
||||
return $this->client->recall($msgid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return property.
|
||||
*
|
||||
* @param string $property
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public function __get($property)
|
||||
{
|
||||
if (property_exists($this, $property)) {
|
||||
return $this->$property;
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException(sprintf('No property named "%s"', $property));
|
||||
}
|
||||
}
|
||||
43
vendor/overtrue/wechat/src/Work/Message/ServiceProvider.php
vendored
Normal file
43
vendor/overtrue/wechat/src/Work/Message/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\Message;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['message'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
|
||||
$app['messenger'] = function ($app) {
|
||||
$messenger = new Messenger($app['message']);
|
||||
|
||||
if (is_numeric($app['config']['agent_id'])) {
|
||||
$messenger->ofAgent($app['config']['agent_id']);
|
||||
}
|
||||
|
||||
return $messenger;
|
||||
};
|
||||
}
|
||||
}
|
||||
41
vendor/overtrue/wechat/src/Work/MiniProgram/Application.php
vendored
Normal file
41
vendor/overtrue/wechat/src/Work/MiniProgram/Application.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\MiniProgram;
|
||||
|
||||
use EasyWeChat\MiniProgram\Application as MiniProgram;
|
||||
use EasyWeChat\Work\Auth\AccessToken;
|
||||
use EasyWeChat\Work\MiniProgram\Auth\Client;
|
||||
|
||||
/**
|
||||
* Class Application.
|
||||
*
|
||||
* @author Caikeal <caikeal@qq.com>
|
||||
*
|
||||
* @property \EasyWeChat\Work\MiniProgram\Auth\Client $auth
|
||||
*/
|
||||
class Application extends MiniProgram
|
||||
{
|
||||
/**
|
||||
* Application constructor.
|
||||
*/
|
||||
public function __construct(?array $config = [], ?array $prepends = [])
|
||||
{
|
||||
parent::__construct($config, $prepends + [
|
||||
'access_token' => function ($app) {
|
||||
return new AccessToken($app);
|
||||
},
|
||||
'auth' => function ($app) {
|
||||
return new Client($app);
|
||||
},
|
||||
]);
|
||||
}
|
||||
}
|
||||
37
vendor/overtrue/wechat/src/Work/MiniProgram/Auth/Client.php
vendored
Normal file
37
vendor/overtrue/wechat/src/Work/MiniProgram/Auth/Client.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\MiniProgram\Auth;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Get session info by code.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function session(?string $code)
|
||||
{
|
||||
$params = [
|
||||
'js_code' => $code,
|
||||
'grant_type' => 'authorization_code',
|
||||
];
|
||||
|
||||
return $this->httpGet('cgi-bin/miniprogram/jscode2session', $params);
|
||||
}
|
||||
}
|
||||
82
vendor/overtrue/wechat/src/Work/MsgAudit/Client.php
vendored
Normal file
82
vendor/overtrue/wechat/src/Work/MsgAudit/Client.php
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\MsgAudit;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author ZengJJ <z373522886@foxmail.com >
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* @param string|null $type
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function getPermitUsers(?string $type = null)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/msgaudit/get_permit_user_list', (empty($type) ? [] : ['type' => $type]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $info 数组,格式: [[userid, exteranalopenid], [userid, exteranalopenid]]
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function getSingleAgreeStatus(?array $info)
|
||||
{
|
||||
$params = [
|
||||
'info' => $info
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/msgaudit/check_single_agree', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $roomid
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function getRoomAgreeStatus(?string $roomId)
|
||||
{
|
||||
$params = [
|
||||
'roomid' => $roomId
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/msgaudit/check_room_agree', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $roomid
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function getRoom(?string $roomId)
|
||||
{
|
||||
$params = [
|
||||
'roomid' => $roomId
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/msgaudit/groupchat/get', $params);
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/Work/MsgAudit/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/Work/MsgAudit/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\MsgAudit;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author ZengJJ <z373522886@foxmail.com >
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['msg_audit'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
149
vendor/overtrue/wechat/src/Work/OA/Client.php
vendored
Normal file
149
vendor/overtrue/wechat/src/Work/OA/Client.php
vendored
Normal file
@@ -0,0 +1,149 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\OA;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Get the checkin data.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function checkinRecords(?int $startTime, ?int $endTime, ?array $userList, ?int $type = 3)
|
||||
{
|
||||
$params = [
|
||||
'opencheckindatatype' => $type,
|
||||
'starttime' => $startTime,
|
||||
'endtime' => $endTime,
|
||||
'useridlist' => $userList,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/checkin/getcheckindata', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the checkin rules.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function checkinRules(?int $datetime, ?array $userList)
|
||||
{
|
||||
$params = [
|
||||
'datetime' => $datetime,
|
||||
'useridlist' => $userList,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/checkin/getcheckinoption', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get approval template details.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function approvalTemplate(?string $templateId)
|
||||
{
|
||||
$params = [
|
||||
'template_id' => $templateId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/oa/gettemplatedetail', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit an application for approval.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function createApproval(?array $data)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/oa/applyevent', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Approval number.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function approvalNumbers(?int $startTime, ?int $endTime, ?int $nextCursor = 0, ?int $size = 100, ?array $filters = [])
|
||||
{
|
||||
$params = [
|
||||
'starttime' => $startTime,
|
||||
'endtime' => $endTime,
|
||||
'cursor' => $nextCursor,
|
||||
'size' => $size > 100 ? 100 : $size,
|
||||
'filters' => $filters,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/oa/getapprovalinfo', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get approval detail.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function approvalDetail(?int $number)
|
||||
{
|
||||
$params = [
|
||||
'sp_no' => $number,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/oa/getapprovaldetail', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Approval Data.
|
||||
*
|
||||
* @param int $nextNumber
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function approvalRecords(?int $startTime, ?int $endTime, ?int $nextNumber = null)
|
||||
{
|
||||
$params = [
|
||||
'starttime' => $startTime,
|
||||
'endtime' => $endTime,
|
||||
'next_spnum' => $nextNumber,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/corp/getapprovaldata', $params);
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/Work/OA/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/Work/OA/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\OA;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['oa'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
43
vendor/overtrue/wechat/src/Work/OAuth/AccessTokenDelegate.php
vendored
Normal file
43
vendor/overtrue/wechat/src/Work/OAuth/AccessTokenDelegate.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\OAuth;
|
||||
|
||||
use EasyWeChat\Work\Application;
|
||||
use Overtrue\Socialite\AccessTokenInterface;
|
||||
|
||||
/**
|
||||
* Class AccessTokenDelegate.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class AccessTokenDelegate implements AccessTokenInterface
|
||||
{
|
||||
/**
|
||||
* @var \EasyWeChat\Work\Application
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
public function __construct(Application $app)
|
||||
{
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the access token string.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getToken()
|
||||
{
|
||||
return $this->app['access_token']->getToken()['access_token'];
|
||||
}
|
||||
}
|
||||
62
vendor/overtrue/wechat/src/Work/OAuth/ServiceProvider.php
vendored
Normal file
62
vendor/overtrue/wechat/src/Work/OAuth/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\OAuth;
|
||||
|
||||
use Overtrue\Socialite\SocialiteManager;
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['oauth'] = function ($app) {
|
||||
$socialite = (new SocialiteManager([
|
||||
'wework' => [
|
||||
'client_id' => $app['config']['corp_id'],
|
||||
'client_secret' => null,
|
||||
'redirect' => $this->prepareCallbackUrl($app),
|
||||
],
|
||||
], $app['request']))->driver('wework');
|
||||
|
||||
$scopes = (array) $app['config']->get('oauth.scopes', ['snsapi_base']);
|
||||
|
||||
if (!empty($scopes)) {
|
||||
$socialite->scopes($scopes);
|
||||
} else {
|
||||
$socialite->setAgentId($app['config']['agent_id']);
|
||||
}
|
||||
|
||||
return $socialite->setAccessToken(new AccessTokenDelegate($app));
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the OAuth callback url for wechat.
|
||||
*
|
||||
* @param Container $app
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function prepareCallbackUrl($app)
|
||||
{
|
||||
$callback = $app['config']->get('oauth.callback');
|
||||
|
||||
if (0 === stripos($callback, 'http')) {
|
||||
return $callback;
|
||||
}
|
||||
|
||||
$baseUrl = $app['request']->getSchemeAndHttpHost();
|
||||
|
||||
return $baseUrl.'/'.ltrim($callback, '/');
|
||||
}
|
||||
}
|
||||
93
vendor/overtrue/wechat/src/Work/Schedule/Client.php
vendored
Normal file
93
vendor/overtrue/wechat/src/Work/Schedule/Client.php
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\Schedule;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author her-cat <i@her-cat.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Add a schedule.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function add(?array $schedule)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/oa/schedule/add', compact('schedule'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the schedule.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function update(?string $id, ?array $schedule)
|
||||
{
|
||||
$schedule += ['schedule_id' => $id];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/oa/schedule/update', compact('schedule'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get one or more schedules.
|
||||
*
|
||||
* @param string|array $ids
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function get($ids)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/oa/schedule/get', ['schedule_id_list' => (array) $ids]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of schedules under a calendar.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getByCalendar(?string $calendarId, ?int $offset = 0, ?int $limit = 500)
|
||||
{
|
||||
$data = compact('offset', 'limit') + ['cal_id' => $calendarId];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/oa/schedule/get_by_calendar', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a schedule.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function delete(?string $id)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/oa/schedule/del', ['schedule_id' => $id]);
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/Work/Schedule/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/Work/Schedule/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\Schedule;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author her-cat <i@her-cat.com>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['schedule'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
43
vendor/overtrue/wechat/src/Work/Server/Guard.php
vendored
Normal file
43
vendor/overtrue/wechat/src/Work/Server/Guard.php
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\Server;
|
||||
|
||||
use EasyWeChat\Kernel\ServerGuard;
|
||||
|
||||
/**
|
||||
* Class Guard.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class Guard extends ServerGuard
|
||||
{
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function validate()
|
||||
{
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the request message safe mode.
|
||||
*/
|
||||
protected function isSafeMode(): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected function shouldReturnRawResponse(): bool
|
||||
{
|
||||
return !is_null($this->app['request']->get('echostr'));
|
||||
}
|
||||
}
|
||||
56
vendor/overtrue/wechat/src/Work/Server/Handlers/EchoStrHandler.php
vendored
Normal file
56
vendor/overtrue/wechat/src/Work/Server/Handlers/EchoStrHandler.php
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\Server\Handlers;
|
||||
|
||||
use EasyWeChat\Kernel\Contracts\EventHandlerInterface;
|
||||
use EasyWeChat\Kernel\Decorators\FinallyResult;
|
||||
use EasyWeChat\Kernel\ServiceContainer;
|
||||
|
||||
/**
|
||||
* Class EchoStrHandler.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class EchoStrHandler implements EventHandlerInterface
|
||||
{
|
||||
/**
|
||||
* @var ServiceContainer
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
* EchoStrHandler constructor.
|
||||
*/
|
||||
public function __construct(ServiceContainer $app)
|
||||
{
|
||||
$this->app = $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $payload
|
||||
*
|
||||
* @return FinallyResult|null
|
||||
*/
|
||||
public function handle($payload = null)
|
||||
{
|
||||
if ($decrypted = $this->app['request']->get('echostr')) {
|
||||
$str = $this->app['encryptor']->decrypt(
|
||||
$decrypted,
|
||||
$this->app['request']->get('msg_signature'),
|
||||
$this->app['request']->get('nonce'),
|
||||
$this->app['request']->get('timestamp')
|
||||
);
|
||||
|
||||
return new FinallyResult($str);
|
||||
}
|
||||
}
|
||||
}
|
||||
46
vendor/overtrue/wechat/src/Work/Server/ServiceProvider.php
vendored
Normal file
46
vendor/overtrue/wechat/src/Work/Server/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\Server;
|
||||
|
||||
use EasyWeChat\Kernel\Encryptor;
|
||||
use EasyWeChat\Work\Server\Handlers\EchoStrHandler;
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
!isset($app['encryptor']) && $app['encryptor'] = function ($app) {
|
||||
return new Encryptor(
|
||||
$app['config']['corp_id'],
|
||||
$app['config']['token'],
|
||||
$app['config']['aes_key']
|
||||
);
|
||||
};
|
||||
|
||||
!isset($app['server']) && $app['server'] = function ($app) {
|
||||
$guard = new Guard($app);
|
||||
$guard->push(new EchoStrHandler($app));
|
||||
|
||||
return $guard;
|
||||
};
|
||||
}
|
||||
}
|
||||
223
vendor/overtrue/wechat/src/Work/User/Client.php
vendored
Normal file
223
vendor/overtrue/wechat/src/Work/User/Client.php
vendored
Normal file
@@ -0,0 +1,223 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\User;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Create a user.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function create(?array $data)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/user/create', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an exist user.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function update(?string $id, ?array $data)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/user/update', array_merge(['userid' => $id], $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a user.
|
||||
*
|
||||
* @param string|array $userId
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function delete($userId)
|
||||
{
|
||||
if (is_array($userId)) {
|
||||
return $this->batchDelete($userId);
|
||||
}
|
||||
|
||||
return $this->httpGet('cgi-bin/user/delete', ['userid' => $userId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch delete users.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function batchDelete(?array $userIds)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/user/batchdelete', ['useridlist' => $userIds]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function get(?string $userId)
|
||||
{
|
||||
return $this->httpGet('cgi-bin/user/get', ['userid' => $userId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get simple user list.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function getDepartmentUsers(?int $departmentId, bool $fetchChild = false)
|
||||
{
|
||||
$params = [
|
||||
'department_id' => $departmentId,
|
||||
'fetch_child' => (int) $fetchChild,
|
||||
];
|
||||
|
||||
return $this->httpGet('cgi-bin/user/simplelist', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user list.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function getDetailedDepartmentUsers(?int $departmentId, bool $fetchChild = false)
|
||||
{
|
||||
$params = [
|
||||
'department_id' => $departmentId,
|
||||
'fetch_child' => (int) $fetchChild,
|
||||
];
|
||||
|
||||
return $this->httpGet('cgi-bin/user/list', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert userId to openid.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function userIdToOpenid(?string $userId, ?int $agentId = null)
|
||||
{
|
||||
$params = [
|
||||
'userid' => $userId,
|
||||
'agentid' => $agentId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/user/convert_to_openid', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert openid to userId.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function openidToUserId(?string $openid)
|
||||
{
|
||||
$params = [
|
||||
'openid' => $openid,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/user/convert_to_userid', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert mobile to userId.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function mobileToUserId(?string $mobile)
|
||||
{
|
||||
$params = [
|
||||
'mobile' => $mobile,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/user/getuserid', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function accept(?string $userId)
|
||||
{
|
||||
$params = [
|
||||
'userid' => $userId,
|
||||
];
|
||||
|
||||
return $this->httpGet('cgi-bin/user/authsucc', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch invite users.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function invite(?array $params)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/batch/invite', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get invitation QR code.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function getInvitationQrCode(?int $sizeType = 1)
|
||||
{
|
||||
if (!\in_array($sizeType, [1, 2, 3, 4], true)) {
|
||||
throw new InvalidArgumentException('The sizeType must be 1, 2, 3, 4.');
|
||||
}
|
||||
|
||||
return $this->httpGet('cgi-bin/corp/get_join_qrcode', ['size_type' => $sizeType]);
|
||||
}
|
||||
}
|
||||
37
vendor/overtrue/wechat/src/Work/User/ServiceProvider.php
vendored
Normal file
37
vendor/overtrue/wechat/src/Work/User/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\User;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['user'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
|
||||
$app['tag'] = function ($app) {
|
||||
return new TagClient($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
151
vendor/overtrue/wechat/src/Work/User/TagClient.php
vendored
Normal file
151
vendor/overtrue/wechat/src/Work/User/TagClient.php
vendored
Normal file
@@ -0,0 +1,151 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the overtrue/wechat.
|
||||
*
|
||||
* (c) overtrue <i@overtrue.me>
|
||||
*
|
||||
* This source file is subject to the MIT license that is bundled
|
||||
* with this source code in the file LICENSE.
|
||||
*/
|
||||
|
||||
namespace EasyWeChat\Work\User;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class TagClient.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class TagClient extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Create tag.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function create(?string $tagName, ?int $tagId = null)
|
||||
{
|
||||
$params = [
|
||||
'tagname' => $tagName,
|
||||
'tagid' => $tagId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/tag/create', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update tag.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function update(?int $tagId, ?string $tagName)
|
||||
{
|
||||
$params = [
|
||||
'tagid' => $tagId,
|
||||
'tagname' => $tagName,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/tag/update', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete tag.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function delete(?int $tagId)
|
||||
{
|
||||
return $this->httpGet('cgi-bin/tag/delete', ['tagid' => $tagId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function get(?int $tagId)
|
||||
{
|
||||
return $this->httpGet('cgi-bin/tag/get', ['tagid' => $tagId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function tagUsers(?int $tagId, ?array $userList = [])
|
||||
{
|
||||
return $this->tagOrUntagUsers('cgi-bin/tag/addtagusers', $tagId, $userList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function tagDepartments(?int $tagId, ?array $partyList = [])
|
||||
{
|
||||
return $this->tagOrUntagUsers('cgi-bin/tag/addtagusers', $tagId, [], $partyList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function untagUsers(?int $tagId, ?array $userList = [])
|
||||
{
|
||||
return $this->tagOrUntagUsers('cgi-bin/tag/deltagusers', $tagId, $userList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function untagDepartments(?int $tagId, ?array $partyList = [])
|
||||
{
|
||||
return $this->tagOrUntagUsers('cgi-bin/tag/deltagusers', $tagId, [], $partyList);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
protected function tagOrUntagUsers(?string $endpoint, ?int $tagId, ?array $userList = [], ?array $partyList = [])
|
||||
{
|
||||
$data = [
|
||||
'tagid' => $tagId,
|
||||
'userlist' => $userList,
|
||||
'partylist' => $partyList,
|
||||
];
|
||||
|
||||
return $this->httpPostJson($endpoint, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function list()
|
||||
{
|
||||
return $this->httpGet('cgi-bin/tag/list');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user