Skip to content

Commit

Permalink
Develop (#410)
Browse files Browse the repository at this point in the history
* Bugfix close #389

* Fix tests.

* Fix url. close #393

* Payment::configForPayment() bugfix. EasyWeChat/docs#27

* Fix tests.

* Add methods for JSSDK payment.

* Fix tests.

* Applied fixes from StyleCI (#400)

* Scrutinizer Auto-Fixes (#399)

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com

* Filter the empty params. #402

* Add User Tag service.

* Applied fixes from StyleCI (#409)

* Typo.
  • Loading branch information
overtrue committed May 4, 2016
1 parent ba17f63 commit fee6ef0
Show file tree
Hide file tree
Showing 43 changed files with 385 additions and 38 deletions.
2 changes: 1 addition & 1 deletion phpunit.xml.dist
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="vendor/autoload.php"
bootstrap="tests/bootstrap.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
Expand Down
8 changes: 8 additions & 0 deletions src/Foundation/ServiceProviders/UserServiceProvider.php
Expand Up @@ -26,6 +26,7 @@
namespace EasyWeChat\Foundation\ServiceProviders;

use EasyWeChat\User\Group;
use EasyWeChat\User\Tag;
use EasyWeChat\User\User;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
Expand Down Expand Up @@ -53,7 +54,14 @@ public function register(Container $pimple)
return new Group($pimple['access_token']);
};

$tag = function ($pimple) {
return new Tag($pimple['access_token']);
};

$pimple['user_group'] = $group;
$pimple['user.group'] = $group;

$pimple['user_tag'] = $tag;
$pimple['user.tag'] = $tag;
}
}
164 changes: 164 additions & 0 deletions src/User/Tag.php
@@ -0,0 +1,164 @@
<?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.
*/

/**
* Group.php.
*
* @author overtrue <i@overtrue.me>
* @copyright 2015 overtrue <i@overtrue.me>
*
* @link https://github.com/overtrue
* @link http://overtrue.me
*/
namespace EasyWeChat\User;

use EasyWeChat\Core\AbstractAPI;

/**
* Class Tag.
*/
class Tag extends AbstractAPI
{
const API_GET = 'https://api.weixin.qq.com/cgi-bin/tags/get';
const API_CREATE = 'https://api.weixin.qq.com/cgi-bin/tags/create';
const API_UPDATE = 'https://api.weixin.qq.com/cgi-bin/tags/update';
const API_DELETE = 'https://api.weixin.qq.com/cgi-bin/tags/delete';
const API_USER_TAGS = 'https://api.weixin.qq.com/cgi-bin/tags/getidlist';
const API_MEMBER_BATCH_TAG = 'https://api.weixin.qq.com/cgi-bin/tags/members/batchtagging';
const API_MEMBER_BATCH_UNTAG = 'https://api.weixin.qq.com/cgi-bin/tags/members/batchuntagging';
const API_USERS_OF_TAG = 'https://api.weixin.qq.com/cgi-bin/user/tag/get';

/**
* Create tag.
*
* @param string $name
*
* @return int
*/
public function create($name)
{
$params = [
'tag' => ['name' => $name],
];

return $this->parseJSON('json', [self::API_CREATE, $params]);
}

/**
* List all tags.
*
* @return array
*/
public function lists()
{
return $this->parseJSON('get', [self::API_GET]);
}

/**
* Update a tag name.
*
* @param int $tagId
* @param string $name
*
* @return bool
*/
public function update($tagId, $name)
{
$params = [
'tag' => [
'id' => $tagId,
'name' => $name,
],
];

return $this->parseJSON('json', [self::API_UPDATE, $params]);
}

/**
* Delete tag.
*
* @param int $tagId
*
* @return bool
*/
public function delete($tagId)
{
$params = [
'tag' => ['id' => $tagId],
];

return $this->parseJSON('json', [self::API_DELETE, $params]);
}

/**
* Get user tags.
*
* @param string $openId
*
* @return int
*/
public function userTags($openId)
{
$params = ['openid' => $openId];

return $this->parseJSON('json', [self::API_USER_TAGS, $params]);
}

/**
* Get users from a tag.
*
* @param string $openId
*
* @return int
*/
public function usersOfTag($tagId)
{
$params = ['tagid' => $tagId];

return $this->parseJSON('json', [self::API_USERS_OF_TAG, $params]);
}

/**
* Batch tag users.
*
* @param array $openIds
* @param int $tagid
*
* @return bool
*/
public function batchTagUsers(array $openIds, $tagId)
{
$params = [
'openid_list' => $openIds,
'tagid' => $tagId,
];

return $this->parseJSON('json', [self::API_MEMBER_BATCH_TAG, $params]);
}

/**
* Untag users from a tag.
*
* @param array $openIds
* @param int $tagid
*
* @return bool
*/
public function batchUntagUsers(array $openIds, $tagId)
{
$params = [
'openid_list' => $openIds,
'tagid' => $tagId,
];

return $this->parseJSON('json', [self::API_MEMBER_BATCH_UNTAG, $params]);
}
}
2 changes: 1 addition & 1 deletion tests/Broadcast/BroadcastBroadcastTest.php
Expand Up @@ -11,7 +11,7 @@

use EasyWeChat\Broadcast\Broadcast;

class BroadcastBroadcastTest extends PHPUnit_Framework_TestCase
class BroadcastBroadcastTest extends TestCase
{
public function getBroadcast()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Broadcast/BroadcastMessageBuilderTest.php
Expand Up @@ -12,7 +12,7 @@
use EasyWeChat\Broadcast\Broadcast;
use EasyWeChat\Broadcast\MessageBuilder;

class BroadcastMessageBuilderTest extends PHPUnit_Framework_TestCase
class BroadcastMessageBuilderTest extends TestCase
{
/**
* Test msgType().
Expand Down
2 changes: 1 addition & 1 deletion tests/Broadcast/BroadcastTransformerTest.php
Expand Up @@ -11,7 +11,7 @@

use EasyWeChat\Broadcast\Transformer;

class BroadcastTransformerTest extends PHPUnit_Framework_TestCase
class BroadcastTransformerTest extends TestCase
{
/**
* Test transform().
Expand Down
2 changes: 1 addition & 1 deletion tests/Core/CoreAbstractAPITest.php
Expand Up @@ -22,7 +22,7 @@ public function getHttpInstance()
}
}

class CoreAbstractAPITest extends PHPUnit_Framework_TestCase
class CoreAbstractAPITest extends TestCase
{
/**
* Test __construct.
Expand Down
2 changes: 1 addition & 1 deletion tests/Core/CoreAccessTokenTest.php
Expand Up @@ -13,7 +13,7 @@
use EasyWeChat\Core\AccessToken;
use EasyWeChat\Core\Http;

class CoreAccessTokenTest extends PHPUnit_Framework_TestCase
class CoreAccessTokenTest extends TestCase
{
public function testGetToken()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Core/CoreHttpTest.php
Expand Up @@ -14,7 +14,7 @@
use GuzzleHttp\Client;
use GuzzleHttp\Psr7\Response;

class CoreHttpTest extends PHPUnit_Framework_TestCase
class CoreHttpTest extends TestCase
{
public function testConstruct()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Encryption/EncryptionEncryptorTest.php
Expand Up @@ -3,7 +3,7 @@
use EasyWeChat\Encryption\Encryptor;
use EasyWeChat\Support\XML;

class EncryptionEncryptorTest extends PHPUnit_Framework_TestCase
class EncryptionEncryptorTest extends TestCase
{
public function getEncryptor()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Foundation/ApplicationTest.php
Expand Up @@ -15,7 +15,7 @@
use Pimple\ServiceProviderInterface;
use Symfony\Component\HttpFoundation\Request;

class ApplicationTest extends PHPUnit_Framework_TestCase
class ApplicationTest extends TestCase
{
/**
* Test __construct().
Expand Down
2 changes: 1 addition & 1 deletion tests/Js/JsJsTest.php
Expand Up @@ -13,7 +13,7 @@
use EasyWeChat\Core\Http;
use EasyWeChat\Js\Js;

class JsJsTest extends PHPUnit_Framework_TestCase
class JsJsTest extends TestCase
{
public function getMockCache()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Material/MaterialMaterialTest.php
Expand Up @@ -14,7 +14,7 @@
use EasyWeChat\Message\Article;
use GuzzleHttp\Psr7\Response;

class MaterialMaterialTest extends PHPUnit_Framework_TestCase
class MaterialMaterialTest extends TestCase
{
/**
* Return mock http.
Expand Down
2 changes: 1 addition & 1 deletion tests/Material/MaterialTemporaryTest.php
Expand Up @@ -15,7 +15,7 @@
use EasyWeChat\Material\Temporary;
use Mockery\Mock;

class MaterialTemporaryTest extends PHPUnit_Framework_TestCase
class MaterialTemporaryTest extends TestCase
{
/**
* Return mock http.
Expand Down
2 changes: 1 addition & 1 deletion tests/Menu/MenuMenuTest.php
Expand Up @@ -11,7 +11,7 @@

use EasyWeChat\Menu\Menu;

class MenuMenuTest extends PHPUnit_Framework_TestCase
class MenuMenuTest extends TestCase
{
public function getMenu()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Message/MessageAbstractMessageTest.php
Expand Up @@ -16,7 +16,7 @@ class FooMessage extends AbstractMessage
protected $properties = ['foo', 'bar'];
}

class MessageAbstractMessageTest extends PHPUnit_Framework_TestCase
class MessageAbstractMessageTest extends TestCase
{
/**
* Test __get().
Expand Down
2 changes: 1 addition & 1 deletion tests/Message/MessageArticleTest.php
Expand Up @@ -11,7 +11,7 @@

use EasyWeChat\Message\Article;

class MessageArticleTest extends PHPUnit_Framework_TestCase
class MessageArticleTest extends TestCase
{
/**
* Test get attributes.
Expand Down
2 changes: 1 addition & 1 deletion tests/Message/MessageImageTest.php
Expand Up @@ -11,7 +11,7 @@

use EasyWeChat\Message\Image;

class MessageImageTest extends PHPUnit_Framework_TestCase
class MessageImageTest extends TestCase
{
/**
* Test media().
Expand Down
2 changes: 1 addition & 1 deletion tests/Message/MessageMaterialTest.php
Expand Up @@ -11,7 +11,7 @@

use EasyWeChat\Message\Material;

class MessageMaterialTest extends PHPUnit_Framework_TestCase
class MessageMaterialTest extends TestCase
{
/**
* Test get attributes.
Expand Down
2 changes: 1 addition & 1 deletion tests/Message/MessageVideoTest.php
Expand Up @@ -11,7 +11,7 @@

use EasyWeChat\Message\Video;

class MessageVideoTest extends PHPUnit_Framework_TestCase
class MessageVideoTest extends TestCase
{
/**
* Test media().
Expand Down
2 changes: 1 addition & 1 deletion tests/Message/MessageVoiceTest.php
Expand Up @@ -11,7 +11,7 @@

use EasyWeChat\Message\Voice;

class MessageVoiceTest extends PHPUnit_Framework_TestCase
class MessageVoiceTest extends TestCase
{
/**
* Test media().
Expand Down
2 changes: 1 addition & 1 deletion tests/Notice/NoticeNoticeTest.php
Expand Up @@ -12,7 +12,7 @@
use EasyWeChat\Core\Exceptions\InvalidArgumentException;
use EasyWeChat\Notice\Notice;

class NoticeNoticeTest extends PHPUnit_Framework_TestCase
class NoticeNoticeTest extends TestCase
{
public function getNotice($mockHttp = false)
{
Expand Down
2 changes: 1 addition & 1 deletion tests/POI/POIPOITest.php
Expand Up @@ -11,7 +11,7 @@

use EasyWeChat\POI\POI;

class POIPOITest extends PHPUnit_Framework_TestCase
class POIPOITest extends TestCase
{
public function getPOI()
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Payment/PaymentAPITest.php
Expand Up @@ -16,7 +16,7 @@
use EasyWeChat\Support\XML;
use Psr\Http\Message\ResponseInterface;

class PaymentAPITest extends PHPUnit_Framework_TestCase
class PaymentAPITest extends TestCase
{
/**
* Build API instance.
Expand Down
2 changes: 1 addition & 1 deletion tests/Payment/PaymentLuckyMoneyAPITest.php
Expand Up @@ -14,7 +14,7 @@
use EasyWeChat\Payment\Merchant;
use EasyWeChat\Support\XML;

class PaymentLuckyMoneyAPITest extends PHPUnit_Framework_TestCase
class PaymentLuckyMoneyAPITest extends TestCase
{
public static function setUpBeforeClass()
{
Expand Down

0 comments on commit fee6ef0

Please sign in to comment.