
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>
810 lines
28 KiB
PHP
810 lines
28 KiB
PHP
<?php namespace App\Http\Controllers;
|
|
/**
|
|
* Copyright 2016 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\Services\Model\IAttendeeService;
|
|
use App\Services\Model\ISummitOrderService;
|
|
use Exception;
|
|
use Illuminate\Support\Facades\Log;
|
|
use Illuminate\Support\Facades\Request;
|
|
use models\exceptions\EntityNotFoundException;
|
|
use models\exceptions\ValidationException;
|
|
use models\main\IMemberRepository;
|
|
use models\main\Member;
|
|
use models\oauth2\IResourceServerContext;
|
|
use models\summit\IEventFeedbackRepository;
|
|
use models\summit\ISpeakerRepository;
|
|
use models\summit\ISummitAttendeeRepository;
|
|
use models\summit\ISummitEventRepository;
|
|
use models\summit\ISummitRepository;
|
|
use models\summit\SummitAttendee;
|
|
use ModelSerializers\SerializerRegistry;
|
|
use services\model\ISummitService;
|
|
use utils\Filter;
|
|
use utils\FilterElement;
|
|
use utils\FilterParser;
|
|
use utils\OrderParser;
|
|
use Illuminate\Support\Facades\Input;
|
|
use Illuminate\Support\Facades\Validator;
|
|
use utils\PagingInfo;
|
|
/**
|
|
* Class OAuth2SummitAttendeesApiController
|
|
* @package App\Http\Controllers
|
|
*/
|
|
final class OAuth2SummitAttendeesApiController extends OAuth2ProtectedController
|
|
{
|
|
use GetAndValidateJsonPayload;
|
|
|
|
/**
|
|
* @var ISummitService
|
|
*/
|
|
private $summit_service;
|
|
|
|
/**
|
|
* @var IAttendeeService
|
|
*/
|
|
private $attendee_service;
|
|
|
|
/**
|
|
* @var ISpeakerRepository
|
|
*/
|
|
private $speaker_repository;
|
|
|
|
/**
|
|
* @var ISummitEventRepository
|
|
*/
|
|
private $event_repository;
|
|
|
|
/**
|
|
* @var IEventFeedbackRepository
|
|
*/
|
|
private $event_feedback_repository;
|
|
|
|
/**
|
|
* @var ISummitRepository
|
|
*/
|
|
private $summit_repository;
|
|
|
|
/**
|
|
* @var IMemberRepository
|
|
*/
|
|
private $member_repository;
|
|
|
|
/**
|
|
* @var ISummitOrderService
|
|
*/
|
|
private $summit_order_service;
|
|
|
|
|
|
use ParametrizedGetAll;
|
|
|
|
/**
|
|
* OAuth2SummitAttendeesApiController constructor.
|
|
* @param ISummitAttendeeRepository $attendee_repository
|
|
* @param ISummitRepository $summit_repository
|
|
* @param ISummitEventRepository $event_repository
|
|
* @param ISpeakerRepository $speaker_repository
|
|
* @param IEventFeedbackRepository $event_feedback_repository
|
|
* @param IMemberRepository $member_repository
|
|
* @param ISummitService $summit_service
|
|
* @param IAttendeeService $attendee_service
|
|
* @param ISummitOrderService $summit_order_service
|
|
* @param IResourceServerContext $resource_server_context
|
|
*/
|
|
public function __construct
|
|
(
|
|
ISummitAttendeeRepository $attendee_repository,
|
|
ISummitRepository $summit_repository,
|
|
ISummitEventRepository $event_repository,
|
|
ISpeakerRepository $speaker_repository,
|
|
IEventFeedbackRepository $event_feedback_repository,
|
|
IMemberRepository $member_repository,
|
|
ISummitService $summit_service,
|
|
IAttendeeService $attendee_service,
|
|
ISummitOrderService $summit_order_service,
|
|
IResourceServerContext $resource_server_context
|
|
) {
|
|
parent::__construct($resource_server_context);
|
|
$this->summit_repository = $summit_repository;
|
|
$this->repository = $attendee_repository;
|
|
$this->speaker_repository = $speaker_repository;
|
|
$this->event_repository = $event_repository;
|
|
$this->event_feedback_repository = $event_feedback_repository;
|
|
$this->member_repository = $member_repository;
|
|
$this->summit_service = $summit_service;
|
|
$this->attendee_service = $attendee_service;
|
|
$this->summit_order_service = $summit_order_service;
|
|
}
|
|
|
|
/**
|
|
* Attendees endpoints
|
|
*/
|
|
|
|
/**
|
|
* @param $summit_id
|
|
* @return mixed
|
|
*/
|
|
public function getOwnAttendee($summit_id){
|
|
$expand = Request::input('expand', '');
|
|
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$type = CheckAttendeeStrategyFactory::Me;
|
|
$attendee = CheckAttendeeStrategyFactory::build($type, $this->resource_server_context)->check('me', $summit);
|
|
if(is_null($attendee)) return $this->error404();
|
|
return $this->ok(SerializerRegistry::getInstance()->getSerializer($attendee)->serialize($expand));
|
|
}
|
|
catch (\HTTP401UnauthorizedException $ex1) {
|
|
Log::warning($ex1);
|
|
return $this->error401();
|
|
}
|
|
catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param $summit_id
|
|
* @param $attendee_id
|
|
* @return mixed
|
|
*/
|
|
public function getAttendee($summit_id, $attendee_id)
|
|
{
|
|
$expand = Request::input('expand', '');
|
|
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$attendee = $this->repository->getById($attendee_id);
|
|
if(is_null($attendee)) return $this->error404();
|
|
|
|
return $this->ok
|
|
(
|
|
SerializerRegistry::getInstance()->getSerializer
|
|
(
|
|
$attendee,
|
|
SerializerRegistry::SerializerType_Private
|
|
)->serialize
|
|
(
|
|
$expand,
|
|
[],
|
|
[],
|
|
[ 'serializer_type' => SerializerRegistry::SerializerType_Private ]
|
|
));
|
|
}
|
|
catch (\HTTP401UnauthorizedException $ex1) {
|
|
Log::warning($ex1);
|
|
return $this->error401();
|
|
}
|
|
catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param $summit_id
|
|
* @param $attendee_id
|
|
* @return mixed
|
|
*/
|
|
public function getAttendeeSchedule($summit_id, $attendee_id)
|
|
{
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$attendee = CheckAttendeeStrategyFactory::build(CheckAttendeeStrategyFactory::Own, $this->resource_server_context)->check($attendee_id, $summit);
|
|
if(is_null($attendee)) return $this->error404();
|
|
|
|
$schedule = [];
|
|
foreach ($attendee->getSchedule() as $attendee_schedule)
|
|
{
|
|
if(!$summit->isEventOnSchedule($attendee_schedule->getEvent()->getId())) continue;
|
|
$schedule[] = SerializerRegistry::getInstance()->getSerializer($attendee_schedule)->serialize();
|
|
}
|
|
|
|
return $this->ok($schedule);
|
|
}
|
|
catch (\HTTP401UnauthorizedException $ex1)
|
|
{
|
|
Log::warning($ex1);
|
|
return $this->error401();
|
|
}
|
|
catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param $summit_id
|
|
* @param $attendee_id
|
|
* @param $event_id
|
|
* @return mixed
|
|
*/
|
|
public function addEventToAttendeeSchedule($summit_id, $attendee_id, $event_id)
|
|
{
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$attendee = CheckAttendeeStrategyFactory::build(CheckAttendeeStrategyFactory::Own, $this->resource_server_context)->check($attendee_id, $summit);
|
|
if (is_null($attendee)) return $this->error404();
|
|
|
|
$this->summit_service->addEventToMemberSchedule($summit, $attendee->getMember(), intval($event_id));
|
|
|
|
return $this->created();
|
|
}
|
|
catch (ValidationException $ex1)
|
|
{
|
|
Log::warning($ex1);
|
|
return $this->error412($ex1->getMessages());
|
|
}
|
|
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 $attendee_id
|
|
* @param $event_id
|
|
* @return mixed
|
|
*/
|
|
public function removeEventFromAttendeeSchedule($summit_id, $attendee_id, $event_id)
|
|
{
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$attendee = CheckAttendeeStrategyFactory::build(CheckAttendeeStrategyFactory::Own, $this->resource_server_context)->check($attendee_id, $summit);
|
|
if (is_null($attendee)) return $this->error404();
|
|
|
|
$this->summit_service->removeEventFromMemberSchedule($summit, $attendee->getMember(), intval($event_id));
|
|
|
|
return $this->deleted();
|
|
|
|
}
|
|
catch (ValidationException $ex1)
|
|
{
|
|
Log::warning($ex1);
|
|
return $this->error412($ex1->getMessages());
|
|
}
|
|
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 $attendee_id
|
|
* @param $event_id
|
|
* @return mixed
|
|
*/
|
|
public function deleteEventRSVP($summit_id, $attendee_id, $event_id){
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$event = $summit->getScheduleEvent(intval($event_id));
|
|
|
|
if (is_null($event)) {
|
|
return $this->error404();
|
|
}
|
|
|
|
$attendee = CheckAttendeeStrategyFactory::build(CheckAttendeeStrategyFactory::Own, $this->resource_server_context)->check($attendee_id, $summit);
|
|
if (is_null($attendee)) return $this->error404();
|
|
|
|
$this->summit_service->unRSVPEvent($summit, $attendee->getMember(), $event_id);
|
|
|
|
return $this->deleted();
|
|
|
|
}
|
|
catch (ValidationException $ex1)
|
|
{
|
|
Log::warning($ex1);
|
|
return $this->error412($ex1->getMessages());
|
|
}
|
|
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 getAttendeesBySummit($summit_id){
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->getResourceServerContext())->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
return $this->_getAll(
|
|
function(){
|
|
return [
|
|
'first_name' => ['=@', '=='],
|
|
'last_name' => ['=@', '=='],
|
|
'full_name' => ['=@', '=='],
|
|
'company' => ['=@', '=='],
|
|
'email' => ['=@', '=='],
|
|
'external_order_id' => ['=@', '=='],
|
|
'external_attendee_id' => ['=@', '=='],
|
|
];
|
|
},
|
|
function(){
|
|
return [
|
|
'first_name' => 'sometimes|string',
|
|
'last_name' => 'sometimes|string',
|
|
'full_name' => 'sometimes|string',
|
|
'company' => 'sometimes|string',
|
|
'email' => 'sometimes|string',
|
|
'external_order_id' => 'sometimes|string',
|
|
'external_attendee_id' => 'sometimes|string',
|
|
];
|
|
},
|
|
function()
|
|
{
|
|
return [
|
|
'first_name',
|
|
'last_name',
|
|
'company',
|
|
'id',
|
|
'external_order_id',
|
|
];
|
|
},
|
|
function($filter) use($summit){
|
|
if($filter instanceof Filter){
|
|
$filter->addFilterCondition(FilterElement::makeEqual('summit_id', $summit->getId()));
|
|
}
|
|
return $filter;
|
|
},
|
|
function(){
|
|
return SerializerRegistry::SerializerType_Private;
|
|
}
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @param $summit_id
|
|
* @return mixed
|
|
*/
|
|
public function getAttendeesBySummitCSV($summit_id){
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->getResourceServerContext())->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
return $this->_getAllCSV(
|
|
function(){
|
|
return [
|
|
'first_name' => ['=@', '=='],
|
|
'last_name' => ['=@', '=='],
|
|
'full_name' => ['=@', '=='],
|
|
'email' => ['=@', '=='],
|
|
'external_order_id' => ['=@', '=='],
|
|
'company' => ['=@', '=='],
|
|
'external_attendee_id' => ['=@', '=='],
|
|
];
|
|
},
|
|
function(){
|
|
return [
|
|
'first_name' => 'sometimes|string',
|
|
'last_name' => 'sometimes|string',
|
|
'full_name' => 'sometimes|string',
|
|
'email' => 'sometimes|string',
|
|
'external_order_id' => 'sometimes|string',
|
|
'external_attendee_id' => 'sometimes|string',
|
|
'company' => 'sometimes|string',
|
|
];
|
|
},
|
|
function()
|
|
{
|
|
return [
|
|
|
|
'first_name',
|
|
'last_name',
|
|
'id',
|
|
'external_order_id',
|
|
'company',
|
|
];
|
|
},
|
|
function($filter) use($summit){
|
|
if($filter instanceof Filter){
|
|
$filter->addFilterCondition(FilterElement::makeEqual('summit_id', $summit->getId()));
|
|
}
|
|
return $filter;
|
|
},
|
|
function(){
|
|
return SerializerRegistry::SerializerType_CSV;
|
|
},
|
|
function(){
|
|
return [];
|
|
},
|
|
function(){
|
|
return [];
|
|
},
|
|
'attendees-'
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @param int $summit_id
|
|
* @return mixed
|
|
*/
|
|
public function addAttendee($summit_id){
|
|
try {
|
|
if(!Request::isJson()) return $this->error400();
|
|
$data = Input::json();
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$rules = [
|
|
'shared_contact_info' => 'sometimes|boolean',
|
|
'summit_hall_checked_in' => 'sometimes|boolean',
|
|
'summit_hall_checked_in_date' => 'sometimes|date_format:U',
|
|
'first_name' => 'required_without:member_id|string|max:255',
|
|
'surname' => 'required_without:member_id|string|max:255',
|
|
'company' => 'sometimes|string|max:255',
|
|
'email' => 'required_without:member_id|string|max:255|email',
|
|
'member_id' => 'required_without_all:email|integer',
|
|
'extra_questions' => 'sometimes|order_extra_question_dto_array',
|
|
];
|
|
|
|
// Creates a Validator instance and validates the data.
|
|
$validation = Validator::make($data->all(), $rules);
|
|
|
|
if ($validation->fails()) {
|
|
$messages = $validation->messages()->toArray();
|
|
|
|
return $this->error412
|
|
(
|
|
$messages
|
|
);
|
|
}
|
|
|
|
$attendee = $this->attendee_service->addAttendee($summit, $data->all());
|
|
|
|
return $this->created(SerializerRegistry::getInstance()->getSerializer($attendee)->serialize());
|
|
}
|
|
catch (ValidationException $ex1) {
|
|
Log::warning($ex1);
|
|
return $this->error412($ex1->getMessages());
|
|
}
|
|
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 $attendee_id
|
|
* @return mixed
|
|
*/
|
|
public function deleteAttendee($summit_id, $attendee_id)
|
|
{
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$attendee = $this->repository->getById($attendee_id);
|
|
if(is_null($attendee)) return $this->error404();
|
|
|
|
$this->attendee_service->deleteAttendee($summit, $attendee->getIdentifier());
|
|
|
|
return $this->deleted();
|
|
|
|
}
|
|
catch (\HTTP401UnauthorizedException $ex1) {
|
|
Log::warning($ex1);
|
|
return $this->error401();
|
|
}
|
|
catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param int $summit_id
|
|
* @param int $attendee_id
|
|
* @return mixed
|
|
*/
|
|
public function updateAttendee($summit_id, $attendee_id){
|
|
try {
|
|
if(!Request::isJson()) return $this->error400();
|
|
$data = Input::json();
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$attendee = $this->repository->getById($attendee_id);
|
|
if(is_null($attendee)) return $this->error404();
|
|
|
|
$rules = [
|
|
'shared_contact_info' => 'sometimes|boolean',
|
|
'summit_hall_checked_in' => 'sometimes|boolean',
|
|
'summit_hall_checked_in_date' => 'sometimes|date_format:U',
|
|
'disclaimer_accepted_date' => 'sometimes|date_format:U',
|
|
'first_name' => 'required_without:member_id|string|max:255',
|
|
'surname' => 'required_without:member_id|string|max:255',
|
|
'company' => 'sometimes|string|max:255',
|
|
'email' => 'required_without:member_id|string|max:255|email',
|
|
'member_id' => 'required_without_all:first_name,surname,email|integer',
|
|
'extra_questions' => 'sometimes|order_extra_question_dto_array',
|
|
];
|
|
|
|
// Creates a Validator instance and validates the data.
|
|
$validation = Validator::make($data->all(), $rules);
|
|
|
|
if ($validation->fails()) {
|
|
$messages = $validation->messages()->toArray();
|
|
|
|
return $this->error412
|
|
(
|
|
$messages
|
|
);
|
|
}
|
|
|
|
$attendee = $this->attendee_service->updateAttendee($summit, $attendee_id, $data->all());
|
|
|
|
return $this->updated(SerializerRegistry::getInstance()->getSerializer($attendee)->serialize());
|
|
}
|
|
catch (ValidationException $ex1) {
|
|
Log::warning($ex1);
|
|
return $this->error412($ex1->getMessages());
|
|
}
|
|
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 $attendee_id
|
|
* @return mixed
|
|
*/
|
|
public function addAttendeeTicket($summit_id, $attendee_id){
|
|
try {
|
|
if(!Request::isJson()) return $this->error400();
|
|
$data = Input::json();
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$attendee = $this->repository->getById($attendee_id);
|
|
if(is_null($attendee) || !$attendee instanceof SummitAttendee) return $this->error404();
|
|
|
|
$rules = [
|
|
'ticket_type_id' => 'required|integer',
|
|
'promo_code' => 'nullable|string',
|
|
'external_order_id' => 'nullable|string',
|
|
'external_attendee_id' => 'nullable|string',
|
|
];
|
|
|
|
$payload = $data->all();
|
|
// 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['owner_email'] = $attendee->getEmail();
|
|
$payload['owner_first_name'] = $attendee->getFirstName();
|
|
$payload['owner_last_name'] = $attendee->getSurname();
|
|
$payload['owner_company'] = $attendee->getCompanyName();
|
|
|
|
if($attendee->hasMember())
|
|
$payload['owner_id'] = $attendee->getMemberId();
|
|
|
|
$ticket = $this->summit_order_service->createOrderSingleTicket($summit, $payload);
|
|
|
|
return $this->created(SerializerRegistry::getInstance()->getSerializer($ticket)->serialize());
|
|
}
|
|
catch (ValidationException $ex1) {
|
|
Log::warning($ex1);
|
|
return $this->error412($ex1->getMessages());
|
|
}
|
|
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 $attendee_id
|
|
* @param $ticket_id
|
|
* @return mixed
|
|
*/
|
|
public function deleteAttendeeTicket($summit_id, $attendee_id, $ticket_id){
|
|
try {
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$attendee = $this->repository->getById($attendee_id);
|
|
if(is_null($attendee)) return $this->error404();
|
|
|
|
$ticket = $this->attendee_service->deleteAttendeeTicket($attendee, $ticket_id);
|
|
|
|
return $this->deleted();
|
|
}
|
|
catch (ValidationException $ex1) {
|
|
Log::warning($ex1);
|
|
return $this->error412($ex1->getMessages());
|
|
}
|
|
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 $attendee_id
|
|
* @param $ticket_id
|
|
* @param $other_member_id
|
|
* @return mixed
|
|
*/
|
|
public function reassignAttendeeTicketByMember($summit_id, $attendee_id, $ticket_id, $other_member_id){
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$attendee = $this->repository->getById($attendee_id);
|
|
if(is_null($attendee) || !$attendee instanceof SummitAttendee) return $this->error404();
|
|
|
|
$other_member = $this->member_repository->getById($other_member_id);
|
|
if(is_null($other_member) || !$other_member instanceof Member) return $this->error404();
|
|
|
|
$ticket = $this->attendee_service->reassignAttendeeTicketByMember($summit, $attendee, $other_member, intval($ticket_id));
|
|
|
|
return $this->updated(SerializerRegistry::getInstance()->getSerializer($ticket)->serialize());
|
|
}
|
|
catch (ValidationException $ex1) {
|
|
Log::warning($ex1);
|
|
return $this->error412($ex1->getMessages());
|
|
}
|
|
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 $attendee_id
|
|
* @param $ticket_id
|
|
* @return \Illuminate\Http\JsonResponse|mixed
|
|
*/
|
|
public function reassignAttendeeTicket($summit_id, $attendee_id, $ticket_id){
|
|
try {
|
|
|
|
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
|
if (is_null($summit)) return $this->error404();
|
|
|
|
$attendee = $this->repository->getById($attendee_id);
|
|
if(is_null($attendee) || !$attendee instanceof SummitAttendee) return $this->error404();
|
|
|
|
$payload = $this->getJsonPayload([
|
|
'attendee_first_name' => 'nullable|string|max:255',
|
|
'attendee_last_name' => 'nullable|string|max:255',
|
|
'attendee_email' => 'required|string|max:255|email',
|
|
'attendee_company' => 'nullable|string|max:255',
|
|
'extra_questions' => 'sometimes|order_extra_question_dto_array'
|
|
]);
|
|
|
|
$ticket = $this->attendee_service->reassignAttendeeTicket($summit, $attendee, intval($ticket_id), $payload);
|
|
|
|
return $this->updated(SerializerRegistry::getInstance()->getSerializer($ticket)->serialize());
|
|
}
|
|
catch (ValidationException $ex1) {
|
|
Log::warning($ex1);
|
|
return $this->error412($ex1->getMessages());
|
|
}
|
|
catch(EntityNotFoundException $ex2)
|
|
{
|
|
Log::warning($ex2);
|
|
return $this->error404(array('message'=> $ex2->getMessage()));
|
|
}
|
|
catch (Exception $ex) {
|
|
Log::error($ex);
|
|
return $this->error500($ex);
|
|
}
|
|
}
|
|
/**
|
|
* @return ISummitRepository
|
|
*/
|
|
protected function getSummitRepository(): ISummitRepository
|
|
{
|
|
return $this->summit_repository;
|
|
}
|
|
} |