
Doc https://docs.google.com/document/d/1gOAceevwutF3QHYWD0_6aESQMZEiIz3YVBVXlyUuRy8 * Summit Registration External Feed https://docs.google.com/document/d/1_2QZUK--A350jxh2USKBtVtisKrrcUcVjdKnbcZ7-4M/edit# * Multi Stripe Config * Added stripe payment configuration per summit * Added webhook automatic creation * Added CRUD endpoints for payment profiles per summit GET api/v1/summits/{id}/payment-gateway-profiles filters active ['=='] application_type ['=@', '=='] scopes summits/read/all summits/payment-gateway-profiles/read POST api/v1/summits/{id}/payment-gateway-profiles payload 'active' => 'sometimes|boolean', 'application_type' => 'sometimes|string|in:Registration,BookableRooms' 'provider' => 'required|string|in:Stripe', 'test_mode_enabled' => 'required|boolean', 'live_secret_key' => 'sometimes|string', 'live_publishable_key' => 'required_with:live_secret_key|string', 'test_secret_key' => 'sometimes|string', 'test_publishable_key' => 'required_with:test_secret_key|string' scopes summits/write summits/payment-gateway-profiles/write GET api/v1/summits/{id}/payment-gateway-profiles/{payment_profile_id} scopes summits/read/all summits/payment-gateway-profiles/read PUT api/v1/summits/{id}/payment-gateway-profiles/{payment_profile_id} payload 'active' => 'sometimes|boolean', 'application_type' => 'sometimes|string|in:Registration,BookableRooms' 'provider' => 'required|string|in:Stripe', 'test_mode_enabled' => 'required|boolean', 'live_secret_key' => 'sometimes|string', 'live_publishable_key' => 'required_with:live_secret_key|string', 'test_secret_key' => 'sometimes|string', 'test_publishable_key' => 'required_with:test_secret_key|string' scopes summits/payment-gateway-profiles/write summits/write DELETE api/v1/summits/{id}/payment-gateway-profiles/{payment_profile_id} scopes summits/payment-gateway-profiles/write summits/write Stripe Webhooks default webhook (SECRET set per application under .env, should be created previously on stripe default account) POST api/public/v1/summits/all/payments/{application_name}/confirm where application_name could be Registration or BookableRooms otherwise if a stripe account is set per summit, when the profile gets activated a webhook will be automatically be created using following url POST api/public/v1/summits/{id}/payments/{application_name}/confirm * Email API Integration * moved all blade templates to mail api ( DB Seeding) * defined email events flows per summmit * created endpoint to set up templates per email events on each flow PUT /api/v1/summits/{id}/email-flows-events/{event_id} payload email_template_identifier: string * added endpoint to get all email events per summit GET /api/v1/summits/{id}/email-flows-events * added endpoint to get email event per summit/id GET /api/v1/summits/{id}/email-flows-events/{event_id} Summit Documents endpoints add summit document POST /api/v1/summits/{id}/summit-documents payload file (mandatory|file stream) label ( mandatory|string) name ( mandatory|string) description (optional|string) get all summit documents GET /api/v1/summits/{id}/summit-documents get by id GET /api/v1/summits/{id}/summit-documents/{document_id} update PUT GET /api/v1/summits/{id}/summit-documents/{document_id} file (optional|file stream) label (optional|string) name (optional|string) description (optional|string) delete DELETE GET /api/v1/summits/{id}/summit-documents/{document_id} add event type to doc PUT /api/v1/summits/{id}/summit-documents/{document_id}/event-types/{event_type_id} delete event type from doc DELETE /api/v1/summits/{id}/summit-documents/{document_id}/event-types/{event_type_id} add document to event type PUT /api/v1/summits/{id}/event-types/{event_type_id}/summit-documents/{document_id} delete document from event type DELETE /api/v1/summits/{id}/event-types/{event_type_id}/summit-documents/{document_id} Updated Summit events to support streaming url, meeting_url and etherpad link * Summit Registration - Invite only Summit Administrator Permission Groups GET /api/v1/summit-administrator-groups filter * title * member_first_name * member_last_name * member_full_name * member_email * summit_id * member_id ordering id title scopes %s/summit-administrator-groups/read /api/v1/summit-administrator-groups/{group_id} scopes %s/summit-administrator-groups/read POST /api/v1/summit-administrator-groups title summits members scopes %s/summit-administrator-groups/write PUT /api/v1/summit-administrator-groups/{group_id} title summits members scopes %s/summit-administrator-groups/write DELETE /api/v1/summit-administrator-groups/{group_id} scopes %s/summit-administrator-groups/write PUT /api/v1/summit-administrator-groups/{group_id}/members/{member_id} DELETE /api/v1/summit-administrator-groups/{group_id}/members/{member_id} PUT /api/v1/summit-administrator-groups/{group_id}/summits/{summit_id} DELETE /api/v1/summit-administrator-groups/{group_id}/summits/{summit_id} Room Metrics PUT /api/v1/summits/{id}/members/{member_id}/schedule/{event_id}/enter Scopes %s/me/summits/events/enter PUT /api/v1/summits/{id}/members/{member_id}/schedule/{event_id}/leave %s/me/summits/events/leave update summit_event serializer new fields total_attendance_count current_attendance_count attendance current_attendance Added new Speakers Endpoints GET /api/v1/summits/{id}/speakers/on-schedule retrieves all speakers on summit schedule filters 'first_name' => ['=@', '=='], 'last_name' => ['=@', '=='], 'email' => ['=@', '=='], 'id' => ['=='], 'full_name' => ['=@', '=='], 'start_date' => ['>', '<', '<=', '>=', '=='], 'end_date' => ['>', '<', '<=', '>=', '=='], Summit Events Image POST /api/v1/summits/{id}/events/{event_id}/image DELETE /api/v1/summits/{id}/events/{event_id}/image Speakers Image Big Pic POST /api/v1/speakers/{speaker_id}/big-photo DELETE /api/v1/speakers/{speaker_id}/big-photo CFP - multiple summits Presentation Materials - Media Uploads New Endpoints GET api/v1/summit-media-file-types filter 'name' => ['=@', '=='] order id, name POST api/v1/summit-media-file-types payload 'name' => 'required|string|max:255', 'description' => 'sometimes|string|max:255', 'allowed_extensions' => 'required|string_array', GET api/v1/summit-media-file-types/{id} PUT api/v1/summit-media-file-types/{id} payload 'name' => 'sometimes|string|max:255', 'description' => 'sometimes|string|max:255', 'allowed_extensions' => 'required|string_array', DELETE api/v1/summit-media-file-types/{id} GET api/v1/summits/{id}/media-upload-types POST payload 'name' => 'required|string|max:255', 'description' => 'sometimes|string|max:255', 'is_mandatory' => 'required|boolean', 'max_size' => 'required|int|megabyte_aligned', 'private_storage_type' => 'required|string|in:None,DropBox,Swift,Local', 'public_storage_type' => 'required|string|in:None,DropBox,Swift,Local' 'type_id' => 'required|int', 'presentation_types' => 'sometimes|int_array', GET api/v1/summits/{id}/media-upload-types/{media_upload_type_id} PUT api/v1/summits/{id}/media-upload-types/{media_upload_type_id} payload 'name' => 'sometimes|string|max:255', 'description' => 'sometimes|string|max:255', 'is_mandatory' => 'sometimes|boolean', 'max_size' => 'sometimes|int|megabyte_aligned', 'private_storage_type' => 'sometimes|string|in:None,DropBox,Swift,Local', 'public_storage_type' => 'sometimes|string|in:None,DropBox,Swift,Local' 'type_id' => 'sometimes|int', 'presentation_types' => 'sometimes|int_array', DELETE api/v1/summits/{id}/media-upload-types/{media_upload_type_id} PUT api/v1/summits/{id}/media-upload-types/{media_upload_type_id}/presentation-types/{event_type_id} DELETE api/v1/summits/{id}/media-upload-types/{media_upload_type_id}/presentation-types/{event_type_id} GET api/v1/summits/{id}/presentations/{presentation_id}/media-uploads POST api/v1/summits/{id}/presentations/{presentation_id}/media-uploads payload multiform file media_upload_type_id GET api/v1/summits/{id}/presentations/{presentation_id}/media-uploads/{media_upload_id} PUT api/v1/summits/{id}/presentations/{presentation_id}/media-uploads/{media_upload_id} payload multiform file DELETE api/v1/summits/{id}/presentations/{presentation_id}/media-uploads/{media_upload_id} POST /api/v1/summits/{id}/media-upload-types/all/clone/{to_summit_id} Summit Invitation Only endpoints V2 CRUD invitations Change-Id: Ia23c247a59c3810f2a738265efdd890fe6f59dfb Signed-off-by: smarcet <smarcet@gmail.com>
1077 lines
36 KiB
PHP
1077 lines
36 KiB
PHP
<?php namespace App\Http\Controllers;
|
|
/**
|
|
* Copyright 2019 OpenStack Foundation
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
**/
|
|
|
|
use App\Http\Utils\BooleanCellFormatter;
|
|
use App\Http\Utils\EpochCellFormatter;
|
|
use App\Http\Utils\PagingConstants;
|
|
use Exception;
|
|
use Illuminate\Support\Facades\Input;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Support\Facades\Request;
|
|
use Illuminate\Support\Facades\Validator;
|
|
use models\exceptions\EntityNotFoundException;
|
|
use models\exceptions\ValidationException;
|
|
use models\summit\SummitBookableVenueRoom;
|
|
use models\summit\SummitBookableVenueRoomAvailableSlot;
|
|
use models\summit\SummitRoomReservation;
|
|
use models\summit\SummitVenue;
|
|
use ModelSerializers\SerializerRegistry;
|
|
use utils\Filter;
|
|
use utils\FilterElement;
|
|
use utils\FilterParser;
|
|
use utils\OrderParser;
|
|
use utils\PagingInfo;
|
|
use utils\PagingResponse;
|
|
use Illuminate\Http\Request as LaravelRequest;
|
|
/**
|
|
* Trait SummitBookableVenueRoomApi
|
|
* @package App\Http\Controllers
|
|
*/
|
|
trait SummitBookableVenueRoomApi
|
|
{
|
|
|
|
/**
|
|
* @param $id
|
|
* @return mixed
|
|
*/
|
|
public function getReservationById($id){
|
|
try {
|
|
|
|
$expand = Request::input('expand', '');
|
|
$relations = Request::input('relations', '');
|
|
$relations = !empty($relations) ? explode(',', $relations) : [];
|
|
|
|
$reservation = $this->reservation_repository->getById($id);
|
|
|
|
if (is_null($reservation)) {
|
|
return $this->error404();
|
|
}
|
|
|
|
return $this->ok(SerializerRegistry::getInstance()->getSerializer($reservation)->serialize($expand,[], $relations));
|
|
}
|
|
catch (ValidationException $ex1) {
|
|
Log::warning($ex1);
|
|
return $this->error412(array($ex1->getMessage()));
|
|
}
|
|
catch(EntityNotFoundException $ex2)
|
|
{
|
|
Log::warning($ex2);
|
|
return $this->error404(array('message'=> $ex2->getMessage()));
|
|
}
|
|
catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param $summit_id
|
|
* @return \Illuminate\Http\JsonResponse|mixed
|
|
*/
|
|
public function getBookableVenueRooms($summit_id){
|
|
$values = Input::all();
|
|
$rules = [
|
|
'page' => 'integer|min:1',
|
|
'per_page' => sprintf('required_with:page|integer|min:%s|max:%s', PagingConstants::MinPageSize, PagingConstants::MaxPageSize),
|
|
];
|
|
|
|
try {
|
|
|
|
$summit = $summit_id === 'current' ? $this->repository->getCurrent() : $this->repository->getById(intval($summit_id));
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$validation = Validator::make($values, $rules);
|
|
|
|
if ($validation->fails()) {
|
|
$ex = new ValidationException();
|
|
throw $ex->setMessages($validation->messages()->toArray());
|
|
}
|
|
|
|
// default values
|
|
$page = 1;
|
|
$per_page = PagingConstants::DefaultPageSize;
|
|
|
|
if (Input::has('page')) {
|
|
$page = intval(Input::get('page'));
|
|
$per_page = intval(Input::get('per_page'));
|
|
}
|
|
|
|
$filter = null;
|
|
|
|
if (Input::has('filter')) {
|
|
$filter = FilterParser::parse(Input::get('filter'), [
|
|
'name' => ['==', '=@'],
|
|
'description' => ['=@'],
|
|
'capacity' => ['>', '<', '<=', '>=', '=='],
|
|
'availability_day' => ['=='],
|
|
'attribute' => ['=='],
|
|
]);
|
|
}
|
|
if(is_null($filter)) $filter = new Filter();
|
|
|
|
$filter->validate([
|
|
'name' => 'sometimes|string',
|
|
'description' => 'sometimes|string',
|
|
'capacity' => 'sometimes|integer',
|
|
'availability_day' => 'sometimes|date_format:U',
|
|
'attribute' => 'sometimes|string',
|
|
]);
|
|
|
|
$order = null;
|
|
|
|
if (Input::has('order'))
|
|
{
|
|
$order = OrderParser::parse(Input::get('order'), [
|
|
'id',
|
|
'name',
|
|
'capacity',
|
|
]);
|
|
}
|
|
|
|
$filter->addFilterCondition(FilterParser::buildFilter('class_name','==', SummitBookableVenueRoom::ClassName));
|
|
|
|
$data = $this->location_repository->getBySummit($summit, new PagingInfo($page, $per_page), $filter, $order, false);
|
|
|
|
return $this->ok
|
|
(
|
|
$data->toArray
|
|
(
|
|
Request::input('expand', ''),
|
|
[],
|
|
[],
|
|
[]
|
|
)
|
|
);
|
|
}
|
|
catch (ValidationException $ex1)
|
|
{
|
|
Log::warning($ex1);
|
|
return $this->error412([$ex1->getMessage()]);
|
|
}
|
|
catch (EntityNotFoundException $ex2)
|
|
{
|
|
Log::warning($ex2);
|
|
return $this->error404(['message' => $ex2->getMessage()]);
|
|
}
|
|
catch(\HTTP401UnauthorizedException $ex3)
|
|
{
|
|
Log::warning($ex3);
|
|
return $this->error401();
|
|
}
|
|
catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param $summit_id
|
|
* @return mixed
|
|
*/
|
|
public function getAllReservationsBySummit($summit_id){
|
|
$values = Input::all();
|
|
$rules = [
|
|
|
|
'page' => 'integer|min:1',
|
|
'per_page' => sprintf('required_with:page|integer|min:%s|max:%s', PagingConstants::MinPageSize, PagingConstants::MaxPageSize),
|
|
];
|
|
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$validation = Validator::make($values, $rules);
|
|
|
|
if ($validation->fails()) {
|
|
$ex = new ValidationException();
|
|
throw $ex->setMessages($validation->messages()->toArray());
|
|
}
|
|
|
|
// default values
|
|
$page = 1;
|
|
$per_page = PagingConstants::DefaultPageSize;
|
|
|
|
if (Input::has('page')) {
|
|
$page = intval(Input::get('page'));
|
|
$per_page = intval(Input::get('per_page'));
|
|
}
|
|
|
|
$filter = null;
|
|
|
|
if (Input::has('filter')) {
|
|
$filter = FilterParser::parse(Input::get('filter'), [
|
|
'summit_id' => ['=='],
|
|
'room_name' => ['==', '=@'],
|
|
'room_id' => ['=='],
|
|
'owner_id' => ['=='],
|
|
'owner_name' => ['==', '=@'],
|
|
'owner_email' => ['==', '=@'],
|
|
'status' => ['=='],
|
|
'start_datetime' => ['>', '<', '<=', '>=', '=='],
|
|
'end_datetime' => ['>', '<', '<=', '>=', '=='],
|
|
]);
|
|
}
|
|
if(is_null($filter)) $filter = new Filter();
|
|
|
|
$filter->validate([
|
|
'status' => sprintf('sometimes|in:%s',implode(',', SummitRoomReservation::$valid_status)),
|
|
'room_name' => 'sometimes|string',
|
|
'owner_name' => 'sometimes|string',
|
|
'owner_email' => 'sometimes|string',
|
|
'summit_id' => 'sometimes|integer',
|
|
'room_id' => 'sometimes|integer',
|
|
'owner_id' => 'sometimes|string',
|
|
'start_datetime' => 'sometimes|required|date_format:U',
|
|
'end_datetime' => 'sometimes|required_with:start_datetime|date_format:U|after:start_datetime',
|
|
|
|
], [
|
|
'status.in' => sprintf
|
|
(
|
|
":attribute has an invalid value ( valid values are %s )",
|
|
implode(", ", SummitRoomReservation::$valid_status)
|
|
)
|
|
]);
|
|
|
|
$order = null;
|
|
|
|
if (Input::has('order'))
|
|
{
|
|
$order = OrderParser::parse(Input::get('order'), [
|
|
'id',
|
|
'start_datetime',
|
|
'end_datetime',
|
|
'room_name',
|
|
'room_id',
|
|
'status',
|
|
'created',
|
|
'owner_name',
|
|
]);
|
|
}
|
|
|
|
$data = $this->reservation_repository->getAllBySummitByPage($summit, new PagingInfo($page, $per_page), $filter, $order);
|
|
|
|
return $this->ok
|
|
(
|
|
$data->toArray
|
|
(
|
|
Request::input('expand', ''),
|
|
[],
|
|
[],
|
|
[]
|
|
)
|
|
);
|
|
}
|
|
catch (ValidationException $ex1)
|
|
{
|
|
Log::warning($ex1);
|
|
return $this->error412(array( $ex1->getMessage()));
|
|
}
|
|
catch (EntityNotFoundException $ex2)
|
|
{
|
|
Log::warning($ex2);
|
|
return $this->error404(array('message' => $ex2->getMessage()));
|
|
}
|
|
catch(\HTTP401UnauthorizedException $ex3)
|
|
{
|
|
Log::warning($ex3);
|
|
return $this->error401();
|
|
}
|
|
catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param $summit_id
|
|
* @return mixed
|
|
*/
|
|
public function getAllReservationsBySummitCSV($summit_id){
|
|
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
// default values
|
|
$page = 1;
|
|
$per_page = PHP_INT_MAX;
|
|
|
|
$filter = null;
|
|
|
|
if (Input::has('filter')) {
|
|
$filter = FilterParser::parse(Input::get('filter'), [
|
|
'summit_id' => ['=='],
|
|
'room_name' => ['==', '=@'],
|
|
'room_id' => ['=='],
|
|
'owner_id' => ['=='],
|
|
'owner_name' => ['==', '=@'],
|
|
'owner_email' => ['==', '=@'],
|
|
'status' => ['=='],
|
|
'start_datetime' => ['>', '<', '<=', '>=', '=='],
|
|
'end_datetime' => ['>', '<', '<=', '>=', '=='],
|
|
]);
|
|
}
|
|
if(is_null($filter)) $filter = new Filter();
|
|
|
|
$filter->validate([
|
|
'status' => sprintf('sometimes|in:%s',implode(',', SummitRoomReservation::$valid_status)),
|
|
'room_name' => 'sometimes|string',
|
|
'owner_name' => 'sometimes|string',
|
|
'owner_email' => 'sometimes|string',
|
|
'summit_id' => 'sometimes|integer',
|
|
'room_id' => 'sometimes|integer',
|
|
'owner_id' => 'sometimes|string',
|
|
'start_datetime' => 'sometimes|required|date_format:U',
|
|
'end_datetime' => 'sometimes|required_with:start_datetime|date_format:U|after:start_datetime',
|
|
|
|
], [
|
|
'status.in' => sprintf
|
|
(
|
|
":attribute has an invalid value ( valid values are %s )",
|
|
implode(", ", SummitRoomReservation::$valid_status)
|
|
)
|
|
]);
|
|
|
|
$order = null;
|
|
|
|
if (Input::has('order'))
|
|
{
|
|
$order = OrderParser::parse(Input::get('order'), [
|
|
'id',
|
|
'start_datetime',
|
|
'end_datetime',
|
|
'room_name',
|
|
'room_id',
|
|
'status',
|
|
'created',
|
|
'owner_name',
|
|
]);
|
|
}
|
|
|
|
$data = $this->reservation_repository->getAllBySummitByPage($summit, new PagingInfo($page, $per_page), $filter, $order);
|
|
|
|
$filename = "bookable-rooms-reservations-" . date('Ymd');
|
|
$list = $data->toArray();
|
|
return $this->export
|
|
(
|
|
'csv',
|
|
$filename,
|
|
$list['data'],
|
|
[
|
|
'created' => new EpochCellFormatter,
|
|
'last_edited' => new EpochCellFormatter,
|
|
'start_datetime' => new EpochCellFormatter,
|
|
'end_datetime' => new EpochCellFormatter,
|
|
]
|
|
);
|
|
}
|
|
catch (ValidationException $ex1)
|
|
{
|
|
Log::warning($ex1);
|
|
return $this->error412(array( $ex1->getMessage()));
|
|
}
|
|
catch (EntityNotFoundException $ex2)
|
|
{
|
|
Log::warning($ex2);
|
|
return $this->error404(array('message' => $ex2->getMessage()));
|
|
}
|
|
catch(\HTTP401UnauthorizedException $ex3)
|
|
{
|
|
Log::warning($ex3);
|
|
return $this->error401();
|
|
}
|
|
catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param $summit_id
|
|
* @param $venue_id
|
|
* @param $room_id
|
|
* @return mixed
|
|
*/
|
|
public function getBookableVenueRoomByVenue($summit_id, $venue_id, $room_id){
|
|
try {
|
|
|
|
$expand = Request::input('expand', '');
|
|
$relations = Request::input('relations', '');
|
|
$relations = !empty($relations) ? explode(',', $relations) : [];
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$venue = $summit->getLocation(intval($venue_id));
|
|
|
|
if (is_null($venue)) {
|
|
return $this->error404();
|
|
}
|
|
|
|
if (!$venue instanceof SummitVenue) {
|
|
return $this->error404();
|
|
}
|
|
|
|
$room = $venue->getRoom(intval($room_id));
|
|
|
|
if (is_null($room) || !$room instanceof SummitBookableVenueRoom) {
|
|
return $this->error404();
|
|
}
|
|
|
|
return $this->ok(SerializerRegistry::getInstance()->getSerializer($room)->serialize($expand,[], $relations));
|
|
}
|
|
catch (ValidationException $ex1) {
|
|
Log::warning($ex1);
|
|
return $this->error412(array($ex1->getMessage()));
|
|
}
|
|
catch(EntityNotFoundException $ex2)
|
|
{
|
|
Log::warning($ex2);
|
|
return $this->error404(array('message'=> $ex2->getMessage()));
|
|
}
|
|
catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param $summit_id
|
|
* @param $venue_id
|
|
* @param $room_id
|
|
* @return mixed
|
|
*/
|
|
public function getBookableVenueRoom($summit_id, $room_id){
|
|
try {
|
|
|
|
$expand = Request::input('expand', '');
|
|
$relations = Request::input('relations', '');
|
|
$relations = !empty($relations) ? explode(',', $relations) : [];
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
|
|
$room = $summit->getLocation(intval($room_id));
|
|
|
|
if (is_null($room) || !$room instanceof SummitBookableVenueRoom) {
|
|
return $this->error404();
|
|
}
|
|
|
|
return $this->ok(SerializerRegistry::getInstance()->getSerializer($room)->serialize($expand,[], $relations));
|
|
}
|
|
catch (ValidationException $ex1) {
|
|
Log::warning($ex1);
|
|
return $this->error412(array($ex1->getMessage()));
|
|
}
|
|
catch(EntityNotFoundException $ex2)
|
|
{
|
|
Log::warning($ex2);
|
|
return $this->error404(array('message'=> $ex2->getMessage()));
|
|
}
|
|
catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
/**
|
|
* @param $summit_id
|
|
* @param $room_id
|
|
* @param $day
|
|
* @return \Illuminate\Http\JsonResponse|mixed
|
|
*/
|
|
public function getBookableVenueRoomAvailability($summit_id, $room_id, $day){
|
|
try {
|
|
$day = intval($day);
|
|
$summit = $summit_id === 'current' ? $this->repository->getCurrent() : $this->repository->getById(intval($summit_id));
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$room = $summit->getLocation($room_id);
|
|
|
|
if(!$room instanceof SummitBookableVenueRoom)
|
|
return $this->error404();
|
|
|
|
$slots_definitions = $room->getAvailableSlots(new \DateTime("@$day"));
|
|
$list = [];
|
|
foreach($slots_definitions as $slot_label => $is_free){
|
|
$dates = explode('|', $slot_label);
|
|
$list[] =
|
|
SerializerRegistry::getInstance()->getSerializer( new SummitBookableVenueRoomAvailableSlot
|
|
(
|
|
$room,
|
|
$summit->convertDateFromTimeZone2UTC(new \DateTime($dates[0], $summit->getTimeZone())),
|
|
$summit->convertDateFromTimeZone2UTC(new \DateTime($dates[1], $summit->getTimeZone())),
|
|
$is_free
|
|
))->serialize();
|
|
}
|
|
|
|
$response = new PagingResponse
|
|
(
|
|
count($list),
|
|
count($list),
|
|
1,
|
|
1,
|
|
$list
|
|
);
|
|
|
|
return $this->ok(
|
|
$response->toArray()
|
|
);
|
|
}
|
|
catch (ValidationException $ex1)
|
|
{
|
|
Log::warning($ex1);
|
|
return $this->error412([$ex1->getMessage()]);
|
|
}
|
|
catch (EntityNotFoundException $ex2)
|
|
{
|
|
Log::warning($ex2);
|
|
return $this->error404(['message' => $ex2->getMessage()]);
|
|
}
|
|
catch(\HTTP401UnauthorizedException $ex3)
|
|
{
|
|
Log::warning($ex3);
|
|
return $this->error401();
|
|
}
|
|
catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param $summit_id
|
|
* @param $room_id
|
|
* @return \Illuminate\Http\JsonResponse|mixed
|
|
*/
|
|
public function createBookableVenueRoomReservation($summit_id, $room_id){
|
|
try {
|
|
if(!Request::isJson()) return $this->error400();
|
|
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
|
|
if (is_null($current_member))
|
|
return $this->error403();
|
|
|
|
$summit = $summit_id === 'current' ? $this->repository->getCurrent() : $this->repository->getById(intval($summit_id));
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$room = $summit->getLocation($room_id);
|
|
|
|
if(!$room instanceof SummitBookableVenueRoom)
|
|
return $this->error404();
|
|
|
|
$payload = Input::json()->all();
|
|
$payload['owner_id'] = $current_member->getId();
|
|
$rules = SummitRoomReservationValidationRulesFactory::build($payload);
|
|
// Creates a Validator instance and validates the data.
|
|
$validation = Validator::make($payload, $rules);
|
|
|
|
if ($validation->fails()) {
|
|
$messages = $validation->messages()->toArray();
|
|
return $this->error412
|
|
(
|
|
$messages
|
|
);
|
|
}
|
|
|
|
$reservation = $this->location_service->addBookableRoomReservation($summit, $room_id, $payload);
|
|
|
|
return $this->created(SerializerRegistry::getInstance()->getSerializer($reservation)->serialize());
|
|
|
|
}
|
|
catch (ValidationException $ex1)
|
|
{
|
|
Log::warning($ex1);
|
|
return $this->error412([$ex1->getMessage()]);
|
|
}
|
|
catch (EntityNotFoundException $ex2)
|
|
{
|
|
Log::warning($ex2);
|
|
return $this->error404(['message' => $ex2->getMessage()]);
|
|
}
|
|
catch(\HTTP401UnauthorizedException $ex3)
|
|
{
|
|
Log::warning($ex3);
|
|
return $this->error401();
|
|
}
|
|
catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param $summit_id
|
|
* @return mixed
|
|
*/
|
|
public function getMyBookableVenueRoomReservations($summit_id){
|
|
try{
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
|
|
if (is_null($current_member))
|
|
return $this->error403();
|
|
|
|
$summit = $summit_id === 'current' ? $this->repository->getCurrent() : $this->repository->getById(intval($summit_id));
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
|
|
$reservations = $current_member->getReservationsBySummit($summit);
|
|
|
|
$response = new PagingResponse
|
|
(
|
|
count($reservations),
|
|
count($reservations),
|
|
1,
|
|
1,
|
|
$reservations
|
|
);
|
|
|
|
return $this->ok(
|
|
$response->toArray(
|
|
Request::input('expand', '')
|
|
)
|
|
);
|
|
}
|
|
catch (ValidationException $ex1)
|
|
{
|
|
Log::warning($ex1);
|
|
return $this->error412([$ex1->getMessage()]);
|
|
}
|
|
catch (EntityNotFoundException $ex2)
|
|
{
|
|
Log::warning($ex2);
|
|
return $this->error404(['message' => $ex2->getMessage()]);
|
|
}
|
|
catch(\HTTP401UnauthorizedException $ex3)
|
|
{
|
|
Log::warning($ex3);
|
|
return $this->error401();
|
|
}
|
|
catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param $summit_id
|
|
* @param $reservation_id
|
|
* @return mixed
|
|
*/
|
|
public function cancelMyBookableVenueRoomReservation($summit_id, $reservation_id){
|
|
try{
|
|
$current_member = $this->resource_server_context->getCurrentUser();
|
|
|
|
if (is_null($current_member))
|
|
return $this->error403();
|
|
|
|
$summit = $summit_id === 'current' ? $this->repository->getCurrent() : $this->repository->getById(intval($summit_id));
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$reservation = $this->location_service->cancelReservation($summit, $current_member, $reservation_id);
|
|
|
|
return $this->updated(SerializerRegistry::getInstance()->getSerializer($reservation)->serialize());
|
|
}
|
|
catch (ValidationException $ex1)
|
|
{
|
|
Log::warning($ex1);
|
|
return $this->error412([$ex1->getMessage()]);
|
|
}
|
|
catch (EntityNotFoundException $ex2)
|
|
{
|
|
Log::warning($ex2);
|
|
return $this->error404(['message' => $ex2->getMessage()]);
|
|
}
|
|
catch(\HTTP401UnauthorizedException $ex3)
|
|
{
|
|
Log::warning($ex3);
|
|
return $this->error401();
|
|
}
|
|
catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param $summit_id
|
|
* @param $venue_id
|
|
* @param $room_id
|
|
* @return mixed
|
|
*/
|
|
public function updateVenueBookableRoom($summit_id, $venue_id, $room_id){
|
|
try {
|
|
if(!Request::isJson()) return $this->error400();
|
|
$payload = Input::json()->all();
|
|
$summit = SummitFinderStrategyFactory::build($this->repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
$payload['class_name'] = SummitBookableVenueRoom::ClassName;
|
|
$rules = SummitLocationValidationRulesFactory::build($payload, true);
|
|
// Creates a Validator instance and validates the data.
|
|
$validation = Validator::make($payload, $rules);
|
|
|
|
if ($validation->fails()) {
|
|
$messages = $validation->messages()->toArray();
|
|
|
|
return $this->error412
|
|
(
|
|
$messages
|
|
);
|
|
}
|
|
|
|
$room = $this->location_service->updateVenueBookableRoom($summit, $venue_id, $room_id, $payload);
|
|
|
|
return $this->created(SerializerRegistry::getInstance()->getSerializer($room)->serialize());
|
|
}
|
|
catch (ValidationException $ex1) {
|
|
Log::warning($ex1);
|
|
return $this->error412(array($ex1->getMessage()));
|
|
}
|
|
catch(EntityNotFoundException $ex2)
|
|
{
|
|
Log::warning($ex2);
|
|
return $this->error404(array('message'=> $ex2->getMessage()));
|
|
}
|
|
catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
public function getVenueFloorBookableRoom($summit_id, $venue_id, $floor_id, $room_id){
|
|
try {
|
|
|
|
$expand = Request::input('expand', '');
|
|
$relations = Request::input('relations', '');
|
|
$relations = !empty($relations) ? explode(',', $relations) : [];
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$venue = $summit->getLocation($venue_id);
|
|
|
|
if (is_null($venue)) {
|
|
return $this->error404();
|
|
}
|
|
|
|
if (!$venue instanceof SummitVenue) {
|
|
return $this->error404();
|
|
}
|
|
|
|
$floor = $venue->getFloor($floor_id);
|
|
|
|
if (is_null($floor)) {
|
|
return $this->error404();
|
|
}
|
|
|
|
$room = $floor->getRoom($room_id);
|
|
|
|
if (is_null($room) || !$room instanceof SummitBookableVenueRoom) {
|
|
return $this->error404();
|
|
}
|
|
|
|
return $this->ok(SerializerRegistry::getInstance()->getSerializer($room)->serialize($expand,[], $relations));
|
|
}
|
|
catch (ValidationException $ex1) {
|
|
Log::warning($ex1);
|
|
return $this->error412(array($ex1->getMessage()));
|
|
}
|
|
catch(EntityNotFoundException $ex2)
|
|
{
|
|
Log::warning($ex2);
|
|
return $this->error404(array('message'=> $ex2->getMessage()));
|
|
}
|
|
catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param $summit_id
|
|
* @param $venue_id
|
|
* @param $floor_id
|
|
* @param $room_id
|
|
* @return mixed
|
|
*/
|
|
public function updateVenueFloorBookableRoom($summit_id, $venue_id, $floor_id, $room_id){
|
|
try {
|
|
if(!Request::isJson()) return $this->error400();
|
|
$payload = Input::json()->all();
|
|
$summit = SummitFinderStrategyFactory::build($this->repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
$payload['class_name'] = SummitBookableVenueRoom::ClassName;
|
|
$rules = SummitLocationValidationRulesFactory::build($payload, true);
|
|
// Creates a Validator instance and validates the data.
|
|
$validation = Validator::make($payload, $rules);
|
|
|
|
if ($validation->fails()) {
|
|
$messages = $validation->messages()->toArray();
|
|
|
|
return $this->error412
|
|
(
|
|
$messages
|
|
);
|
|
}
|
|
|
|
if(!isset($payload['floor_id']))
|
|
$payload['floor_id'] = intval($floor_id);
|
|
|
|
$room = $this->location_service->updateVenueBookableRoom($summit, $venue_id, $room_id, $payload);
|
|
|
|
return $this->created(SerializerRegistry::getInstance()->getSerializer($room)->serialize());
|
|
}
|
|
catch (ValidationException $ex1) {
|
|
Log::warning($ex1);
|
|
return $this->error412(array($ex1->getMessage()));
|
|
}
|
|
catch(EntityNotFoundException $ex2)
|
|
{
|
|
Log::warning($ex2);
|
|
return $this->error404(array('message'=> $ex2->getMessage()));
|
|
}
|
|
catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
public function deleteVenueBookableRoom($summit_id, $venue_id, $room_id){
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$this->location_service->deleteVenueBookableRoom($summit, $venue_id, $room_id);
|
|
|
|
return $this->deleted();
|
|
}
|
|
catch (ValidationException $ex1) {
|
|
Log::warning($ex1);
|
|
return $this->error412(array($ex1->getMessage()));
|
|
}
|
|
catch(EntityNotFoundException $ex2)
|
|
{
|
|
Log::warning($ex2);
|
|
return $this->error404(array('message'=> $ex2->getMessage()));
|
|
}
|
|
catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param $summit_id
|
|
* @param $venue_id
|
|
* @return mixed
|
|
*/
|
|
public function addVenueBookableRoom($summit_id, $venue_id){
|
|
try {
|
|
if(!Request::isJson()) return $this->error400();
|
|
$payload = Input::json()->all();
|
|
$summit = SummitFinderStrategyFactory::build($this->repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
$payload['class_name'] = SummitBookableVenueRoom::ClassName;
|
|
$rules = SummitLocationValidationRulesFactory::build($payload);
|
|
// Creates a Validator instance and validates the data.
|
|
$validation = Validator::make($payload, $rules);
|
|
|
|
if ($validation->fails()) {
|
|
$messages = $validation->messages()->toArray();
|
|
|
|
return $this->error412
|
|
(
|
|
$messages
|
|
);
|
|
}
|
|
|
|
$room = $this->location_service->addVenueBookableRoom($summit, $venue_id, $payload);
|
|
|
|
return $this->created(SerializerRegistry::getInstance()->getSerializer($room)->serialize());
|
|
}
|
|
catch (ValidationException $ex1) {
|
|
Log::warning($ex1);
|
|
return $this->error412(array($ex1->getMessage()));
|
|
}
|
|
catch(EntityNotFoundException $ex2)
|
|
{
|
|
Log::warning($ex2);
|
|
return $this->error404(array('message'=> $ex2->getMessage()));
|
|
}
|
|
catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param $summit_id
|
|
* @param $venue_id
|
|
* @return mixed
|
|
*/
|
|
public function addVenueFloorBookableRoom($summit_id, $venue_id, $floor_id){
|
|
try {
|
|
if(!Request::isJson()) return $this->error400();
|
|
$payload = Input::json()->all();
|
|
$summit = SummitFinderStrategyFactory::build($this->repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
$payload['class_name'] = SummitBookableVenueRoom::ClassName;
|
|
$rules = SummitLocationValidationRulesFactory::build($payload);
|
|
// Creates a Validator instance and validates the data.
|
|
$validation = Validator::make($payload, $rules);
|
|
|
|
if ($validation->fails()) {
|
|
$messages = $validation->messages()->toArray();
|
|
|
|
return $this->error412
|
|
(
|
|
$messages
|
|
);
|
|
}
|
|
|
|
$payload['floor_id'] = intval($floor_id);
|
|
|
|
$room = $this->location_service->addVenueBookableRoom($summit, $venue_id, $payload);
|
|
|
|
return $this->created(SerializerRegistry::getInstance()->getSerializer($room)->serialize());
|
|
}
|
|
catch (ValidationException $ex1) {
|
|
Log::warning($ex1);
|
|
return $this->error412(array($ex1->getMessage()));
|
|
}
|
|
catch(EntityNotFoundException $ex2)
|
|
{
|
|
Log::warning($ex2);
|
|
return $this->error404(array('message'=> $ex2->getMessage()));
|
|
}
|
|
catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param $summit_id
|
|
* @param $venue_id
|
|
* @param $room_id
|
|
* @param $attribute_id
|
|
* @return mixed
|
|
*/
|
|
public function addVenueBookableRoomAttribute($summit_id, $venue_id, $room_id, $attribute_id){
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$room = $this->location_service->addVenueBookableRoomAttribute($summit, $venue_id, $room_id, $attribute_id);
|
|
|
|
return $this->created(SerializerRegistry::getInstance()->getSerializer($room)->serialize());
|
|
}
|
|
catch (ValidationException $ex1) {
|
|
Log::warning($ex1);
|
|
return $this->error412(array($ex1->getMessage()));
|
|
}
|
|
catch(EntityNotFoundException $ex2)
|
|
{
|
|
Log::warning($ex2);
|
|
return $this->error404(array('message'=> $ex2->getMessage()));
|
|
}
|
|
catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param $summit_id
|
|
* @param $venue_id
|
|
* @param $room_id
|
|
* @param $attribute_id
|
|
* @return mixed
|
|
*/
|
|
public function deleteVenueBookableRoomAttribute($summit_id, $venue_id, $room_id, $attribute_id){
|
|
try {
|
|
$summit = SummitFinderStrategyFactory::build($this->repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$room = $this->location_service->deleteVenueBookableRoomAttribute($summit, $venue_id, $room_id, $attribute_id);
|
|
|
|
return $this->deleted(SerializerRegistry::getInstance()->getSerializer($room)->serialize());
|
|
}
|
|
catch (ValidationException $ex1) {
|
|
Log::warning($ex1);
|
|
return $this->error412(array($ex1->getMessage()));
|
|
}
|
|
catch(EntityNotFoundException $ex2)
|
|
{
|
|
Log::warning($ex2);
|
|
return $this->error404(array('message'=> $ex2->getMessage()));
|
|
}
|
|
catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
public function refundBookableVenueRoomReservation($summit_id, $room_id, $reservation_id){
|
|
try {
|
|
if(!Request::isJson()) return $this->error400();
|
|
$payload = Input::json()->all();
|
|
$rules = [
|
|
'amount' => 'required|integer|greater_than:0',
|
|
];
|
|
|
|
// Creates a Validator instance and validates the data.
|
|
$validation = Validator::make($payload, $rules);
|
|
|
|
if ($validation->fails()) {
|
|
$messages = $validation->messages()->toArray();
|
|
|
|
return $this->error412
|
|
(
|
|
$messages
|
|
);
|
|
}
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$room = $summit->getLocation($room_id);
|
|
if (is_null($room)) return $this->error404();
|
|
if (!$room instanceof SummitBookableVenueRoom) return $this->error404();
|
|
|
|
$amount = intval($payload['amount']);
|
|
$reservation = $this->location_service->refundReservation($room, $reservation_id, $amount);
|
|
|
|
return SerializerRegistry::getInstance()->getSerializer($reservation)->serialize();
|
|
}
|
|
catch (ValidationException $ex1) {
|
|
Log::warning($ex1);
|
|
return $this->error412(array($ex1->getMessage()));
|
|
}
|
|
catch(EntityNotFoundException $ex2)
|
|
{
|
|
Log::warning($ex2);
|
|
return $this->error404(array('message'=> $ex2->getMessage()));
|
|
}
|
|
catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
} |