init
This commit is contained in:
93
vendor/overtrue/wechat/src/OfficialAccount/Application.php
vendored
Normal file
93
vendor/overtrue/wechat/src/OfficialAccount/Application.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\OfficialAccount;
|
||||
|
||||
use EasyWeChat\BasicService;
|
||||
use EasyWeChat\Kernel\ServiceContainer;
|
||||
|
||||
/**
|
||||
* Class Application.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*
|
||||
* @property \EasyWeChat\BasicService\Media\Client $media
|
||||
* @property \EasyWeChat\BasicService\Url\Client $url
|
||||
* @property \EasyWeChat\BasicService\QrCode\Client $qrcode
|
||||
* @property \EasyWeChat\BasicService\Jssdk\Client $jssdk
|
||||
* @property \EasyWeChat\OfficialAccount\Auth\AccessToken $access_token
|
||||
* @property \EasyWeChat\OfficialAccount\Server\Guard $server
|
||||
* @property \EasyWeChat\OfficialAccount\User\UserClient $user
|
||||
* @property \EasyWeChat\OfficialAccount\User\TagClient $user_tag
|
||||
* @property \EasyWeChat\OfficialAccount\Menu\Client $menu
|
||||
* @property \EasyWeChat\OfficialAccount\TemplateMessage\Client $template_message
|
||||
* @property \EasyWeChat\OfficialAccount\SubscribeMessage\Client $subscribe_message
|
||||
* @property \EasyWeChat\OfficialAccount\Material\Client $material
|
||||
* @property \EasyWeChat\OfficialAccount\CustomerService\Client $customer_service
|
||||
* @property \EasyWeChat\OfficialAccount\CustomerService\SessionClient $customer_service_session
|
||||
* @property \EasyWeChat\OfficialAccount\Semantic\Client $semantic
|
||||
* @property \EasyWeChat\OfficialAccount\DataCube\Client $data_cube
|
||||
* @property \EasyWeChat\OfficialAccount\AutoReply\Client $auto_reply
|
||||
* @property \EasyWeChat\OfficialAccount\Broadcasting\Client $broadcasting
|
||||
* @property \EasyWeChat\OfficialAccount\Card\Card $card
|
||||
* @property \EasyWeChat\OfficialAccount\Device\Client $device
|
||||
* @property \EasyWeChat\OfficialAccount\ShakeAround\ShakeAround $shake_around
|
||||
* @property \EasyWeChat\OfficialAccount\POI\Client $poi
|
||||
* @property \EasyWeChat\OfficialAccount\Store\Client $store
|
||||
* @property \EasyWeChat\OfficialAccount\Base\Client $base
|
||||
* @property \EasyWeChat\OfficialAccount\Comment\Client $comment
|
||||
* @property \EasyWeChat\OfficialAccount\OCR\Client $ocr
|
||||
* @property \EasyWeChat\OfficialAccount\Goods\Client $goods
|
||||
* @property \Overtrue\Socialite\Providers\WeChatProvider $oauth
|
||||
* @property \EasyWeChat\OfficialAccount\WiFi\Client $wifi
|
||||
* @property \EasyWeChat\OfficialAccount\WiFi\CardClient $wifi_card
|
||||
* @property \EasyWeChat\OfficialAccount\WiFi\DeviceClient $wifi_device
|
||||
* @property \EasyWeChat\OfficialAccount\WiFi\ShopClient $wifi_shop
|
||||
* @property \EasyWeChat\OfficialAccount\Guide\Client $guide
|
||||
*/
|
||||
class Application extends ServiceContainer
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $providers = [
|
||||
Auth\ServiceProvider::class,
|
||||
Server\ServiceProvider::class,
|
||||
User\ServiceProvider::class,
|
||||
OAuth\ServiceProvider::class,
|
||||
Menu\ServiceProvider::class,
|
||||
TemplateMessage\ServiceProvider::class,
|
||||
SubscribeMessage\ServiceProvider::class,
|
||||
Material\ServiceProvider::class,
|
||||
CustomerService\ServiceProvider::class,
|
||||
Semantic\ServiceProvider::class,
|
||||
DataCube\ServiceProvider::class,
|
||||
POI\ServiceProvider::class,
|
||||
AutoReply\ServiceProvider::class,
|
||||
Broadcasting\ServiceProvider::class,
|
||||
Card\ServiceProvider::class,
|
||||
Device\ServiceProvider::class,
|
||||
ShakeAround\ServiceProvider::class,
|
||||
Store\ServiceProvider::class,
|
||||
Comment\ServiceProvider::class,
|
||||
Base\ServiceProvider::class,
|
||||
OCR\ServiceProvider::class,
|
||||
Goods\ServiceProvider::class,
|
||||
WiFi\ServiceProvider::class,
|
||||
// Base services
|
||||
BasicService\QrCode\ServiceProvider::class,
|
||||
BasicService\Media\ServiceProvider::class,
|
||||
BasicService\Url\ServiceProvider::class,
|
||||
BasicService\Jssdk\ServiceProvider::class,
|
||||
// Append Guide Interface
|
||||
Guide\ServiceProvider::class,
|
||||
];
|
||||
}
|
||||
36
vendor/overtrue/wechat/src/OfficialAccount/Auth/AccessToken.php
vendored
Normal file
36
vendor/overtrue/wechat/src/OfficialAccount/Auth/AccessToken.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?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\OfficialAccount\Auth;
|
||||
|
||||
use EasyWeChat\Kernel\AccessToken as BaseAccessToken;
|
||||
|
||||
/**
|
||||
* Class AuthorizerAccessToken.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class AccessToken extends BaseAccessToken
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $endpointToGetToken = 'cgi-bin/token';
|
||||
|
||||
protected function getCredentials(): array
|
||||
{
|
||||
return [
|
||||
'grant_type' => 'client_credential',
|
||||
'appid' => $this->app['config']['app_id'],
|
||||
'secret' => $this->app['config']['secret'],
|
||||
];
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/OfficialAccount/Auth/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/OfficialAccount/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\OfficialAccount\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/OfficialAccount/AutoReply/Client.php
vendored
Normal file
34
vendor/overtrue/wechat/src/OfficialAccount/AutoReply/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\OfficialAccount\AutoReply;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Get current auto reply settings.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
return $this->httpGet('cgi-bin/get_current_autoreply_info');
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/OfficialAccount/AutoReply/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/OfficialAccount/AutoReply/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\OfficialAccount\AutoReply;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['auto_reply'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
81
vendor/overtrue/wechat/src/OfficialAccount/Base/Client.php
vendored
Normal file
81
vendor/overtrue/wechat/src/OfficialAccount/Base/Client.php
vendored
Normal file
@@ -0,0 +1,81 @@
|
||||
<?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\OfficialAccount\Base;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Clear quota.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function clearQuota()
|
||||
{
|
||||
$params = [
|
||||
'appid' => $this->app['config']['app_id'],
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/clear_quota', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get wechat callback ip.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function getValidIps()
|
||||
{
|
||||
return $this->httpGet('cgi-bin/getcallbackip');
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the callback address network.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws InvalidArgumentException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function checkCallbackUrl(string $action = 'all', string $operator = 'DEFAULT')
|
||||
{
|
||||
if (!in_array($action, ['dns', 'ping', 'all'], true)) {
|
||||
throw new InvalidArgumentException('The action must be dns, ping, all.');
|
||||
}
|
||||
|
||||
$operator = strtoupper($operator);
|
||||
|
||||
if (!in_array($operator, ['CHINANET', 'UNICOM', 'CAP', 'DEFAULT'], true)) {
|
||||
throw new InvalidArgumentException('The operator must be CHINANET, UNICOM, CAP, DEFAULT.');
|
||||
}
|
||||
|
||||
$params = [
|
||||
'action' => $action,
|
||||
'check_operator' => $operator,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/callback/check', $params);
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/OfficialAccount/Base/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/OfficialAccount/Base/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\OfficialAccount\Base;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author mingyoung <mingyoungcheung@gmail.com>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['base'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
359
vendor/overtrue/wechat/src/OfficialAccount/Broadcasting/Client.php
vendored
Normal file
359
vendor/overtrue/wechat/src/OfficialAccount/Broadcasting/Client.php
vendored
Normal file
@@ -0,0 +1,359 @@
|
||||
<?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\OfficialAccount\Broadcasting;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
use EasyWeChat\Kernel\Contracts\MessageInterface;
|
||||
use EasyWeChat\Kernel\Exceptions\RuntimeException;
|
||||
use EasyWeChat\Kernel\Messages\Card;
|
||||
use EasyWeChat\Kernel\Messages\Image;
|
||||
use EasyWeChat\Kernel\Messages\Media;
|
||||
use EasyWeChat\Kernel\Messages\Text;
|
||||
use EasyWeChat\Kernel\Support\Arr;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @method \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string previewTextByName($text, $name);
|
||||
* @method \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string previewNewsByName($mediaId, $name);
|
||||
* @method \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string previewVoiceByName($mediaId, $name);
|
||||
* @method \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string previewImageByName($mediaId, $name);
|
||||
* @method \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string previewVideoByName($message, $name);
|
||||
* @method \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string previewCardByName($cardId, $name);
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
public const PREVIEW_BY_OPENID = 'touser';
|
||||
public const PREVIEW_BY_NAME = 'towxname';
|
||||
|
||||
/**
|
||||
* Send a message.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function send(array $message)
|
||||
{
|
||||
if (empty($message['filter']) && empty($message['touser'])) {
|
||||
throw new RuntimeException('The message reception object is not specified');
|
||||
}
|
||||
|
||||
$api = Arr::get($message, 'touser') ? 'cgi-bin/message/mass/send' : 'cgi-bin/message/mass/sendall';
|
||||
|
||||
return $this->httpPostJson($api, $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Preview a message.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function preview(array $message)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/message/mass/preview', $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a broadcast.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function delete(string $msgId, int $index = 0)
|
||||
{
|
||||
$options = [
|
||||
'msg_id' => $msgId,
|
||||
'article_idx' => $index,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/message/mass/delete', $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a broadcast status.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function status(string $msgId)
|
||||
{
|
||||
$options = [
|
||||
'msg_id' => $msgId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/message/mass/get', $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a text message.
|
||||
*
|
||||
* @param mixed $reception
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
|
||||
*/
|
||||
public function sendText(string $message, $reception = null, array $attributes = [])
|
||||
{
|
||||
return $this->sendMessage(new Text($message), $reception, $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a news message.
|
||||
*
|
||||
* @param mixed $reception
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
|
||||
*/
|
||||
public function sendNews(string $mediaId, $reception = null, array $attributes = [])
|
||||
{
|
||||
return $this->sendMessage(new Media($mediaId, 'mpnews'), $reception, $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a voice message.
|
||||
*
|
||||
* @param mixed $reception
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
|
||||
*/
|
||||
public function sendVoice(string $mediaId, $reception = null, array $attributes = [])
|
||||
{
|
||||
return $this->sendMessage(new Media($mediaId, 'voice'), $reception, $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a image message.
|
||||
*
|
||||
* @param mixed $reception
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
|
||||
*/
|
||||
public function sendImage(string $mediaId, $reception = null, array $attributes = [])
|
||||
{
|
||||
return $this->sendMessage(new Image($mediaId), $reception, $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a video message.
|
||||
*
|
||||
* @param mixed $reception
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
|
||||
*/
|
||||
public function sendVideo(string $mediaId, $reception = null, array $attributes = [])
|
||||
{
|
||||
return $this->sendMessage(new Media($mediaId, 'mpvideo'), $reception, $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a card message.
|
||||
*
|
||||
* @param mixed $reception
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
|
||||
*/
|
||||
public function sendCard(string $cardId, $reception = null, array $attributes = [])
|
||||
{
|
||||
return $this->sendMessage(new Card($cardId), $reception, $attributes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Preview a text message.
|
||||
*
|
||||
* @param string $message message
|
||||
* @param string $reception
|
||||
* @param string $method
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function previewText(string $message, $reception, $method = self::PREVIEW_BY_OPENID)
|
||||
{
|
||||
return $this->previewMessage(new Text($message), $reception, $method);
|
||||
}
|
||||
|
||||
/**
|
||||
* Preview a news message.
|
||||
*
|
||||
* @param string $mediaId message
|
||||
* @param string $reception
|
||||
* @param string $method
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function previewNews(string $mediaId, $reception, $method = self::PREVIEW_BY_OPENID)
|
||||
{
|
||||
return $this->previewMessage(new Media($mediaId, 'mpnews'), $reception, $method);
|
||||
}
|
||||
|
||||
/**
|
||||
* Preview a voice message.
|
||||
*
|
||||
* @param string $mediaId message
|
||||
* @param string $reception
|
||||
* @param string $method
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function previewVoice(string $mediaId, $reception, $method = self::PREVIEW_BY_OPENID)
|
||||
{
|
||||
return $this->previewMessage(new Media($mediaId, 'voice'), $reception, $method);
|
||||
}
|
||||
|
||||
/**
|
||||
* Preview a image message.
|
||||
*
|
||||
* @param string $mediaId message
|
||||
* @param string $reception
|
||||
* @param string $method
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function previewImage(string $mediaId, $reception, $method = self::PREVIEW_BY_OPENID)
|
||||
{
|
||||
return $this->previewMessage(new Image($mediaId), $reception, $method);
|
||||
}
|
||||
|
||||
/**
|
||||
* Preview a video message.
|
||||
*
|
||||
* @param string $mediaId message
|
||||
* @param string $reception
|
||||
* @param string $method
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function previewVideo(string $mediaId, $reception, $method = self::PREVIEW_BY_OPENID)
|
||||
{
|
||||
return $this->previewMessage(new Media($mediaId, 'mpvideo'), $reception, $method);
|
||||
}
|
||||
|
||||
/**
|
||||
* Preview a card message.
|
||||
*
|
||||
* @param string $cardId message
|
||||
* @param string $reception
|
||||
* @param string $method
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function previewCard(string $cardId, $reception, $method = self::PREVIEW_BY_OPENID)
|
||||
{
|
||||
return $this->previewMessage(new Card($cardId), $reception, $method);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $method
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function previewMessage(MessageInterface $message, string $reception, $method = self::PREVIEW_BY_OPENID)
|
||||
{
|
||||
$message = (new MessageBuilder())->message($message)->buildForPreview($method, $reception);
|
||||
|
||||
return $this->preview($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $reception
|
||||
* @param array $attributes
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
|
||||
*/
|
||||
public function sendMessage(MessageInterface $message, $reception = null, $attributes = [])
|
||||
{
|
||||
$message = (new MessageBuilder())->message($message)->with($attributes)->toAll();
|
||||
|
||||
if (\is_int($reception)) {
|
||||
$message->toTag($reception);
|
||||
} elseif (\is_array($reception)) {
|
||||
$message->toUsers($reception);
|
||||
}
|
||||
|
||||
return $this->send($message->build());
|
||||
}
|
||||
|
||||
/**
|
||||
* @codeCoverageIgnore
|
||||
*
|
||||
* @param string $method
|
||||
* @param array $args
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __call($method, $args)
|
||||
{
|
||||
if (strpos($method, 'ByName') > 0) {
|
||||
$method = strstr($method, 'ByName', true);
|
||||
|
||||
if (method_exists($this, $method)) {
|
||||
array_push($args, self::PREVIEW_BY_NAME);
|
||||
|
||||
return $this->$method(...$args);
|
||||
}
|
||||
}
|
||||
|
||||
throw new \BadMethodCallException(sprintf('Method %s not exists.', $method));
|
||||
}
|
||||
}
|
||||
143
vendor/overtrue/wechat/src/OfficialAccount/Broadcasting/MessageBuilder.php
vendored
Normal file
143
vendor/overtrue/wechat/src/OfficialAccount/Broadcasting/MessageBuilder.php
vendored
Normal file
@@ -0,0 +1,143 @@
|
||||
<?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\OfficialAccount\Broadcasting;
|
||||
|
||||
use EasyWeChat\Kernel\Contracts\MessageInterface;
|
||||
use EasyWeChat\Kernel\Exceptions\RuntimeException;
|
||||
|
||||
/**
|
||||
* Class MessageBuilder.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class MessageBuilder
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $to = [];
|
||||
|
||||
/**
|
||||
* @var \EasyWeChat\Kernel\Contracts\MessageInterface
|
||||
*/
|
||||
protected $message;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $attributes = [];
|
||||
|
||||
/**
|
||||
* Set message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function message(MessageInterface $message)
|
||||
{
|
||||
$this->message = $message;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set target user or group.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function to(array $to)
|
||||
{
|
||||
$this->to = $to;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \EasyWeChat\OfficialAccount\Broadcasting\MessageBuilder
|
||||
*/
|
||||
public function toTag(int $tagId)
|
||||
{
|
||||
$this->to([
|
||||
'filter' => [
|
||||
'is_to_all' => false,
|
||||
'tag_id' => $tagId,
|
||||
],
|
||||
]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \EasyWeChat\OfficialAccount\Broadcasting\MessageBuilder
|
||||
*/
|
||||
public function toUsers(array $openids)
|
||||
{
|
||||
$this->to([
|
||||
'touser' => $openids,
|
||||
]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return $this
|
||||
*/
|
||||
public function toAll()
|
||||
{
|
||||
$this->to([
|
||||
'filter' => ['is_to_all' => true],
|
||||
]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \EasyWeChat\OfficialAccount\Broadcasting\MessageBuilder
|
||||
*/
|
||||
public function with(array $attributes)
|
||||
{
|
||||
$this->attributes = $attributes;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build message.
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
|
||||
*/
|
||||
public function build(array $prepends = []): array
|
||||
{
|
||||
if (empty($this->message)) {
|
||||
throw new RuntimeException('No message content to send.');
|
||||
}
|
||||
|
||||
$content = $this->message->transformForJsonRequest();
|
||||
|
||||
if (empty($prepends)) {
|
||||
$prepends = $this->to;
|
||||
}
|
||||
|
||||
$message = array_merge($prepends, $content, $this->attributes);
|
||||
|
||||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build preview message.
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
|
||||
*/
|
||||
public function buildForPreview(string $by, string $user): array
|
||||
{
|
||||
return $this->build([$by => $user]);
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/OfficialAccount/Broadcasting/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/OfficialAccount/Broadcasting/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\OfficialAccount\Broadcasting;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['broadcasting'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
31
vendor/overtrue/wechat/src/OfficialAccount/Card/BoardingPassClient.php
vendored
Normal file
31
vendor/overtrue/wechat/src/OfficialAccount/Card/BoardingPassClient.php
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?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\OfficialAccount\Card;
|
||||
|
||||
/**
|
||||
* Class BoardingPassClient.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class BoardingPassClient extends Client
|
||||
{
|
||||
/**
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function checkin(array $params)
|
||||
{
|
||||
return $this->httpPostJson('card/boardingpass/checkin', $params);
|
||||
}
|
||||
}
|
||||
52
vendor/overtrue/wechat/src/OfficialAccount/Card/Card.php
vendored
Normal file
52
vendor/overtrue/wechat/src/OfficialAccount/Card/Card.php
vendored
Normal file
@@ -0,0 +1,52 @@
|
||||
<?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\OfficialAccount\Card;
|
||||
|
||||
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Class Card.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*
|
||||
* @property \EasyWeChat\OfficialAccount\Card\CodeClient $code
|
||||
* @property \EasyWeChat\OfficialAccount\Card\MeetingTicketClient $meeting_ticket
|
||||
* @property \EasyWeChat\OfficialAccount\Card\MemberCardClient $member_card
|
||||
* @property \EasyWeChat\OfficialAccount\Card\GeneralCardClient $general_card
|
||||
* @property \EasyWeChat\OfficialAccount\Card\MovieTicketClient $movie_ticket
|
||||
* @property \EasyWeChat\OfficialAccount\Card\CoinClient $coin
|
||||
* @property \EasyWeChat\OfficialAccount\Card\SubMerchantClient $sub_merchant
|
||||
* @property \EasyWeChat\OfficialAccount\Card\BoardingPassClient $boarding_pass
|
||||
* @property \EasyWeChat\OfficialAccount\Card\JssdkClient $jssdk
|
||||
* @property \EasyWeChat\OfficialAccount\Card\GiftCardClient $gift_card
|
||||
* @property \EasyWeChat\OfficialAccount\Card\GiftCardOrderClient $gift_card_order
|
||||
* @property \EasyWeChat\OfficialAccount\Card\GiftCardPageClient $gift_card_page
|
||||
* @property \EasyWeChat\OfficialAccount\Card\InvoiceClient $invoice
|
||||
*/
|
||||
class Card extends Client
|
||||
{
|
||||
/**
|
||||
* @param string $property
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
public function __get($property)
|
||||
{
|
||||
if (isset($this->app["card.{$property}"])) {
|
||||
return $this->app["card.{$property}"];
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException(sprintf('No card service named "%s".', $property));
|
||||
}
|
||||
}
|
||||
422
vendor/overtrue/wechat/src/OfficialAccount/Card/Client.php
vendored
Normal file
422
vendor/overtrue/wechat/src/OfficialAccount/Card/Client.php
vendored
Normal file
@@ -0,0 +1,422 @@
|
||||
<?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\OfficialAccount\Card;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
use EasyWeChat\Kernel\Traits\InteractsWithCache;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
use InteractsWithCache;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected $url;
|
||||
|
||||
/**
|
||||
* Ticket cache key.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $ticketCacheKey;
|
||||
|
||||
/**
|
||||
* Ticket cache prefix.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $ticketCachePrefix = 'easywechat.official_account.card.api_ticket.';
|
||||
|
||||
/**
|
||||
* 获取卡券颜色.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function colors()
|
||||
{
|
||||
return $this->httpGet('card/getcolors');
|
||||
}
|
||||
|
||||
/**
|
||||
* 卡券开放类目查询接口.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function categories()
|
||||
{
|
||||
return $this->httpGet('card/getapplyprotocol');
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建卡券.
|
||||
*
|
||||
* @param string $cardType
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function create($cardType = 'member_card', array $attributes)
|
||||
{
|
||||
$params = [
|
||||
'card' => [
|
||||
'card_type' => strtoupper($cardType),
|
||||
strtolower($cardType) => $attributes,
|
||||
],
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/create', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看卡券详情.
|
||||
*
|
||||
* @param string $cardId
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function get($cardId)
|
||||
{
|
||||
$params = [
|
||||
'card_id' => $cardId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/get', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量查询卡列表.
|
||||
*
|
||||
* @param int $offset
|
||||
* @param int $count
|
||||
* @param string $statusList
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function list($offset = 0, $count = 10, $statusList = 'CARD_STATUS_VERIFY_OK')
|
||||
{
|
||||
$params = [
|
||||
'offset' => $offset,
|
||||
'count' => $count,
|
||||
'status_list' => $statusList,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/batchget', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更改卡券信息接口 and 设置跟随推荐接口.
|
||||
*
|
||||
* @param string $cardId
|
||||
* @param string $type
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function update($cardId, $type, array $attributes = [])
|
||||
{
|
||||
$card = [];
|
||||
$card['card_id'] = $cardId;
|
||||
$card[strtolower($type)] = $attributes;
|
||||
|
||||
return $this->httpPostJson('card/update', $card);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除卡券接口.
|
||||
*
|
||||
* @param string $cardId
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function delete($cardId)
|
||||
{
|
||||
$params = [
|
||||
'card_id' => $cardId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/delete', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建二维码.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function createQrCode(array $cards)
|
||||
{
|
||||
return $this->httpPostJson('card/qrcode/create', $cards);
|
||||
}
|
||||
|
||||
/**
|
||||
* ticket 换取二维码图片.
|
||||
*
|
||||
* @param string $ticket
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getQrCode($ticket)
|
||||
{
|
||||
$baseUri = 'https://mp.weixin.qq.com/cgi-bin/showqrcode';
|
||||
$params = [
|
||||
'ticket' => $ticket,
|
||||
];
|
||||
|
||||
$response = $this->requestRaw($baseUri, 'GET', $params);
|
||||
|
||||
return [
|
||||
'status' => $response->getStatusCode(),
|
||||
'reason' => $response->getReasonPhrase(),
|
||||
'headers' => $response->getHeaders(),
|
||||
'body' => strval($response->getBody()),
|
||||
'url' => $baseUri.'?'.http_build_query($params),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过ticket换取二维码 链接.
|
||||
*
|
||||
* @param string $ticket
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getQrCodeUrl($ticket)
|
||||
{
|
||||
return sprintf('https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=%s', $ticket);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建货架接口.
|
||||
*
|
||||
* @param string $banner
|
||||
* @param string $pageTitle
|
||||
* @param bool $canShare
|
||||
* @param string $scene [SCENE_NEAR_BY 附近,SCENE_MENU 自定义菜单,SCENE_QRCODE 二维码,SCENE_ARTICLE 公众号文章,
|
||||
* SCENE_H5 h5页面,SCENE_IVR 自动回复,SCENE_CARD_CUSTOM_CELL 卡券自定义cell]
|
||||
* @param array $cardList
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function createLandingPage($banner, $pageTitle, $canShare, $scene, $cardList)
|
||||
{
|
||||
$params = [
|
||||
'banner' => $banner,
|
||||
'page_title' => $pageTitle,
|
||||
'can_share' => $canShare,
|
||||
'scene' => $scene,
|
||||
'card_list' => $cardList,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/landingpage/create', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 图文消息群发卡券.
|
||||
*
|
||||
* @param string $cardId
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getHtml($cardId)
|
||||
{
|
||||
$params = [
|
||||
'card_id' => $cardId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/mpnews/gethtml', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置测试白名单.
|
||||
*
|
||||
* @param array $openids
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function setTestWhitelist($openids)
|
||||
{
|
||||
$params = [
|
||||
'openid' => $openids,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/testwhitelist/set', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置测试白名单(by username).
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function setTestWhitelistByName(array $usernames)
|
||||
{
|
||||
$params = [
|
||||
'username' => $usernames,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/testwhitelist/set', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户已领取卡券接口.
|
||||
*
|
||||
* @param string $openid
|
||||
* @param string $cardId
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getUserCards($openid, $cardId = '')
|
||||
{
|
||||
$params = [
|
||||
'openid' => $openid,
|
||||
'card_id' => $cardId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/user/getcardlist', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置微信买单接口.
|
||||
* 设置买单的 card_id 必须已经配置了门店,否则会报错.
|
||||
*
|
||||
* @param string $cardId
|
||||
* @param bool $isOpen
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function setPayCell($cardId, $isOpen = true)
|
||||
{
|
||||
$params = [
|
||||
'card_id' => $cardId,
|
||||
'is_open' => $isOpen,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/paycell/set', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置自助核销接口
|
||||
* 设置买单的 card_id 必须已经配置了门店,否则会报错.
|
||||
*
|
||||
* @param string $cardId
|
||||
* @param bool $isOpen
|
||||
* @param bool $verifyCod
|
||||
* @param bool $remarkAmount
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function setPayConsumeCell($cardId, $isOpen = true, $verifyCod = false, $remarkAmount = false)
|
||||
{
|
||||
$params = [
|
||||
'card_id' => $cardId,
|
||||
'is_open' => $isOpen,
|
||||
'need_verify_cod' => $verifyCod,
|
||||
'need_remark_amount' => $remarkAmount,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/selfconsumecell/set', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加库存.
|
||||
*
|
||||
* @param string $cardId
|
||||
* @param int $amount
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*/
|
||||
public function increaseStock($cardId, $amount)
|
||||
{
|
||||
return $this->updateStock($cardId, $amount, 'increase');
|
||||
}
|
||||
|
||||
/**
|
||||
* 减少库存.
|
||||
*
|
||||
* @param string $cardId
|
||||
* @param int $amount
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*/
|
||||
public function reduceStock($cardId, $amount)
|
||||
{
|
||||
return $this->updateStock($cardId, $amount, 'reduce');
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改库存接口.
|
||||
*
|
||||
* @param string $cardId
|
||||
* @param int $amount
|
||||
* @param string $action
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
protected function updateStock($cardId, $amount, $action = 'increase')
|
||||
{
|
||||
$key = 'increase' === $action ? 'increase_stock_value' : 'reduce_stock_value';
|
||||
$params = [
|
||||
'card_id' => $cardId,
|
||||
$key => abs($amount),
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/modifystock', $params);
|
||||
}
|
||||
}
|
||||
169
vendor/overtrue/wechat/src/OfficialAccount/Card/CodeClient.php
vendored
Normal file
169
vendor/overtrue/wechat/src/OfficialAccount/Card/CodeClient.php
vendored
Normal file
@@ -0,0 +1,169 @@
|
||||
<?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\OfficialAccount\Card;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class CodeClient.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class CodeClient extends BaseClient
|
||||
{
|
||||
/**
|
||||
* 导入code接口.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function deposit(string $cardId, array $codes)
|
||||
{
|
||||
$params = [
|
||||
'card_id' => $cardId,
|
||||
'code' => $codes,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/code/deposit', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询导入code数目.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getDepositedCount(string $cardId)
|
||||
{
|
||||
$params = [
|
||||
'card_id' => $cardId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/code/getdepositcount', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 核查code接口.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function check(string $cardId, array $codes)
|
||||
{
|
||||
$params = [
|
||||
'card_id' => $cardId,
|
||||
'code' => $codes,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/code/checkcode', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询 Code 接口.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function get(string $code, string $cardId = '', bool $checkConsume = true)
|
||||
{
|
||||
$params = [
|
||||
'code' => $code,
|
||||
'check_consume' => $checkConsume,
|
||||
'card_id' => $cardId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/code/get', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更改Code接口.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function update(string $code, string $newCode, string $cardId = '')
|
||||
{
|
||||
$params = [
|
||||
'code' => $code,
|
||||
'new_code' => $newCode,
|
||||
'card_id' => $cardId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/code/update', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置卡券失效.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function disable(string $code, string $cardId = '')
|
||||
{
|
||||
$params = [
|
||||
'code' => $code,
|
||||
'card_id' => $cardId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/code/unavailable', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 核销 Code 接口.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function consume(string $code, string $cardId = null)
|
||||
{
|
||||
$params = [
|
||||
'code' => $code,
|
||||
];
|
||||
|
||||
if (!is_null($cardId)) {
|
||||
$params['card_id'] = $cardId;
|
||||
}
|
||||
|
||||
return $this->httpPostJson('card/code/consume', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Code解码接口.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function decrypt(string $encryptedCode)
|
||||
{
|
||||
$params = [
|
||||
'encrypt_code' => $encryptedCode,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/code/decrypt', $params);
|
||||
}
|
||||
}
|
||||
106
vendor/overtrue/wechat/src/OfficialAccount/Card/CoinClient.php
vendored
Normal file
106
vendor/overtrue/wechat/src/OfficialAccount/Card/CoinClient.php
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
<?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\OfficialAccount\Card;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class CoinClient.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class CoinClient extends BaseClient
|
||||
{
|
||||
/**
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function activate()
|
||||
{
|
||||
return $this->httpGet('card/pay/activate');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getPrice(string $cardId, int $quantity)
|
||||
{
|
||||
return $this->httpPostJson('card/pay/getpayprice', [
|
||||
'card_id' => $cardId,
|
||||
'quantity' => $quantity,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function summary()
|
||||
{
|
||||
return $this->httpGet('card/pay/getcoinsinfo');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function recharge(int $count)
|
||||
{
|
||||
return $this->httpPostJson('card/pay/recharge', [
|
||||
'coin_count' => $count,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function order(string $orderId)
|
||||
{
|
||||
return $this->httpPostJson('card/pay/getorder', ['order_id' => $orderId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function orders(array $filters)
|
||||
{
|
||||
return $this->httpPostJson('card/pay/getorderlist', $filters);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function confirm(string $cardId, string $orderId, int $quantity)
|
||||
{
|
||||
return $this->httpPostJson('card/pay/confirm', [
|
||||
'card_id' => $cardId,
|
||||
'order_id' => $orderId,
|
||||
'quantity' => $quantity,
|
||||
]);
|
||||
}
|
||||
}
|
||||
64
vendor/overtrue/wechat/src/OfficialAccount/Card/GeneralCardClient.php
vendored
Normal file
64
vendor/overtrue/wechat/src/OfficialAccount/Card/GeneralCardClient.php
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
<?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\OfficialAccount\Card;
|
||||
|
||||
/**
|
||||
* Class GeneralCardClient.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class GeneralCardClient extends Client
|
||||
{
|
||||
/**
|
||||
* 通用卡接口激活.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function activate(array $info = [])
|
||||
{
|
||||
return $this->httpPostJson('card/generalcard/activate', $info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通用卡撤销激活.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function deactivate(string $cardId, string $code)
|
||||
{
|
||||
$params = [
|
||||
'card_id' => $cardId,
|
||||
'code' => $code,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/generalcard/unactivate', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新会员信息.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function updateUser(array $params = [])
|
||||
{
|
||||
return $this->httpPostJson('card/generalcard/updateuser', $params);
|
||||
}
|
||||
}
|
||||
66
vendor/overtrue/wechat/src/OfficialAccount/Card/GiftCardClient.php
vendored
Normal file
66
vendor/overtrue/wechat/src/OfficialAccount/Card/GiftCardClient.php
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
<?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\OfficialAccount\Card;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class GiftCardClient.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class GiftCardClient extends BaseClient
|
||||
{
|
||||
/**
|
||||
* 申请微信支付礼品卡权限接口.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function add(string $subMchId)
|
||||
{
|
||||
$params = [
|
||||
'sub_mch_id' => $subMchId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/giftcard/pay/whitelist/add', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定商户号到礼品卡小程序接口(商户号必须为公众号申请的商户号,否则报错).
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function bind(string $subMchId, string $wxaAppid)
|
||||
{
|
||||
$params = [
|
||||
'sub_mch_id' => $subMchId,
|
||||
'wxa_appid' => $wxaAppid,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/giftcard/pay/submch/bind', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传小程序代码.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function set(string $wxaAppid, string $pageId)
|
||||
{
|
||||
$params = [
|
||||
'wxa_appid' => $wxaAppid,
|
||||
'page_id' => $pageId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/giftcard/wxa/set', $params);
|
||||
}
|
||||
}
|
||||
68
vendor/overtrue/wechat/src/OfficialAccount/Card/GiftCardOrderClient.php
vendored
Normal file
68
vendor/overtrue/wechat/src/OfficialAccount/Card/GiftCardOrderClient.php
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
<?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\OfficialAccount\Card;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class GiftCardOrderClient.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class GiftCardOrderClient extends BaseClient
|
||||
{
|
||||
/**
|
||||
* 查询-单个礼品卡订单信息接口.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get(string $orderId)
|
||||
{
|
||||
$params = [
|
||||
'order_id' => $orderId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/giftcard/order/get', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询-批量查询礼品卡订单信息接口.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function list(int $beginTime, int $endTime, int $offset = 0, int $count = 10, string $sortType = 'ASC')
|
||||
{
|
||||
$params = [
|
||||
'begin_time' => $beginTime,
|
||||
'end_time' => $endTime,
|
||||
'sort_type' => $sortType,
|
||||
'offset' => $offset,
|
||||
'count' => $count,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/giftcard/order/batchget', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款接口.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function refund(string $orderId)
|
||||
{
|
||||
$params = [
|
||||
'order_id' => $orderId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/giftcard/order/refund', $params);
|
||||
}
|
||||
}
|
||||
92
vendor/overtrue/wechat/src/OfficialAccount/Card/GiftCardPageClient.php
vendored
Normal file
92
vendor/overtrue/wechat/src/OfficialAccount/Card/GiftCardPageClient.php
vendored
Normal file
@@ -0,0 +1,92 @@
|
||||
<?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\OfficialAccount\Card;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class GiftCardPageClient.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class GiftCardPageClient extends BaseClient
|
||||
{
|
||||
/**
|
||||
* 创建-礼品卡货架接口.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function add(array $attributes)
|
||||
{
|
||||
$params = [
|
||||
'page' => $attributes,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/giftcard/page/add', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询-礼品卡货架信息接口.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get(string $pageId)
|
||||
{
|
||||
$params = [
|
||||
'page_id' => $pageId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/giftcard/page/get', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改-礼品卡货架信息接口.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function update(string $pageId, string $bannerPicUrl, array $themeList)
|
||||
{
|
||||
$params = [
|
||||
'page' => [
|
||||
'page_id' => $pageId,
|
||||
'banner_pic_url' => $bannerPicUrl,
|
||||
'theme_list' => $themeList,
|
||||
],
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/giftcard/page/update', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询-礼品卡货架列表接口.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function list()
|
||||
{
|
||||
return $this->httpPostJson('card/giftcard/page/batchget');
|
||||
}
|
||||
|
||||
/**
|
||||
* 下架-礼品卡货架接口(下架某一个货架或者全部货架).
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function setMaintain(string $pageId = '')
|
||||
{
|
||||
$params = ($pageId ? ['page_id' => $pageId] : ['all' => true]) + [
|
||||
'maintain' => true,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/giftcard/maintain/set', $params);
|
||||
}
|
||||
}
|
||||
101
vendor/overtrue/wechat/src/OfficialAccount/Card/InvoiceClient.php
vendored
Normal file
101
vendor/overtrue/wechat/src/OfficialAccount/Card/InvoiceClient.php
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
<?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\OfficialAccount\Card;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class InvoiceClient.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class InvoiceClient extends BaseClient
|
||||
{
|
||||
/**
|
||||
* 设置支付后开票信息接口.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function set(string $mchid, string $sPappid)
|
||||
{
|
||||
$params = [
|
||||
'paymch_info' => [
|
||||
'mchid' => $mchid,
|
||||
's_pappid' => $sPappid,
|
||||
],
|
||||
];
|
||||
|
||||
return $this->setBizAttr('set_pay_mch', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询支付后开票信息接口.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function get()
|
||||
{
|
||||
return $this->setBizAttr('get_pay_mch');
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置授权页字段信息接口.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function setAuthField(array $userData, array $bizData)
|
||||
{
|
||||
$params = [
|
||||
'auth_field' => [
|
||||
'user_field' => $userData,
|
||||
'biz_field' => $bizData,
|
||||
],
|
||||
];
|
||||
|
||||
return $this->setBizAttr('set_auth_field', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询授权页字段信息接口.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAuthField()
|
||||
{
|
||||
return $this->setBizAttr('get_auth_field');
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询开票信息.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAuthData(string $appId, string $orderId)
|
||||
{
|
||||
$params = [
|
||||
'order_id' => $orderId,
|
||||
's_appid' => $appId,
|
||||
];
|
||||
|
||||
return $this->httpPost('card/invoice/getauthdata', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
private function setBizAttr(string $action, array $params = [])
|
||||
{
|
||||
return $this->httpPostJson('card/invoice/setbizattr', $params, ['action' => $action]);
|
||||
}
|
||||
}
|
||||
77
vendor/overtrue/wechat/src/OfficialAccount/Card/JssdkClient.php
vendored
Normal file
77
vendor/overtrue/wechat/src/OfficialAccount/Card/JssdkClient.php
vendored
Normal file
@@ -0,0 +1,77 @@
|
||||
<?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\OfficialAccount\Card;
|
||||
|
||||
use EasyWeChat\BasicService\Jssdk\Client as Jssdk;
|
||||
use EasyWeChat\Kernel\Support\Arr;
|
||||
use function EasyWeChat\Kernel\Support\str_random;
|
||||
|
||||
/**
|
||||
* Class Jssdk.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class JssdkClient extends Jssdk
|
||||
{
|
||||
/**
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
*/
|
||||
public function getTicket(bool $refresh = false, string $type = 'wx_card'): array
|
||||
{
|
||||
return parent::getTicket($refresh, $type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信卡券:JSAPI 卡券发放.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function assign(array $cards)
|
||||
{
|
||||
return json_encode(array_map(function ($card) {
|
||||
return $this->attachExtension($card['card_id'], $card);
|
||||
}, $cards));
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成 js添加到卡包 需要的 card_list 项.
|
||||
*
|
||||
* @param string $cardId
|
||||
*
|
||||
* @return array
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
*/
|
||||
public function attachExtension($cardId, array $extension = [])
|
||||
{
|
||||
$timestamp = time();
|
||||
$nonce = str_random(6);
|
||||
$ticket = $this->getTicket()['ticket'];
|
||||
|
||||
$ext = array_merge(['timestamp' => $timestamp, 'nonce_str' => $nonce], Arr::only(
|
||||
$extension,
|
||||
['code', 'openid', 'outer_id', 'balance', 'fixed_begintimestamp', 'outer_str']
|
||||
));
|
||||
|
||||
$ext['signature'] = $this->dictionaryOrderSignature($ticket, $timestamp, $cardId, $ext['code'] ?? '', $ext['openid'] ?? '', $nonce);
|
||||
|
||||
return [
|
||||
'cardId' => $cardId,
|
||||
'cardExt' => json_encode($ext),
|
||||
];
|
||||
}
|
||||
}
|
||||
31
vendor/overtrue/wechat/src/OfficialAccount/Card/MeetingTicketClient.php
vendored
Normal file
31
vendor/overtrue/wechat/src/OfficialAccount/Card/MeetingTicketClient.php
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?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\OfficialAccount\Card;
|
||||
|
||||
/**
|
||||
* Class MeetingTicketClient.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class MeetingTicketClient extends Client
|
||||
{
|
||||
/**
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function updateUser(array $params)
|
||||
{
|
||||
return $this->httpPostJson('card/meetingticket/updateuser', $params);
|
||||
}
|
||||
}
|
||||
113
vendor/overtrue/wechat/src/OfficialAccount/Card/MemberCardClient.php
vendored
Normal file
113
vendor/overtrue/wechat/src/OfficialAccount/Card/MemberCardClient.php
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
<?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\OfficialAccount\Card;
|
||||
|
||||
/**
|
||||
* Class MemberCardClient.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class MemberCardClient extends Client
|
||||
{
|
||||
/**
|
||||
* 会员卡接口激活.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function activate(array $info = [])
|
||||
{
|
||||
return $this->httpPostJson('card/membercard/activate', $info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置开卡字段接口.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function setActivationForm(string $cardId, array $settings)
|
||||
{
|
||||
$params = array_merge(['card_id' => $cardId], $settings);
|
||||
|
||||
return $this->httpPostJson('card/membercard/activateuserform/set', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉取会员信息接口.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getUser(string $cardId, string $code)
|
||||
{
|
||||
$params = [
|
||||
'card_id' => $cardId,
|
||||
'code' => $code,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/membercard/userinfo/get', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新会员信息.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function updateUser(array $params = [])
|
||||
{
|
||||
return $this->httpPostJson('card/membercard/updateuser', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户提交资料.
|
||||
*
|
||||
* @param string $activateTicket
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getActivationForm($activateTicket)
|
||||
{
|
||||
$params = [
|
||||
'activate_ticket' => $activateTicket,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/membercard/activatetempinfo/get', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取开卡组件链接接口.
|
||||
*
|
||||
* @param array $params 包含会员卡ID和随机字符串
|
||||
*
|
||||
* @return string 开卡组件链接
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getActivateUrl(array $params = [])
|
||||
{
|
||||
return $this->httpPostJson('card/membercard/activate/geturl', $params);
|
||||
}
|
||||
}
|
||||
31
vendor/overtrue/wechat/src/OfficialAccount/Card/MovieTicketClient.php
vendored
Normal file
31
vendor/overtrue/wechat/src/OfficialAccount/Card/MovieTicketClient.php
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?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\OfficialAccount\Card;
|
||||
|
||||
/**
|
||||
* Class MovieTicketClient.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class MovieTicketClient extends Client
|
||||
{
|
||||
/**
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function updateUser(array $params)
|
||||
{
|
||||
return $this->httpPostJson('card/movieticket/updateuser', $params);
|
||||
}
|
||||
}
|
||||
89
vendor/overtrue/wechat/src/OfficialAccount/Card/ServiceProvider.php
vendored
Normal file
89
vendor/overtrue/wechat/src/OfficialAccount/Card/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
<?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\OfficialAccount\Card;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['card'] = function ($app) {
|
||||
return new Card($app);
|
||||
};
|
||||
|
||||
$app['card.client'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
|
||||
$app['card.coin'] = function ($app) {
|
||||
return new CoinClient($app);
|
||||
};
|
||||
|
||||
$app['card.sub_merchant'] = function ($app) {
|
||||
return new SubMerchantClient($app);
|
||||
};
|
||||
|
||||
$app['card.code'] = function ($app) {
|
||||
return new CodeClient($app);
|
||||
};
|
||||
|
||||
$app['card.movie_ticket'] = function ($app) {
|
||||
return new MovieTicketClient($app);
|
||||
};
|
||||
|
||||
$app['card.member_card'] = function ($app) {
|
||||
return new MemberCardClient($app);
|
||||
};
|
||||
|
||||
$app['card.general_card'] = function ($app) {
|
||||
return new GeneralCardClient($app);
|
||||
};
|
||||
|
||||
$app['card.boarding_pass'] = function ($app) {
|
||||
return new BoardingPassClient($app);
|
||||
};
|
||||
|
||||
$app['card.meeting_ticket'] = function ($app) {
|
||||
return new MeetingTicketClient($app);
|
||||
};
|
||||
|
||||
$app['card.jssdk'] = function ($app) {
|
||||
return new JssdkClient($app);
|
||||
};
|
||||
|
||||
$app['card.gift_card'] = function ($app) {
|
||||
return new GiftCardClient($app);
|
||||
};
|
||||
|
||||
$app['card.gift_card_order'] = function ($app) {
|
||||
return new GiftCardOrderClient($app);
|
||||
};
|
||||
|
||||
$app['card.gift_card_page'] = function ($app) {
|
||||
return new GiftCardPageClient($app);
|
||||
};
|
||||
|
||||
$app['card.invoice'] = function ($app) {
|
||||
return new InvoiceClient($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
112
vendor/overtrue/wechat/src/OfficialAccount/Card/SubMerchantClient.php
vendored
Normal file
112
vendor/overtrue/wechat/src/OfficialAccount/Card/SubMerchantClient.php
vendored
Normal file
@@ -0,0 +1,112 @@
|
||||
<?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\OfficialAccount\Card;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
use EasyWeChat\Kernel\Support\Arr;
|
||||
|
||||
/**
|
||||
* Class SubMerchantClient.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class SubMerchantClient extends BaseClient
|
||||
{
|
||||
/**
|
||||
* 添加子商户.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function create(array $info = [])
|
||||
{
|
||||
$params = [
|
||||
'info' => Arr::only($info, [
|
||||
'brand_name',
|
||||
'logo_url',
|
||||
'protocol',
|
||||
'end_time',
|
||||
'primary_category_id',
|
||||
'secondary_category_id',
|
||||
'agreement_media_id',
|
||||
'operator_media_id',
|
||||
'app_id',
|
||||
]),
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/submerchant/submit', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新子商户.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function update(int $merchantId, array $info = [])
|
||||
{
|
||||
$params = [
|
||||
'info' => array_merge(
|
||||
['merchant_id' => $merchantId],
|
||||
Arr::only($info, [
|
||||
'brand_name',
|
||||
'logo_url',
|
||||
'protocol',
|
||||
'end_time',
|
||||
'primary_category_id',
|
||||
'secondary_category_id',
|
||||
'agreement_media_id',
|
||||
'operator_media_id',
|
||||
'app_id',
|
||||
])
|
||||
),
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/submerchant/update', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取子商户信息.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function get(int $merchantId)
|
||||
{
|
||||
return $this->httpPostJson('card/submerchant/get', ['merchant_id' => $merchantId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量获取子商户信息.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function list(int $beginId = 0, int $limit = 50, string $status = 'CHECKING')
|
||||
{
|
||||
$params = [
|
||||
'begin_id' => $beginId,
|
||||
'limit' => $limit,
|
||||
'status' => $status,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('card/submerchant/batchget', $params);
|
||||
}
|
||||
}
|
||||
175
vendor/overtrue/wechat/src/OfficialAccount/Comment/Client.php
vendored
Normal file
175
vendor/overtrue/wechat/src/OfficialAccount/Comment/Client.php
vendored
Normal file
@@ -0,0 +1,175 @@
|
||||
<?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\OfficialAccount\Comment;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Open article comment.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function open(string $msgId, int $index = null)
|
||||
{
|
||||
$params = [
|
||||
'msg_data_id' => $msgId,
|
||||
'index' => $index,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/comment/open', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close comment.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function close(string $msgId, int $index = null)
|
||||
{
|
||||
$params = [
|
||||
'msg_data_id' => $msgId,
|
||||
'index' => $index,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/comment/close', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get article comments.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function list(string $msgId, int $index, int $begin, int $count, int $type = 0)
|
||||
{
|
||||
$params = [
|
||||
'msg_data_id' => $msgId,
|
||||
'index' => $index,
|
||||
'begin' => $begin,
|
||||
'count' => $count,
|
||||
'type' => $type,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/comment/list', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mark elect comment.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function markElect(string $msgId, int $index, int $commentId)
|
||||
{
|
||||
$params = [
|
||||
'msg_data_id' => $msgId,
|
||||
'index' => $index,
|
||||
'user_comment_id' => $commentId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/comment/markelect', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unmark elect comment.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function unmarkElect(string $msgId, int $index, int $commentId)
|
||||
{
|
||||
$params = [
|
||||
'msg_data_id' => $msgId,
|
||||
'index' => $index,
|
||||
'user_comment_id' => $commentId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/comment/unmarkelect', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete comment.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function delete(string $msgId, int $index, int $commentId)
|
||||
{
|
||||
$params = [
|
||||
'msg_data_id' => $msgId,
|
||||
'index' => $index,
|
||||
'user_comment_id' => $commentId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/comment/delete', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reply to a comment.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function reply(string $msgId, int $index, int $commentId, string $content)
|
||||
{
|
||||
$params = [
|
||||
'msg_data_id' => $msgId,
|
||||
'index' => $index,
|
||||
'user_comment_id' => $commentId,
|
||||
'content' => $content,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/comment/reply/add', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a reply.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function deleteReply(string $msgId, int $index, int $commentId)
|
||||
{
|
||||
$params = [
|
||||
'msg_data_id' => $msgId,
|
||||
'index' => $index,
|
||||
'user_comment_id' => $commentId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/comment/reply/delete', $params);
|
||||
}
|
||||
}
|
||||
44
vendor/overtrue/wechat/src/OfficialAccount/Comment/ServiceProvider.php
vendored
Normal file
44
vendor/overtrue/wechat/src/OfficialAccount/Comment/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* ServiceProvider.php.
|
||||
*
|
||||
* This file is part of the 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\OfficialAccount\Comment;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['comment'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
208
vendor/overtrue/wechat/src/OfficialAccount/CustomerService/Client.php
vendored
Normal file
208
vendor/overtrue/wechat/src/OfficialAccount/CustomerService/Client.php
vendored
Normal file
@@ -0,0 +1,208 @@
|
||||
<?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\OfficialAccount\CustomerService;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* List all staffs.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function list()
|
||||
{
|
||||
return $this->httpGet('cgi-bin/customservice/getkflist');
|
||||
}
|
||||
|
||||
/**
|
||||
* List all online staffs.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function online()
|
||||
{
|
||||
return $this->httpGet('cgi-bin/customservice/getonlinekflist');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a staff.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function create(string $account, string $nickname)
|
||||
{
|
||||
$params = [
|
||||
'kf_account' => $account,
|
||||
'nickname' => $nickname,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('customservice/kfaccount/add', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a staff.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function update(string $account, string $nickname)
|
||||
{
|
||||
$params = [
|
||||
'kf_account' => $account,
|
||||
'nickname' => $nickname,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('customservice/kfaccount/update', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a staff.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function delete(string $account)
|
||||
{
|
||||
return $this->httpPostJson('customservice/kfaccount/del', [], ['kf_account' => $account]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Invite a staff.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function invite(string $account, string $wechatId)
|
||||
{
|
||||
$params = [
|
||||
'kf_account' => $account,
|
||||
'invite_wx' => $wechatId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('customservice/kfaccount/inviteworker', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set staff avatar.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function setAvatar(string $account, string $path)
|
||||
{
|
||||
return $this->httpUpload('customservice/kfaccount/uploadheadimg', ['media' => $path], [], ['kf_account' => $account]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get message builder.
|
||||
*
|
||||
* @param \EasyWeChat\Kernel\Messages\Message|string $message
|
||||
*
|
||||
* @return \EasyWeChat\OfficialAccount\CustomerService\Messenger
|
||||
*/
|
||||
public function message($message)
|
||||
{
|
||||
$messageBuilder = new Messenger($this);
|
||||
|
||||
return $messageBuilder->message($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a message.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function send(array $message)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/message/custom/send', $message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show typing status.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function showTypingStatusToUser(string $openid)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/message/custom/typing', [
|
||||
'touser' => $openid,
|
||||
'command' => 'Typing',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide typing status.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function hideTypingStatusToUser(string $openid)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/message/custom/typing', [
|
||||
'touser' => $openid,
|
||||
'command' => 'CancelTyping',
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get messages history.
|
||||
*
|
||||
* @param int $startTime
|
||||
* @param int $endTime
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function messages($startTime, $endTime, int $msgId = 1, int $number = 10000)
|
||||
{
|
||||
$params = [
|
||||
'starttime' => is_numeric($startTime) ? $startTime : strtotime($startTime),
|
||||
'endtime' => is_numeric($endTime) ? $endTime : strtotime($endTime),
|
||||
'msgid' => $msgId,
|
||||
'number' => $number,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('customservice/msgrecord/getmsglist', $params);
|
||||
}
|
||||
}
|
||||
159
vendor/overtrue/wechat/src/OfficialAccount/CustomerService/Messenger.php
vendored
Normal file
159
vendor/overtrue/wechat/src/OfficialAccount/CustomerService/Messenger.php
vendored
Normal file
@@ -0,0 +1,159 @@
|
||||
<?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\OfficialAccount\CustomerService;
|
||||
|
||||
use EasyWeChat\Kernel\Exceptions\RuntimeException;
|
||||
use EasyWeChat\Kernel\Messages\Message;
|
||||
use EasyWeChat\Kernel\Messages\Raw as RawMessage;
|
||||
use EasyWeChat\Kernel\Messages\Text;
|
||||
|
||||
/**
|
||||
* Class MessageBuilder.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class Messenger
|
||||
{
|
||||
/**
|
||||
* Messages to send.
|
||||
*
|
||||
* @var \EasyWeChat\Kernel\Messages\Message;
|
||||
*/
|
||||
protected $message;
|
||||
|
||||
/**
|
||||
* Messages target user open id.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $to;
|
||||
|
||||
/**
|
||||
* Messages sender staff id.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $account;
|
||||
|
||||
/**
|
||||
* Customer service instance.
|
||||
*
|
||||
* @var \EasyWeChat\OfficialAccount\CustomerService\Client
|
||||
*/
|
||||
protected $client;
|
||||
|
||||
/**
|
||||
* MessageBuilder constructor.
|
||||
*
|
||||
* @param \EasyWeChat\OfficialAccount\CustomerService\Client $client
|
||||
*/
|
||||
public function __construct(Client $client)
|
||||
{
|
||||
$this->client = $client;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set message to send.
|
||||
*
|
||||
* @param string|Message $message
|
||||
*
|
||||
* @return Messenger
|
||||
*/
|
||||
public function message($message)
|
||||
{
|
||||
if (is_string($message)) {
|
||||
$message = new Text($message);
|
||||
}
|
||||
|
||||
$this->message = $message;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set staff account to send message.
|
||||
*
|
||||
* @return Messenger
|
||||
*/
|
||||
public function by(string $account)
|
||||
{
|
||||
$this->account = $account;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Messenger
|
||||
*/
|
||||
public function from(string $account)
|
||||
{
|
||||
return $this->by($account);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set target user open id.
|
||||
*
|
||||
* @param string $openid
|
||||
*
|
||||
* @return Messenger
|
||||
*/
|
||||
public function to($openid)
|
||||
{
|
||||
$this->to = $openid;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the message.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
|
||||
*/
|
||||
public function send()
|
||||
{
|
||||
if (empty($this->message)) {
|
||||
throw new RuntimeException('No message to send.');
|
||||
}
|
||||
|
||||
if ($this->message instanceof RawMessage) {
|
||||
$message = json_decode($this->message->get('content'), true);
|
||||
} else {
|
||||
$prepends = [
|
||||
'touser' => $this->to,
|
||||
];
|
||||
if ($this->account) {
|
||||
$prepends['customservice'] = ['kf_account' => $this->account];
|
||||
}
|
||||
$message = $this->message->transformForJsonRequest($prepends);
|
||||
}
|
||||
|
||||
return $this->client->send($message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return property.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function __get(string $property)
|
||||
{
|
||||
if (property_exists($this, $property)) {
|
||||
return $this->$property;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
37
vendor/overtrue/wechat/src/OfficialAccount/CustomerService/ServiceProvider.php
vendored
Normal file
37
vendor/overtrue/wechat/src/OfficialAccount/CustomerService/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\OfficialAccount\CustomerService;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['customer_service'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
|
||||
$app['customer_service_session'] = function ($app) {
|
||||
return new SessionClient($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
94
vendor/overtrue/wechat/src/OfficialAccount/CustomerService/SessionClient.php
vendored
Normal file
94
vendor/overtrue/wechat/src/OfficialAccount/CustomerService/SessionClient.php
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
<?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\OfficialAccount\CustomerService;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class SessionClient.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class SessionClient extends BaseClient
|
||||
{
|
||||
/**
|
||||
* List all sessions of $account.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function list(string $account)
|
||||
{
|
||||
return $this->httpGet('customservice/kfsession/getsessionlist', ['kf_account' => $account]);
|
||||
}
|
||||
|
||||
/**
|
||||
* List all the people waiting.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function waiting()
|
||||
{
|
||||
return $this->httpGet('customservice/kfsession/getwaitcase');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a session.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function create(string $account, string $openid)
|
||||
{
|
||||
$params = [
|
||||
'kf_account' => $account,
|
||||
'openid' => $openid,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('customservice/kfsession/create', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close a session.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function close(string $account, string $openid)
|
||||
{
|
||||
$params = [
|
||||
'kf_account' => $account,
|
||||
'openid' => $openid,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('customservice/kfsession/close', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a session.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function get(string $openid)
|
||||
{
|
||||
return $this->httpGet('customservice/kfsession/getsession', ['openid' => $openid]);
|
||||
}
|
||||
}
|
||||
271
vendor/overtrue/wechat/src/OfficialAccount/DataCube/Client.php
vendored
Normal file
271
vendor/overtrue/wechat/src/OfficialAccount/DataCube/Client.php
vendored
Normal file
@@ -0,0 +1,271 @@
|
||||
<?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\OfficialAccount\DataCube;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* 获取用户增减数据.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function userSummary(string $from, string $to)
|
||||
{
|
||||
return $this->query('datacube/getusersummary', $from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取累计用户数据.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function userCumulate(string $from, string $to)
|
||||
{
|
||||
return $this->query('datacube/getusercumulate', $from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图文群发每日数据.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function articleSummary(string $from, string $to)
|
||||
{
|
||||
return $this->query('datacube/getarticlesummary', $from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图文群发总数据.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function articleTotal(string $from, string $to)
|
||||
{
|
||||
return $this->query('datacube/getarticletotal', $from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图文统计数据.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function userReadSummary(string $from, string $to)
|
||||
{
|
||||
return $this->query('datacube/getuserread', $from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图文统计分时数据.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function userReadHourly(string $from, string $to)
|
||||
{
|
||||
return $this->query('datacube/getuserreadhour', $from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图文分享转发数据.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function userShareSummary(string $from, string $to)
|
||||
{
|
||||
return $this->query('datacube/getusershare', $from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取图文分享转发分时数据.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function userShareHourly(string $from, string $to)
|
||||
{
|
||||
return $this->query('datacube/getusersharehour', $from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取消息发送概况数据.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function upstreamMessageSummary(string $from, string $to)
|
||||
{
|
||||
return $this->query('datacube/getupstreammsg', $from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取消息分送分时数据.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function upstreamMessageHourly(string $from, string $to)
|
||||
{
|
||||
return $this->query('datacube/getupstreammsghour', $from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取消息发送周数据.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function upstreamMessageWeekly(string $from, string $to)
|
||||
{
|
||||
return $this->query('datacube/getupstreammsgweek', $from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取消息发送月数据.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function upstreamMessageMonthly(string $from, string $to)
|
||||
{
|
||||
return $this->query('datacube/getupstreammsgmonth', $from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取消息发送分布数据.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function upstreamMessageDistSummary(string $from, string $to)
|
||||
{
|
||||
return $this->query('datacube/getupstreammsgdist', $from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取消息发送分布周数据.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function upstreamMessageDistWeekly(string $from, string $to)
|
||||
{
|
||||
return $this->query('datacube/getupstreammsgdistweek', $from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取消息发送分布月数据.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function upstreamMessageDistMonthly(string $from, string $to)
|
||||
{
|
||||
return $this->query('datacube/getupstreammsgdistmonth', $from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取接口分析数据.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function interfaceSummary(string $from, string $to)
|
||||
{
|
||||
return $this->query('datacube/getinterfacesummary', $from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取接口分析分时数据.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function interfaceSummaryHourly(string $from, string $to)
|
||||
{
|
||||
return $this->query('datacube/getinterfacesummaryhour', $from, $to);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉取卡券概况数据接口.
|
||||
*
|
||||
* @param int $condSource
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function cardSummary(string $from, string $to, $condSource = 0)
|
||||
{
|
||||
$ext = [
|
||||
'cond_source' => intval($condSource),
|
||||
];
|
||||
|
||||
return $this->query('datacube/getcardbizuininfo', $from, $to, $ext);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取免费券数据接口.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function freeCardSummary(string $from, string $to, int $condSource = 0, string $cardId = '')
|
||||
{
|
||||
$ext = [
|
||||
'cond_source' => intval($condSource),
|
||||
'card_id' => $cardId,
|
||||
];
|
||||
|
||||
return $this->query('datacube/getcardcardinfo', $from, $to, $ext);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉取会员卡数据接口.
|
||||
*
|
||||
* @param int $condSource
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function memberCardSummary(string $from, string $to, $condSource = 0)
|
||||
{
|
||||
$ext = [
|
||||
'cond_source' => intval($condSource),
|
||||
];
|
||||
|
||||
return $this->query('datacube/getcardmembercardinfo', $from, $to, $ext);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拉取单张会员卡数据接口.
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function memberCardSummaryById(string $from, string $to, string $cardId)
|
||||
{
|
||||
$ext = [
|
||||
'card_id' => $cardId,
|
||||
];
|
||||
|
||||
return $this->query('datacube/getcardmembercarddetail', $from, $to, $ext);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询数据.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
protected function query(string $api, string $from, string $to, array $ext = [])
|
||||
{
|
||||
$params = array_merge([
|
||||
'begin_date' => $from,
|
||||
'end_date' => $to,
|
||||
], $ext);
|
||||
|
||||
return $this->httpPostJson($api, $params);
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/OfficialAccount/DataCube/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/OfficialAccount/DataCube/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\OfficialAccount\DataCube;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['data_cube'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
217
vendor/overtrue/wechat/src/OfficialAccount/Device/Client.php
vendored
Normal file
217
vendor/overtrue/wechat/src/OfficialAccount/Device/Client.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\OfficialAccount\Device;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @see http://iot.weixin.qq.com/wiki/new/index.html
|
||||
*
|
||||
* @author soone <66812590@qq.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 message(string $deviceId, string $openid, string $content)
|
||||
{
|
||||
$params = [
|
||||
'device_type' => $this->app['config']['device_type'],
|
||||
'device_id' => $deviceId,
|
||||
'open_id' => $openid,
|
||||
'content' => base64_encode($content),
|
||||
];
|
||||
|
||||
return $this->httpPostJson('device/transmsg', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get device qrcode.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function qrCode(array $deviceIds)
|
||||
{
|
||||
$params = [
|
||||
'device_num' => count($deviceIds),
|
||||
'device_id_list' => $deviceIds,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('device/create_qrcode', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function authorize(array $devices, string $productId, int $opType = 0)
|
||||
{
|
||||
$params = [
|
||||
'device_num' => count($devices),
|
||||
'device_list' => $devices,
|
||||
'op_type' => $opType,
|
||||
'product_id' => $productId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('device/authorize_device', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取 device id 和二维码
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function createId(string $productId)
|
||||
{
|
||||
$params = [
|
||||
'product_id' => $productId,
|
||||
];
|
||||
|
||||
return $this->httpGet('device/getqrcode', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function bind(string $openid, string $deviceId, string $ticket)
|
||||
{
|
||||
$params = [
|
||||
'ticket' => $ticket,
|
||||
'device_id' => $deviceId,
|
||||
'openid' => $openid,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('device/bind', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function unbind(string $openid, string $deviceId, string $ticket)
|
||||
{
|
||||
$params = [
|
||||
'ticket' => $ticket,
|
||||
'device_id' => $deviceId,
|
||||
'openid' => $openid,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('device/unbind', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function forceBind(string $openid, string $deviceId)
|
||||
{
|
||||
$params = [
|
||||
'device_id' => $deviceId,
|
||||
'openid' => $openid,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('device/compel_bind', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function forceUnbind(string $openid, string $deviceId)
|
||||
{
|
||||
$params = [
|
||||
'device_id' => $deviceId,
|
||||
'openid' => $openid,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('device/compel_unbind', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function status(string $deviceId)
|
||||
{
|
||||
$params = [
|
||||
'device_id' => $deviceId,
|
||||
];
|
||||
|
||||
return $this->httpGet('device/get_stat', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function verify(string $ticket)
|
||||
{
|
||||
$params = [
|
||||
'ticket' => $ticket,
|
||||
];
|
||||
|
||||
return $this->httpPost('device/verify_qrcode', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function openid(string $deviceId)
|
||||
{
|
||||
$params = [
|
||||
'device_type' => $this->app['config']['device_type'],
|
||||
'device_id' => $deviceId,
|
||||
];
|
||||
|
||||
return $this->httpGet('device/get_openid', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function listByOpenid(string $openid)
|
||||
{
|
||||
$params = [
|
||||
'openid' => $openid,
|
||||
];
|
||||
|
||||
return $this->httpGet('device/get_bind_device', $params);
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/OfficialAccount/Device/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/OfficialAccount/Device/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\OfficialAccount\Device;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author soone <66812590@qq.com
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['device'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
101
vendor/overtrue/wechat/src/OfficialAccount/Goods/Client.php
vendored
Normal file
101
vendor/overtrue/wechat/src/OfficialAccount/Goods/Client.php
vendored
Normal file
@@ -0,0 +1,101 @@
|
||||
<?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\OfficialAccount\Goods;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author her-cat <hxhsoft@foxmail.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Add the goods.
|
||||
*
|
||||
* @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 $data)
|
||||
{
|
||||
return $this->httpPostJson('scan/product/v2/add', [
|
||||
'product' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the goods.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function update(array $data)
|
||||
{
|
||||
return $this->httpPostJson('scan/product/v2/add', [
|
||||
'product' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get add or update goods results.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function status(string $ticket)
|
||||
{
|
||||
return $this->httpPostJson('scan/product/v2/status', [
|
||||
'status_ticket' => $ticket,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get goods information.
|
||||
*
|
||||
* @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 $pid)
|
||||
{
|
||||
return $this->httpPostJson('scan/product/v2/getinfo', [
|
||||
'product' => [
|
||||
'pid' => $pid,
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of goods.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function list(string $context = '', int $page = 1, int $size = 10)
|
||||
{
|
||||
return $this->httpPostJson('scan/product/v2/getinfobypage', [
|
||||
'page_context' => $context,
|
||||
'page_num' => $page,
|
||||
'page_size' => $size,
|
||||
]);
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/OfficialAccount/Goods/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/OfficialAccount/Goods/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\OfficialAccount\Goods;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author her-cat <hxhsoft@foxmail.com>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['goods'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
991
vendor/overtrue/wechat/src/OfficialAccount/Guide/Client.php
vendored
Normal file
991
vendor/overtrue/wechat/src/OfficialAccount/Guide/Client.php
vendored
Normal file
@@ -0,0 +1,991 @@
|
||||
<?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\OfficialAccount\Guide;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
use EasyWeChat\Kernel\Exceptions\InvalidConfigException;
|
||||
use EasyWeChat\Kernel\Support\Collection;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author MillsGuo <millsguo@gmail.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* 添加顾问
|
||||
* @param string $guideAccount
|
||||
* @param string $guideOpenid
|
||||
* @param string $guideHeadImgUrl
|
||||
* @param string $guideNickname
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function createAdviser($guideAccount = '', $guideOpenid = '', $guideHeadImgUrl = '', $guideNickname = '')
|
||||
{
|
||||
$params = $this->selectAccountAndOpenid(array(), $guideAccount, $guideOpenid);
|
||||
if (!empty($guideHeadImgUrl)) {
|
||||
$params['guide_headimgurl'] = $guideHeadImgUrl;
|
||||
}
|
||||
if (!empty($guideNickname)) {
|
||||
$params['guide_nickname'] = $guideNickname;
|
||||
}
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/addguideacct', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取顾问信息
|
||||
* @param string $guideAccount
|
||||
* @param string $guideOpenid
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function getAdviser($guideAccount = '', $guideOpenid = '')
|
||||
{
|
||||
$params = $this->selectAccountAndOpenid(array(), $guideAccount, $guideOpenid);
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/getguideacct', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改顾问的昵称或头像
|
||||
* @param string $guideAccount
|
||||
* @param string $guideOpenid
|
||||
* @param string $guideHeadImgUrl
|
||||
* @param string $guideNickname
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function updateAdviser($guideAccount = '', $guideOpenid = '', $guideHeadImgUrl = '', $guideNickname = '')
|
||||
{
|
||||
$params = $this->selectAccountAndOpenid(array(), $guideAccount, $guideOpenid);
|
||||
if (!empty($guideHeadImgUrl)) {
|
||||
$params['guide_headimgurl'] = $guideHeadImgUrl;
|
||||
}
|
||||
if (!empty($guideNickname)) {
|
||||
$params['guide_nickname'] = $guideNickname;
|
||||
}
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/updateguideacct', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除顾问
|
||||
* @param string $guideAccount
|
||||
* @param string $guideOpenid
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function deleteAdviser($guideAccount = '', $guideOpenid = '')
|
||||
{
|
||||
$params = $this->selectAccountAndOpenid(array(), $guideAccount, $guideOpenid);
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/delguideacct', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取服务号顾问列表
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function getAdvisers($count, $page)
|
||||
{
|
||||
$params = [
|
||||
'page' => $page,
|
||||
'num' => $count
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/getguideacctlist', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成顾问二维码
|
||||
* @param string $guideAccount
|
||||
* @param string $guideOpenid
|
||||
* @param string $qrCodeInfo
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function createQrCode($guideAccount = '', $guideOpenid = '', $qrCodeInfo = '')
|
||||
{
|
||||
$params = $this->selectAccountAndOpenid(array(), $guideAccount, $guideOpenid);
|
||||
if (!empty($qrCodeInfo)) {
|
||||
$params['qrcode_info'] = $qrCodeInfo;
|
||||
}
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/guidecreateqrcode', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取顾问聊天记录
|
||||
* @param string $guideAccount
|
||||
* @param string $guideOpenid
|
||||
* @param string $openid
|
||||
* @param int $beginTime
|
||||
* @param int $endTime
|
||||
* @param int $page
|
||||
* @param int $count
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function getBuyerChatRecords($guideAccount = '', $guideOpenid = '', $openid = '', $beginTime = 0, $endTime = 0, $page = 1, $count = 100)
|
||||
{
|
||||
$params = [
|
||||
'page' => $page,
|
||||
'num' => $count
|
||||
];
|
||||
$params = $this->selectAccountAndOpenid($params, $guideAccount, $guideOpenid);
|
||||
if (!empty($openid)) {
|
||||
$params['openid'] = $openid;
|
||||
}
|
||||
if (!empty($beginTime)) {
|
||||
$params['begin_time'] = $beginTime;
|
||||
}
|
||||
if (!empty($endTime)) {
|
||||
$params['end_time'] = $endTime;
|
||||
}
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/getguidebuyerchatrecord', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置快捷回复与关注自动回复
|
||||
* @param string $guideAccount
|
||||
* @param string $guideOpenid
|
||||
* @param bool $isDelete
|
||||
* @param array $fastReplyListArray
|
||||
* @param array $guideAutoReply
|
||||
* @param array $guideAutoReplyPlus
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function setConfig($guideAccount = '', $guideOpenid = '', $isDelete = false, $fastReplyListArray = array(), $guideAutoReply = array(), $guideAutoReplyPlus = array())
|
||||
{
|
||||
$params = [
|
||||
'is_delete' => $isDelete
|
||||
];
|
||||
$params = $this->selectAccountAndOpenid($params, $guideAccount, $guideOpenid);
|
||||
if (!empty($fastReplyListArray)) {
|
||||
$params['guide_fast_reply_list'] = $fastReplyListArray;
|
||||
}
|
||||
if (!empty($guideAutoReply)) {
|
||||
$params['guide_auto_reply'] = $guideAutoReply;
|
||||
}
|
||||
if (!empty($guideAutoReplyPlus)) {
|
||||
$params['guide_auto_reply_plus'] = $guideAutoReplyPlus;
|
||||
}
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/setguideconfig', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取快捷回复与关注自动回复
|
||||
* @param string $guideAccount
|
||||
* @param string $guideOpenid
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function getConfig($guideAccount = '', $guideOpenid = '')
|
||||
{
|
||||
try {
|
||||
$params = $this->selectAccountAndOpenid(array(), $guideAccount, $guideOpenid);
|
||||
} catch (InvalidConfigException $e) {
|
||||
$params = array();
|
||||
}
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/getguideconfig', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置离线自动回复与敏感词
|
||||
* @param bool $isDelete
|
||||
* @param array $blackKeyword
|
||||
* @param array $guideAutoReply
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function setAdviserConfig(bool $isDelete, array $blackKeyword = [], array $guideAutoReply = [])
|
||||
{
|
||||
$params = [
|
||||
'is_delete' => $isDelete
|
||||
];
|
||||
if (!empty($blackKeyword)) {
|
||||
$params['black_keyword'] = $blackKeyword;
|
||||
}
|
||||
if (!empty($guideAutoReply)) {
|
||||
$params['guide_auto_reply'] = $guideAutoReply;
|
||||
}
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/setguideacctconfig', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取离线自动回复与敏感词
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function getAdviserConfig()
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/guide/getguideacctconfig', array());
|
||||
}
|
||||
|
||||
/**
|
||||
* 允许微信用户复制小程序页面路径
|
||||
* @param string $wxaAppid 小程序APPID
|
||||
* @param string $wxUsername 微信用户的微信号
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function allowCopyMiniAppPath(string $wxaAppid, string $wxUsername)
|
||||
{
|
||||
$params = [
|
||||
'wxa_appid' => $wxaAppid,
|
||||
'wx_username' => $wxUsername
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/pushshowwxapathmenu', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 传入微信号或OPENID二选一
|
||||
* @param array $params
|
||||
* @param string $guideAccount
|
||||
* @param string $guideOpenid
|
||||
* @return array
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
protected function selectAccountAndOpenid($params, $guideAccount = '', $guideOpenid = '')
|
||||
{
|
||||
if (!is_array($params)) {
|
||||
throw new InvalidConfigException("传入配置参数必须为数组");
|
||||
}
|
||||
if (!empty($guideOpenid)) {
|
||||
$params['guide_openid'] = $guideOpenid;
|
||||
} elseif (!empty($guideAccount)) {
|
||||
$params['guide_account'] = $guideAccount;
|
||||
} else {
|
||||
throw new InvalidConfigException("微信号和OPENID不能同时为空");
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建顾问分组
|
||||
* @param string $groupName
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function createGroup(string $groupName)
|
||||
{
|
||||
$params = [
|
||||
'group_name' => $groupName
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/newguidegroup', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取顾问分组列表
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function getGuideGroups()
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/guide/getguidegrouplist', array());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定顾问分组信息
|
||||
* @param int $groupId
|
||||
* @param int $page
|
||||
* @param int $num
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function getGroups(int $groupId, int $page, int $num)
|
||||
{
|
||||
$params = [
|
||||
'group_id' => $groupId,
|
||||
'page' => $page,
|
||||
'num' => $num
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/getgroupinfo', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分组内添加顾问
|
||||
* @param int $groupId
|
||||
* @param string $guideAccount
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function addGroupGuide(int $groupId, string $guideAccount)
|
||||
{
|
||||
$params = [
|
||||
'group_id' => $groupId,
|
||||
'gruide_account' => $guideAccount
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/addguide2guidegroup', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 分组内删除顾问
|
||||
* @param int $groupId
|
||||
* @param string $guideAccount
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function deleteGroupGuide(int $groupId, string $guideAccount)
|
||||
{
|
||||
$params = [
|
||||
'group_id' => $groupId,
|
||||
'guide_account' => $guideAccount
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/delguide2guidegroup', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取顾问所在分组
|
||||
* @param string $guideAccount
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function getGuideGroup(string $guideAccount)
|
||||
{
|
||||
$params = [
|
||||
'guide_account' => $guideAccount
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/getgroupbyguide', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定顾问分组
|
||||
* @param int $groupId
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function deleteGroup(int $groupId)
|
||||
{
|
||||
$params = [
|
||||
'group_id' => $groupId
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/delguidegroup', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 为顾问分配客户
|
||||
* @param string $guideAccount
|
||||
* @param string $guideOpenid
|
||||
* @param array $buyerList
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function createBuyerRelation(string $guideAccount, string $guideOpenid, array $buyerList)
|
||||
{
|
||||
$params = [
|
||||
'buyer_list' => $buyerList
|
||||
];
|
||||
$params = $this->selectAccountAndOpenid($params, $guideAccount, $guideOpenid);
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/addguidebuyerrelation', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 为顾问移除客户
|
||||
* @param string $guideAccount
|
||||
* @param string $guideOpenid
|
||||
* @param array $openidList
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function deleteBuyerRelation(string $guideAccount, string $guideOpenid, array $openidList)
|
||||
{
|
||||
$params = [
|
||||
'openid_list' => $openidList
|
||||
];
|
||||
$params = $this->selectAccountAndOpenid($params, $guideAccount, $guideOpenid);
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/delguidebuyerrelation', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取顾问的客户列表
|
||||
* @param string $guideAccount
|
||||
* @param string $guideOpenid
|
||||
* @param int $page
|
||||
* @param int $num
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function getBuyerRelations(string $guideAccount, string $guideOpenid, int $page, int $num)
|
||||
{
|
||||
$params = [
|
||||
'page' => $page,
|
||||
'num' => $num
|
||||
];
|
||||
$params = $this->selectAccountAndOpenid($params, $guideAccount, $guideOpenid);
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/getguidebuyerrelationlist', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 为客户更换顾问
|
||||
* @param string $oldGuideTarget
|
||||
* @param string $newGuideTarget
|
||||
* @param array $openidList
|
||||
* @param bool $useTargetOpenid true使用OPENID,false使用微信号
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function rebindBuyerGuide(string $oldGuideTarget, string $newGuideTarget, array $openidList, bool $useTargetOpenid = true)
|
||||
{
|
||||
$params = [
|
||||
'openid_list' => $openidList
|
||||
];
|
||||
if ($useTargetOpenid) {
|
||||
$params['old_guide_openid'] = $oldGuideTarget;
|
||||
$params['new_guide_openid'] = $newGuideTarget;
|
||||
} else {
|
||||
$params['old_guide_account'] = $oldGuideTarget;
|
||||
$params['new_guide_account'] = $newGuideTarget;
|
||||
}
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/rebindguideacctforbuyer', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改客户昵称
|
||||
* @param string $guideAccount
|
||||
* @param string $guideOpenid
|
||||
* @param string $openid
|
||||
* @param string $nickname
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function updateBuyerRelation(string $guideAccount, string $guideOpenid, string $openid, string $nickname)
|
||||
{
|
||||
$params = [
|
||||
'openid' => $openid,
|
||||
'buyer_nickname' => $nickname
|
||||
];
|
||||
$params = $this->selectAccountAndOpenid($params, $guideAccount, $guideOpenid);
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/updateguidebuyerrelation', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询客户所属顾问
|
||||
* @param string $openid
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function getBuyerRelation(string $openid)
|
||||
{
|
||||
$params = [
|
||||
'openid' => $openid
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/getguidebuyerrelationbybuyer', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询指定顾问和客户的关系
|
||||
* @param string $guideAccount
|
||||
* @param string $guideOpenid
|
||||
* @param string $openid
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function getBuyerRelationByGuide(string $guideAccount, string $guideOpenid, string $openid)
|
||||
{
|
||||
$params = [
|
||||
'openid' => $openid
|
||||
];
|
||||
$params = $this->selectAccountAndOpenid($params, $guideAccount, $guideOpenid);
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/getguidebuyerrelation', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新建可查询的标签类型
|
||||
* @param string $tagName
|
||||
* @param array $tagValues
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function newTagOption(string $tagName, array $tagValues)
|
||||
{
|
||||
$params = [
|
||||
'tag_name' => $tagName,
|
||||
'tag_values' => $tagValues
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/newguidetagoption', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除指定标签类型
|
||||
* @param string $tagName
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function deleteTagOption(string $tagName)
|
||||
{
|
||||
$params = [
|
||||
'tag_name' => $tagName
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/delguidetagoption', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 为标签添加可选值
|
||||
* @param string $tagName
|
||||
* @param array $tagValues
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function createTagOption(string $tagName, array $tagValues)
|
||||
{
|
||||
$params = [
|
||||
'tag_name' => $tagName,
|
||||
'tag_values' => $tagValues
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/addguidetagoption', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取标签和可选值
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function getTagOption()
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/guide/getguidetagoption', array());
|
||||
}
|
||||
|
||||
/**
|
||||
* 为客户设置标签
|
||||
* @param string $guideAccount
|
||||
* @param string $guideOpenid
|
||||
* @param array $openidList
|
||||
* @param string $tagValue
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function setBuyersTag(string $guideAccount, string $guideOpenid, array $openidList, string $tagValue)
|
||||
{
|
||||
$params = [
|
||||
'tag_value' => $tagValue,
|
||||
'openid_list' => $openidList
|
||||
];
|
||||
$params = $this->selectAccountAndOpenid($params, $guideAccount, $guideOpenid);
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/addguidebuyertag', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询客户标签
|
||||
* @param string $guideAccount
|
||||
* @param string $guideOpenid
|
||||
* @param string $openid
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function getBuyerTags(string $guideAccount, string $guideOpenid, string $openid)
|
||||
{
|
||||
$params = [
|
||||
'openid' => $openid
|
||||
];
|
||||
$params = $this->selectAccountAndOpenid($params, $guideAccount, $guideOpenid);
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/getguidebuyertag', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据标签值筛选粉丝
|
||||
* @param string $guideAccount
|
||||
* @param string $guideOpenid
|
||||
* @param int $pushCount
|
||||
* @param array $tagValues
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function getBuyerByTag(string $guideAccount, string $guideOpenid, int $pushCount = 0, array $tagValues = array())
|
||||
{
|
||||
$params = $this->selectAccountAndOpenid(array(), $guideAccount, $guideOpenid);
|
||||
if ($pushCount > 0) {
|
||||
$params['push_count'] = $pushCount;
|
||||
}
|
||||
if (count($tagValues) > 0) {
|
||||
$params['tag_values'] = $tagValues;
|
||||
}
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/queryguidebuyerbytag', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除客户标签
|
||||
* @param string $guideAccount
|
||||
* @param string $guideOpenid
|
||||
* @param string $tagValue
|
||||
* @param array $openidList
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function deleteBuyerTag(string $guideAccount, string $guideOpenid, string $tagValue, array $openidList)
|
||||
{
|
||||
$params = [
|
||||
'tag_value' => $tagValue
|
||||
];
|
||||
$params = $this->selectAccountAndOpenid($params, $guideAccount, $guideOpenid);
|
||||
if (count($openidList) > 0) {
|
||||
$params['openid_list'] = $openidList;
|
||||
}
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/delguidebuyertag', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置自定义客户信息
|
||||
* @param string $guideAccount
|
||||
* @param string $guideOpenid
|
||||
* @param string $openid
|
||||
* @param array $displayTagList
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function setBuyerDisplayTags(string $guideAccount, string $guideOpenid, string $openid, array $displayTagList)
|
||||
{
|
||||
$params = [
|
||||
'openid' => $openid,
|
||||
'display_tag_list' => $displayTagList
|
||||
];
|
||||
$params = $this->selectAccountAndOpenid($params, $guideAccount, $guideOpenid);
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/addguidebuyerdisplaytag', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取自定义客户信息
|
||||
* @param string $guideAccount
|
||||
* @param string $guideOpenid
|
||||
* @param string $openid
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function getBuyerDisplayTags(string $guideAccount, string $guideOpenid, string $openid)
|
||||
{
|
||||
$params = [
|
||||
'openid' => $openid
|
||||
];
|
||||
$params = $this->selectAccountAndOpenid($params, $guideAccount, $guideOpenid);
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/getguidebuyerdisplaytag', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加小程序卡片素材
|
||||
* @param string $mediaId
|
||||
* @param string $title
|
||||
* @param string $path
|
||||
* @param string $appid
|
||||
* @param int $type
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function createCardMaterial(string $mediaId, string $title, string $path, string $appid, int $type = 0)
|
||||
{
|
||||
$params = [
|
||||
'media_id' => $mediaId,
|
||||
'type' => $type,
|
||||
'title' => $title,
|
||||
'path' => $path,
|
||||
'appid' => $appid
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/setguidecardmaterial', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询小程序卡片素材
|
||||
* @param int $type
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function getCardMaterial(int $type = 0)
|
||||
{
|
||||
$params = [
|
||||
'type' => $type
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/getguidecardmaterial', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除小程序卡片素材
|
||||
* @param string $title
|
||||
* @param string $path
|
||||
* @param string $appid
|
||||
* @param int $type
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function deleteCardMaterial(string $title, string $path, string $appid, int $type = 0)
|
||||
{
|
||||
$params = [
|
||||
'type' => $type,
|
||||
'title' => $title,
|
||||
'path' => $path,
|
||||
'appid' => $appid
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/delguidecardmaterial', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加图片素材
|
||||
* @param string $mediaId
|
||||
* @param int $type
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function createImageMaterial(string $mediaId, int $type = 0)
|
||||
{
|
||||
$params = [
|
||||
'media_id' => $mediaId,
|
||||
'type' => $type
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/setguideimagematerial', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询图片素材
|
||||
* @param int $type
|
||||
* @param int $start
|
||||
* @param int $num
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function getImageMaterial(int $type, int $start, int $num)
|
||||
{
|
||||
$params = [
|
||||
'type' => $type,
|
||||
'start' => $start,
|
||||
'num' => $num
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/getguideimagematerial', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除图片素材
|
||||
* @param int $type
|
||||
* @param string $picUrl
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function deleteImageMaterial(int $type, string $picUrl)
|
||||
{
|
||||
$params = [
|
||||
'type' => $type,
|
||||
'picurl' => $picUrl
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/delguideimagematerial', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加文字素材
|
||||
* @param int $type
|
||||
* @param string $word
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function createWordMaterial(int $type, string $word)
|
||||
{
|
||||
$params = [
|
||||
'type' => $type,
|
||||
'word' => $word
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/setguidewordmaterial', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询文字素材
|
||||
* @param int $type
|
||||
* @param int $start
|
||||
* @param int $num
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function getWordMaterial(int $type, int $start, int $num)
|
||||
{
|
||||
$params = [
|
||||
'type' => $type,
|
||||
'start' => $start,
|
||||
'num' => $num
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/getguidewordmaterial', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文字素材
|
||||
* @param int $type
|
||||
* @param string $word
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function deleteWordMaterial(int $type, string $word)
|
||||
{
|
||||
$params = [
|
||||
'type' => $type,
|
||||
'word' => $word
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/delguidewordmaterial', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加群发任务,为指定顾问添加群发任务
|
||||
* @param string $guideAccount
|
||||
* @param string $guideOpenid
|
||||
* @param string $taskName
|
||||
* @param string $taskRemark
|
||||
* @param int $pushTime
|
||||
* @param array $openidArray
|
||||
* @param array $materialArray
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function createMasSendJob(string $guideAccount, string $guideOpenid, string $taskName, string $taskRemark, int $pushTime, array $openidArray, array $materialArray)
|
||||
{
|
||||
$params = [
|
||||
'task_name' => $taskName,
|
||||
'push_time' => $pushTime,
|
||||
'openid' => $openidArray,
|
||||
'material' => $materialArray
|
||||
];
|
||||
if (!empty($taskRemark)) {
|
||||
$params['task_remark'] = $taskRemark;
|
||||
}
|
||||
$params = $this->selectAccountAndOpenid($params, $guideAccount, $guideOpenid);
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/addguidemassendjob', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取群发任务列表
|
||||
* @param string $guideAccount
|
||||
* @param string $guideOpenid
|
||||
* @param array $taskStatus
|
||||
* @param int $offset
|
||||
* @param int $limit
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function getMasSendJobs(string $guideAccount, string $guideOpenid, array $taskStatus = [], int $offset = 0, int $limit = 50)
|
||||
{
|
||||
$params = $this->selectAccountAndOpenid(array(), $guideAccount, $guideOpenid);
|
||||
if (!empty($taskStatus)) {
|
||||
$params['task_status'] = $taskStatus;
|
||||
}
|
||||
if ($offset > 0) {
|
||||
$params['offset'] = $offset;
|
||||
}
|
||||
if ($limit != 50) {
|
||||
$params['limit'] = $limit;
|
||||
}
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/getguidemassendjoblist', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定群发任务信息
|
||||
* @param string $taskId
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function getMasSendJob(string $taskId)
|
||||
{
|
||||
$params = [
|
||||
'task_id' => $taskId
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/getguidemassendjob', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改群发任务
|
||||
* @param string $taskId
|
||||
* @param string $taskName
|
||||
* @param string $taskRemark
|
||||
* @param int $pushTime
|
||||
* @param array $openidArray
|
||||
* @param array $materialArray
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function updateMasSendJob(string $taskId, string $taskName, string $taskRemark, int $pushTime, array $openidArray, array $materialArray)
|
||||
{
|
||||
$params = [
|
||||
'task_id' => $taskId
|
||||
];
|
||||
if (!empty($taskName)) {
|
||||
$params['task_name'] = $taskName;
|
||||
}
|
||||
if (!empty($taskRemark)) {
|
||||
$params['task_remark'] = $taskRemark;
|
||||
}
|
||||
if (!empty($pushTime)) {
|
||||
$params['push_time'] = $pushTime;
|
||||
}
|
||||
if (!empty($openidArray)) {
|
||||
$params['openid'] = $openidArray;
|
||||
}
|
||||
if (!empty($materialArray)) {
|
||||
$params['material'] = $materialArray;
|
||||
}
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/updateguidemassendjob', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消群发任务
|
||||
* @param string $taskId
|
||||
* @return array|Collection|object|ResponseInterface|string
|
||||
* @throws InvalidConfigException
|
||||
*/
|
||||
public function cancelMasSendJob(string $taskId)
|
||||
{
|
||||
$params = [
|
||||
'task_id' => $taskId
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/guide/cancelguidemassendjob', $params);
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/OfficialAccount/Guide/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/OfficialAccount/Guide/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\OfficialAccount\Guide;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author millsguo <millsguo@gmail.com>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['guide'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
275
vendor/overtrue/wechat/src/OfficialAccount/Material/Client.php
vendored
Normal file
275
vendor/overtrue/wechat/src/OfficialAccount/Material/Client.php
vendored
Normal file
@@ -0,0 +1,275 @@
|
||||
<?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\OfficialAccount\Material;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
|
||||
use EasyWeChat\Kernel\Http\StreamResponse;
|
||||
use EasyWeChat\Kernel\Messages\Article;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Allow media type.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $allowTypes = ['image', 'voice', 'video', 'thumb', 'news_image'];
|
||||
|
||||
/**
|
||||
* Upload image.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function uploadImage(string $path)
|
||||
{
|
||||
return $this->upload('image', $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload voice.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function uploadVoice(string $path)
|
||||
{
|
||||
return $this->upload('voice', $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload thumb.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function uploadThumb(string $path)
|
||||
{
|
||||
return $this->upload('thumb', $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload video.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function uploadVideo(string $path, string $title, string $description)
|
||||
{
|
||||
$params = [
|
||||
'description' => json_encode(
|
||||
[
|
||||
'title' => $title,
|
||||
'introduction' => $description,
|
||||
],
|
||||
JSON_UNESCAPED_UNICODE
|
||||
),
|
||||
];
|
||||
|
||||
return $this->upload('video', $path, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload articles.
|
||||
*
|
||||
* @param array|Article $articles
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function uploadArticle($articles)
|
||||
{
|
||||
if ($articles instanceof Article || !empty($articles['title'])) {
|
||||
$articles = [$articles];
|
||||
}
|
||||
|
||||
$params = ['articles' => array_map(function ($article) {
|
||||
if ($article instanceof Article) {
|
||||
return $article->transformForJsonRequestWithoutType();
|
||||
}
|
||||
|
||||
return $article;
|
||||
}, $articles)];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/material/add_news', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update article.
|
||||
*
|
||||
* @param array|Article $article
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function updateArticle(string $mediaId, $article, int $index = 0)
|
||||
{
|
||||
if ($article instanceof Article) {
|
||||
$article = $article->transformForJsonRequestWithoutType();
|
||||
}
|
||||
|
||||
$params = [
|
||||
'media_id' => $mediaId,
|
||||
'index' => $index,
|
||||
'articles' => isset($article['title']) ? $article : (isset($article[$index]) ? $article[$index] : []),
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/material/update_news', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload image for article.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function uploadArticleImage(string $path)
|
||||
{
|
||||
return $this->upload('news_image', $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch material.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function get(string $mediaId)
|
||||
{
|
||||
$response = $this->requestRaw('cgi-bin/material/get_material', 'POST', ['json' => ['media_id' => $mediaId]]);
|
||||
|
||||
if (false !== stripos($response->getHeaderLine('Content-disposition'), 'attachment')) {
|
||||
return StreamResponse::buildFromPsrResponse($response);
|
||||
}
|
||||
|
||||
return $this->castResponseToType($response, $this->app['config']->get('response_type'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete material by media ID.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function delete(string $mediaId)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/material/del_material', ['media_id' => $mediaId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* List materials.
|
||||
*
|
||||
* example:
|
||||
*
|
||||
* {
|
||||
* "total_count": TOTAL_COUNT,
|
||||
* "item_count": ITEM_COUNT,
|
||||
* "item": [{
|
||||
* "media_id": MEDIA_ID,
|
||||
* "name": NAME,
|
||||
* "update_time": UPDATE_TIME
|
||||
* },
|
||||
* // more...
|
||||
* ]
|
||||
* }
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function list(string $type, int $offset = 0, int $count = 20)
|
||||
{
|
||||
$params = [
|
||||
'type' => $type,
|
||||
'offset' => $offset,
|
||||
'count' => $count,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/material/batchget_material', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get stats of materials.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function stats()
|
||||
{
|
||||
return $this->httpGet('cgi-bin/material/get_materialcount');
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload material.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function upload(string $type, string $path, array $form = [])
|
||||
{
|
||||
if (!file_exists($path) || !is_readable($path)) {
|
||||
throw new InvalidArgumentException(sprintf('File does not exist, or the file is unreadable: "%s"', $path));
|
||||
}
|
||||
|
||||
$form['type'] = $type;
|
||||
|
||||
return $this->httpUpload($this->getApiByType($type), ['media' => $path], $form);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get API by type.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getApiByType(string $type)
|
||||
{
|
||||
switch ($type) {
|
||||
case 'news_image':
|
||||
return 'cgi-bin/media/uploadimg';
|
||||
default:
|
||||
return 'cgi-bin/material/add_material';
|
||||
}
|
||||
}
|
||||
}
|
||||
44
vendor/overtrue/wechat/src/OfficialAccount/Material/ServiceProvider.php
vendored
Normal file
44
vendor/overtrue/wechat/src/OfficialAccount/Material/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
<?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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* ServiceProvider.php.
|
||||
*
|
||||
* This file is part of the 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\OfficialAccount\Material;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['material'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
98
vendor/overtrue/wechat/src/OfficialAccount/Menu/Client.php
vendored
Normal file
98
vendor/overtrue/wechat/src/OfficialAccount/Menu/Client.php
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
<?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\OfficialAccount\Menu;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Get all menus.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function list()
|
||||
{
|
||||
return $this->httpGet('cgi-bin/menu/get');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get current menus.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function current()
|
||||
{
|
||||
return $this->httpGet('cgi-bin/get_current_selfmenu_info');
|
||||
}
|
||||
|
||||
/**
|
||||
* Add menu.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function create(array $buttons, array $matchRule = [])
|
||||
{
|
||||
if (!empty($matchRule)) {
|
||||
return $this->httpPostJson('cgi-bin/menu/addconditional', [
|
||||
'button' => $buttons,
|
||||
'matchrule' => $matchRule,
|
||||
]);
|
||||
}
|
||||
|
||||
return $this->httpPostJson('cgi-bin/menu/create', ['button' => $buttons]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy menu.
|
||||
*
|
||||
* @param int $menuId
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function delete(int $menuId = null)
|
||||
{
|
||||
if (is_null($menuId)) {
|
||||
return $this->httpGet('cgi-bin/menu/delete');
|
||||
}
|
||||
|
||||
return $this->httpPostJson('cgi-bin/menu/delconditional', ['menuid' => $menuId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test conditional menu.
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function match(string $userId)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/menu/trymatch', ['user_id' => $userId]);
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/OfficialAccount/Menu/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/OfficialAccount/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\OfficialAccount\Menu;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['menu'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
66
vendor/overtrue/wechat/src/OfficialAccount/OAuth/ServiceProvider.php
vendored
Normal file
66
vendor/overtrue/wechat/src/OfficialAccount/OAuth/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,66 @@
|
||||
<?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\OfficialAccount\OAuth;
|
||||
|
||||
use Overtrue\Socialite\SocialiteManager as Socialite;
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['oauth'] = function ($app) {
|
||||
$socialite = (new Socialite([
|
||||
'wechat' => [
|
||||
'client_id' => $app['config']['app_id'],
|
||||
'client_secret' => $app['config']['secret'],
|
||||
'redirect' => $this->prepareCallbackUrl($app),
|
||||
],
|
||||
], $app['request']))->driver('wechat');
|
||||
|
||||
$scopes = (array) $app['config']->get('oauth.scopes', ['snsapi_userinfo']);
|
||||
|
||||
if (!empty($scopes)) {
|
||||
$socialite->scopes($scopes);
|
||||
}
|
||||
|
||||
return $socialite;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, '/');
|
||||
}
|
||||
}
|
||||
78
vendor/overtrue/wechat/src/OfficialAccount/OCR/Client.php
vendored
Normal file
78
vendor/overtrue/wechat/src/OfficialAccount/OCR/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\OfficialAccount\OCR;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author joyeekk <xygao2420@gmail.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Allow image parameter type.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $allowTypes = ['photo', 'scan'];
|
||||
|
||||
/**
|
||||
* ID card OCR.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function idCard(string $path, string $type = 'photo')
|
||||
{
|
||||
if (!\in_array($type, $this->allowTypes, true)) {
|
||||
throw new InvalidArgumentException(sprintf("Unsupported type: '%s'", $type));
|
||||
}
|
||||
|
||||
return $this->httpPost('cv/ocr/idcard', [
|
||||
'type' => $type,
|
||||
'img_url' => $path,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bank card OCR.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function bankCard(string $path)
|
||||
{
|
||||
return $this->httpPost('cv/ocr/bankcard', [
|
||||
'img_url' => $path,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Vehicle license OCR.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function vehicleLicense(string $path)
|
||||
{
|
||||
return $this->httpPost('cv/ocr/drivinglicense', [
|
||||
'img_url' => $path,
|
||||
]);
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/OfficialAccount/OCR/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/OfficialAccount/OCR/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\OfficialAccount\OCR;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author joyeekk <xygao2420@gmail.com>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['ocr'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
131
vendor/overtrue/wechat/src/OfficialAccount/POI/Client.php
vendored
Normal file
131
vendor/overtrue/wechat/src/OfficialAccount/POI/Client.php
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
<?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\OfficialAccount\POI;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Get POI supported categories.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function categories()
|
||||
{
|
||||
return $this->httpGet('cgi-bin/poi/getwxcategory');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get POI by ID.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function get(int $poiId)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/poi/getpoi', ['poi_id' => $poiId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* List POI.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function list(int $offset = 0, int $limit = 10)
|
||||
{
|
||||
$params = [
|
||||
'begin' => $offset,
|
||||
'limit' => $limit,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/poi/getpoilist', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a POI.
|
||||
*
|
||||
* @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 $baseInfo)
|
||||
{
|
||||
$params = [
|
||||
'business' => [
|
||||
'base_info' => $baseInfo,
|
||||
],
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/poi/addpoi', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
public function createAndGetId(array $databaseInfo)
|
||||
{
|
||||
/** @var array $response */
|
||||
$response = $this->detectAndCastResponseToType($this->create($databaseInfo), 'array');
|
||||
|
||||
return $response['poi_id'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a POI.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function update(int $poiId, array $baseInfo)
|
||||
{
|
||||
$params = [
|
||||
'business' => [
|
||||
'base_info' => array_merge($baseInfo, ['poi_id' => $poiId]),
|
||||
],
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/poi/updatepoi', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a POI.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function delete(int $poiId)
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/poi/delpoi', ['poi_id' => $poiId]);
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/OfficialAccount/POI/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/OfficialAccount/POI/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\OfficialAccount\POI;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['poi'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
41
vendor/overtrue/wechat/src/OfficialAccount/Semantic/Client.php
vendored
Normal file
41
vendor/overtrue/wechat/src/OfficialAccount/Semantic/Client.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\OfficialAccount\Semantic;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Get the semantic content of giving string.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function query(string $keyword, string $categories, array $optional = [])
|
||||
{
|
||||
$params = [
|
||||
'query' => $keyword,
|
||||
'category' => $categories,
|
||||
'appid' => $this->app['config']['app_id'],
|
||||
];
|
||||
|
||||
return $this->httpPostJson('semantic/semproxy/search', array_merge($params, $optional));
|
||||
}
|
||||
}
|
||||
31
vendor/overtrue/wechat/src/OfficialAccount/Semantic/ServiceProvider.php
vendored
Normal file
31
vendor/overtrue/wechat/src/OfficialAccount/Semantic/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
<?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\OfficialAccount\Semantic;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['semantic'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
27
vendor/overtrue/wechat/src/OfficialAccount/Server/Guard.php
vendored
Normal file
27
vendor/overtrue/wechat/src/OfficialAccount/Server/Guard.php
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
<?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\OfficialAccount\Server;
|
||||
|
||||
use EasyWeChat\Kernel\ServerGuard;
|
||||
|
||||
/**
|
||||
* Class Guard.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class Guard extends ServerGuard
|
||||
{
|
||||
protected function shouldReturnRawResponse(): bool
|
||||
{
|
||||
return !is_null($this->app['request']->get('echostr'));
|
||||
}
|
||||
}
|
||||
49
vendor/overtrue/wechat/src/OfficialAccount/Server/Handlers/EchoStrHandler.php
vendored
Normal file
49
vendor/overtrue/wechat/src/OfficialAccount/Server/Handlers/EchoStrHandler.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\OfficialAccount\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 ($str = $this->app['request']->get('echostr')) {
|
||||
return new FinallyResult($str);
|
||||
}
|
||||
}
|
||||
}
|
||||
46
vendor/overtrue/wechat/src/OfficialAccount/Server/ServiceProvider.php
vendored
Normal file
46
vendor/overtrue/wechat/src/OfficialAccount/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\OfficialAccount\Server;
|
||||
|
||||
use EasyWeChat\Kernel\Encryptor;
|
||||
use EasyWeChat\OfficialAccount\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']['app_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;
|
||||
};
|
||||
}
|
||||
}
|
||||
76
vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/Client.php
vendored
Normal file
76
vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/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\OfficialAccount\ShakeAround;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* @param array $data
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function register($data)
|
||||
{
|
||||
return $this->httpPostJson('shakearound/account/register', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get audit status.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function status()
|
||||
{
|
||||
return $this->httpGet('shakearound/account/auditstatus');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get shake info.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function user(string $ticket, bool $needPoi = false)
|
||||
{
|
||||
$params = [
|
||||
'ticket' => $ticket,
|
||||
];
|
||||
|
||||
if ($needPoi) {
|
||||
$params['need_poi'] = 1;
|
||||
}
|
||||
|
||||
return $this->httpPostJson('shakearound/user/getshakeinfo', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*/
|
||||
public function userWithPoi(string $ticket)
|
||||
{
|
||||
return $this->user($ticket, true);
|
||||
}
|
||||
}
|
||||
165
vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/DeviceClient.php
vendored
Normal file
165
vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/DeviceClient.php
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
<?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\OfficialAccount\ShakeAround;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class DeviceClient.
|
||||
*
|
||||
* @author allen05ren <allen05ren@outlook.com>
|
||||
*/
|
||||
class DeviceClient 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 apply(array $data)
|
||||
{
|
||||
return $this->httpPostJson('shakearound/device/applyid', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get audit status.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function status(int $applyId)
|
||||
{
|
||||
$params = [
|
||||
'apply_id' => $applyId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('shakearound/device/applystatus', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a device comment.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function update(array $deviceIdentifier, string $comment)
|
||||
{
|
||||
$params = [
|
||||
'device_identifier' => $deviceIdentifier,
|
||||
'comment' => $comment,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('shakearound/device/update', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind location for device.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function bindPoi(array $deviceIdentifier, int $poiId)
|
||||
{
|
||||
$params = [
|
||||
'device_identifier' => $deviceIdentifier,
|
||||
'poi_id' => $poiId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('shakearound/device/bindlocation', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function bindThirdPoi(array $deviceIdentifier, int $poiId, string $appId)
|
||||
{
|
||||
$params = [
|
||||
'device_identifier' => $deviceIdentifier,
|
||||
'poi_id' => $poiId,
|
||||
'type' => 2,
|
||||
'poi_appid' => $appId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('shakearound/device/bindlocation', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch batch of devices by deviceIds.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*/
|
||||
public function listByIds(array $deviceIdentifiers)
|
||||
{
|
||||
$params = [
|
||||
'type' => 1,
|
||||
'device_identifiers' => $deviceIdentifiers,
|
||||
];
|
||||
|
||||
return $this->search($params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pagination to get batch of devices.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*/
|
||||
public function list(int $lastId, int $count)
|
||||
{
|
||||
$params = [
|
||||
'type' => 2,
|
||||
'last_seen' => $lastId,
|
||||
'count' => $count,
|
||||
];
|
||||
|
||||
return $this->search($params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch batch of devices by applyId.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*/
|
||||
public function listByApplyId(int $applyId, int $lastId, int $count)
|
||||
{
|
||||
$params = [
|
||||
'type' => 3,
|
||||
'apply_id' => $applyId,
|
||||
'last_seen' => $lastId,
|
||||
'count' => $count,
|
||||
];
|
||||
|
||||
return $this->search($params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch batch of devices.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function search(array $params)
|
||||
{
|
||||
return $this->httpPostJson('shakearound/device/search', $params);
|
||||
}
|
||||
}
|
||||
147
vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/GroupClient.php
vendored
Normal file
147
vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/GroupClient.php
vendored
Normal file
@@ -0,0 +1,147 @@
|
||||
<?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\OfficialAccount\ShakeAround;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class GroupClient.
|
||||
*
|
||||
* @author allen05ren <allen05ren@outlook.com>
|
||||
*/
|
||||
class GroupClient extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Add device group.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function create(string $name)
|
||||
{
|
||||
$params = [
|
||||
'group_name' => $name,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('shakearound/device/group/add', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a device group name.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function update(int $groupId, string $name)
|
||||
{
|
||||
$params = [
|
||||
'group_id' => $groupId,
|
||||
'group_name' => $name,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('shakearound/device/group/update', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete device group.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function delete(int $groupId)
|
||||
{
|
||||
$params = [
|
||||
'group_id' => $groupId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('shakearound/device/group/delete', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* List all device groups.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function list(int $begin, int $count)
|
||||
{
|
||||
$params = [
|
||||
'begin' => $begin,
|
||||
'count' => $count,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('shakearound/device/group/getlist', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get detail of a device group.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function get(int $groupId, int $begin, int $count)
|
||||
{
|
||||
$params = [
|
||||
'group_id' => $groupId,
|
||||
'begin' => $begin,
|
||||
'count' => $count,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('shakearound/device/group/getdetail', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add one or more devices to a device group.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function addDevices(int $groupId, array $deviceIdentifiers)
|
||||
{
|
||||
$params = [
|
||||
'group_id' => $groupId,
|
||||
'device_identifiers' => $deviceIdentifiers,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('shakearound/device/group/adddevice', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove one or more devices from a device group.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function removeDevices(int $groupId, array $deviceIdentifiers)
|
||||
{
|
||||
$params = [
|
||||
'group_id' => $groupId,
|
||||
'device_identifiers' => $deviceIdentifiers,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('shakearound/device/group/deletedevice', $params);
|
||||
}
|
||||
}
|
||||
41
vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/MaterialClient.php
vendored
Normal file
41
vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/MaterialClient.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\OfficialAccount\ShakeAround;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Class MaterialClient.
|
||||
*
|
||||
* @author allen05ren <allen05ren@outlook.com>
|
||||
*/
|
||||
class MaterialClient extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Upload image material.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function uploadImage(string $path, string $type = 'icon')
|
||||
{
|
||||
if (!file_exists($path) || !is_readable($path)) {
|
||||
throw new InvalidArgumentException(sprintf('File does not exist, or the file is unreadable: "%s"', $path));
|
||||
}
|
||||
|
||||
return $this->httpUpload('shakearound/material/add', ['media' => $path], [], ['type' => strtolower($type)]);
|
||||
}
|
||||
}
|
||||
98
vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/PageClient.php
vendored
Normal file
98
vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/PageClient.php
vendored
Normal file
@@ -0,0 +1,98 @@
|
||||
<?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\OfficialAccount\ShakeAround;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class PageClient.
|
||||
*
|
||||
* @author allen05ren <allen05ren@outlook.com>
|
||||
*/
|
||||
class PageClient 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(array $data)
|
||||
{
|
||||
return $this->httpPostJson('shakearound/page/add', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function update(int $pageId, array $data)
|
||||
{
|
||||
return $this->httpPostJson('shakearound/page/update', array_merge(['page_id' => $pageId], $data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch batch of pages by pageIds.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function listByIds(array $pageIds)
|
||||
{
|
||||
$params = [
|
||||
'type' => 1,
|
||||
'page_ids' => $pageIds,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('shakearound/page/search', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pagination to get batch of pages.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function list(int $begin, int $count)
|
||||
{
|
||||
$params = [
|
||||
'type' => 2,
|
||||
'begin' => $begin,
|
||||
'count' => $count,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('shakearound/page/search', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* delete a page.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function delete(int $pageId)
|
||||
{
|
||||
$params = [
|
||||
'page_id' => $pageId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('shakearound/page/delete', $params);
|
||||
}
|
||||
}
|
||||
78
vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/RelationClient.php
vendored
Normal file
78
vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/RelationClient.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\OfficialAccount\ShakeAround;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class RelationClient.
|
||||
*
|
||||
* @author allen05ren <allen05ren@outlook.com>
|
||||
*/
|
||||
class RelationClient extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Bind pages for device.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function bindPages(array $deviceIdentifier, array $pageIds)
|
||||
{
|
||||
$params = [
|
||||
'device_identifier' => $deviceIdentifier,
|
||||
'page_ids' => $pageIds,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('shakearound/device/bindpage', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pageIds by deviceId.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function listByDeviceId(array $deviceIdentifier)
|
||||
{
|
||||
$params = [
|
||||
'type' => 1,
|
||||
'device_identifier' => $deviceIdentifier,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('shakearound/relation/search', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get devices by pageId.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function listByPageId(int $pageId, int $begin, int $count)
|
||||
{
|
||||
$params = [
|
||||
'type' => 2,
|
||||
'page_id' => $pageId,
|
||||
'begin' => $begin,
|
||||
'count' => $count,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('shakearound/relation/search', $params);
|
||||
}
|
||||
}
|
||||
57
vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/ServiceProvider.php
vendored
Normal file
57
vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
<?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\OfficialAccount\ShakeAround;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author allen05ren <allen05ren@outlook.com>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['shake_around'] = function ($app) {
|
||||
return new ShakeAround($app);
|
||||
};
|
||||
|
||||
$app['shake_around.device'] = function ($app) {
|
||||
return new DeviceClient($app);
|
||||
};
|
||||
|
||||
$app['shake_around.page'] = function ($app) {
|
||||
return new PageClient($app);
|
||||
};
|
||||
|
||||
$app['shake_around.material'] = function ($app) {
|
||||
return new MaterialClient($app);
|
||||
};
|
||||
|
||||
$app['shake_around.group'] = function ($app) {
|
||||
return new GroupClient($app);
|
||||
};
|
||||
|
||||
$app['shake_around.relation'] = function ($app) {
|
||||
return new RelationClient($app);
|
||||
};
|
||||
|
||||
$app['shake_around.stats'] = function ($app) {
|
||||
return new StatsClient($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
44
vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/ShakeAround.php
vendored
Normal file
44
vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/ShakeAround.php
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
<?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\OfficialAccount\ShakeAround;
|
||||
|
||||
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Class Card.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*
|
||||
* @property \EasyWeChat\OfficialAccount\ShakeAround\DeviceClient $device
|
||||
* @property \EasyWeChat\OfficialAccount\ShakeAround\GroupClient $group
|
||||
* @property \EasyWeChat\OfficialAccount\ShakeAround\MaterialClient $material
|
||||
* @property \EasyWeChat\OfficialAccount\ShakeAround\RelationClient $relation
|
||||
* @property \EasyWeChat\OfficialAccount\ShakeAround\StatsClient $stats
|
||||
*/
|
||||
class ShakeAround extends Client
|
||||
{
|
||||
/**
|
||||
* @param string $property
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
public function __get($property)
|
||||
{
|
||||
if (isset($this->app["shake_around.{$property}"])) {
|
||||
return $this->app["shake_around.{$property}"];
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException(sprintf('No shake_around service named "%s".', $property));
|
||||
}
|
||||
}
|
||||
102
vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/StatsClient.php
vendored
Normal file
102
vendor/overtrue/wechat/src/OfficialAccount/ShakeAround/StatsClient.php
vendored
Normal file
@@ -0,0 +1,102 @@
|
||||
<?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\OfficialAccount\ShakeAround;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class StatsClient.
|
||||
*
|
||||
* @author allen05ren <allen05ren@outlook.com>
|
||||
*/
|
||||
class StatsClient extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Fetch statistics data by deviceId.
|
||||
*
|
||||
* @param int $beginTime (Unix timestamp)
|
||||
* @param int $endTime (Unix timestamp)
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function deviceSummary(array $deviceIdentifier, int $beginTime, int $endTime)
|
||||
{
|
||||
$params = [
|
||||
'device_identifier' => $deviceIdentifier,
|
||||
'begin_date' => $beginTime,
|
||||
'end_date' => $endTime,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('shakearound/statistics/device', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch all devices statistics data by date.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function devicesSummary(int $timestamp, int $pageIndex)
|
||||
{
|
||||
$params = [
|
||||
'date' => $timestamp,
|
||||
'page_index' => $pageIndex,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('shakearound/statistics/devicelist', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch statistics data by pageId.
|
||||
*
|
||||
* @param int $beginTime (Unix timestamp)
|
||||
* @param int $endTime (Unix timestamp)
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function pageSummary(int $pageId, int $beginTime, int $endTime)
|
||||
{
|
||||
$params = [
|
||||
'page_id' => $pageId,
|
||||
'begin_date' => $beginTime,
|
||||
'end_date' => $endTime,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('shakearound/statistics/page', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch all pages statistics data by date.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function pagesSummary(int $timestamp, int $pageIndex)
|
||||
{
|
||||
$params = [
|
||||
'date' => $timestamp,
|
||||
'page_index' => $pageIndex,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('shakearound/statistics/pagelist', $params);
|
||||
}
|
||||
}
|
||||
188
vendor/overtrue/wechat/src/OfficialAccount/Store/Client.php
vendored
Normal file
188
vendor/overtrue/wechat/src/OfficialAccount/Store/Client.php
vendored
Normal file
@@ -0,0 +1,188 @@
|
||||
<?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\OfficialAccount\Store;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author bigface <saybye720@gmail.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Get WXA supported categories.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function categories()
|
||||
{
|
||||
return $this->httpGet('wxa/get_merchant_category');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get district from tencent map .
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function districts()
|
||||
{
|
||||
return $this->httpGet('wxa/get_district');
|
||||
}
|
||||
|
||||
/**
|
||||
* Search store from tencent map.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function searchFromMap(int $districtId, string $keyword)
|
||||
{
|
||||
$params = [
|
||||
'districtid' => $districtId,
|
||||
'keyword' => $keyword,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('wxa/search_map_poi', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get store check status.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getStatus()
|
||||
{
|
||||
return $this->httpPostJson('wxa/get_merchant_audit_info');
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a merchant.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function createMerchant(array $baseInfo)
|
||||
{
|
||||
return $this->httpPostJson('wxa/apply_merchant', $baseInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a merchant.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function updateMerchant(array $params)
|
||||
{
|
||||
return $this->httpPostJson('wxa/modify_merchant', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a store from tencent map.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function createFromMap(array $baseInfo)
|
||||
{
|
||||
return $this->httpPostJson('wxa/create_map_poi', $baseInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a store.
|
||||
*
|
||||
* @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 $baseInfo)
|
||||
{
|
||||
return $this->httpPostJson('wxa/add_store', $baseInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a store.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function update(int $poiId, array $baseInfo)
|
||||
{
|
||||
$params = array_merge($baseInfo, ['poi_id' => $poiId]);
|
||||
|
||||
return $this->httpPostJson('wxa/update_store', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get store by ID.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function get(int $poiId)
|
||||
{
|
||||
return $this->httpPostJson('wxa/get_store_info', ['poi_id' => $poiId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* List store.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function list(int $offset = 0, int $limit = 10)
|
||||
{
|
||||
$params = [
|
||||
'offset' => $offset,
|
||||
'limit' => $limit,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('wxa/get_store_list', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a store.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function delete(int $poiId)
|
||||
{
|
||||
return $this->httpPostJson('wxa/del_store', ['poi_id' => $poiId]);
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/OfficialAccount/Store/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/OfficialAccount/Store/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\OfficialAccount\Store;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author bigface <saybye720@gmail.com>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['store'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
193
vendor/overtrue/wechat/src/OfficialAccount/SubscribeMessage/Client.php
vendored
Normal file
193
vendor/overtrue/wechat/src/OfficialAccount/SubscribeMessage/Client.php
vendored
Normal file
@@ -0,0 +1,193 @@
|
||||
<?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\OfficialAccount\SubscribeMessage;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
|
||||
use ReflectionClass;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author hugo <rabbitzhang52@gmail.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
protected $message = [
|
||||
'touser' => '',
|
||||
'template_id' => '',
|
||||
'page' => '',
|
||||
'miniprogram' => '',
|
||||
'data' => [],
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
protected $required = ['touser', 'template_id', 'data'];
|
||||
|
||||
/**
|
||||
* Combine templates and add them to your personal template library under your account.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function addTemplate(string $tid, array $kidList, string $sceneDesc = null)
|
||||
{
|
||||
$sceneDesc = $sceneDesc ?? '';
|
||||
$data = \compact('tid', 'kidList', 'sceneDesc');
|
||||
|
||||
return $this->httpPost('wxaapi/newtmpl/addtemplate', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete personal template under account.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function deleteTemplate(string $id)
|
||||
{
|
||||
return $this->httpPost('wxaapi/newtmpl/deltemplate', ['priTmplId' => $id]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the category of the applet account.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getCategory()
|
||||
{
|
||||
return $this->httpGet('wxaapi/newtmpl/getcategory');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get keyword list under template title.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getTemplateKeywords(string $tid)
|
||||
{
|
||||
return $this->httpGet('wxaapi/newtmpl/getpubtemplatekeywords', compact('tid'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the title of the public template under the category to which the account belongs.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getTemplateTitles(array $ids, int $start = 0, int $limit = 30)
|
||||
{
|
||||
$ids = \implode(',', $ids);
|
||||
$query = \compact('ids', 'start', 'limit');
|
||||
|
||||
return $this->httpGet('wxaapi/newtmpl/getpubtemplatetitles', $query);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get list of personal templates under the current account.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getTemplates()
|
||||
{
|
||||
return $this->httpGet('wxaapi/newtmpl/gettemplate');
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a subscribe message.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function send(array $data = [])
|
||||
{
|
||||
$params = $this->formatMessage($data);
|
||||
|
||||
$this->restoreMessage();
|
||||
|
||||
return $this->httpPostJson('cgi-bin/message/subscribe/bizsend', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
protected function formatMessage(array $data = [])
|
||||
{
|
||||
$params = array_merge($this->message, $data);
|
||||
|
||||
foreach ($params as $key => $value) {
|
||||
if (in_array($key, $this->required, true) && empty($value) && empty($this->message[$key])) {
|
||||
throw new InvalidArgumentException(sprintf('Attribute "%s" can not be empty!', $key));
|
||||
}
|
||||
|
||||
$params[$key] = empty($value) ? $this->message[$key] : $value;
|
||||
}
|
||||
|
||||
foreach ($params['data'] as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
if (\array_key_exists('value', $value)) {
|
||||
$params['data'][$key] = ['value' => $value['value']];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (count($value) >= 1) {
|
||||
$value = [
|
||||
'value' => $value[0],
|
||||
// 'color' => $value[1],// color unsupported
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$value = [
|
||||
'value' => strval($value),
|
||||
];
|
||||
}
|
||||
|
||||
$params['data'][$key] = $value;
|
||||
}
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore message.
|
||||
*/
|
||||
protected function restoreMessage()
|
||||
{
|
||||
$this->message = (new ReflectionClass(static::class))->getDefaultProperties()['message'];
|
||||
}
|
||||
}
|
||||
28
vendor/overtrue/wechat/src/OfficialAccount/SubscribeMessage/ServiceProvider.php
vendored
Normal file
28
vendor/overtrue/wechat/src/OfficialAccount/SubscribeMessage/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\OfficialAccount\SubscribeMessage;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['subscribe_message'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
226
vendor/overtrue/wechat/src/OfficialAccount/TemplateMessage/Client.php
vendored
Normal file
226
vendor/overtrue/wechat/src/OfficialAccount/TemplateMessage/Client.php
vendored
Normal file
@@ -0,0 +1,226 @@
|
||||
<?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\OfficialAccount\TemplateMessage;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
use EasyWeChat\Kernel\Exceptions\InvalidArgumentException;
|
||||
use ReflectionClass;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
public const API_SEND = 'cgi-bin/message/template/send';
|
||||
|
||||
/**
|
||||
* Attributes.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $message = [
|
||||
'touser' => '',
|
||||
'template_id' => '',
|
||||
'url' => '',
|
||||
'data' => [],
|
||||
'miniprogram' => '',
|
||||
];
|
||||
|
||||
/**
|
||||
* Required attributes.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $required = ['touser', 'template_id'];
|
||||
|
||||
/**
|
||||
* Set industry.
|
||||
*
|
||||
* @param int $industryOne
|
||||
* @param int $industryTwo
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function setIndustry($industryOne, $industryTwo)
|
||||
{
|
||||
$params = [
|
||||
'industry_id1' => $industryOne,
|
||||
'industry_id2' => $industryTwo,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/template/api_set_industry', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get industry.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getIndustry()
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/template/get_industry');
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a template and get template ID.
|
||||
*
|
||||
* @param string $shortId
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function addTemplate($shortId)
|
||||
{
|
||||
$params = ['template_id_short' => $shortId];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/template/api_add_template', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get private templates.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getPrivateTemplates()
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/template/get_all_private_template');
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete private template.
|
||||
*
|
||||
* @param string $templateId
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function deletePrivateTemplate($templateId)
|
||||
{
|
||||
$params = ['template_id' => $templateId];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/template/del_private_template', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a template message.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function send(array $data = [])
|
||||
{
|
||||
$params = $this->formatMessage($data);
|
||||
|
||||
$this->restoreMessage();
|
||||
|
||||
return $this->httpPostJson(static::API_SEND, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send template-message for subscription.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function sendSubscription(array $data = [])
|
||||
{
|
||||
$params = $this->formatMessage($data);
|
||||
|
||||
$this->restoreMessage();
|
||||
|
||||
return $this->httpPostJson('cgi-bin/message/template/subscribe', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
*/
|
||||
protected function formatMessage(array $data = [])
|
||||
{
|
||||
$params = array_merge($this->message, $data);
|
||||
|
||||
foreach ($params as $key => $value) {
|
||||
if (in_array($key, $this->required, true) && empty($value) && empty($this->message[$key])) {
|
||||
throw new InvalidArgumentException(sprintf('Attribute "%s" can not be empty!', $key));
|
||||
}
|
||||
|
||||
$params[$key] = empty($value) ? $this->message[$key] : $value;
|
||||
}
|
||||
|
||||
$params['data'] = $this->formatData($params['data'] ?? []);
|
||||
|
||||
return $params;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function formatData(array $data)
|
||||
{
|
||||
$formatted = [];
|
||||
|
||||
foreach ($data as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
if (\array_key_exists('value', $value)) {
|
||||
$formatted[$key] = $value;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (count($value) >= 2) {
|
||||
$value = [
|
||||
'value' => $value[0],
|
||||
'color' => $value[1],
|
||||
];
|
||||
}
|
||||
} else {
|
||||
$value = [
|
||||
'value' => strval($value),
|
||||
];
|
||||
}
|
||||
|
||||
$formatted[$key] = $value;
|
||||
}
|
||||
|
||||
return $formatted;
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore message.
|
||||
*/
|
||||
protected function restoreMessage()
|
||||
{
|
||||
$this->message = (new ReflectionClass(static::class))->getDefaultProperties()['message'];
|
||||
}
|
||||
}
|
||||
33
vendor/overtrue/wechat/src/OfficialAccount/TemplateMessage/ServiceProvider.php
vendored
Normal file
33
vendor/overtrue/wechat/src/OfficialAccount/TemplateMessage/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\OfficialAccount\TemplateMessage;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['template_message'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
35
vendor/overtrue/wechat/src/OfficialAccount/User/ServiceProvider.php
vendored
Normal file
35
vendor/overtrue/wechat/src/OfficialAccount/User/ServiceProvider.php
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
<?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\OfficialAccount\User;
|
||||
|
||||
use Pimple\Container;
|
||||
use Pimple\ServiceProviderInterface;
|
||||
|
||||
/**
|
||||
* Class ServiceProvider.
|
||||
*/
|
||||
class ServiceProvider implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}.
|
||||
*/
|
||||
public function register(Container $app)
|
||||
{
|
||||
$app['user'] = function ($app) {
|
||||
return new UserClient($app);
|
||||
};
|
||||
|
||||
$app['user_tag'] = function ($app) {
|
||||
return new TagClient($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
157
vendor/overtrue/wechat/src/OfficialAccount/User/TagClient.php
vendored
Normal file
157
vendor/overtrue/wechat/src/OfficialAccount/User/TagClient.php
vendored
Normal file
@@ -0,0 +1,157 @@
|
||||
<?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\OfficialAccount\User;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class TagClient.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class TagClient extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Create tag.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function create(string $name)
|
||||
{
|
||||
$params = [
|
||||
'tag' => ['name' => $name],
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/tags/create', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* List all tags.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function list()
|
||||
{
|
||||
return $this->httpGet('cgi-bin/tags/get');
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a tag name.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function update(int $tagId, string $name)
|
||||
{
|
||||
$params = [
|
||||
'tag' => [
|
||||
'id' => $tagId,
|
||||
'name' => $name,
|
||||
],
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/tags/update', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete tag.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function delete(int $tagId)
|
||||
{
|
||||
$params = [
|
||||
'tag' => ['id' => $tagId],
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/tags/delete', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user tags.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function userTags(string $openid)
|
||||
{
|
||||
$params = ['openid' => $openid];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/tags/getidlist', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get users from a tag.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function usersOfTag(int $tagId, string $nextOpenId = '')
|
||||
{
|
||||
$params = [
|
||||
'tagid' => $tagId,
|
||||
'next_openid' => $nextOpenId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/user/tag/get', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch tag users.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function tagUsers(array $openids, int $tagId)
|
||||
{
|
||||
$params = [
|
||||
'openid_list' => $openids,
|
||||
'tagid' => $tagId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/tags/members/batchtagging', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Untag users from a tag.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function untagUsers(array $openids, int $tagId)
|
||||
{
|
||||
$params = [
|
||||
'openid_list' => $openids,
|
||||
'tagid' => $tagId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/tags/members/batchuntagging', $params);
|
||||
}
|
||||
}
|
||||
158
vendor/overtrue/wechat/src/OfficialAccount/User/UserClient.php
vendored
Normal file
158
vendor/overtrue/wechat/src/OfficialAccount/User/UserClient.php
vendored
Normal file
@@ -0,0 +1,158 @@
|
||||
<?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\OfficialAccount\User;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class UserClient.
|
||||
*
|
||||
* @author overtrue <i@overtrue.me>
|
||||
*/
|
||||
class UserClient extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Fetch a user by open id.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function get(string $openid, string $lang = 'zh_CN')
|
||||
{
|
||||
$params = [
|
||||
'openid' => $openid,
|
||||
'lang' => $lang,
|
||||
];
|
||||
|
||||
return $this->httpGet('cgi-bin/user/info', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch get users.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function select(array $openids, string $lang = 'zh_CN')
|
||||
{
|
||||
return $this->httpPostJson('cgi-bin/user/info/batchget', [
|
||||
'user_list' => array_map(function ($openid) use ($lang) {
|
||||
return [
|
||||
'openid' => $openid,
|
||||
'lang' => $lang,
|
||||
];
|
||||
}, $openids),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* List users.
|
||||
*
|
||||
* @param string $nextOpenId
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
*/
|
||||
public function list(string $nextOpenId = null)
|
||||
{
|
||||
$params = ['next_openid' => $nextOpenId];
|
||||
|
||||
return $this->httpGet('cgi-bin/user/get', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set user remark.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function remark(string $openid, string $remark)
|
||||
{
|
||||
$params = [
|
||||
'openid' => $openid,
|
||||
'remark' => $remark,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/user/info/updateremark', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get black list.
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function blacklist(string $beginOpenid = null)
|
||||
{
|
||||
$params = ['begin_openid' => $beginOpenid];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/tags/members/getblacklist', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch block user.
|
||||
*
|
||||
* @param array|string $openidList
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function block($openidList)
|
||||
{
|
||||
$params = ['openid_list' => (array) $openidList];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/tags/members/batchblacklist', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Batch unblock user.
|
||||
*
|
||||
* @param array $openidList
|
||||
*
|
||||
* @return \Psr\Http\Message\ResponseInterface|\EasyWeChat\Kernel\Support\Collection|array|object|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function unblock($openidList)
|
||||
{
|
||||
$params = ['openid_list' => (array) $openidList];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/tags/members/batchunblacklist', $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function changeOpenid(string $oldAppId, array $openidList)
|
||||
{
|
||||
$params = [
|
||||
'from_appid' => $oldAppId,
|
||||
'openid_list' => $openidList,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('cgi-bin/changeopenid', $params);
|
||||
}
|
||||
}
|
||||
48
vendor/overtrue/wechat/src/OfficialAccount/WiFi/CardClient.php
vendored
Normal file
48
vendor/overtrue/wechat/src/OfficialAccount/WiFi/CardClient.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\OfficialAccount\WiFi;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class CardClient.
|
||||
*
|
||||
* @author her-cat <i@her-cat.com>
|
||||
*/
|
||||
class CardClient extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Set shop card coupon delivery information.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function set(array $data)
|
||||
{
|
||||
return $this->httpPostJson('bizwifi/couponput/set', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get shop card coupon delivery information.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function get(int $shopId = 0)
|
||||
{
|
||||
return $this->httpPostJson('bizwifi/couponput/get', ['shop_id' => $shopId]);
|
||||
}
|
||||
}
|
||||
86
vendor/overtrue/wechat/src/OfficialAccount/WiFi/Client.php
vendored
Normal file
86
vendor/overtrue/wechat/src/OfficialAccount/WiFi/Client.php
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
<?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\OfficialAccount\WiFi;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class Client.
|
||||
*
|
||||
* @author her-cat <i@her-cat.com>
|
||||
*/
|
||||
class Client extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Get Wi-Fi statistics.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function summary(string $beginDate, string $endDate, int $shopId = -1)
|
||||
{
|
||||
$data = [
|
||||
'begin_date' => $beginDate,
|
||||
'end_date' => $endDate,
|
||||
'shop_id' => $shopId,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('bizwifi/statistics/list', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the material QR code.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function getQrCodeUrl(int $shopId, string $ssid, int $type = 0)
|
||||
{
|
||||
$data = [
|
||||
'shop_id' => $shopId,
|
||||
'ssid' => $ssid,
|
||||
'img_id' => $type,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('bizwifi/qrcode/get', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Wi-Fi completion page jump applet.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function setFinishPage(array $data)
|
||||
{
|
||||
return $this->httpPostJson('bizwifi/finishpage/set', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the top banner jump applet.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function setHomePage(array $data)
|
||||
{
|
||||
return $this->httpPostJson('bizwifi/homepage/set', $data);
|
||||
}
|
||||
}
|
||||
110
vendor/overtrue/wechat/src/OfficialAccount/WiFi/DeviceClient.php
vendored
Normal file
110
vendor/overtrue/wechat/src/OfficialAccount/WiFi/DeviceClient.php
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
<?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\OfficialAccount\WiFi;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class DeviceClient.
|
||||
*
|
||||
* @author her-cat <i@her-cat.com>
|
||||
*/
|
||||
class DeviceClient extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Add a password device.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function addPasswordDevice(int $shopId, string $ssid, string $password)
|
||||
{
|
||||
$data = [
|
||||
'shop_id' => $shopId,
|
||||
'ssid' => $ssid,
|
||||
'password' => $password,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('bizwifi/device/add', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a portal device.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function addPortalDevice(int $shopId, string $ssid, bool $reset = false)
|
||||
{
|
||||
$data = [
|
||||
'shop_id' => $shopId,
|
||||
'ssid' => $ssid,
|
||||
'reset' => $reset,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('bizwifi/apportal/register', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete device by MAC address.
|
||||
*
|
||||
* @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 $macAddress)
|
||||
{
|
||||
return $this->httpPostJson('bizwifi/device/delete', ['bssid' => $macAddress]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of devices.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function list(int $page = 1, int $size = 10)
|
||||
{
|
||||
$data = [
|
||||
'pageindex' => $page,
|
||||
'pagesize' => $size,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('bizwifi/device/list', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of devices by shop ID.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function listByShopId(int $shopId, int $page = 1, int $size = 10)
|
||||
{
|
||||
$data = [
|
||||
'shop_id' => $shopId,
|
||||
'pageindex' => $page,
|
||||
'pagesize' => $size,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('bizwifi/device/list', $data);
|
||||
}
|
||||
}
|
||||
45
vendor/overtrue/wechat/src/OfficialAccount/WiFi/ServiceProvider.php
vendored
Normal file
45
vendor/overtrue/wechat/src/OfficialAccount/WiFi/ServiceProvider.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\OfficialAccount\WiFi;
|
||||
|
||||
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['wifi'] = function ($app) {
|
||||
return new Client($app);
|
||||
};
|
||||
|
||||
$app['wifi_card'] = function ($app) {
|
||||
return new CardClient($app);
|
||||
};
|
||||
|
||||
$app['wifi_device'] = function ($app) {
|
||||
return new DeviceClient($app);
|
||||
};
|
||||
|
||||
$app['wifi_shop'] = function ($app) {
|
||||
return new ShopClient($app);
|
||||
};
|
||||
}
|
||||
}
|
||||
89
vendor/overtrue/wechat/src/OfficialAccount/WiFi/ShopClient.php
vendored
Normal file
89
vendor/overtrue/wechat/src/OfficialAccount/WiFi/ShopClient.php
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
<?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\OfficialAccount\WiFi;
|
||||
|
||||
use EasyWeChat\Kernel\BaseClient;
|
||||
|
||||
/**
|
||||
* Class ShopClient.
|
||||
*
|
||||
* @author her-cat <i@her-cat.com>
|
||||
*/
|
||||
class ShopClient extends BaseClient
|
||||
{
|
||||
/**
|
||||
* Get shop Wi-Fi information.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function get(int $shopId)
|
||||
{
|
||||
return $this->httpPostJson('bizwifi/shop/get', ['shop_id' => $shopId]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of Wi-Fi shops.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function list(int $page = 1, int $size = 10)
|
||||
{
|
||||
$data = [
|
||||
'pageindex' => $page,
|
||||
'pagesize' => $size,
|
||||
];
|
||||
|
||||
return $this->httpPostJson('bizwifi/shop/list', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update shop Wi-Fi information.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function update(int $shopId, array $data)
|
||||
{
|
||||
$data = array_merge(['shop_id' => $shopId], $data);
|
||||
|
||||
return $this->httpPostJson('bizwifi/shop/update', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear shop network and equipment.
|
||||
*
|
||||
* @return array|\EasyWeChat\Kernel\Support\Collection|object|\Psr\Http\Message\ResponseInterface|string
|
||||
*
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
*/
|
||||
public function clearDevice(int $shopId, string $ssid = null)
|
||||
{
|
||||
$data = [
|
||||
'shop_id' => $shopId,
|
||||
];
|
||||
|
||||
if (!is_null($ssid)) {
|
||||
$data['ssid'] = $ssid;
|
||||
}
|
||||
|
||||
return $this->httpPostJson('bizwifi/shop/clean', $data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user