<?php
namespace App\Services;
use App\Security\User;
use DateTime;
use stdClass;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\Mime\Part\DataPart;
use Symfony\Component\Mime\Part\Multipart\FormDataPart;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\String\Slugger\SluggerInterface;
use Symfony\Contracts\HttpClient\Exception\ClientExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\RedirectionExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\ServerExceptionInterface;
use Symfony\Contracts\HttpClient\Exception\TransportExceptionInterface;
use Symfony\Contracts\HttpClient\HttpClientInterface;
class UlteamApiService
{
const MERGE_CONTENT_TYPE = 'application/merge-patch+json';
/**
* @var HttpClientInterface
*/
private $client;
/**
* @var array
*/
private $headers = [];
/**
* @var SessionInterface
*/
private $session;
/**
* @var Security
*/
private $security;
/**
* @var RouterInterface
*/
private $router;
/**
* @var SluggerInterface
*/
private $slugger;
/**
* UserProvider constructor.
* @param HttpClientInterface $client
* @param Security $security
* @param SessionInterface $session
* @param RouterInterface $router
*/
public function __construct(HttpClientInterface $client, Security $security, SessionInterface $session, RouterInterface $router, SluggerInterface $slugger)
{
$this->client = $client;
$this->session = $session;
$this->security = $security;
$this->router = $router;
$this->slugger = $slugger;
}
private function sessionNameConverter($name, $direction = 'normalize')
{
if ($direction == 'normalize') {
$name = str_replace('/', '_', $name);
} elseif ($direction == 'denormalize') {
$name = str_replace('_', '/', $name);
}
return $name;
}
/**
* @param array $body
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function login(array $body, $type = 'admin')
{
// $entrypoint = 'api/login_check';
$entrypoint = '/api/admin/login_check';
if($type == 'entreprise'){
$entrypoint = '/api/company/login_check';
}
return $this->callUrl($entrypoint, 'POST', [], json_encode($body));
}
/**
* Calls an entrypoint to be stored in session
* @param $entrypoint
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
private function sessionStorageCall($entrypoint)
{
$sessionName = $this->sessionNameConverter($entrypoint);
if ($this->session->has($sessionName)) {
$result = $this->session->get($sessionName);
} else {
$result = $this->callUrl($entrypoint);
$this->session->set($sessionName, $result);
}
return $result;
}
/**
* Gets the subject for the given messages
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getMessageSubjects()
{
$entrypoint = 'api/messages/subjects';
$result = $this->sessionStorageCall($entrypoint);
foreach ($result as $key => $item) {
$result[$item] = $item;
unset($result[$key]);
}
return $result;
}
/**
* @param array $query
* 2021-01-24 15:17:43.489344
* @return array
*/
public function convertQueryDates(array $query): array
{
foreach ($query as $key=>$item) {
if ($item instanceof DateTime){
$query[$key] = $item->format('Y-m-d H:i:s');
}
}
return $query;
}
/**
* Function to call an url and recover the decoded content
* @param $entrypoint
* @param string $method
* @param array $headers
* @param array $body
* @param array $query
* @param bool $json
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
private function callUrl($entrypoint, $method = 'GET', $headers = [], $body = [], $query = [], $json = true)
{
$_headers = array_merge($this->headers, $headers);
$_url = $entrypoint;
$query = $this->convertQueryDates($query);
$params = [
'headers' => $_headers,
'body' => $body,
'query' => $query,
];
$user = $this->security->getUser();
if ($user instanceof User) {
$params['auth_bearer'] = $user->getToken();
}
$response = $this->client->request($method, $_url, $params);
if ($json) {
return json_decode($response->getContent());
}
return $response->getContent();
}
/**
* @param string $entrypoint
* @param array $query
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
private function callGetUrl(string $entrypoint, array $query = [])
{
return $this->callUrl($entrypoint, 'GET', [], [], $query);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getCompanies(array $filters = [], ?array $extra = [])
{
$entrypoint = '/api/companies';
$filters = array_merge($filters, $extra);
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getFirstSurvey(array $filters = [])
{
$entrypoint = '/api/surveys_homepage';
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getFirstSurveyTags(int $id, array $filters = [])
{
$entrypoint = "/api/surveys/{$id}/tv_tags";
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getHpSurveys(array $filters = [])
{
$entrypoint = '/api/surveys?active=1&type=homepage_survey';
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getQuestions(array $filters = [], array $extra = [])
{
$filters = array_merge($filters, $extra);
$entrypoint = '/api/questions';
// $entrypoint = strtr($entrypoint, ['{id}' => $filters['id']]);
// unset($filters['id']);
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param string $id
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getQuestion(int $id, array $filters = [])
{
$entrypoint = "/api/questions/$id";
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param int $id
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getTags(array $filters = [], array $extra = [])
{
$filters = array_merge($filters, $extra);
$entrypoint = "/api/tv_tags";
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param int $id
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getProgramTags(array $filters = [], array $extra = [], int $id)
{
$filters = array_merge($filters, $extra);
$entrypoint = "/api/programs/". $id ."/program_tags";
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function postProgramTag(array $data)
{
$entrypoint = '/api/program-tag/submit';
$data = json_encode($data);
return $this->callUrl($entrypoint, 'POST', [], $data);
}
/**
* @param string $id
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getTag(int $id, array $filters = [])
{
$entrypoint = "/api/tv_tags/$id";
return $this->callUrl($entrypoint, "GET", [], [], $filters);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function deleteTag(int $id)
{
$entrypoint = '/api/tv_tags/' . $id;
return $this->callUrl($entrypoint, 'DELETE');
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function postSurvey(array $data)
{
$entrypoint = '/api/surveys';
$data = json_encode($data);
return $this->callUrl($entrypoint, 'POST', [], $data);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function postTag(array $data)
{
$entrypoint = '/api/tv_tags';
$data = json_encode($data);
return $this->callUrl($entrypoint, 'POST', [], $data);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function updateTag(int $id, $data)
{
$entrypoint = '/api/tv_tags/'. $id;
$_data = $data;
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => self::MERGE_CONTENT_TYPE
], $data);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function activateTag(int $id, $data)
{
$entrypoint = '/api/tv_tags/'. $id;
$data = json_encode($data, JSON_UNESCAPED_UNICODE);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => self::MERGE_CONTENT_TYPE
], $data);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function postQuestion(array $data)
{
$entrypoint = '/api/questions';
$data = json_encode($data);
return $this->callUrl($entrypoint, 'POST', [], $data);
}
/**
* @param mixed $company infos on the company to be modified
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function updateQuestion(int $id, $data)
{
$entrypoint = '/api/questions/'. $id;
$_data = $data;
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => self::MERGE_CONTENT_TYPE
], $data);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function activateQuestion(int $id, $data)
{
$entrypoint = '/api/questions/'. $id;
$data = json_encode($data, JSON_UNESCAPED_UNICODE);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => self::MERGE_CONTENT_TYPE
], $data);
}
/**
* @param int $id
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getProgramSurveys(array $filters = [], array $extra = [])
{
$filters = array_merge($filters, $extra);
$entrypoint = "/api/surveys_program";
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param string $id
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getProgramSurvey(int $id, array $filters = [])
{
$entrypoint = "/api/surveys/". $id;
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param int $id
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getSurveyQuestions(array $filters = [], array $extra = [])
{
// $filters = array_merge($filters, $extra);
$entrypoint = "/api/surveys/". $extra['id'] ."/questions";
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function postAnswer(array $data)
{
$entrypoint = '/api/answers';
$data = json_encode($data);
return $this->callUrl($entrypoint, 'POST', [], $data);
}
/**
* @param string $id
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getAnswer(int $id, array $filters = [])
{
$entrypoint = "/api/answers/$id";
return $this->callUrl($entrypoint,'GET', [], [], $filters);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function updateAnswer(int $id, $data)
{
$entrypoint = '/api/answers/'. $id;
$_data = $data;
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => self::MERGE_CONTENT_TYPE
], $data);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getAnswers(array $filters = [], array $extra = [])
{
$filters = array_merge($filters, $extra);
$entrypoint = "/api/answers";
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param int $id
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getQuestionAnswers(array $filters = [], array $extra = [])
{
// $filters = array_merge($filters, $extra);
$entrypoint = "/api/answers?question.id=". $extra['id'] . "";
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function activateProgramSurvey(int $id, $data)
{
$entrypoint = '/api/surveys/'. $id;
$data = json_encode($data, JSON_UNESCAPED_UNICODE);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => self::MERGE_CONTENT_TYPE
], $data);
}
/**
* @param array $filters
* @param array $extra
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getUsers(array $filters = [], array $extra = [])
{
$entrypoint = '/api/users';
$filters = array_merge($filters, $extra);
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $filters
* @param array $extra
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getClients(array $filters = [], array $extra = [])
{
$entrypoint = '/api/clients';
$filters = array_merge($filters, $extra);
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* This posts a group of new users linked to a company
* @param array $data
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function postUsersBulk(array $data)
{
$entrypoint = '/api/users/create';
$data = json_encode($data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\', '', $data);
return $this->callUrl($entrypoint, 'POST', [
'Content-Type' => 'application/ld+json'
], $data, [], false);
}
/**
* @param string $id
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getUser(string $id)
{
$entrypoint = "/api/users/$id";
return $this->callUrl($entrypoint);
}
/**
* @param stdClass $user
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function updateUser(stdClass $user)
{
$entrypoint = "/api/users/{$user->id}";
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => self::MERGE_CONTENT_TYPE
], json_encode($user));
}
/**
* @param string $userId
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function activateUser(string $userId)
{
$entrypoint = "api/users/$userId/active";
return $this->callUrl($entrypoint);
}
/**
* @param array $filters
* @param bool $session
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getCategories(array $filters = [], bool $session = false)
{
$entrypoint = '/api/categories';
if ($session){
return $this->sessionStorageCall($entrypoint);
}
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $filters
* @param bool $session
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getCategoriesBis(array $filters = [], array $extra =[])
{
$entrypoint = '/api/categories';
$filters = array_merge($filters, $extra);
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param mixed $video
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getChannelsFromCategory(array $filters = [], array $extra = [])
{
$filters = array_merge($filters, $extra);
$entrypoint = '/api/categories/{id}/channels';
$entrypoint = strtr($entrypoint, ['{id}' => $filters['id']]);
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $filters
* @param array $extra
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getVideosManager(array $filters = [], array $extra = [])
{
$company = $extra['company'];
unset($extra['company']);
$videos = $this->getVideos($filters, $extra);
return $videos;
}
/**
* @param array $filters
* @param array $extra
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getChannelsManager(array $filters = [], array $extra = [])
{
return $this->getChannelsBis($filters, $extra);
}
/**
* @param array $filters
* @param array $extra
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getCategoriesManager(array $filters = [], array $extra = [])
{
// $categories = $this->getCategoriesBis($filters, $extra);
// return $categories;
$entrypoint = '/api/manager/categories';
$filters = array_merge($filters, $extra);
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param string $class
* @param string $object
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function exclusionToggleManager(string $class, string $object)
{
$entrypoint = "/api/exclusionsManager/$class/toggle/$object";
return $this->callUrl($entrypoint);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getVideos(array $filters = [], array $extra =[])
{
$entrypoint = '/api/videos';
$filters = array_merge($filters, $extra);
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getDailyAdvices(array $filters = [])
{
$entrypoint = '/api/daily_advices';
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param int $id
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getAdvice(int $id)
{
$entrypoint = "/api/daily_advices/" . $id;
return $this->callUrl($entrypoint);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function deleteAdvice(int $id)
{
$entrypoint = '/api/daily_advices/' . $id;
return $this->callUrl($entrypoint, 'DELETE');
}
/**
* @param int $id
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function activateAdvice($id)
{
$entrypoint = '/api/daily_advices/{id}';
$entrypoint = strtr($entrypoint, ['{id}' => $id]);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => 'application/merge-patch+json'
], json_encode(['active' => true]));
}
/**
* @param int $id
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function deactivateAdvice($id)
{
$entrypoint = '/api/daily_advices/{id}';
$entrypoint = strtr($entrypoint, ['{id}' => $id]);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => 'application/merge-patch+json'
], json_encode(['active' => false]));
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function postAdvice(array $data)
{
$entrypoint = '/api/daily_advices';
$data = json_encode($data);
return $this->callUrl($entrypoint, 'POST', [], $data);
}
/**
* @param array $dataExpert
* @param array $video
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function updateAdvice(int $id, array $data)
{
$entrypoint = "/api/daily_advices/" . $id;
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => self::MERGE_CONTENT_TYPE
], json_encode($data));
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function postDepartment(string $name, string $iri)
{
$entrypoint = '/api/segmentations';
$data['name'] = $name;
$data['company'] = $iri;
$data = json_encode($data, JSON_UNESCAPED_UNICODE);
return $this->callUrl($entrypoint, 'POST', [], $data);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function deleteDepartment(int $id)
{
$entrypoint = '/api/segmentations/' . $id;
return $this->callUrl($entrypoint, 'DELETE');
}
/**
* @param int $id
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getVideo(int $id, array $filters = [])
{
$entrypoint = '/api/videos/' . $id;
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $data
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function updateVideoInformation(int $id, array $data, ?UploadedFile $preview, ?UploadedFile $picture, ?UploadedFile $pdf, ?array $filters = [])
{
$entrypoint = "/api/videos/" . $id;
$_data = $data;
if ($preview != null) {
$_data['preview'] = $this->postMediaObject($preview)->{'@id'};
}else {
unset($_data['preview']);
}
if ($picture != null) {
$_data['picture'] = $this->postMediaObject($picture)->{'@id'};
}else {
unset($_data['picture']);
}
if ($pdf != null) {
$_data['tip'] = $this->postMediaObject($pdf)->{'@id'};
}else {
unset($_data['tip']);
}
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
return $this->callUrl($entrypoint, 'PATCH', ['Content-Type' => self::MERGE_CONTENT_TYPE], $data, $filters);
}
/**
* This updates the PDF(tip) on an existing video, at least the id of the video
* is required in order for this to work
*
* @param $video
* @param UploadedFile|null $pdf pdf file to be modified if any
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function updateVideoTip($id, ?UploadedFile $pdf = null)
{
$entrypoint = '/api/videos/' . $id;
$data = [];
if ($pdf != null) {
$idPdf = $this->postMediaObject($pdf)->{'id'};
$data = '{"tip": "/api/media_objects/'.$idPdf.'"}' ;
}
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => 'application/merge-patch+json'
], $data);
}
/**
* This deletes the PDF(tip) on an existing video, at least the id of the video
* is required in order for this to work
*
* @param $video
* @param UploadedFile|null $pdf pdf file to be modified if any
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function deleteVideoTip($id, $data)
{
$entrypoint = '/api/videos/' . $id;
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => self::MERGE_CONTENT_TYPE
],json_encode($data));
}
/**
* This updates the image on an existing video, at least the id of the video
* is required in order for this to work
*
* @param $video
* @param UploadedFile|null $image image file to be modified if any
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function updateVideoPreview($id, ?UploadedFile $image = null)
{
$entrypoint = '/api/videos/' . $id;
$data = [];
if ($image != null) {
$idImage = $this->postMediaObject($image)->{'id'};
$data = '{"preview": "/api/media_objects/'.$idImage.'"}' ;
}
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => 'application/merge-patch+json'
], $data);
}
/**
* This updates the image on an existing video, at least the id of the video
* is required in order for this to work
*
* @param $video
* @param UploadedFile|null $image image file to be modified if any
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function updateVideoPicture($id, ?UploadedFile $image = null)
{
$entrypoint = '/api/videos/' . $id;
$data = [];
if ($image != null) {
$idImage = $this->postMediaObject($image)->{'id'};
$data = '{"picture": "/api/media_objects/'.$idImage.'"}' ;
}
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => 'application/merge-patch+json'
], $data);
}
/**
* @param array $dataExpert
* @param array $video
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function updateVideoExpert(int $id, array $data)
{
$entrypoint = "/api/videos/" . $id;
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => self::MERGE_CONTENT_TYPE
], json_encode($data));
}
/**
* @param array $data
* @param array $video
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function updateVideoChannel(int $id, array $data)
{
$entrypoint = "/api/videos/" . $id;
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => self::MERGE_CONTENT_TYPE
], json_encode($data));
}
/**
* @param array $filters
* @param array $extra
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getPrograms(array $filters = [], array $extra = [])
{
$filters = array_merge($filters, $extra);
$entrypoint = '/api/programs';
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* This posts a new Program
* @param array $data
* @param UploadedFile|null $image image file to be posted
* @param UploadedFile|null $pdf pdf file to be posted
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function postProgram($data ,?UploadedFile $image = null, ?UploadedFile $picture = null, ?UploadedFile $pdf = null)
{
$entrypoint = '/api/programs';
$_data = $data;
if ($image != null) {
$_data['illustration'] = $this->postMediaObject($image)->{'@id'};
}
if ($picture != null) {
$_data['picture'] = $this->postMediaObject($picture)->{'@id'};
}
if ($pdf != null) {
$_data['tip'] = $this->postMediaObject($pdf)->{'@id'};
}
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/','/', $data);
return $this->callUrl($entrypoint, 'POST', [
'Content-Type' => 'application/ld+json'
], $data);
}
/**
* This edits a Program
* @param array $data
* @param UploadedFile|null $image image file to be posted
* @param UploadedFile|null $pdf pdf file to be posted
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function editProgram( int $id, $data ,?UploadedFile $image = null, ?UploadedFile $picture = null, ?UploadedFile $pdf = null)
{
$entrypoint = '/api/programs/'. $id ;
$_data = $data;
if ($image != null) {
$_data['illustration'] = $this->postMediaObject($image)->{'@id'};
}
if ($picture != null) {
$_data['picture'] = $this->postMediaObject($picture)->{'@id'};
}
if ($pdf != null) {
$_data['tip'] = $this->postMediaObject($pdf)->{'@id'};
}
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => self::MERGE_CONTENT_TYPE
], $data);
}
/**
* @param array $data
* @param array $video
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function updateProgramVideo(int $id, array $data)
{
$entrypoint = '/api/days/'. $id;
$data = json_encode($data);
$data = str_replace('\\/', '/', $data);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => self::MERGE_CONTENT_TYPE
], $data);
}
/**
* @param array $data
* @param array $video
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function updateProgramDayContent(int $id, array $data)
{
$entrypoint = '/api/days/'. $id;
$data = json_encode($data);
$data = str_replace('\\/', '/', $data);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => self::MERGE_CONTENT_TYPE
], $data);
}
/**
* @param array $data
* @param array $video
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function deleteProgramVideo(int $id, array $data)
{
$entrypoint = '/api/days/'. $id;
$data = json_encode($data);
$data = str_replace('\\/', '/', $data);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => self::MERGE_CONTENT_TYPE
], $data);
}
/**
* This updates the image on an existing video, at least the id of the video
* is required in order for this to work
*
* @param $video
* @param UploadedFile|null $image image file to be modified if any
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function postProgramPicture(?UploadedFile $image = null)
{
$entrypoint = '/api/programs';
$data = [];
if ($image != null) {
$idImage = $this->postMediaObject($image)->{'id'};
$data = '{"picture": "/api/media_objects/'.$idImage.'"}' ;
}
return $this->callUrl($entrypoint, 'POST', [
'Content-Type' => 'application/ld+json'
], $data);
}
/**
* This updates the image on an existing video, at least the id of the video
* is required in order for this to work
*
* @param $video
* @param UploadedFile|null $image image file to be modified if any
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function postProgramPdf(?UploadedFile $pdf = null)
{
$entrypoint = '/api/programs';
$data = [];
if ($pdf != null) {
$idpdf = $this->postMediaObject($pdf)->{'id'};
$data = '{"picture": "/api/media_objects/'.$idpdf.'"}' ;
}
return $this->callUrl($entrypoint, 'POST', [
'Content-Type' => 'application/ld+json'
], $data);
}
/**
* @param string $programsId
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function activateProgram(int $id)
{
$entrypoint = "/api/programs/". $id ."/activate";
return $this->callUrl($entrypoint);
}
/**
* @param string $programsId
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function deactivateProgram(int $id)
{
$entrypoint = "/api/programs/". $id ."/deactivate";
return $this->callUrl($entrypoint);
}
/**
* @param int $id
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getProgram(int $id, array $filters = [])
{
$entrypoint = '/api/programs/' . $id;
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function deleteProgram(int $id)
{
$entrypoint = '/api/programs/' . $id;
return $this->callUrl($entrypoint, 'DELETE');
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function cloneProgram(int $id, array $filters = [])
{
$entrypoint = '/api/programs/' . $id . '/clone';
return $this->callUrl($entrypoint, 'POST', [], ['' => ''], $filters);
}
/**
* @param int $id
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getProgramDay(int $id, array $filters = [])
{
$entrypoint = '/api/programs/' . $id . '/days';
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getDays(array $filters = [])
{
$entrypoint = '/api/days';
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $filters
* @param array $extra
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getDayVideos( array $filters = [], array $extra = [])
{
$entrypoint = '/api/days/'. $extra['id'] .'/playlist/videos';
unset($extra['id']);
$filters = array_merge($filters, $extra);
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param int $id
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getDay(int $id, array $filters = [])
{
$entrypoint = '/api/days/'.$id;
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getMessages(array $filters = [])
{
$entrypoint = '/api/messages';
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param int $id
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getCompany(int $id, array $filters = [])
{
$entrypoint = '/api/companies/{id}';
$entrypoint = strtr($entrypoint, [
'{id}' => $id
]);
return $this->callGetUrl($entrypoint, $filters);
}
/**
* @param int $companyId
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getCompanyDepartments(int $companyId, array $filters = [])
{
$entrypoint = "/api/companies/{$companyId}/departments";
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param int $id
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getCompanySlides(array $filters = [], array $extra = [])
{
$filters = array_merge($filters, $extra);
$entrypoint = '/api/companies/{id}/slides';
$entrypoint = strtr($entrypoint, [
'{id}' => $filters['id']
]);
return $this->callUrl($entrypoint);
}
/**
* @param int $id
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getCompanySlide(int $id, array $filters = [])
{
$entrypoint = '/api/slides/{id}';
$entrypoint = strtr($entrypoint, [
'{id}' => $id
]);
return $this->callUrl($entrypoint);
}
/**
* @param int $id
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getCompanyUsers( array $filters = [], int $id)
{
$entrypoint = '/api/companies/'. $id .'/users';
$entrypoint = '/api/companies/'. $id .'/clients';
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* This posts a new Program
* @param array $data
* @param UploadedFile|null $image image file to be posted
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function postCompany($data ,?UploadedFile $image = null)
{
$entrypoint = '/api/companies';
$_data = $data;
if ($image != null) {
$_data['logo'] = $this->postMediaObject($image)->{'@id'};
}
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
return $this->callUrl($entrypoint, 'POST', [
'Content-Type' => 'application/ld+json'
], $data);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function deleteCompany(int $id)
{
$entrypoint = '/api/companies/' . $id;
return $this->callUrl($entrypoint, 'DELETE');
}
/**
* @param int $id
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getCategory(int $id, array $filters = [])
{
$entrypoint = '/api/categories/{id}';
$entrypoint = strtr($entrypoint, [
'{id}' => $id
]);
return $this->callUrl($entrypoint);
}
/**
* Uploads a media object to the api this function
* is not meant to be called without any other
* orphan media objects will be removed from the API
*
* @param $file
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
protected function postMediaObject(UploadedFile $file)
{
$entrypoint = '/api/media_objects';
$dataFile = new DataPart($file->getContent(), $this->slugger->slug($file->getClientOriginalName(), '.') , $file->getMimeType());
$formFields = [
'file' => $dataFile,
];
$formData = new FormDataPart($formFields);
return $this->callUrl($entrypoint, 'POST', $formData->getPreparedHeaders()->toArray(), $formData->bodyToString(), ['fields' => ["id"]]);
}
/**
* This updates the infos on an existing company, at leas the id of the company
* is required in order for this to work
*
* @param mixed $company infos on the company to be modified
* @param UploadedFile|null $logo logo file to be modified if any
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function UpdateCompany(int $id, array $data, UploadedFile $logo = null, UploadedFile $cmsImage = null, array $filters = [])
{
$entrypoint = '/api/companies/'. $id;
$_data = $data;
if ($logo != null) {
$_data['logo'] = $this->postMediaObject($logo)->{'@id'};
}elseif ($cmsImage != null){
$_data['cmsImg'] = $this->postMediaObject($cmsImage)->{'@id'};
}elseif (!empty($_data['removeImage']) && $_data['removeImage'] == "true") {
$_data['cmsImg'] = null;
} else {
unset($_data['logo']);
unset($_data['cmsImg']);
}
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => self::MERGE_CONTENT_TYPE
], $data, $filters);
}
/**
* This deletes the image on a company page without having to send a form.
*
* @param mixed $company infos on the company to be modified
* @param UploadedFile|null $logo logo file to be modified if any
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function DeleteCmsImage(int $id, array $data)
{
$entrypoint = '/api/companies/'. $id;
$_data = $data;
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => self::MERGE_CONTENT_TYPE
], $data);
}
/**
* This updates the subscription infos on an existing company, at leas the id of the company
* is required in order for this to work
*
* @param mixed $company infos on the company to be modified
* @param UploadedFile|null $logo logo file to be modified if any
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function updateCompanySubscription(int $id, array $data)
{
$entrypoint = '/api/companies/'. $id;
$_data = $data;
$data = json_encode($_data);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => self::MERGE_CONTENT_TYPE
], $data);
}
/**
* This updates the restriction infos on an existing company, at least the id of the company
* is required in order for this to work
*
* @param mixed $company infos on the company to be modified
* @param UploadedFile|null $logo logo file to be modified if any
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function updateCompanyRestriction(int $id, array $data)
{
$entrypoint = '/api/companies/'. $id;
$_data = $data;
$data = json_encode($_data);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => self::MERGE_CONTENT_TYPE
], $data);
}
/**
* This updates the image on an existing company, at least the id of the company
* is required in order for this to work
*
* @param $video
* @param UploadedFile|null $image image file to be modified if any
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function updateCompanyLogo($id, ?UploadedFile $image = null)
{
$entrypoint = '/api/videos/' . $id;
$data = [];
if ($image != null) {
$idImage = $this->postMediaObject($image)->{'id'};
$data = '{"logo": "/api/media_objects/'.$idImage.'"}' ;
}
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => 'application/merge-patch+json'
], $data);
}
/**
* @param mixed $category
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function activateCategory($id)
{
$entrypoint = '/api/categories/{id}';
$entrypoint = strtr($entrypoint, ['{id}' => $id]);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => 'application/merge-patch+json'
], json_encode(['active' => true]));
}
/**
* @param mixed $category
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function deactivateCategory($id)
{
$entrypoint = '/api/categories/{id}';
$entrypoint = strtr($entrypoint, ['{id}' => $id]);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => 'application/merge-patch+json'
], json_encode(['active' => false]));
}
/**
* @param mixed $channel
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function activateChaine($id)
{
$entrypoint = '/api/channels/{id}';
$entrypoint = strtr($entrypoint, ['{id}' => $id]);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => 'application/merge-patch+json'
], json_encode(['active' => true]));
}
/**
* @param mixed $channel
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function deactivateChaine($id)
{
$entrypoint = '/api/channels/{id}';
$entrypoint = strtr($entrypoint, ['{id}' => $id]);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => 'application/merge-patch+json'
], json_encode(['active' => false]));
}
/**
* @param mixed $video
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getVideosFromChannel(array $filters = [], array $extra = [])
{
$filters = array_merge($filters, $extra);
$entrypoint = '/api/channels/{id}/playlist/videos';
$entrypoint = strtr($entrypoint, ['{id}' => $filters['id']]);
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param mixed $video
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getVideosFromChannelPlaylist(array $filters = [], array $extra = [])
{
$filters = array_merge($filters, $extra);
$entrypoint = '/api/playlists/{id}/videos';
$entrypoint = strtr($entrypoint, ['{id}' => $filters['id']]);
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param mixed $video
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function setVideosChannelRank(array $data = [])
{
$entrypoint = "/api/custom/playlist_video_configs/update-rank";
return $this->callUrl($entrypoint, 'POST', [], json_encode($data));
}
/**
* @param array $data
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function updateProgramMoods(array $data = [])
{
$entrypoint = "api/moods_after_post_responses/programs/bulk/add_link";
return $this->callUrl($entrypoint, 'POST', [], json_encode($data));
}
/**
* @param mixed $channel
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function deleteChannel($id)
{
$entrypoint = '/api/channels/{id}';
$entrypoint = strtr($entrypoint, ['{id}' => $id]);
return $this->callUrl($entrypoint, 'DELETE');
}
/**
* @param mixed $category
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function deleteCategory($id)
{
$entrypoint = '/api/categories/{id}';
$entrypoint = strtr($entrypoint, ['{id}' => $id]);
return $this->callUrl($entrypoint, 'DELETE');
}
/**
* This updates the infos on an existing company, at leas the id of the company
* is required in order for this to work
*
* @param $category
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function updateCategory($category, ?UploadedFile $illustration = null, ?UploadedFile $picture = null, ?UploadedFile $appPicture = null)
{
$entrypoint = '/api/categories/{id}';
$_category = (array)$category;
$id = $this->extractProperty($category, 'id');
if($illustration != null){
$_category['illustration'] = $this->postMediaObject($illustration)->{'@id'};
} else {
unset($_category['illustration']);
}
if($picture != null){
$_category['picture'] = $this->postMediaObject($picture)->{'@id'};
} else {
unset($_category['picture']);
}
if($appPicture != null){
$_category['appPicture'] = $this->postMediaObject($appPicture)->{'@id'};
} else {
unset($_category['appPicture']);
}
$data = json_encode($_category, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
$entrypoint = strtr($entrypoint, ['{id}' => $id]);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => 'application/merge-patch+json'
], $data);
}
/**
* This updates the infos on an existing company, at leas the id of the company
* is required in order for this to work
*
* @param mixed $company infos on the company to be modified
* @param UploadedFile|null $logo logo file to be modified if any
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function updateChannel(int $id, $channel, ?UploadedFile $image = null)
{
$entrypoint = '/api/channels/'. $id;
$_channel = (array)$channel;
if($image != null){
$_channel['image'] = $this->postMediaObject($image)->{'@id'};
} else {
unset($_channel['image']);
}
$data = json_encode($_channel, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => 'application/merge-patch+json'
], $data);
}
/**
* Calls activation toggle on a company
*
* @param int $id
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function activateCompany(int $id)
{
$entrypoint = '/api/companies/{id}/activation';
$entrypoint = strtr($entrypoint, ['{id}' => $id]);
return $this->callUrl($entrypoint);
}
/**
* Extracts property of generic object or array
* @param array|object $element
* @param string $property
* @return mixed
*/
private function extractProperty($element, string $property)
{
$result = null;
if (is_array($element) && isset($element[$property])) {
$result = $element[$property];
} elseif (is_object($element) && isset($element->$property)) {
$result = $element->$property;
}
if ($result === null) {
throw new \InvalidArgumentException("Unable to extract '$property'");
}
return $result;
}
/**
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getLoginImages()
{
$entrypoint = '/api/slides_slug/login_page';
return $this->callUrl($entrypoint);
}
/**
* @param string $user
* @param DateTime|null $start
* @param DateTime|null $end
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getStatsUser(string $user, ?DateTime $start, ?DateTime $end)
{
$entrypoint = "/api/stats/user-views/{$user}";
return $this->callUrl($entrypoint, 'GET', [], '', [
'start' => $start,
'end' => $end,
]);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getTotalViews(array $filters = [])
{
$entrypoint = '/api/stats/total-views';
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getTopFiveVideos(array $filters = [])
{
$entrypoint = '/api/stats/top-5';
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getTopFiveVideosCategories()
{
$entrypoint = '/api/stats/top-5';
return $this->callUrl($entrypoint);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getFiveCategories(array $filters = [])
{
$entrypoint = "/api/stats/videos/top-categories";
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getUsersStats(array $filters = [])
{
$entrypoint = "/api/stats/users";
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getFullStats(array $filters = [])
{
$entrypoint = "/api/stats/full";
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param int $id
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getChannel(int $id, array $filters = [])
{
$entrypoint = '/api/channels/{id}';
$entrypoint = strtr($entrypoint, [
'{id}' => $id
]);
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param string $channelId
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getFiveChannel(string $channelId)
{
$entrypoint = "/api/stats/top-channel/$channelId";
return $this->callUrl($entrypoint);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getTopChannels(array $filters = [])
{
$entrypoint = "/api/stats/top-channels";
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getTopChannelsCategories(array $filters = [])
{
$entrypoint = "/api/stats/categories/top-channels";
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getTopCategories(array $filters = [])
{
$entrypoint = "/api/stats/top-categories";
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getWeeklyRestrictions()
{
$entrypoint = "/api/restrictions/manager/week-days";
return $this->callUrl($entrypoint);
}
/**
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function updateWeeklyRestrictions($data)
{
$entrypoint = "/api/restrictions/manager/week-days";
return $this->callUrl($entrypoint, 'POST', [], json_encode($data));
}
/**
* @param array $filters
* @param bool $session
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getChannels(array $filters = [], bool $session = false)
{
$entrypoint = '/api/channels';
if ($session){
return $this->sessionStorageCall($entrypoint);
}
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $filters
* @param bool $playlist
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getChannelsForm(array $filters = [], bool $playlist = true)
{
$entrypoint = '/api/channels';
$result = $this->callUrl($entrypoint, 'GET', [], [], $filters)->{'hydra:member'};
$values = [];
foreach ($result as $item) {
if ($playlist && !empty($item->playlist) && !empty($item->playlist->{'@id'})) {
$values[$item->name] = $item->playlist->{'@id'};
} else {
$values[$item->name] = $item->{'@id'};
}
}
return $values;
}
/**
* @param array $filters
* @param bool $session
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function postChannel($data, ?UploadedFile $image = null)
{
$entrypoint = '/api/channels';
$_data = (array)$data;
if($image != null){
$_data['image'] = $this->postMediaObject($image)->{'@id'};
}
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
return $this->callUrl($entrypoint, 'POST', [], $data);
}
/**
* @param array $filters
* @param array $extra
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getExperts(array $filters = [], array $extra = [])
{
$entrypoint = '/api/experts';
$filters = array_merge($filters, $extra);
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function deleteExpert(int $id)
{
$entrypoint = '/api/experts/' . $id;
return $this->callUrl($entrypoint, 'DELETE');
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getExpert(int $id)
{
$entrypoint = '/api/experts/'.$id;
return $this->callUrl($entrypoint, 'GET');
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getExpertVideos( array $filters = [], int $id)
{
$entrypoint = '/api/experts/'. $id .'/videos';
$filters['active'] = true;
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* This updates the infos on an existing expert, at leas the id of the expert
* is required in order for this to work
*
* @param mixed $company infos on the company to be modified
* @param UploadedFile|null $logo logo file to be modified if any
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function updateExpert(int $id, array $data, ?UploadedFile $picture = null, ?UploadedFile $avatar = null )
{
$entrypoint = '/api/experts/'. $id;
$_data =(array)$data;
if ($picture != null) {
$_data['picture'] = $this->postMediaObject($picture)->{'@id'};
}else{
unset($_data['picture']);
}
if ($avatar != null) {
$_data['avatar'] = $this->postMediaObject($avatar)->{'@id'};
}else{
unset($_data['avatar']);
}
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => self::MERGE_CONTENT_TYPE
], $data);
}
/**
* @param array $filters
* @param bool $session
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function postExpert($data, ?UploadedFile $picture = null, ?UploadedFile $avatar = null)
{
$entrypoint = '/api/experts';
$_data = (array)$data;
if ($picture != null) {
$_data['picture'] = $this->postMediaObject($picture)->{'@id'};
}
if ($avatar != null) {
$_data['avatar'] = $this->postMediaObject($avatar)->{'@id'};
}
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
return $this->callUrl($entrypoint, 'POST', [], $data);
}
public function postCategory($data, ?UploadedFile $illustration = null, ?UploadedFile $picture = null, ?UploadedFile $appPicture = null )
{
$entrypoint = '/api/categories';
$_data = (array)$data;
if($illustration != null){
$_data['illustration'] = $this->postMediaObject($illustration)->{'@id'};
}
if($picture != null){
$_data['picture'] = $this->postMediaObject($picture)->{'@id'};
}
if($appPicture != null){
$_data['appPicture'] = $this->postMediaObject($appPicture)->{'@id'};
}
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
return $this->callUrl($entrypoint, 'POST', [], $data);
}
/**
* @param array $filters
* @param bool $session
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getChannelsBis(array $filters = [], array $extra = [])
{
$entrypoint = '/api/channels';
$filters = array_merge($filters, $extra);
$filters['isThematic'] = false;
$filters['exists[user]'] = false;
$filters['exists[category]'] = true;
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $filters
* @param bool $session
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getThematics(array $filters = [], array $extra = [])
{
$entrypoint = '/api/channels';
$filters = array_merge($filters, $extra);
$filters['isThematic'] = true;
$filters['exists[user]'] = false;
$filters['exists[category]'] = true;
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $filters
* @param bool $session
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getSlidesHome(array $filters = [], array $extra =[])
{
$entrypoint = '/api/slides';
$filters['type'] = "homepage_slide";
$filters = array_merge($filters, $extra);
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $filters
* @param bool $session
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getSlidesFromChannel(array $filters = [], array $extra =[])
{
$filters = array_merge($filters, $extra);
$entrypoint = '/api/channels/{id}/slides';
$entrypoint = strtr($entrypoint, ['{id}' => $filters['id']]);
return $this->callUrl($entrypoint, 'GET');
}
/**
* @param int $id
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function activateSlide($id)
{
$entrypoint = '/api/slides/{id}';
$entrypoint = strtr($entrypoint, ['{id}' => $id]);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => 'application/merge-patch+json'
], json_encode(['active' => true]));
}
/**
* @param int $id
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function deactivateSlide($id)
{
$entrypoint = '/api/slides/{id}';
$entrypoint = strtr($entrypoint, ['{id}' => $id]);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => 'application/merge-patch+json'
], json_encode(['active' => false]));
}
/**
* @param string $iri
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getChannelFromIri($iri)
{
return $this->callUrl($iri, 'GET');
}
/**
* @param string $iri
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getProgramFromIri($iri)
{
return $this->callUrl($iri, 'GET');
}
/**
* @param string $iri
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getVideoFromIri($iri)
{
return $this->callUrl($iri, 'GET');
}
/**
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function postSlide($data, ?UploadedFile $image = null)
{
$entrypoint = '/api/slides';
$_data = (array)$data;
if($image != null){
$_data['image'] = $this->postMediaObject($image)->{'@id'};
}
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
return $this->callUrl($entrypoint, 'POST', [], $data);
}
/**
* @param $data
* @param int $id
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function updateSlide($data, $id, ?UploadedFile $image = null, $removeImage = "")
{
$entrypoint = '/api/slides/{id}';
$_data = (array)$data;
if($removeImage == "true"){
$_data['image'] == null;
} elseif($image != null){
$_data['image'] = $this->postMediaObject($image)->{'@id'};
} else {
unset($_data['image']);
}
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
$entrypoint = strtr($entrypoint, ['{id}' => $id]);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => 'application/merge-patch+json'
], $data);
}
/**
* This deletes the image on a company page without having to send a form.
*
* @param mixed $company infos on the company to be modified
* @param UploadedFile|null $logo logo file to be modified if any
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function deleteSlideImage(int $id, array $data)
{
$entrypoint = '/api/slides/'. $id;
$_data = $data;
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => self::MERGE_CONTENT_TYPE
], $data);
}
/**
* @param int $id
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function deleteSlide($id)
{
$entrypoint = '/api/slides/{id}';
$entrypoint = strtr($entrypoint, ['{id}' => $id]);
return $this->callUrl($entrypoint, 'DELETE');
}
/**
* @param int $id
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getSlide($id)
{
$entrypoint = '/api/slides/{id}';
$entrypoint = strtr($entrypoint, ['{id}' => $id]);
return $this->callUrl($entrypoint, 'GET');
}
// /**
// * @param int $id
// * @return null
// * @throws ClientExceptionInterface
// * @throws RedirectionExceptionInterface
// * @throws ServerExceptionInterface
// * @throws TransportExceptionInterface
// */
// public function getCompanySlide($id)
// {
// $entrypoint = '/api/slides/{id}';
// $entrypoint = strtr($entrypoint, ['{id}' => $id]);
// return $this->callUrl($entrypoint, 'GET');
// }
/**
* @param $username
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function resetPwdRequest($email)
{
$entrypoint = '/security/forgot_password/back/{email}';
$entrypoint = strtr($entrypoint, ['{email}' => $email]);
return $this->callUrl($entrypoint, 'GET', [
'X-url' => $this->router->generate('app_reset_pwd', [], RouterInterface::ABSOLUTE_URL),
]);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function resetPwd(array $data)
{
$entrypoint = '/security/forgot_password';
$data = json_encode($data);
return $this->callUrl($entrypoint, 'POST', [], $data);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getFilterCategs(array $filters = [])
{
$entrypoint = '/api/filters_categories';
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getFilterCateg(int $id)
{
$entrypoint = '/api/filters_categories/'. $id;
return $this->callUrl($entrypoint, 'GET');
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function postFilterCateg(array $data)
{
$entrypoint = '/api/filters_categories';
$data = json_encode($data);
return $this->callUrl($entrypoint, 'POST', [], $data);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function activateFilterCateg(int $id, array $data)
{
$entrypoint = '/api/filters_categories/'. $id;
$data = json_encode($data, JSON_UNESCAPED_UNICODE);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => self::MERGE_CONTENT_TYPE
], $data);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function editFilterCateg(int $id, array $data)
{
$entrypoint = '/api/filters_categories/'. $id;
$data = json_encode($data, JSON_UNESCAPED_UNICODE);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => self::MERGE_CONTENT_TYPE
], $data);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function deleteFilterCateg(int $id)
{
$entrypoint = '/api/filters_categories/' . $id;
return $this->callUrl($entrypoint, 'DELETE');
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getFiltersFilters(array $filters = [])
{
$entrypoint = '/api/filters_filters';
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getFiltersFilter(int $id)
{
$entrypoint = '/api/filters_filters/'. $id;
return $this->callUrl($entrypoint, 'GET');
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function postFiltersFilter(array $data)
{
$entrypoint = '/api/filters_filters';
$data = json_encode($data);
return $this->callUrl($entrypoint, 'POST', [], $data);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function editFiltersFilter(int $id, array $data)
{
$entrypoint = '/api/filters_filters/'. $id;
$data = json_encode($data, JSON_UNESCAPED_UNICODE);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => self::MERGE_CONTENT_TYPE
], $data);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function activateFiltersFilter(int $id, array $data)
{
$entrypoint = '/api/filters_filters/'. $id;
$data = json_encode($data, JSON_UNESCAPED_UNICODE);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => self::MERGE_CONTENT_TYPE
], $data);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function deleteFiltersFilter(int $id)
{
$entrypoint = '/api/filters_filters/' . $id;
return $this->callUrl($entrypoint, 'DELETE');
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getMoods(array $filters = [])
{
$entrypoint = '/api/custom/moods';
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getMoodResponses(array $filters = [])
{
$entrypoint = '/api/mood_after_post_responses';
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getMoodResponse(int $id)
{
$entrypoint = '/api/mood_after_post_responses/'. $id;
return $this->callUrl($entrypoint, 'GET');
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function postMoodResponse(array $data)
{
$entrypoint = '/api/mood_after_post_responses';
$data = json_encode($data);
return $this->callUrl($entrypoint, 'POST', [], $data);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function editMoodResponse(int $id, array $data)
{
$entrypoint = '/api/mood_after_post_responses/'. $id;
$data = json_encode($data, JSON_UNESCAPED_UNICODE);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => self::MERGE_CONTENT_TYPE
], $data);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function deleteMoodResponse(int $id)
{
$entrypoint = '/api/mood_after_post_responses/' . $id;
return $this->callUrl($entrypoint, 'DELETE');
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function linkMoodResponse(array $data)
{
$entrypoint = '/api/custom/moods_after_post_responses/add_link';
$data = json_encode($data);
return $this->callUrl($entrypoint, 'POST', [], $data);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function unlinkMoodResponse(array $data)
{
$entrypoint = '/api/custom/moods_after_post_responses/remove_link';
$data = json_encode($data);
return $this->callUrl($entrypoint, 'POST', [], $data);
}
/**
* @return array
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getChannelsTypes()
{
$entrypoint = '/api/custom/channels/types';
return $this->callUrl($entrypoint, 'GET');
}
/**
* @param string $iri
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getIriValue(string $iri, array $filters)
{
return $this->callUrl($iri, 'GET', [], [], $filters);
}
/**
* @param array $resources
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getIriValues(array $resources, array $filters)
{
$filters['resources'] = $resources;
return $this->callUrl('/api/resources', 'GET', [], [], $filters);
}
/**
* @param array $moods
* @param int $videoId
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function bulkMoodsVideoAssociation(array $moods, int $videoId)
{
$data = [];
$entrypoint = "/api/moods_after_post_responses/bulk/add_link";
foreach ($moods as $mood) {
$data[] = [
'id' => explode('/', $mood)[3],
'videos' => [
$videoId
]
];
}
return $this->callUrl($entrypoint, 'POST', [], json_encode($data));
}
/**
* @param array $filters
* @param array $extra
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getObjectives(array $filters = [], array $extra = [])
{
$entrypoint = '/api/objectives';
$filters = array_merge($filters, $extra);
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $data
* @param UploadedFile $illustration
* @param UploadedFile $picture
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function postObjective($data, ?UploadedFile $illustration = null, ?UploadedFile $picture = null )
{
$entrypoint = '/api/objectives';
$_data = (array)$data;
if($illustration != null){
$_data['illustration'] = $this->postMediaObject($illustration)->{'@id'};
}
if($picture != null){
$_data['picture'] = $this->postMediaObject($picture)->{'@id'};
}
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
return $this->callUrl($entrypoint, 'POST', [], $data);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getObjective(int $id , array $filters = [])
{
$entrypoint = '/api/objectives/'.$id;
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param $objective
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function updateObjective($objective, ?UploadedFile $illustration = null, ?UploadedFile $picture = null)
{
$entrypoint = '/api/objectives/{id}';
$_objective = (array)$objective;
$id = $this->extractProperty($objective, 'id');
if($illustration != null){
$_objective['illustration'] = $this->postMediaObject($illustration)->{'@id'};
} else {
unset($_objective['illustration']);
}
if($picture != null){
$_objective['picture'] = $this->postMediaObject($picture)->{'@id'};
} else {
unset($_objective['picture']);
}
$data = json_encode($_objective, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
$entrypoint = strtr($entrypoint, ['{id}' => $id]);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => 'application/merge-patch+json'
], $data);
}
/**
* @param mixed $objective
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function activateObjective($id)
{
$entrypoint = '/api/objectives/{id}/activate';
$entrypoint = strtr($entrypoint, ['{id}' => $id]);
return $this->callUrl($entrypoint);
}
/**
* @param mixed $objective
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function deactivateObjective($id)
{
$entrypoint = '/api/objectives/{id}/deactivate';
$entrypoint = strtr($entrypoint, ['{id}' => $id]);
return $this->callUrl($entrypoint);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function deleteObjective(int $id)
{
$entrypoint = '/api/objectives/' . $id;
return $this->callUrl($entrypoint, 'DELETE');
}
/**
* @param array $filters
* @param array $extra
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getGames(array $filters = [], array $extra = [])
{
$entrypoint = '/api/awards';
$filters = array_merge($filters, $extra);
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $data
* @param UploadedFile $illustration
* @param UploadedFile $picture
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function postGame($data, ?UploadedFile $rulePdf = null )
{
$entrypoint = '/api/awards';
$_data = (array)$data;
if($rulePdf != null){
$_data['rules'] = $this->postMediaObject($rulePdf)->{'@id'};
}
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
return $this->callUrl($entrypoint, 'POST', [], $data);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getGame(int $id , array $filters = [])
{
$entrypoint = '/api/awards/'.$id;
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function updateGame(int $id, $data)
{
$entrypoint = '/api/awards/'. $id;
$_data = $data;
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => self::MERGE_CONTENT_TYPE
], $data);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function customUpdateGame(int $id, $data)
{
$entrypoint = '/api/custom/awards/'. $id;
$_data = $data;
if($_data['rules'] != null){
$_data['rules'] = $this->postMediaObject($_data['rules'])->{'@id'};
}else{
unset($_data['rules']);
}
if($_data['firstAward']['picture'] != null){
$_data['firstAward']['picture'] = $this->postMediaObject($_data['firstAward']['picture'])->{'@id'};
}else{
unset($_data['firstAward']['picture']);
}
if($_data['secondAward']['picture'] != null){
$_data['secondAward']['picture'] = $this->postMediaObject($_data['secondAward']['picture'])->{'@id'};
}else{
unset($_data['secondAward']['picture']);
}
if($_data['thirdAward']['picture'] != null){
$_data['thirdAward']['picture'] = $this->postMediaObject($_data['thirdAward']['picture'])->{'@id'};
}else{
unset($_data['thirdAward']['picture']);
}
if($_data['firstAward']['illustration'] != null){
$_data['firstAward']['illustration'] = $this->postMediaObject($_data['firstAward']['illustration'])->{'@id'};
}else{
unset($_data['firstAward']['illustration']);
}
if($_data['secondAward']['illustration'] != null){
$_data['secondAward']['illustration'] = $this->postMediaObject($_data['secondAward']['illustration'])->{'@id'};
}else{
unset($_data['secondAward']['illustration']);
}
if($_data['thirdAward']['illustration'] != null){
$_data['thirdAward']['illustration'] = $this->postMediaObject($_data['thirdAward']['illustration'])->{'@id'};
}else{
unset($_data['thirdAward']['illustration']);
}
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => self::MERGE_CONTENT_TYPE
], $data);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getGameConfigs( array $filters = [])
{
$entrypoint = '/api/award_configs';
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getGameConfig(int $id, array $filters = [])
{
$entrypoint = '/api/award_configs/'.$id;
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function updateOperation(int $id, $data)
{
$entrypoint = '/api/award_configs/'. $id;
$_data = $data;
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => self::MERGE_CONTENT_TYPE
], $data);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getAssociations( array $filters = [])
{
$entrypoint = '/api/associations';
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getCompanyAssociations( array $filters = [], int $id)
{
$entrypoint = '/api/companies/'. $id .'/associations';
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function postAssociation($data, ?UploadedFile $illustration = null, ?UploadedFile $picture = null )
{
$entrypoint = '/api/associations';
$_data = (array)$data;
if($illustration != null){
$_data['illustration'] = $this->postMediaObject($illustration)->{'@id'};
}
if($picture != null){
$_data['picture'] = $this->postMediaObject($picture)->{'@id'};
}
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
return $this->callUrl($entrypoint, 'POST', [], $data);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getAssociation(int $id , array $filters = [])
{
$entrypoint = '/api/associations/'.$id;
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param $objective
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function updateAssociation(int $id, $data, ?UploadedFile $illustration = null, ?UploadedFile $picture = null)
{
$entrypoint = '/api/associations/'. $id;
$_data = (array)$data;
if($illustration != null){
$_data['illustration'] = $this->postMediaObject($illustration)->{'@id'};
} else {
unset($_data['illustration']);
}
if($picture != null){
$_data['picture'] = $this->postMediaObject($picture)->{'@id'};
} else {
unset($_data['picture']);
}
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
$entrypoint = strtr($entrypoint, ['{id}' => $id]);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => 'application/merge-patch+json'
], $data);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function deleteAssociation(int $id)
{
$entrypoint = '/api/associations/' . $id;
return $this->callUrl($entrypoint, 'DELETE');
}
public function cleanCache()
{
$entrypoint = '/api/cache/clear';
return $this->callUrl($entrypoint, 'GET');
}
public function cleanAllCache()
{
$entrypoint = '/api/cache/clear-all';
return $this->callUrl($entrypoint, 'GET');
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getRecoSurveys( array $filters = [])
{
$filters = [
'type' => 'vitality_survey'
];
$entrypoint = '/api/surveys';
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function postRecoSurvey(array $data)
{
$entrypoint = '/api/vitality_surveys';
$data = json_encode($data);
return $this->callUrl($entrypoint, 'POST', [], $data);
}
/**
* @param string $id
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getSurvey(int $id, array $filters = [])
{
$entrypoint = "/api/surveys/". $id;
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function updateAnswerWithReco(int $id, array $data)
{
$entrypoint = '/api/answers/'. $id .'/update-with-recommended-objective';
$data = json_encode($data);
return $this->callUrl($entrypoint, 'POST', [], $data);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function updateRecoSurvey(int $id, array $data)
{
$entrypoint = "/api/surveys/{$id}/update/recommended-objectives";
$data = json_encode($data);
return $this->callUrl($entrypoint, 'POST', [], $data);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function renderCompanyResa(int $id, bool $force = false)
{
$entrypoint = "/api/companies/{$id}/resa-activation/{$force}";
return $this->callUrl($entrypoint);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function updateHomeSurveyTag(int $id, array $data)
{
$entrypoint = "/api/tv_tags/{$id}/update-with-motivations-phrases";
$data = json_encode($data);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => 'application/merge-patch+json'
], $data);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getChallenges(array $filters = [], array $extra = [])
{
$entrypoint = "/api/teamplay_challenges";
$filters = array_merge($filters, $extra);
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getChallengeTypes(array $filters = [])
{
$entrypoint = "/api/teamplay_challenge_types";
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function postChallenge(array $data, ?UploadedFile $picture = null)
{
$entrypoint = '/api/teamplay_challenges';
$_data = (array)$data;
if($picture != null){
$_data['picture'] = $this->postMediaObject($picture)->{'@id'};
}
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
return $this->callUrl($entrypoint, 'POST', [], $data);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getChallenge(int $id, array $filters = [])
{
$entrypoint = "/api/teamplay_challenges/". $id;
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param $objective
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function editChallenge(int $id, $data, ?UploadedFile $picture = null)
{
$entrypoint = '/api/teamplay_challenges/'. $id;
$_data = (array)$data;
if($picture != null){
$_data['picture'] = $this->postMediaObject($picture)->{'@id'};
} else {
unset($_data['picture']);
}
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
$entrypoint = strtr($entrypoint, ['{id}' => $id]);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => 'application/merge-patch+json'
], $data);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function deleteChallenge(int $id)
{
$entrypoint = '/api/teamplay_challenges/' . $id;
return $this->callUrl($entrypoint, 'DELETE');
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getPlannings(array $filters = [], array $extra = [])
{
$filters = array_merge($filters, $extra);
$entrypoint = "/api/teamplays";
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getPlanningChallenges(array $filters = [], array $extra = [])
{
$entrypoint = "/api/teamplays/". $extra['id'] ."/challenges";
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function postPlanning(array $data, ?UploadedFile $picture = null)
{
$entrypoint = '/api/teamplays';
$_data = (array)$data;
if($picture != null){
$_data['picture'] = $this->postMediaObject($picture)->{'@id'};
}
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
return $this->callUrl($entrypoint, 'POST', [], $data);
}
/**
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getPlanning(int $id, array $filters = [])
{
$entrypoint = "/api/teamplays/". $id;
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param $objective
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function editPlanning(int $id, $data, ?UploadedFile $picture = null)
{
$entrypoint = '/api/teamplays/'. $id;
$_data = (array)$data;
if($picture != null){
$_data['picture'] = $this->postMediaObject($picture)->{'@id'};
} else {
unset($_data['picture']);
}
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
$entrypoint = strtr($entrypoint, ['{id}' => $id]);
$fields = [
'id', 'name', 'dateStart', 'dateEnd', 'duration', 'active', 'inProgress', 'description', 'active',
'association' => ['id', 'name'],
'company' => ['id', 'name'],
'picture' => ['id', 'contentUrl']
];
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => 'application/merge-patch+json'
], $data, ['groups' => ["teamplay:write"]]);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function deletePlanning(int $id)
{
$entrypoint = '/api/teamplays/' . $id;
return $this->callUrl($entrypoint, 'DELETE');
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getDashboardBO(array $filters = [])
{
$entrypoint = "/api/stats/bo/dashboard";
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $filters
* @param array $extra
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getTeams(array $filters = [], array $extra = [])
{
$filters = array_merge($filters, $extra);
$entrypoint = '/api/teams';
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $data
* @param UploadedFile $illustration
* @param UploadedFile $picture
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function postTeam($data, ?UploadedFile $picture = null )
{
$entrypoint = '/api/teams';
$_data = (array)$data;
if($picture != null){
$_data['picture'] = $this->postMediaObject($picture)->{'@id'};
}
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
return $this->callUrl($entrypoint, 'POST', [], $data);
}
/**
* @param string $id
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getTeam(int $id, array $filters = [])
{
$entrypoint = "/api/teams/". $id;
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param string $id
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getTeamUsers(array $filters = [], array $extra = [])
{
$id = $extra['id'];
unset($extra['id']);
$filters = array_merge($filters, $extra);
$entrypoint = "/api/teams/". $id ."/team_users";
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param array $data
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function editTeam(int $id, array $data, ?UploadedFile $picture = null)
{
$entrypoint = '/api/teams/'. $id;
$_data = (array)$data;
if($picture != null){
$_data['picture'] = $this->postMediaObject($picture)->{'@id'};
} else {
unset($_data['picture']);
}
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => 'application/merge-patch+json'
], $data);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function deleteTeam(int $id)
{
$entrypoint = '/api/teams/' . $id;
return $this->callUrl($entrypoint, 'DELETE');
}
/**
* @param string $id
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getManagerAwards(array $filters = [])
{
$entrypoint = "api/bo/manager/games/award/dashboard";
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @param string $id
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getManagerTeamplays(array $filters = [])
{
$entrypoint = "/api/bo/manager/games/teamplay/dashboard";
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/****** NOTIFICATION ********/
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getNotificationTypes(array $filters = [])
{
$entrypoint = "/api/notification_types";
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getNotification(int $id, array $filters = [])
{
$entrypoint = "/api/notifications/". $id;
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function getNotifications(array $filters = [], array $extra = [])
{
$entrypoint = "/api/notifications";
$filters = array_merge($filters, $extra);
return $this->callUrl($entrypoint, 'GET', [], [], $filters);
}
/**
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function postNotification(array $data, ?UploadedFile $picture = null)
{
$entrypoint = '/api/notifications';
$_data = (array)$data;
if($picture != null){
$_data['picture'] = $this->postMediaObject($picture)->{'@id'};
}
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
return $this->callUrl($entrypoint, 'POST', [], $data);
}
/**
* @param $objective
* @return null
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function editNotification(int $id, $data, ?UploadedFile $picture = null)
{
$entrypoint = '/api/notifications/'. $id;
$_data = (array)$data;
if($picture != null){
$_data['picture'] = $this->postMediaObject($picture)->{'@id'};
} else {
unset($_data['picture']);
}
$data = json_encode($_data, JSON_UNESCAPED_UNICODE);
$data = str_replace('\\/', '/', $data);
$entrypoint = strtr($entrypoint, ['{id}' => $id]);
return $this->callUrl($entrypoint, 'PATCH', [
'Content-Type' => 'application/merge-patch+json'
], $data);
}
/**
* @param array $filters
* @return mixed
* @throws ClientExceptionInterface
* @throws RedirectionExceptionInterface
* @throws ServerExceptionInterface
* @throws TransportExceptionInterface
*/
public function deleteNotification(int $id)
{
$entrypoint = '/api/notifications/' . $id;
return $this->callUrl($entrypoint, 'DELETE');
}
/**
* Envoie la notification dans OneSignal
*/
public function sendNotification(int $id)
{
$entrypoint = "/api/notifications/{$id}/send";
return $this->callUrl($entrypoint, 'GET');
}
/**
* Annule la notification via OneSignal
*/
public function canceledNotification(int $id)
{
$entrypoint = "/api/notifications/{$id}/canceled";
return $this->callUrl($entrypoint, 'GET');
}
/**
* MAJ de toutes les notifications via OneSignal
*/
public function importNotificationFromOneSignal()
{
$entrypoint = "/api/onesignal/notifications/import";
return $this->callUrl($entrypoint, 'GET');
}
/**
* MAJ d'une notification via OneSignal
*/
public function importNotificationByIdFromOneSignal(int $id)
{
$entrypoint = "/api/notifications/{$id}/import";
return $this->callUrl($entrypoint, 'GET');
}
}