Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade packages version to 4.0 #590

Merged
merged 13 commits into from
Feb 12, 2017
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ language: php

php:
# using major version aliases
# aliased to a recent 5.5.x version
- 5.5
# aliased to a recent 5.6.x version
- 5.6
# aliased to a recent 7.0.x version
- 7.0

Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@
}
],
"require": {
"php":">=5.5.0",
"php":">=7.0",
"ext-openssl": "*",
"pimple/pimple": "~3.0",
"monolog/monolog": "^1.17",
"monolog/monolog": "^1.22",
"overtrue/socialite": ">=1.0.7",
"doctrine/cache": "~1.4",
"doctrine/cache": "~1.6",
"guzzlehttp/guzzle": "~6.2.1",
"symfony/http-foundation": "~2.6|~2.7|~2.8|~3.0",
"symfony/psr-http-message-bridge": "~0.3|^1.0"
},
"require-dev": {
"phpunit/phpunit": "~4.0",
"phpunit/phpunit": "~6.0",
"overtrue/phplint": "dev-master",
"mockery/mockery": "^1.0@dev"
},
Expand Down
20 changes: 18 additions & 2 deletions src/OpenPlatform/AccessToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,14 @@

namespace EasyWeChat\OpenPlatform;

use Doctrine\Common\Cache\Cache;
use EasyWeChat\Core\AccessToken as WechatAccessToken;
use EasyWeChat\Core\Exceptions\HttpException;
use EasyWeChat\OpenPlatform\Traits\VerifyTicket;
use EasyWeChat\OpenPlatform\Traits\VerifyTicketTrait;

class AccessToken extends WechatAccessToken
{
use VerifyTicket;
use VerifyTicketTrait;

/**
* API.
Expand All @@ -54,6 +55,21 @@ class AccessToken extends WechatAccessToken
*/
protected $prefix = 'easywechat.common.component_access_token.';

/**
* AccessToken constructor.
*
* @param string $appId
* @param string $secret
* @param Cache $cache
* @param VerifyTicket $verifyTicket
*/
public function __construct($appId, $secret, VerifyTicket $verifyTicket, Cache $cache = null)
{
parent::__construct($appId, $secret, $cache);

$this->setVerifyTicket($verifyTicket);
}

/**
* {@inheritdoc}.
*/
Expand Down
1 change: 0 additions & 1 deletion src/OpenPlatform/EventHandlers/EventHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ abstract public function handle(Collection $message);
*/
public function forward(Collection $message)
{
//
return $message;
}
}
19 changes: 17 additions & 2 deletions src/OpenPlatform/Guard.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@
namespace EasyWeChat\OpenPlatform;

use EasyWeChat\Core\Exceptions\InvalidArgumentException;
use EasyWeChat\OpenPlatform\Traits\VerifyTicket;
use EasyWeChat\OpenPlatform\Traits\VerifyTicketTrait;
use EasyWeChat\Server\Guard as ServerGuard;
use EasyWeChat\Support\Arr;
use Symfony\Component\HttpFoundation\Request;

class Guard extends ServerGuard
{
use VerifyTicket;
use VerifyTicketTrait;

/**
* Wechat push event types.
Expand All @@ -47,6 +48,20 @@ class Guard extends ServerGuard
'component_verify_ticket' => EventHandlers\ComponentVerifyTicket::class,
];

/**
* Guard constructor.
*
* @param string $token
* @param VerifyTicket $ticketTrait
* @param Request|null $request
*/
public function __construct($token, VerifyTicket $ticketTrait, Request $request = null)
{
parent::__construct($token, $request);

$this->setVerifyTicket($ticketTrait);
}

/**
* Return for laravel-wechat.
*
Expand Down
8 changes: 2 additions & 6 deletions src/OpenPlatform/OpenPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
*
* @property \EasyWeChat\OpenPlatform\Guard $server
* @property \EasyWeChat\OpenPlatform\Components\PreAuthCode $pre_auth
* @property \EasyWeChat\OpenPlatform\AccessToken $access_token
* @property \EasyWeChat\OpenPlatform\Components\Authorizer $authorizer
*/
class OpenPlatform
Expand Down Expand Up @@ -75,16 +76,11 @@ class OpenPlatform
* @param Guard $server
* @param $access_token
* @param array $config
* @param $verifyTicket
*/
public function __construct(Guard $server, $access_token, $config, $verifyTicket)
public function __construct(Guard $server, $access_token, $config)
{
$this->server = $server;
$this->server->setVerifyTicket($verifyTicket);

$this->access_token = $access_token;
$this->access_token->setVerifyTicket($verifyTicket);

$this->config = $config;
}

Expand Down
20 changes: 10 additions & 10 deletions src/OpenPlatform/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,18 @@ class ServiceProvider implements ServiceProviderInterface
*/
public function register(Container $pimple)
{
$pimple['open_platform_access_token'] = function ($pimple) {
return new AccessToken(
$pimple['config']['open_platform']['app_id'],
$pimple['config']['open_platform']['secret'],
$pimple['component_verify_ticket'] = function ($pimple) {
return new VerifyTicket(
$pimple['config']['open_platform'],
$pimple['cache']
);
};

$pimple['component_verify_ticket'] = function ($pimple) {
return new VerifyTicket(
$pimple['config']['open_platform'],
$pimple['open_platform_access_token'] = function ($pimple) {
return new AccessToken(
$pimple['config']['open_platform']['app_id'],
$pimple['config']['open_platform']['secret'],
$pimple['component_verify_ticket'],
$pimple['cache']
);
};
Expand All @@ -65,7 +66,7 @@ public function register(Container $pimple)
};

$pimple['open_platform'] = function ($pimple) {
$server = new Guard($pimple['config']['open_platform']['token']);
$server = new Guard($pimple['config']['open_platform']['token'], $pimple['component_verify_ticket']);

$server->debug($pimple['config']['debug']);

Expand All @@ -74,8 +75,7 @@ public function register(Container $pimple)
return new OpenPlatform(
$server,
$pimple['open_platform_access_token'],
$pimple['config']['open_platform'],
$pimple['component_verify_ticket']
$pimple['config']['open_platform']
);
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

namespace EasyWeChat\OpenPlatform\Traits;

use EasyWeChat\OpenPlatform\VerifyTicket as ComponentVerifyTicket;
use EasyWeChat\OpenPlatform\VerifyTicket;

trait VerifyTicket
trait VerifyTicketTrait
{
/**
* Verify Ticket.
Expand All @@ -44,7 +44,7 @@ trait VerifyTicket
*
* @return $this
*/
public function setVerifyTicket(ComponentVerifyTicket $verifyTicket)
public function setVerifyTicket(VerifyTicket $verifyTicket)
{
$this->verifyTicket = $verifyTicket;

Expand Down
20 changes: 11 additions & 9 deletions src/Staff/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,31 +15,33 @@
* @author overtrue <i@overtrue.me>
* @copyright 2015 overtrue <i@overtrue.me>
*
* @see https://github.com/overtrue
* @see http://overtrue.me
* @link https://github.com/overtrue
* @link http://overtrue.me
*/

namespace EasyWeChat\Staff;

use EasyWeChat\Core\AbstractAPI;
use EasyWeChat\Support\Collection;

/**
* Class Session.
*/
class Session extends AbstractAPI
{

const API_CREATE = 'https://api.weixin.qq.com/customservice/kfsession/create';
const API_CLOSE = 'https://api.weixin.qq.com/customservice/kfsession/close';
const API_GET = 'https://api.weixin.qq.com/customservice/kfsession/getsession';
const API_LISTS = 'https://api.weixin.qq.com/customservice/kfsession/getsessionlist';
const API_WAITERS = 'https://api.weixin.qq.com/customservice/kfsession/getwaitcase';


/**
* List all sessions of $account.
*
* @param string $account
*
* @return \EasyWeChat\Support\Collection
* @return array
*/
public function lists($account)
{
Expand All @@ -49,7 +51,7 @@ public function lists($account)
/**
* List all waiters of $account.
*
* @return \EasyWeChat\Support\Collection
* @return array
*/
public function waiters()
{
Expand All @@ -60,9 +62,9 @@ public function waiters()
* Create a session.
*
* @param string $account
* @param string $openId
* @param string $openid
*
* @return \EasyWeChat\Support\Collection
* @return bool
*/
public function create($account, $openId)
{
Expand All @@ -80,7 +82,7 @@ public function create($account, $openId)
* @param string $account
* @param string $openId
*
* @return \EasyWeChat\Support\Collection
* @return bool
*/
public function close($account, $openId)
{
Expand All @@ -97,7 +99,7 @@ public function close($account, $openId)
*
* @param string $openId
*
* @return \EasyWeChat\Support\Collection
* @return bool
*/
public function get($openId)
{
Expand Down
17 changes: 8 additions & 9 deletions src/Staff/Staff.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
* @author overtrue <i@overtrue.me>
* @copyright 2015 overtrue <i@overtrue.me>
*
* @see https://github.com/overtrue
* @see http://overtrue.me
* @link https://github.com/overtrue
* @link http://overtrue.me
*/

namespace EasyWeChat\Staff;

use EasyWeChat\Core\AbstractAPI;
Expand Down Expand Up @@ -181,20 +180,20 @@ public function send($message)
/**
* Get staff session history.
*
* @param int $startTime
* @param int $endTime
* @param int $page
* @param int $pageSize
* @param int $startTime
* @param int $endTime
* @param int $page
* @param int $pageSize
*
* @return \EasyWeChat\Support\Collection
*/
public function records($startTime, $endTime, $page = 1, $pageSize = 10)
{
$params = [
'starttime' => is_numeric($startTime) ? $startTime : strtotime($startTime),
'endtime' => is_numeric($endTime) ? $endTime : strtotime($endTime),
'endtime' => is_numeric($endTime) ? $endTime : strtotime($endTime),
'pageindex' => $page,
'pagesize' => $pageSize,
'pagesize' => $pageSize,
];

return $this->parseJSON('json', [self::API_RECORDS, $params]);
Expand Down
9 changes: 5 additions & 4 deletions src/Support/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
* @author overtrue <i@overtrue.me>
* @copyright 2015 overtrue <i@overtrue.me>
*
* @see https://github.com/overtrue
* @see http://overtrue.me
* @link https://github.com/overtrue
* @link http://overtrue.me
*/

namespace EasyWeChat\Support;

use finfo;
Expand Down Expand Up @@ -47,8 +46,9 @@ class File
'image/png' => '.png',
'image/tiff' => '.tiff',
'image/jpeg' => '.jpg',
'application/pdf' => '.pdf',

// 列举更多的文件 mime, 企业号是支持的, 公众平台这边之后万一也更新了呢
// 列举更多的文件 mime, 企业号是支持的,公众平台这边之后万一也更新了呢
'application/msword' => '.doc',

'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => '.docx',
Expand Down Expand Up @@ -93,6 +93,7 @@ class File
'000001ba' => '.mpg',
'000001b3' => '.mpg',
'2321414d52' => '.amr',
'25504446' => '.pdf',
];

/**
Expand Down