| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- <?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 allen05ren <allen05ren@outlook.com>
- * @copyright 2016 overtrue <i@overtrue.me>
- *
- * @see https://github.com/overtrue
- * @see http://overtrue.me
- */
- namespace EasyWeChat\ShakeAround;
- use EasyWeChat\Core\AbstractAPI;
- /**
- * Class Group.
- */
- class Group extends AbstractAPI
- {
- const API_ADD = 'https://api.weixin.qq.com/shakearound/device/group/add';
- const API_UPDATE = 'https://api.weixin.qq.com/shakearound/device/group/update';
- const API_DELETE = 'https://api.weixin.qq.com/shakearound/device/group/delete';
- const API_GET_LIST = 'https://api.weixin.qq.com/shakearound/device/group/getlist';
- const API_GET_DETAIL = 'https://api.weixin.qq.com/shakearound/device/group/getdetail';
- const API_ADD_DEVICE = 'https://api.weixin.qq.com/shakearound/device/group/adddevice';
- const API_DELETE_DEVICE = 'https://api.weixin.qq.com/shakearound/device/group/deletedevice';
- /**
- * Add device group.
- *
- * @param string $name
- *
- * @return \EasyWeChat\Support\Collection
- */
- public function add($name)
- {
- $params = [
- 'group_name' => $name,
- ];
- return $this->parseJSON('json', [self::API_ADD, $params]);
- }
- /**
- * Update a device group name.
- *
- * @param int $groupId
- * @param string $name
- *
- * @return \EasyWeChat\Support\Collection
- */
- public function update($groupId, $name)
- {
- $params = [
- 'group_id' => intval($groupId),
- 'group_name' => $name,
- ];
- return $this->parseJSON('json', [self::API_UPDATE, $params]);
- }
- /**
- * Delete device group.
- *
- * @param int $groupId
- *
- * @return \EasyWeChat\Support\Collection
- */
- public function delete($groupId)
- {
- $params = [
- 'group_id' => intval($groupId),
- ];
- return $this->parseJSON('json', [self::API_DELETE, $params]);
- }
- /**
- * List all device groups.
- *
- * @param int $begin
- * @param int $count
- *
- * @return \EasyWeChat\Support\Collection
- */
- public function lists($begin, $count)
- {
- $params = [
- 'begin' => intval($begin),
- 'count' => intval($count),
- ];
- return $this->parseJSON('json', [self::API_GET_LIST, $params]);
- }
- /**
- * Get details of a device group.
- *
- * @param int $groupId
- * @param int $begin
- * @param int $count
- *
- * @return \EasyWeChat\Support\Collection
- */
- public function getDetails($groupId, $begin, $count)
- {
- $params = [
- 'group_id' => intval($groupId),
- 'begin' => intval($begin),
- 'count' => intval($count),
- ];
- return $this->parseJSON('json', [self::API_GET_DETAIL, $params]);
- }
- /**
- * Add one or more devices to a device group.
- *
- * @param int $groupId
- * @param array $deviceIdentifiers
- *
- * @return \EasyWeChat\Support\Collection
- */
- public function addDevice($groupId, array $deviceIdentifiers)
- {
- $params = [
- 'group_id' => intval($groupId),
- 'device_identifiers' => $deviceIdentifiers,
- ];
- return $this->parseJSON('json', [self::API_ADD_DEVICE, $params]);
- }
- /**
- * Remove one or more devices from a device group.
- *
- * @param int $groupId
- * @param array $deviceIdentifiers
- *
- * @return \EasyWeChat\Support\Collection
- */
- public function removeDevice($groupId, array $deviceIdentifiers)
- {
- $params = [
- 'group_id' => intval($groupId),
- 'device_identifiers' => $deviceIdentifiers,
- ];
- return $this->parseJSON('json', [self::API_DELETE_DEVICE, $params]);
- }
- }
|