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\Service;
35
36/**
37 * @package Kaltura
38 * @subpackage Client
39 */
40class UserEntryService extends \Kaltura\Client\ServiceBase
41{
42	function __construct(\Kaltura\Client\Client $client = null)
43	{
44		parent::__construct($client);
45	}
46
47	/**
48	 * Adds a user_entry to the Kaltura DB.
49	 *
50	 * @return \Kaltura\Client\Type\UserEntry
51	 */
52	function add(\Kaltura\Client\Type\UserEntry $userEntry)
53	{
54		$kparams = array();
55		$this->client->addParam($kparams, "userEntry", $userEntry->toParams());
56		$this->client->queueServiceActionCall("userentry", "add", "KalturaUserEntry", $kparams);
57		if ($this->client->isMultiRequest())
58			return $this->client->getMultiRequestResult();
59		$resultXml = $this->client->doQueue();
60		$resultXmlObject = new \SimpleXMLElement($resultXml);
61		$this->client->checkIfError($resultXmlObject->result);
62		$resultObject = \Kaltura\Client\ParseUtils::unmarshalObject($resultXmlObject->result, "KalturaUserEntry");
63		$this->client->validateObjectType($resultObject, "\\Kaltura\\Client\\Type\\UserEntry");
64		return $resultObject;
65	}
66
67	/**
68	 *
69	 * @return int
70	 */
71	function bulkDelete(\Kaltura\Client\Type\UserEntryFilter $filter)
72	{
73		$kparams = array();
74		$this->client->addParam($kparams, "filter", $filter->toParams());
75		$this->client->queueServiceActionCall("userentry", "bulkDelete", 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 = (int)\Kaltura\Client\ParseUtils::unmarshalSimpleType($resultXmlObject->result);
82		return $resultObject;
83	}
84
85	/**
86	 *
87	 * @return \Kaltura\Client\Type\UserEntry
88	 */
89	function delete($id)
90	{
91		$kparams = array();
92		$this->client->addParam($kparams, "id", $id);
93		$this->client->queueServiceActionCall("userentry", "delete", "KalturaUserEntry", $kparams);
94		if ($this->client->isMultiRequest())
95			return $this->client->getMultiRequestResult();
96		$resultXml = $this->client->doQueue();
97		$resultXmlObject = new \SimpleXMLElement($resultXml);
98		$this->client->checkIfError($resultXmlObject->result);
99		$resultObject = \Kaltura\Client\ParseUtils::unmarshalObject($resultXmlObject->result, "KalturaUserEntry");
100		$this->client->validateObjectType($resultObject, "\\Kaltura\\Client\\Type\\UserEntry");
101		return $resultObject;
102	}
103
104	/**
105	 *
106	 * @return \Kaltura\Client\Type\UserEntry
107	 */
108	function get($id)
109	{
110		$kparams = array();
111		$this->client->addParam($kparams, "id", $id);
112		$this->client->queueServiceActionCall("userentry", "get", "KalturaUserEntry", $kparams);
113		if ($this->client->isMultiRequest())
114			return $this->client->getMultiRequestResult();
115		$resultXml = $this->client->doQueue();
116		$resultXmlObject = new \SimpleXMLElement($resultXml);
117		$this->client->checkIfError($resultXmlObject->result);
118		$resultObject = \Kaltura\Client\ParseUtils::unmarshalObject($resultXmlObject->result, "KalturaUserEntry");
119		$this->client->validateObjectType($resultObject, "\\Kaltura\\Client\\Type\\UserEntry");
120		return $resultObject;
121	}
122
123	/**
124	 *
125	 * @return \Kaltura\Client\Type\UserEntryListResponse
126	 */
127	function listAction(\Kaltura\Client\Type\UserEntryFilter $filter, \Kaltura\Client\Type\FilterPager $pager = null)
128	{
129		$kparams = array();
130		$this->client->addParam($kparams, "filter", $filter->toParams());
131		if ($pager !== null)
132			$this->client->addParam($kparams, "pager", $pager->toParams());
133		$this->client->queueServiceActionCall("userentry", "list", "KalturaUserEntryListResponse", $kparams);
134		if ($this->client->isMultiRequest())
135			return $this->client->getMultiRequestResult();
136		$resultXml = $this->client->doQueue();
137		$resultXmlObject = new \SimpleXMLElement($resultXml);
138		$this->client->checkIfError($resultXmlObject->result);
139		$resultObject = \Kaltura\Client\ParseUtils::unmarshalObject($resultXmlObject->result, "KalturaUserEntryListResponse");
140		$this->client->validateObjectType($resultObject, "\\Kaltura\\Client\\Type\\UserEntryListResponse");
141		return $resultObject;
142	}
143
144	/**
145	 * Submits the quiz so that it's status will be submitted and calculates the score for the quiz
146	 *
147	 * @return \Kaltura\Client\Type\QuizUserEntry
148	 */
149	function submitQuiz($id)
150	{
151		$kparams = array();
152		$this->client->addParam($kparams, "id", $id);
153		$this->client->queueServiceActionCall("userentry", "submitQuiz", "KalturaQuizUserEntry", $kparams);
154		if ($this->client->isMultiRequest())
155			return $this->client->getMultiRequestResult();
156		$resultXml = $this->client->doQueue();
157		$resultXmlObject = new \SimpleXMLElement($resultXml);
158		$this->client->checkIfError($resultXmlObject->result);
159		$resultObject = \Kaltura\Client\ParseUtils::unmarshalObject($resultXmlObject->result, "KalturaQuizUserEntry");
160		$this->client->validateObjectType($resultObject, "\\Kaltura\\Client\\Type\\QuizUserEntry");
161		return $resultObject;
162	}
163
164	/**
165	 *
166	 */
167	function update($id, \Kaltura\Client\Type\UserEntry $userEntry)
168	{
169		$kparams = array();
170		$this->client->addParam($kparams, "id", $id);
171		$this->client->addParam($kparams, "userEntry", $userEntry->toParams());
172		$this->client->queueServiceActionCall("userentry", "update", null, $kparams);
173		if ($this->client->isMultiRequest())
174			return $this->client->getMultiRequestResult();
175		$resultXml = $this->client->doQueue();
176		$resultXmlObject = new \SimpleXMLElement($resultXml);
177		$this->client->checkIfError($resultXmlObject->result);
178	}
179}
180