Added new endpoints
GET /api/v1/summits/{id}/locations/metadata GET /api/v1/summits/{id}/locations Change-Id: If17e03e61c142e196dca0cd3358ea62e6def3809
This commit is contained in:
parent
74d64b113b
commit
1ebb1cd908
@ -12,6 +12,9 @@
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
use App\Http\Utils\PagingConstants;
|
||||
use App\Models\Foundation\Summit\Locations\SummitLocationConstants;
|
||||
use App\Models\Foundation\Summit\Repositories\ISummitLocationRepository;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@ -27,6 +30,7 @@ use models\summit\ISummitRepository;
|
||||
use ModelSerializers\SerializerRegistry;
|
||||
use services\model\ISummitService;
|
||||
use utils\Filter;
|
||||
use utils\FilterElement;
|
||||
use utils\FilterParser;
|
||||
use utils\FilterParserException;
|
||||
use utils\OrderParser;
|
||||
@ -59,6 +63,11 @@ final class OAuth2SummitLocationsApiController extends OAuth2ProtectedController
|
||||
*/
|
||||
private $event_feedback_repository;
|
||||
|
||||
/**
|
||||
* @var ISummitLocationRepository
|
||||
*/
|
||||
private $location_repository;
|
||||
|
||||
|
||||
public function __construct
|
||||
(
|
||||
@ -66,6 +75,7 @@ final class OAuth2SummitLocationsApiController extends OAuth2ProtectedController
|
||||
ISummitEventRepository $event_repository,
|
||||
ISpeakerRepository $speaker_repository,
|
||||
IEventFeedbackRepository $event_feedback_repository,
|
||||
ISummitLocationRepository $location_repository,
|
||||
ISummitService $service,
|
||||
IResourceServerContext $resource_server_context
|
||||
) {
|
||||
@ -74,176 +84,127 @@ final class OAuth2SummitLocationsApiController extends OAuth2ProtectedController
|
||||
$this->speaker_repository = $speaker_repository;
|
||||
$this->event_repository = $event_repository;
|
||||
$this->event_feedback_repository = $event_feedback_repository;
|
||||
$this->location_repository = $location_repository;
|
||||
$this->service = $service;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $filter_element
|
||||
* @return bool
|
||||
*/
|
||||
private function validateClassName($filter_element){
|
||||
if($filter_element instanceof FilterElement){
|
||||
return in_array($filter_element->getValue(), SummitLocationConstants::$valid_class_names);
|
||||
}
|
||||
$valid = true;
|
||||
foreach($filter_element[0] as $elem){
|
||||
$valid = $valid && in_array($elem->getValue(), SummitLocationConstants::$valid_class_names);
|
||||
}
|
||||
return $valid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLocations($summit_id)
|
||||
{
|
||||
try {
|
||||
$summit = SummitFinderStrategyFactory::build($this->repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
|
||||
//locations
|
||||
$locations = array();
|
||||
foreach ($summit->getLocations() as $location)
|
||||
{
|
||||
$locations[] = SerializerRegistry::getInstance()->getSerializer($location)->serialize();
|
||||
}
|
||||
|
||||
$response = new PagingResponse
|
||||
(
|
||||
count($locations),
|
||||
count($locations),
|
||||
1,
|
||||
1,
|
||||
$locations
|
||||
);
|
||||
|
||||
return $this->ok($response->toArray($expand = Input::get('expand','')));
|
||||
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @param $location_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLocation($summit_id, $location_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();
|
||||
|
||||
$location = $summit->getLocation($location_id);
|
||||
if (is_null($location)) {
|
||||
return $this->error404();
|
||||
}
|
||||
return $this->ok(SerializerRegistry::getInstance()->getSerializer($location)->serialize($expand,[], $relations));
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $summit_id
|
||||
* @param string $location_id
|
||||
* @param bool $published
|
||||
* @return PagingResponse
|
||||
* @throws EntityNotFoundException
|
||||
* @throws ValidationException
|
||||
*/
|
||||
private function _getLocationEvents($summit_id, $location_id, $published = true)
|
||||
{
|
||||
$summit = SummitFinderStrategyFactory::build($this->repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit))
|
||||
throw new EntityNotFoundException;
|
||||
|
||||
if(strtolower($location_id) != "tbd") {
|
||||
$location = $summit->getLocation(intval($location_id));
|
||||
if (is_null($location))
|
||||
throw new EntityNotFoundException;
|
||||
}
|
||||
|
||||
$values = Input::all();
|
||||
$rules = [
|
||||
|
||||
$rules =
|
||||
[
|
||||
'page' => 'integer|min:1',
|
||||
'per_page' => 'required_with:page|integer|min:5|max:100',
|
||||
'per_page' => sprintf('required_with:page|integer|min:%s|max:%s', PagingConstants::MinPageSize, PagingConstants::MaxPageSize),
|
||||
];
|
||||
|
||||
$validation = Validator::make($values, $rules);
|
||||
|
||||
if ($validation->fails()) {
|
||||
$ex = new ValidationException();
|
||||
throw $ex->setMessages($validation->messages()->toArray());
|
||||
}
|
||||
|
||||
// default values
|
||||
$page = 1;
|
||||
$per_page = 5;
|
||||
|
||||
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'),
|
||||
[
|
||||
'title' => ['=@', '=='],
|
||||
'start_date' => ['>', '<', '<=', '>=', '=='],
|
||||
'end_date' => ['>', '<', '<=', '>=', '=='],
|
||||
'speaker' => ['=@', '=='],
|
||||
'tags' => ['=@', '=='],
|
||||
'event_type_id' => ['=='],
|
||||
'track_id' => ['==']
|
||||
]);
|
||||
}
|
||||
|
||||
$order = null;
|
||||
|
||||
if (Input::has('order'))
|
||||
{
|
||||
$order = OrderParser::parse(Input::get('order'),
|
||||
[
|
||||
'title',
|
||||
'start_date',
|
||||
'end_date',
|
||||
'id',
|
||||
'created',
|
||||
]);
|
||||
}
|
||||
|
||||
if(is_null($filter)) $filter = new Filter();
|
||||
|
||||
$filter->addFilterCondition(FilterParser::buildFilter('summit_id','==', $summit_id));
|
||||
|
||||
if(intval($location_id) > 0)
|
||||
$filter->addFilterCondition(FilterParser::buildFilter('location_id','==', $location_id));
|
||||
|
||||
if($published)
|
||||
{
|
||||
$filter->addFilterCondition(FilterParser::buildFilter('published','==', 1));
|
||||
}
|
||||
|
||||
return strtolower($location_id) == "tbd" ?
|
||||
$this->event_repository->getAllByPageLocationTBD(new PagingInfo($page, $per_page), $filter, $order):
|
||||
$this->event_repository->getAllByPage(new PagingInfo($page, $per_page), $filter, $order);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @param $location_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLocationEvents($summit_id, $location_id)
|
||||
{
|
||||
try {
|
||||
return $this->ok($this->_getLocationEvents($summit_id, $location_id, false)->toArray(Request::input('expand', '')));
|
||||
|
||||
$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'), [
|
||||
'class_name' => ['=='],
|
||||
'name' => ['==', '=@'],
|
||||
'description' => ['=@'],
|
||||
'address1' => ['=@'],
|
||||
'address2' => ['=@'],
|
||||
'zip_code' => ['==','=@'],
|
||||
'city' => ['==','=@'],
|
||||
'state' => ['==','=@'],
|
||||
'country' => ['==','=@'],
|
||||
'sold_out' => ['=='],
|
||||
'is_main' => ['=='],
|
||||
]);
|
||||
}
|
||||
|
||||
$order = null;
|
||||
|
||||
if (Input::has('order'))
|
||||
{
|
||||
$order = OrderParser::parse(Input::get('order'), [
|
||||
'id',
|
||||
'name',
|
||||
'order'
|
||||
]);
|
||||
}
|
||||
|
||||
if(is_null($filter)) $filter = new Filter();
|
||||
|
||||
if($filter->hasFilter("class_name") && !$this->validateClassName($filter->getFilter("class_name"))){
|
||||
throw new ValidationException(
|
||||
sprintf
|
||||
(
|
||||
"class_name filter has an invalid value ( valid values are %s",
|
||||
implode(", ", SummitLocationConstants::$valid_class_names)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$data = $this->location_repository->getBySummit($summit, new PagingInfo($page, $per_page), $filter, $order);
|
||||
|
||||
return $this->ok
|
||||
(
|
||||
$data->toArray
|
||||
(
|
||||
Request::input('expand', ''),
|
||||
[],
|
||||
[],
|
||||
[]
|
||||
)
|
||||
);
|
||||
}
|
||||
catch (EntityNotFoundException $ex1) {
|
||||
catch (ValidationException $ex1)
|
||||
{
|
||||
Log::warning($ex1);
|
||||
return $this->error404();
|
||||
return $this->error412(array( $ex1->getMessage()));
|
||||
}
|
||||
catch (ValidationException $ex2) {
|
||||
catch (EntityNotFoundException $ex2)
|
||||
{
|
||||
Log::warning($ex2);
|
||||
return $this->error412($ex2->getMessages());
|
||||
return $this->error404(array('message' => $ex2->getMessage()));
|
||||
}
|
||||
catch(FilterParserException $ex3){
|
||||
catch(\HTTP401UnauthorizedException $ex3)
|
||||
{
|
||||
Log::warning($ex3);
|
||||
return $this->error412($ex3->getMessages());
|
||||
return $this->error401();
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
@ -251,31 +212,6 @@ final class OAuth2SummitLocationsApiController extends OAuth2ProtectedController
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @param $location_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLocationPublishedEvents($summit_id, $location_id)
|
||||
{
|
||||
try {
|
||||
return $this->ok($this->_getLocationEvents($summit_id, $location_id, true)->toArray(Request::input('expand', '')));
|
||||
}
|
||||
catch (EntityNotFoundException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error404();
|
||||
}
|
||||
catch (ValidationException $ex2) {
|
||||
Log::warning($ex2);
|
||||
return $this->error412($ex2->getMessages());
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @return mixed
|
||||
@ -380,7 +316,6 @@ final class OAuth2SummitLocationsApiController extends OAuth2ProtectedController
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @return mixed
|
||||
@ -414,5 +349,185 @@ final class OAuth2SummitLocationsApiController extends OAuth2ProtectedController
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @param $location_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLocation($summit_id, $location_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();
|
||||
|
||||
$location = $summit->getLocation($location_id);
|
||||
if (is_null($location)) {
|
||||
return $this->error404();
|
||||
}
|
||||
return $this->ok(SerializerRegistry::getInstance()->getSerializer($location)->serialize($expand,[], $relations));
|
||||
} catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $summit_id
|
||||
* @param string $location_id
|
||||
* @param bool $published
|
||||
* @return PagingResponse
|
||||
* @throws EntityNotFoundException
|
||||
* @throws ValidationException
|
||||
*/
|
||||
private function _getLocationEvents($summit_id, $location_id, $published = true)
|
||||
{
|
||||
$summit = SummitFinderStrategyFactory::build($this->repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit))
|
||||
throw new EntityNotFoundException;
|
||||
|
||||
if(strtolower($location_id) != "tbd") {
|
||||
$location = $summit->getLocation(intval($location_id));
|
||||
if (is_null($location))
|
||||
throw new EntityNotFoundException;
|
||||
}
|
||||
|
||||
$values = Input::all();
|
||||
|
||||
$rules =
|
||||
[
|
||||
'page' => 'integer|min:1',
|
||||
'per_page' => sprintf('required_with:page|integer|min:%s|max:%s', PagingConstants::MinPageSize, PagingConstants::MaxPageSize),
|
||||
];
|
||||
|
||||
$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'),
|
||||
[
|
||||
'title' => ['=@', '=='],
|
||||
'start_date' => ['>', '<', '<=', '>=', '=='],
|
||||
'end_date' => ['>', '<', '<=', '>=', '=='],
|
||||
'speaker' => ['=@', '=='],
|
||||
'tags' => ['=@', '=='],
|
||||
'event_type_id' => ['=='],
|
||||
'track_id' => ['==']
|
||||
]);
|
||||
}
|
||||
|
||||
$order = null;
|
||||
|
||||
if (Input::has('order'))
|
||||
{
|
||||
$order = OrderParser::parse(Input::get('order'),
|
||||
[
|
||||
'title',
|
||||
'start_date',
|
||||
'end_date',
|
||||
'id',
|
||||
'created',
|
||||
]);
|
||||
}
|
||||
|
||||
if(is_null($filter)) $filter = new Filter();
|
||||
|
||||
$filter->addFilterCondition(FilterParser::buildFilter('summit_id','==', $summit_id));
|
||||
|
||||
if(intval($location_id) > 0)
|
||||
$filter->addFilterCondition(FilterParser::buildFilter('location_id','==', $location_id));
|
||||
|
||||
if($published)
|
||||
{
|
||||
$filter->addFilterCondition(FilterParser::buildFilter('published','==', 1));
|
||||
}
|
||||
|
||||
return strtolower($location_id) == "tbd" ?
|
||||
$this->event_repository->getAllByPageLocationTBD(new PagingInfo($page, $per_page), $filter, $order):
|
||||
$this->event_repository->getAllByPage(new PagingInfo($page, $per_page), $filter, $order);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @param $location_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLocationEvents($summit_id, $location_id)
|
||||
{
|
||||
try {
|
||||
return $this->ok($this->_getLocationEvents($summit_id, $location_id, false)->toArray(Request::input('expand', '')));
|
||||
}
|
||||
catch (EntityNotFoundException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error404();
|
||||
}
|
||||
catch (ValidationException $ex2) {
|
||||
Log::warning($ex2);
|
||||
return $this->error412($ex2->getMessages());
|
||||
}
|
||||
catch(FilterParserException $ex3){
|
||||
Log::warning($ex3);
|
||||
return $this->error412($ex3->getMessages());
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @param $location_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLocationPublishedEvents($summit_id, $location_id)
|
||||
{
|
||||
try {
|
||||
return $this->ok($this->_getLocationEvents($summit_id, $location_id, true)->toArray(Request::input('expand', '')));
|
||||
}
|
||||
catch (EntityNotFoundException $ex1) {
|
||||
Log::warning($ex1);
|
||||
return $this->error404();
|
||||
}
|
||||
catch (ValidationException $ex2) {
|
||||
Log::warning($ex2);
|
||||
return $this->error412($ex2->getMessages());
|
||||
}
|
||||
catch (Exception $ex) {
|
||||
Log::error($ex);
|
||||
return $this->error500($ex);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function getMetadata($summit_id){
|
||||
$summit = SummitFinderStrategyFactory::build($this->repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
|
||||
return $this->ok
|
||||
(
|
||||
$this->location_repository->getMetadata($summit)
|
||||
);
|
||||
}
|
||||
}
|
23
app/Http/Utils/PagingConstants.php
Normal file
23
app/Http/Utils/PagingConstants.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php namespace App\Http\Utils;
|
||||
/**
|
||||
* Copyright 2018 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.
|
||||
**/
|
||||
/**
|
||||
* Class PagingConstants
|
||||
* @package App\Http\Utils
|
||||
*/
|
||||
final class PagingConstants
|
||||
{
|
||||
const DefaultPageSize = 5; // should be >= MinPageSize and <= MaxPageSize
|
||||
const MinPageSize = 5;
|
||||
const MaxPageSize = 100;
|
||||
}
|
@ -286,6 +286,8 @@ Route::group([
|
||||
Route::get('/external-locations', 'OAuth2SummitLocationsApiController@getExternalLocations');
|
||||
Route::get('/hotels', 'OAuth2SummitLocationsApiController@getHotels');
|
||||
Route::get('/airports', 'OAuth2SummitLocationsApiController@getAirports');
|
||||
Route::get('metadata', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2SummitLocationsApiController@getMetadata']);
|
||||
|
||||
Route::group(array('prefix' => '{location_id}'), function () {
|
||||
Route::get('', 'OAuth2SummitLocationsApiController@getLocation');
|
||||
Route::get('/events/published','OAuth2SummitLocationsApiController@getLocationPublishedEvents')->where('location_id', 'tbd|[0-9]+');
|
||||
|
@ -27,7 +27,7 @@ use Doctrine\ORM\Mapping AS ORM;
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Entity(repositoryClass="App\Repositories\Summit\DoctrineSummitLocationRepository")
|
||||
* @ORM\Table(name="SummitAbstractLocation")
|
||||
* @ORM\InheritanceType("JOINED")
|
||||
* @ORM\DiscriminatorColumn(name="ClassName", type="string")
|
||||
@ -41,6 +41,40 @@ class SummitAbstractLocation extends SilverstripeBaseModel
|
||||
const TypeInternal = 'Internal';
|
||||
const TypeNone = 'None';
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Name", type="string")
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Description", type="string")
|
||||
*/
|
||||
protected $description;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="LocationType", type="string")
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Order", type="integer")
|
||||
*/
|
||||
protected $order;
|
||||
|
||||
public static $metadata = [
|
||||
'name' => 'string',
|
||||
'description' => 'string',
|
||||
'type' => 'string',
|
||||
'order' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getMetadata(){
|
||||
return self::$metadata;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
@ -120,28 +154,6 @@ class SummitAbstractLocation extends SilverstripeBaseModel
|
||||
|
||||
use SummitOwned;
|
||||
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Name", type="string")
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Description", type="string")
|
||||
*/
|
||||
protected $description;
|
||||
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="LocationType", type="string")
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Order", type="integer")
|
||||
*/
|
||||
protected $order;
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
|
@ -11,9 +11,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
use Doctrine\ORM\Mapping AS ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="SummitAirport")
|
||||
@ -26,9 +24,11 @@ class SummitAirport extends SummitExternalLocation
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName(){
|
||||
return 'SummitAirport';
|
||||
return self::ClassName;
|
||||
}
|
||||
|
||||
const ClassName = 'SummitAirport';
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@ -49,4 +49,16 @@ class SummitAirport extends SummitExternalLocation
|
||||
* @ORM\Column(name="Type", type="string")
|
||||
*/
|
||||
private $airport_type;
|
||||
|
||||
public static $metadata = [
|
||||
'class_name' => self::ClassName,
|
||||
'airport_type' => 'string',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getMetadata(){
|
||||
return array_merge(SummitExternalLocation::getMetadata(), self::$metadata);
|
||||
}
|
||||
}
|
@ -11,9 +11,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
use Doctrine\ORM\Mapping AS ORM;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="SummitExternalLocation")
|
||||
@ -26,11 +24,13 @@ class SummitExternalLocation extends SummitGeoLocatedLocation
|
||||
const Lounge = 'Lounge';
|
||||
const Other = 'Other';
|
||||
|
||||
const ClassName = 'SummitExternalLocation';
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName(){
|
||||
return 'SummitExternalLocation';
|
||||
return self::ClassName;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -54,4 +54,16 @@ class SummitExternalLocation extends SummitGeoLocatedLocation
|
||||
*/
|
||||
protected $capacity;
|
||||
|
||||
public static $metadata = [
|
||||
'class_name' => self::ClassName,
|
||||
'capacity' => 'integer',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getMetadata(){
|
||||
return array_merge(SummitGeoLocatedLocation::getMetadata(), self::$metadata);
|
||||
}
|
||||
|
||||
}
|
@ -98,6 +98,28 @@ class SummitGeoLocatedLocation extends SummitAbstractLocation
|
||||
*/
|
||||
protected $images;
|
||||
|
||||
public static $metadata = [
|
||||
'address1' => 'string',
|
||||
'address2' => 'string',
|
||||
'zip_code' => 'string',
|
||||
'city' => 'string',
|
||||
'state' => 'string',
|
||||
'country' => 'string',
|
||||
'website_url' => 'string',
|
||||
'lng' => 'string',
|
||||
'lat' => 'string',
|
||||
'display_on_site' => 'boolean',
|
||||
'details_page' => 'boolean',
|
||||
'location_message' => 'string',
|
||||
'images' => 'array',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getMetadata(){
|
||||
return array_merge(SummitAbstractLocation::getMetadata(), self::$metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param SummitVenueRoom|null $room
|
||||
|
@ -26,9 +26,11 @@ class SummitHotel extends SummitExternalLocation
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName(){
|
||||
return 'SummitHotel';
|
||||
return self::ClassName;
|
||||
}
|
||||
|
||||
const ClassName = 'SummitHotel';
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@ -91,4 +93,18 @@ class SummitHotel extends SummitExternalLocation
|
||||
*/
|
||||
private $hotel_type;
|
||||
|
||||
public static $metadata = [
|
||||
'class_name' => self::ClassName,
|
||||
'hotel_type' => 'string',
|
||||
'sold_out' => 'boolean',
|
||||
'booking_link' => 'string',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getMetadata(){
|
||||
return array_merge(SummitExternalLocation::getMetadata(), self::$metadata);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
<?php namespace App\Models\Foundation\Summit\Locations;
|
||||
/**
|
||||
* Copyright 2018 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 models\summit\SummitAirport;
|
||||
use models\summit\SummitExternalLocation;
|
||||
use models\summit\SummitHotel;
|
||||
use models\summit\SummitVenue;
|
||||
/**
|
||||
* Class SummitLocationConstants
|
||||
* @package App\Models\Foundation\Summit\Locations
|
||||
*/
|
||||
final class SummitLocationConstants
|
||||
{
|
||||
public static $valid_class_names = [
|
||||
SummitVenue::ClassName,
|
||||
SummitAirport::ClassName,
|
||||
SummitHotel::ClassName,
|
||||
SummitExternalLocation::ClassName,
|
||||
];
|
||||
}
|
@ -11,11 +11,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
|
||||
use Doctrine\Common\Collections\Criteria;
|
||||
use Doctrine\ORM\Mapping AS ORM;
|
||||
use Doctrine\Common\Collections\ArrayCollection;
|
||||
|
||||
/**
|
||||
* @ORM\Entity
|
||||
* @ORM\Table(name="SummitVenue")
|
||||
@ -24,14 +22,15 @@ use Doctrine\Common\Collections\ArrayCollection;
|
||||
*/
|
||||
class SummitVenue extends SummitGeoLocatedLocation
|
||||
{
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName(){
|
||||
return 'SummitVenue';
|
||||
return self::ClassName;
|
||||
}
|
||||
|
||||
const ClassName = 'SummitVenue';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
@ -109,4 +108,19 @@ class SummitVenue extends SummitGeoLocatedLocation
|
||||
return $floor === false ? null:$floor;
|
||||
}
|
||||
|
||||
|
||||
public static $metadata = [
|
||||
'class_name' => self::ClassName,
|
||||
'is_main' => 'boolean',
|
||||
'floors' => 'array',
|
||||
'rooms' => 'array',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getMetadata(){
|
||||
return array_merge(SummitGeoLocatedLocation::getMetadata(), self::$metadata);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
<?php namespace App\Models\Foundation\Summit\Repositories;
|
||||
/**
|
||||
* Copyright 2018 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 models\summit\Summit;
|
||||
use models\utils\IBaseRepository;
|
||||
use utils\Filter;
|
||||
use utils\Order;
|
||||
use utils\PagingInfo;
|
||||
use utils\PagingResponse;
|
||||
/**
|
||||
* Interface ISummitLocationRepository
|
||||
* @package App\Models\Foundation\Summit\Repositories
|
||||
*/
|
||||
interface ISummitLocationRepository extends IBaseRepository
|
||||
{
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param PagingInfo $paging_info
|
||||
* @param Filter|null $filter
|
||||
* @param Order|null $order
|
||||
* @return PagingResponse
|
||||
*/
|
||||
public function getBySummit
|
||||
(
|
||||
Summit $summit,
|
||||
PagingInfo $paging_info,
|
||||
Filter $filter = null,
|
||||
Order $order = null
|
||||
);
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @return array
|
||||
*/
|
||||
public function getMetadata(Summit $summit);
|
||||
}
|
@ -42,5 +42,5 @@ interface ISummitRegistrationPromoCodeRepository extends IBaseRepository
|
||||
* @param Summit $summit
|
||||
* @return array
|
||||
*/
|
||||
public function getMetadata( Summit $summit);
|
||||
public function getMetadata(Summit $summit);
|
||||
}
|
@ -17,6 +17,7 @@ use App\Models\Foundation\Summit\Repositories\IDefaultSummitEventTypeRepository;
|
||||
use App\Models\Foundation\Summit\Repositories\IPresentationSpeakerSummitAssistanceConfirmationRequestRepository;
|
||||
use App\Models\Foundation\Summit\Repositories\IRSVPTemplateRepository;
|
||||
use App\Models\Foundation\Summit\Repositories\ISummitEventTypeRepository;
|
||||
use App\Models\Foundation\Summit\Repositories\ISummitLocationRepository;
|
||||
use App\Models\Foundation\Summit\Repositories\ISummitTrackRepository;
|
||||
use Illuminate\Support\Facades\App;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
@ -33,6 +34,7 @@ use models\summit\PresentationCategory;
|
||||
use models\summit\PresentationSpeakerSummitAssistanceConfirmationRequest;
|
||||
use models\summit\SpeakerRegistrationRequest;
|
||||
use models\summit\SpeakerSummitRegistrationPromoCode;
|
||||
use models\summit\SummitAbstractLocation;
|
||||
use models\summit\SummitEventType;
|
||||
use models\summit\SummitRegistrationPromoCode;
|
||||
use models\summit\SummitTicketType;
|
||||
@ -299,5 +301,12 @@ final class RepositoriesProvider extends ServiceProvider
|
||||
return EntityManager::getRepository(RSVPTemplate::class);
|
||||
}
|
||||
);
|
||||
|
||||
App::singleton(
|
||||
ISummitLocationRepository::class,
|
||||
function(){
|
||||
return EntityManager::getRepository(SummitAbstractLocation::class);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
162
app/Repositories/Summit/DoctrineSummitLocationRepository.php
Normal file
162
app/Repositories/Summit/DoctrineSummitLocationRepository.php
Normal file
@ -0,0 +1,162 @@
|
||||
<?php namespace App\Repositories\Summit;
|
||||
/**
|
||||
* Copyright 2018 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\Models\Foundation\Summit\Repositories\ISummitLocationRepository;
|
||||
use App\Repositories\SilverStripeDoctrineRepository;
|
||||
use Doctrine\ORM\Tools\Pagination\Paginator;
|
||||
use models\summit\Summit;
|
||||
use models\summit\SummitAbstractLocation;
|
||||
use models\summit\SummitAirport;
|
||||
use models\summit\SummitExternalLocation;
|
||||
use models\summit\SummitGeoLocatedLocation;
|
||||
use models\summit\SummitHotel;
|
||||
use models\summit\SummitVenue;
|
||||
use utils\DoctrineInstanceOfFilterMapping;
|
||||
use utils\Filter;
|
||||
use utils\Order;
|
||||
use utils\PagingInfo;
|
||||
use utils\PagingResponse;
|
||||
/**
|
||||
* Class DoctrineSummitLocationRepository
|
||||
* @package App\Repositories\Summit
|
||||
*/
|
||||
final class DoctrineSummitLocationRepository
|
||||
extends SilverStripeDoctrineRepository
|
||||
implements ISummitLocationRepository
|
||||
{
|
||||
|
||||
private static $forbidded_classes = [
|
||||
'models\\summit\\SummitVenueRoom',
|
||||
];
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
protected function getBaseEntity()
|
||||
{
|
||||
return SummitAbstractLocation::class;
|
||||
}
|
||||
|
||||
protected function getFilterMappings()
|
||||
{
|
||||
return [
|
||||
'name' => 'al.name:json_string',
|
||||
'description' => 'al.description:json_string',
|
||||
'address1' => 'gll.address1:json_string',
|
||||
'address2' => 'gll.address2:json_string',
|
||||
'zip_code' => 'gll.zip_code:json_string',
|
||||
'city' => 'gll.city:json_string',
|
||||
'state' => 'gll.state:json_string',
|
||||
'country' => 'gll.country:json_string',
|
||||
'sold_out' => 'h.sold_out:json_boolean',
|
||||
'is_main' => 'v.is_main:json_boolean',
|
||||
'class_name' => new DoctrineInstanceOfFilterMapping(
|
||||
"al",
|
||||
[
|
||||
SummitVenue::ClassName => SummitVenue::class,
|
||||
SummitHotel::ClassName => SummitHotel::class,
|
||||
SummitExternalLocation::ClassName => SummitExternalLocation::class,
|
||||
SummitAirport::ClassName => SummitAirport::class,
|
||||
]
|
||||
)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function getOrderMappings()
|
||||
{
|
||||
return [
|
||||
'id' => 'al.id',
|
||||
'name' => 'al.name',
|
||||
'order' => 'al.order',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @param PagingInfo $paging_info
|
||||
* @param Filter|null $filter
|
||||
* @param Order|null $order
|
||||
* @return PagingResponse
|
||||
*/
|
||||
public function getBySummit
|
||||
(
|
||||
Summit $summit,
|
||||
PagingInfo $paging_info,
|
||||
Filter $filter = null,
|
||||
Order $order = null
|
||||
)
|
||||
{
|
||||
$query = $this->getEntityManager()
|
||||
->createQueryBuilder()
|
||||
->select("al")
|
||||
->from(SummitAbstractLocation::class, "al")
|
||||
->leftJoin(SummitGeoLocatedLocation::class, 'gll', 'WITH', 'gll.id = al.id')
|
||||
->leftJoin(SummitVenue::class, 'v', 'WITH', 'v.id = gll.id')
|
||||
->leftJoin(SummitExternalLocation::class, 'el', 'WITH', 'el.id = gll.id')
|
||||
->leftJoin(SummitHotel::class, 'h', 'WITH', 'h.id = el.id')
|
||||
->leftJoin(SummitAirport::class, 'ap', 'WITH', 'ap.id = el.id')
|
||||
->leftJoin('al.summit', 's')
|
||||
->where("s.id = :summit_id")
|
||||
->andWhere("not al INSTANCE OF ('" . implode("','", self::$forbidded_classes) . "')");
|
||||
|
||||
$query->setParameter("summit_id", $summit->getId());
|
||||
|
||||
if(!is_null($filter)){
|
||||
$filter->apply2Query($query, $this->getFilterMappings());
|
||||
}
|
||||
|
||||
if (!is_null($order)) {
|
||||
$order->apply2Query($query, $this->getOrderMappings());
|
||||
} else {
|
||||
//default order
|
||||
$query = $query->addOrderBy("al.id",'ASC');
|
||||
}
|
||||
|
||||
$query = $query
|
||||
->setFirstResult($paging_info->getOffset())
|
||||
->setMaxResults($paging_info->getPerPage());
|
||||
|
||||
$paginator = new Paginator($query, $fetchJoinCollection = true);
|
||||
$total = $paginator->count();
|
||||
$data = [];
|
||||
|
||||
foreach($paginator as $entity)
|
||||
$data[] = $entity;
|
||||
|
||||
return new PagingResponse
|
||||
(
|
||||
$total,
|
||||
$paging_info->getPerPage(),
|
||||
$paging_info->getCurrentPage(),
|
||||
$paging_info->getLastPage($total),
|
||||
$data
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @return array
|
||||
*/
|
||||
public function getMetadata(Summit $summit)
|
||||
{
|
||||
return [
|
||||
SummitVenue::getMetadata(),
|
||||
SummitAirport::getMetadata(),
|
||||
SummitHotel::getMetadata(),
|
||||
SummitExternalLocation::getMetadata()
|
||||
];
|
||||
}
|
||||
}
|
@ -464,7 +464,7 @@ class ApiEndpointsSeeder extends Seeder
|
||||
'scopes' => [sprintf(SummitScopes::WriteSummitData, $current_realm)],
|
||||
),
|
||||
// locations
|
||||
array(
|
||||
[
|
||||
'name' => 'get-locations',
|
||||
'route' => '/api/v1/summits/{id}/locations',
|
||||
'http_method' => 'GET',
|
||||
@ -472,8 +472,17 @@ class ApiEndpointsSeeder extends Seeder
|
||||
sprintf(SummitScopes::ReadSummitData, $current_realm),
|
||||
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
||||
],
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'get-locations-metadata',
|
||||
'route' => '/api/v1/summits/{id}/locations/metadata',
|
||||
'http_method' => 'GET',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::ReadSummitData, $current_realm),
|
||||
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'get-venues',
|
||||
'route' => '/api/v1/summits/{id}/locations/venues',
|
||||
'http_method' => 'GET',
|
||||
@ -481,8 +490,8 @@ class ApiEndpointsSeeder extends Seeder
|
||||
sprintf(SummitScopes::ReadSummitData, $current_realm),
|
||||
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
||||
],
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'get-external-locations',
|
||||
'route' => '/api/v1/summits/{id}/locations/external-locations',
|
||||
'http_method' => 'GET',
|
||||
@ -490,8 +499,8 @@ class ApiEndpointsSeeder extends Seeder
|
||||
sprintf(SummitScopes::ReadSummitData, $current_realm),
|
||||
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
||||
],
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'get-hotels',
|
||||
'route' => '/api/v1/summits/{id}/locations/hotels',
|
||||
'http_method' => 'GET',
|
||||
@ -499,8 +508,8 @@ class ApiEndpointsSeeder extends Seeder
|
||||
sprintf(SummitScopes::ReadSummitData, $current_realm),
|
||||
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
||||
],
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'get-airports',
|
||||
'route' => '/api/v1/summits/{id}/locations/airports',
|
||||
'http_method' => 'GET',
|
||||
@ -508,8 +517,8 @@ class ApiEndpointsSeeder extends Seeder
|
||||
sprintf(SummitScopes::ReadSummitData, $current_realm),
|
||||
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
||||
],
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'get-location',
|
||||
'route' => '/api/v1/summits/{id}/locations/{location_id}',
|
||||
'http_method' => 'GET',
|
||||
@ -517,8 +526,8 @@ class ApiEndpointsSeeder extends Seeder
|
||||
sprintf(SummitScopes::ReadSummitData, $current_realm),
|
||||
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
||||
],
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'get-location-events',
|
||||
'route' => '/api/v1/summits/{id}/locations/{location_id}/events',
|
||||
'http_method' => 'GET',
|
||||
@ -526,8 +535,8 @@ class ApiEndpointsSeeder extends Seeder
|
||||
sprintf(SummitScopes::ReadSummitData, $current_realm),
|
||||
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
||||
],
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'name' => 'get-location-published-events',
|
||||
'route' => '/api/v1/summits/{id}/locations/{location_id}/events/published',
|
||||
'http_method' => 'GET',
|
||||
@ -535,7 +544,7 @@ class ApiEndpointsSeeder extends Seeder
|
||||
sprintf(SummitScopes::ReadSummitData, $current_realm),
|
||||
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
||||
],
|
||||
),
|
||||
],
|
||||
// event types
|
||||
[
|
||||
'name' => 'get-event-types',
|
||||
|
@ -671,196 +671,6 @@ final class OAuth2SummitApiTest extends ProtectedApiTest
|
||||
$this->assertTrue(!is_null($events));
|
||||
}
|
||||
|
||||
public function testGetCurrentSummitLocations()
|
||||
{
|
||||
$params = array
|
||||
(
|
||||
'id' => 'current',
|
||||
);
|
||||
|
||||
$headers = array
|
||||
(
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
);
|
||||
|
||||
$response = $this->action
|
||||
(
|
||||
"GET",
|
||||
"OAuth2SummitLocationsApiController@getLocations",
|
||||
$params,
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
$headers
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(200);
|
||||
|
||||
$locations = json_decode($content);
|
||||
$this->assertTrue(!is_null($locations));
|
||||
}
|
||||
|
||||
|
||||
public function testGetCurrentSummitVenues()
|
||||
{
|
||||
$params = array
|
||||
(
|
||||
'id' => 'current',
|
||||
);
|
||||
|
||||
$headers = array
|
||||
(
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
);
|
||||
|
||||
$response = $this->action
|
||||
(
|
||||
"GET",
|
||||
"OAuth2SummitLocationsApiController@getVenues",
|
||||
$params,
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
$headers
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(200);
|
||||
|
||||
$locations = json_decode($content);
|
||||
$this->assertTrue(!is_null($locations));
|
||||
}
|
||||
|
||||
|
||||
public function testGetCurrentSummitHotels()
|
||||
{
|
||||
$params = array
|
||||
(
|
||||
'id' => 'current',
|
||||
);
|
||||
|
||||
$headers = array
|
||||
(
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
);
|
||||
|
||||
$response = $this->action
|
||||
(
|
||||
"GET",
|
||||
"OAuth2SummitLocationsApiController@getHotels",
|
||||
$params,
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
$headers
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(200);
|
||||
|
||||
$locations = json_decode($content);
|
||||
$this->assertTrue(!is_null($locations));
|
||||
}
|
||||
|
||||
public function testGetCurrentSummitAirports()
|
||||
{
|
||||
$params = array
|
||||
(
|
||||
'id' => 'current',
|
||||
);
|
||||
|
||||
$headers = array
|
||||
(
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
);
|
||||
|
||||
$response = $this->action
|
||||
(
|
||||
"GET",
|
||||
"OAuth2SummitLocationsApiController@getAirports",
|
||||
$params,
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
$headers
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(200);
|
||||
|
||||
$locations = json_decode($content);
|
||||
$this->assertTrue(!is_null($locations));
|
||||
}
|
||||
|
||||
|
||||
public function testGetCurrentSummitExternalLocations()
|
||||
{
|
||||
$params = array
|
||||
(
|
||||
'id' => 'current',
|
||||
);
|
||||
|
||||
$headers = array
|
||||
(
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
);
|
||||
|
||||
$response = $this->action
|
||||
(
|
||||
"GET",
|
||||
"OAuth2SummitLocationsApiController@getExternalLocations",
|
||||
$params,
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
$headers
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(200);
|
||||
|
||||
$locations = json_decode($content);
|
||||
$this->assertTrue(!is_null($locations));
|
||||
}
|
||||
|
||||
public function testGetCurrentSummitLocation()
|
||||
{
|
||||
$params = array
|
||||
(
|
||||
'id' => 'current',
|
||||
'location_id' => 25
|
||||
);
|
||||
|
||||
$headers = array
|
||||
(
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
);
|
||||
|
||||
$response = $this->action
|
||||
(
|
||||
"GET",
|
||||
"OAuth2SummitLocationsApiController@getLocation",
|
||||
$params,
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
$headers
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(200);
|
||||
|
||||
$locations = json_decode($content);
|
||||
$this->assertTrue(!is_null($locations));
|
||||
}
|
||||
|
||||
public function testGetCurrentSummitExternalOrder()
|
||||
{
|
||||
$params = array
|
||||
@ -958,114 +768,6 @@ final class OAuth2SummitApiTest extends ProtectedApiTest
|
||||
$this->assertTrue(!is_null($attendee));
|
||||
}
|
||||
|
||||
public function testCurrentSummitLocationEventsWithFilter($summit_id = 7)
|
||||
{
|
||||
$params = array
|
||||
(
|
||||
'id' => $summit_id,
|
||||
'page' => 1,
|
||||
'per_page' => 50,
|
||||
'location_id' => 52,
|
||||
'filter' => array
|
||||
(
|
||||
'tags=@Nova',
|
||||
'speaker=@Todd'
|
||||
)
|
||||
);
|
||||
|
||||
$headers = array
|
||||
(
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
);
|
||||
|
||||
|
||||
$response = $this->action
|
||||
(
|
||||
"GET",
|
||||
"OAuth2SummitLocationsApiController@getLocationEvents",
|
||||
$params,
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
$headers
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(200);
|
||||
|
||||
$events = json_decode($content);
|
||||
$this->assertTrue(!is_null($events));
|
||||
}
|
||||
|
||||
public function testCurrentSummitPublishedLocationEventsWithFilter()
|
||||
{
|
||||
$params = array
|
||||
(
|
||||
'id' => 23,
|
||||
'location_id' => 311,
|
||||
'filter' => [
|
||||
|
||||
'start_date>=1451479955'
|
||||
]
|
||||
);
|
||||
|
||||
$headers = array
|
||||
(
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
);
|
||||
|
||||
$response = $this->action
|
||||
(
|
||||
"GET",
|
||||
"OAuth2SummitLocationsApiController@getLocationPublishedEvents",
|
||||
$params,
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
$headers
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(200);
|
||||
|
||||
$events = json_decode($content);
|
||||
$this->assertTrue(!is_null($events));
|
||||
}
|
||||
|
||||
public function testCurrentSummitPublishedLocationTBAEvents()
|
||||
{
|
||||
$params = array
|
||||
(
|
||||
'id' => 23,
|
||||
'location_id' => "tba",
|
||||
);
|
||||
|
||||
$headers = array
|
||||
(
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
);
|
||||
|
||||
$response = $this->action
|
||||
(
|
||||
"GET",
|
||||
"OAuth2SummitLocationsApiController@getLocationPublishedEvents",
|
||||
$params,
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
$headers
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(200);
|
||||
|
||||
$events = json_decode($content);
|
||||
$this->assertTrue(!is_null($events));
|
||||
}
|
||||
|
||||
public function testAddPresentationVideo($summit_id = 7, $presentation_id = 15404)
|
||||
{
|
||||
$params = array
|
||||
|
381
tests/OAuth2SummitLocationsApiTest.php
Normal file
381
tests/OAuth2SummitLocationsApiTest.php
Normal file
@ -0,0 +1,381 @@
|
||||
<?php
|
||||
/**
|
||||
* Copyright 2018 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.
|
||||
**/
|
||||
|
||||
/**
|
||||
* Class OAuth2SummitLocationsApiTest
|
||||
*/
|
||||
final class OAuth2SummitLocationsApiTest extends ProtectedApiTest
|
||||
{
|
||||
public function testGetCurrentSummitLocations($summit_id = 23)
|
||||
{
|
||||
$params = [
|
||||
'id' => $summit_id,
|
||||
'page' => 1,
|
||||
'per_page' => 5,
|
||||
'order' => '-order'
|
||||
];
|
||||
|
||||
$headers =
|
||||
[
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
];
|
||||
|
||||
$response = $this->action
|
||||
(
|
||||
"GET",
|
||||
"OAuth2SummitLocationsApiController@getLocations",
|
||||
$params,
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
$headers
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(200);
|
||||
|
||||
$locations = json_decode($content);
|
||||
$this->assertTrue(!is_null($locations));
|
||||
}
|
||||
|
||||
public function testGetCurrentSummitLocationsMetadata($summit_id = 23)
|
||||
{
|
||||
$params = [
|
||||
'id' => $summit_id,
|
||||
];
|
||||
|
||||
$headers =
|
||||
[
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
];
|
||||
|
||||
$response = $this->action
|
||||
(
|
||||
"GET",
|
||||
"OAuth2SummitLocationsApiController@getMetadata",
|
||||
$params,
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
$headers
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(200);
|
||||
|
||||
$metadata = json_decode($content);
|
||||
$this->assertTrue(!is_null($metadata));
|
||||
}
|
||||
|
||||
public function testGetCurrentSummitLocationsByClassNameVenueORAirport($summit_id = 24)
|
||||
{
|
||||
$params = [
|
||||
'id' => $summit_id,
|
||||
'page' => 1,
|
||||
'per_page' => 5,
|
||||
'filter' => [
|
||||
'class_name=='.\models\summit\SummitVenue::ClassName.',class_name=='.\models\summit\SummitAirport::ClassName,
|
||||
]
|
||||
];
|
||||
|
||||
$headers =
|
||||
[
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
];
|
||||
|
||||
$response = $this->action
|
||||
(
|
||||
"GET",
|
||||
"OAuth2SummitLocationsApiController@getLocations",
|
||||
$params,
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
$headers
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(200);
|
||||
|
||||
$locations = json_decode($content);
|
||||
$this->assertTrue(!is_null($locations));
|
||||
}
|
||||
|
||||
public function testGetCurrentSummitVenues()
|
||||
{
|
||||
$params = array
|
||||
(
|
||||
'id' => 'current',
|
||||
);
|
||||
|
||||
$headers = array
|
||||
(
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
);
|
||||
|
||||
$response = $this->action
|
||||
(
|
||||
"GET",
|
||||
"OAuth2SummitLocationsApiController@getVenues",
|
||||
$params,
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
$headers
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(200);
|
||||
|
||||
$locations = json_decode($content);
|
||||
$this->assertTrue(!is_null($locations));
|
||||
}
|
||||
|
||||
public function testGetCurrentSummitHotels()
|
||||
{
|
||||
$params = array
|
||||
(
|
||||
'id' => 'current',
|
||||
);
|
||||
|
||||
$headers = array
|
||||
(
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
);
|
||||
|
||||
$response = $this->action
|
||||
(
|
||||
"GET",
|
||||
"OAuth2SummitLocationsApiController@getHotels",
|
||||
$params,
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
$headers
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(200);
|
||||
|
||||
$locations = json_decode($content);
|
||||
$this->assertTrue(!is_null($locations));
|
||||
}
|
||||
|
||||
public function testGetCurrentSummitAirports()
|
||||
{
|
||||
$params = array
|
||||
(
|
||||
'id' => 'current',
|
||||
);
|
||||
|
||||
$headers = array
|
||||
(
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
);
|
||||
|
||||
$response = $this->action
|
||||
(
|
||||
"GET",
|
||||
"OAuth2SummitLocationsApiController@getAirports",
|
||||
$params,
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
$headers
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(200);
|
||||
|
||||
$locations = json_decode($content);
|
||||
$this->assertTrue(!is_null($locations));
|
||||
}
|
||||
|
||||
public function testGetCurrentSummitExternalLocations()
|
||||
{
|
||||
$params = array
|
||||
(
|
||||
'id' => 'current',
|
||||
);
|
||||
|
||||
$headers = array
|
||||
(
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
);
|
||||
|
||||
$response = $this->action
|
||||
(
|
||||
"GET",
|
||||
"OAuth2SummitLocationsApiController@getExternalLocations",
|
||||
$params,
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
$headers
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(200);
|
||||
|
||||
$locations = json_decode($content);
|
||||
$this->assertTrue(!is_null($locations));
|
||||
}
|
||||
|
||||
public function testGetCurrentSummitLocation()
|
||||
{
|
||||
$params = array
|
||||
(
|
||||
'id' => 'current',
|
||||
'location_id' => 25
|
||||
);
|
||||
|
||||
$headers = array
|
||||
(
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
);
|
||||
|
||||
$response = $this->action
|
||||
(
|
||||
"GET",
|
||||
"OAuth2SummitLocationsApiController@getLocation",
|
||||
$params,
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
$headers
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(200);
|
||||
|
||||
$locations = json_decode($content);
|
||||
$this->assertTrue(!is_null($locations));
|
||||
}
|
||||
|
||||
public function testCurrentSummitLocationEventsWithFilter($summit_id = 7)
|
||||
{
|
||||
$params = array
|
||||
(
|
||||
'id' => $summit_id,
|
||||
'page' => 1,
|
||||
'per_page' => 50,
|
||||
'location_id' => 52,
|
||||
'filter' => array
|
||||
(
|
||||
'tags=@Nova',
|
||||
'speaker=@Todd'
|
||||
)
|
||||
);
|
||||
|
||||
$headers = array
|
||||
(
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
);
|
||||
|
||||
|
||||
$response = $this->action
|
||||
(
|
||||
"GET",
|
||||
"OAuth2SummitLocationsApiController@getLocationEvents",
|
||||
$params,
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
$headers
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(200);
|
||||
|
||||
$events = json_decode($content);
|
||||
$this->assertTrue(!is_null($events));
|
||||
}
|
||||
|
||||
public function testCurrentSummitPublishedLocationEventsWithFilter()
|
||||
{
|
||||
$params = array
|
||||
(
|
||||
'id' => 23,
|
||||
'location_id' => 311,
|
||||
'filter' => [
|
||||
|
||||
'start_date>=1451479955'
|
||||
]
|
||||
);
|
||||
|
||||
$headers = array
|
||||
(
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
);
|
||||
|
||||
$response = $this->action
|
||||
(
|
||||
"GET",
|
||||
"OAuth2SummitLocationsApiController@getLocationPublishedEvents",
|
||||
$params,
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
$headers
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(200);
|
||||
|
||||
$events = json_decode($content);
|
||||
$this->assertTrue(!is_null($events));
|
||||
}
|
||||
|
||||
public function testCurrentSummitPublishedLocationTBAEvents()
|
||||
{
|
||||
$params = array
|
||||
(
|
||||
'id' => 23,
|
||||
'location_id' => "tba",
|
||||
);
|
||||
|
||||
$headers = array
|
||||
(
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
);
|
||||
|
||||
$response = $this->action
|
||||
(
|
||||
"GET",
|
||||
"OAuth2SummitLocationsApiController@getLocationPublishedEvents",
|
||||
$params,
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
$headers
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(200);
|
||||
|
||||
$events = json_decode($content);
|
||||
$this->assertTrue(!is_null($events));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user