From 4dfda2140181516a5186a8bd135c31aa107dac63 Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Sat, 8 Aug 2015 12:22:35 +0300 Subject: [PATCH] getUserSubscriptions methods in UserApi. --- .../PointToolsBundle/Service/UserApi.php | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/Skobkin/Bundle/PointToolsBundle/Service/UserApi.php b/src/Skobkin/Bundle/PointToolsBundle/Service/UserApi.php index 5de211f..4fca586 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/Service/UserApi.php +++ b/src/Skobkin/Bundle/PointToolsBundle/Service/UserApi.php @@ -78,6 +78,40 @@ class UserApi extends AbstractApi return $users; } + /** + * Get user subscriptions by user login + * + * @param string $login + * @return User[] + */ + public function getUserSubscriptionsByLogin($login) + { + $usersList = $this->getGetRequestData('/api/user/' . $login . '/subscriptions', [], true); + + $users = $this->getUsersFromList($usersList); + + return $users; + } + + /** + * Get user subscriptions by user id + * + * @param int $id + * @return User[] + */ + public function getUserSubscriptionsById($id) + { + if (!is_numeric($id)) { + throw new \InvalidArgumentException('$id must be an integer'); + } + + $usersList = $this->getGetRequestData('/api/user/id/' . (int) $id . '/subscriptions', [], true); + + $users = $this->getUsersFromList($usersList); + + return $users; + } + /** * @return User[] */