1<?php
2// ===================================================================================================
3//                           _  __     _ _
4//                          | |/ /__ _| | |_ _  _ _ _ __ _
5//                          | ' </ _` | |  _| || | '_/ _` |
6//                          |_|\_\__,_|_|\__|\_,_|_| \__,_|
7//
8// This file is part of the Kaltura Collaborative Media Suite which allows users
9// to do with audio, video, and animation what Wiki platfroms allow them to do with
10// text.
11//
12// Copyright (C) 2006-2017  Kaltura Inc.
13//
14// This program is free software: you can redistribute it and/or modify
15// it under the terms of the GNU Affero General Public License as
16// published by the Free Software Foundation, either version 3 of the
17// License, or (at your option) any later version.
18//
19// This program is distributed in the hope that it will be useful,
20// but WITHOUT ANY WARRANTY; without even the implied warranty of
21// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22// GNU Affero General Public License for more details.
23//
24// You should have received a copy of the GNU Affero General Public License
25// along with this program.  If not, see <http://www.gnu.org/licenses/>.
26//
27// @ignore
28// ===================================================================================================
29
30
31/**
32 * @namespace
33 */
34namespace Kaltura\Client\Plugin\Like\Service;
35
36/**
37 * Allows user to 'like' or 'unlike' and entry
38 * @package Kaltura
39 * @subpackage Client
40 */
41class LikeService extends \Kaltura\Client\ServiceBase
42{
43	function __construct(\Kaltura\Client\Client $client = null)
44	{
45		parent::__construct($client);
46	}
47
48	/**
49	 *
50	 * @return bool
51	 */
52	function checkLikeExists($entryId, $userId = null)
53	{
54		$kparams = array();
55		$this->client->addParam($kparams, "entryId", $entryId);
56		$this->client->addParam($kparams, "userId", $userId);
57		$this->client->queueServiceActionCall("like_like", "checkLikeExists", null, $kparams);
58		if ($this->client->isMultiRequest())
59			return $this->client->getMultiRequestResult();
60		$resultXml = $this->client->doQueue();
61		$resultXmlObject = new \SimpleXMLElement($resultXml);
62		$this->client->checkIfError($resultXmlObject->result);
63		$resultObject = (bool)\Kaltura\Client\ParseUtils::unmarshalSimpleType($resultXmlObject->result);
64		return $resultObject;
65	}
66
67	/**
68	 *
69	 * @return bool
70	 */
71	function like($entryId)
72	{
73		$kparams = array();
74		$this->client->addParam($kparams, "entryId", $entryId);
75		$this->client->queueServiceActionCall("like_like", "like", null, $kparams);
76		if ($this->client->isMultiRequest())
77			return $this->client->getMultiRequestResult();
78		$resultXml = $this->client->doQueue();
79		$resultXmlObject = new \SimpleXMLElement($resultXml);
80		$this->client->checkIfError($resultXmlObject->result);
81		$resultObject = (bool)\Kaltura\Client\ParseUtils::unmarshalSimpleType($resultXmlObject->result);
82		return $resultObject;
83	}
84
85	/**
86	 *
87	 * @return \Kaltura\Client\Plugin\Like\Type\LikeListResponse
88	 */
89	function listAction(\Kaltura\Client\Plugin\Like\Type\LikeFilter $filter = null, \Kaltura\Client\Type\FilterPager $pager = null)
90	{
91		$kparams = array();
92		if ($filter !== null)
93			$this->client->addParam($kparams, "filter", $filter->toParams());
94		if ($pager !== null)
95			$this->client->addParam($kparams, "pager", $pager->toParams());
96		$this->client->queueServiceActionCall("like_like", "list", "KalturaLikeListResponse", $kparams);
97		if ($this->client->isMultiRequest())
98			return $this->client->getMultiRequestResult();
99		$resultXml = $this->client->doQueue();
100		$resultXmlObject = new \SimpleXMLElement($resultXml);
101		$this->client->checkIfError($resultXmlObject->result);
102		$resultObject = \Kaltura\Client\ParseUtils::unmarshalObject($resultXmlObject->result, "KalturaLikeListResponse");
103		$this->client->validateObjectType($resultObject, "\\Kaltura\\Client\\Plugin\\Like\\Type\\LikeListResponse");
104		return $resultObject;
105	}
106
107	/**
108	 *
109	 * @return bool
110	 */
111	function unlike($entryId)
112	{
113		$kparams = array();
114		$this->client->addParam($kparams, "entryId", $entryId);
115		$this->client->queueServiceActionCall("like_like", "unlike", null, $kparams);
116		if ($this->client->isMultiRequest())
117			return $this->client->getMultiRequestResult();
118		$resultXml = $this->client->doQueue();
119		$resultXmlObject = new \SimpleXMLElement($resultXml);
120		$this->client->checkIfError($resultXmlObject->result);
121		$resultObject = (bool)\Kaltura\Client\ParseUtils::unmarshalSimpleType($resultXmlObject->result);
122		return $resultObject;
123	}
124}
125