Added get ticket types endpoints
GET /api/v1/summits/{id}/ticket-types GET /api/v1/summits/{id}/ticket-types/csv Filters * name (=@, ==) * description (=@, ==) * external_id (=@, ==) Order * id * name * external_id Change-Id: I0988947da1d9913b7507d9b30912d47f38773a64
This commit is contained in:
parent
d2a9492239
commit
9a360b00b1
@ -69,21 +69,6 @@ final class OAuth2SummitsEventTypesApiController extends OAuth2ProtectedControll
|
||||
$this->event_type_service = $event_type_service;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $filter_element
|
||||
* @return bool
|
||||
*/
|
||||
private function validateClassName($filter_element){
|
||||
if($filter_element instanceof FilterElement){
|
||||
return in_array($filter_element->getValue(), SummitEventTypeConstants::$valid_class_names);
|
||||
}
|
||||
$valid = true;
|
||||
foreach($filter_element[0] as $elem){
|
||||
$valid = $valid && in_array($elem->getValue(), SummitEventTypeConstants::$valid_class_names);
|
||||
}
|
||||
return $valid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @return mixed
|
||||
@ -136,6 +121,29 @@ final class OAuth2SummitsEventTypesApiController extends OAuth2ProtectedControll
|
||||
]);
|
||||
}
|
||||
|
||||
if(is_null($filter)) $filter = new Filter();
|
||||
|
||||
$filter->validate([
|
||||
'class_name' => sprintf('sometimes|in:%s',implode(',', SummitEventTypeConstants::$valid_class_names)),
|
||||
'name' => 'sometimes|string',
|
||||
'is_default' => 'sometimes|boolean',
|
||||
'black_out_times' => 'sometimes|boolean',
|
||||
'use_sponsors' => 'sometimes|boolean',
|
||||
'are_sponsors_mandatory' => 'sometimes|boolean',
|
||||
'allows_attachment' => 'sometimes|boolean',
|
||||
'use_speakers' => 'sometimes|boolean',
|
||||
'are_speakers_mandatory' => 'sometimes|boolean',
|
||||
'use_moderator' => 'sometimes|boolean',
|
||||
'is_moderator_mandatory' => 'sometimes|boolean',
|
||||
'should_be_available_on_cfp' => 'sometimes|boolean',
|
||||
], [
|
||||
'class_name.in' => sprintf
|
||||
(
|
||||
":attribute has an invalid value ( valid values are %s )",
|
||||
implode(", ", SummitEventTypeConstants::$valid_class_names)
|
||||
),
|
||||
]);
|
||||
|
||||
$order = null;
|
||||
|
||||
if (Input::has('order'))
|
||||
@ -147,18 +155,6 @@ final class OAuth2SummitsEventTypesApiController extends OAuth2ProtectedControll
|
||||
]);
|
||||
}
|
||||
|
||||
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(", ", SummitEventTypeConstants::$valid_class_names)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$data = $this->repository->getBySummit($summit, new PagingInfo($page, $per_page), $filter, $order);
|
||||
|
||||
return $this->ok
|
||||
@ -242,6 +238,29 @@ final class OAuth2SummitsEventTypesApiController extends OAuth2ProtectedControll
|
||||
]);
|
||||
}
|
||||
|
||||
if(is_null($filter)) $filter = new Filter();
|
||||
|
||||
$filter->validate([
|
||||
'class_name' => sprintf('sometimes|in:%s',implode(',', SummitEventTypeConstants::$valid_class_names)),
|
||||
'name' => 'sometimes|string',
|
||||
'is_default' => 'sometimes|boolean',
|
||||
'black_out_times' => 'sometimes|boolean',
|
||||
'use_sponsors' => 'sometimes|boolean',
|
||||
'are_sponsors_mandatory' => 'sometimes|boolean',
|
||||
'allows_attachment' => 'sometimes|boolean',
|
||||
'use_speakers' => 'sometimes|boolean',
|
||||
'are_speakers_mandatory' => 'sometimes|boolean',
|
||||
'use_moderator' => 'sometimes|boolean',
|
||||
'is_moderator_mandatory' => 'sometimes|boolean',
|
||||
'should_be_available_on_cfp' => 'sometimes|boolean',
|
||||
], [
|
||||
'class_name.in' => sprintf
|
||||
(
|
||||
":attribute has an invalid value ( valid values are %s )",
|
||||
implode(", ", SummitEventTypeConstants::$valid_class_names)
|
||||
),
|
||||
]);
|
||||
|
||||
$order = null;
|
||||
|
||||
if (Input::has('order'))
|
||||
@ -253,18 +272,6 @@ final class OAuth2SummitsEventTypesApiController extends OAuth2ProtectedControll
|
||||
]);
|
||||
}
|
||||
|
||||
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(", ", SummitEventTypeConstants::$valid_class_names)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
$data = $this->repository->getBySummit($summit, new PagingInfo($page, $per_page), $filter, $order);
|
||||
|
||||
$filename = "event-types-" . date('Ymd');
|
||||
|
@ -0,0 +1,262 @@
|
||||
<?php namespace App\Http\Controllers;
|
||||
/**
|
||||
* 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\Http\Utils\EpochCellFormatter;
|
||||
use App\Services\Model\ISummitTicketTypeService;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use App\Models\Foundation\Summit\Events\SummitEventTypeConstants;
|
||||
use models\summit\ISummitTicketTypeRepository;
|
||||
use Illuminate\Support\Facades\Input;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use models\exceptions\ValidationException;
|
||||
use models\oauth2\IResourceServerContext;
|
||||
use models\summit\ISummitRepository;
|
||||
use models\exceptions\EntityNotFoundException;
|
||||
use ModelSerializers\SerializerRegistry;
|
||||
use utils\Filter;
|
||||
use utils\FilterParser;
|
||||
use utils\OrderParser;
|
||||
use utils\PagingInfo;
|
||||
use Exception;
|
||||
use utils\PagingResponse;
|
||||
/**
|
||||
* Class OAuth2SummitsTicketTypesApiController
|
||||
* @package App\Http\Controllers
|
||||
*/
|
||||
final class OAuth2SummitsTicketTypesApiController extends OAuth2ProtectedController
|
||||
{
|
||||
/**
|
||||
* @var ISummitRepository
|
||||
*/
|
||||
private $summit_repository;
|
||||
|
||||
/**
|
||||
* @var ISummitTicketTypeService
|
||||
*/
|
||||
private $ticket_type_service;
|
||||
|
||||
/**
|
||||
* OAuth2SummitsTicketTypesApiController constructor.
|
||||
* @param ISummitTicketTypeRepository $repository
|
||||
* @param ISummitRepository $summit_repository
|
||||
* @param ISummitTicketTypeService $ticket_type_service
|
||||
* @param IResourceServerContext $resource_server_context
|
||||
*/
|
||||
public function __construct
|
||||
(
|
||||
ISummitTicketTypeRepository $repository,
|
||||
ISummitRepository $summit_repository,
|
||||
ISummitTicketTypeService $ticket_type_service,
|
||||
IResourceServerContext $resource_server_context
|
||||
)
|
||||
{
|
||||
parent::__construct($resource_server_context);
|
||||
$this->repository = $repository;
|
||||
$this->summit_repository = $summit_repository;
|
||||
$this->ticket_type_service = $ticket_type_service;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function getAllBySummit($summit_id){
|
||||
$values = Input::all();
|
||||
$rules = [
|
||||
|
||||
'page' => 'integer|min:1',
|
||||
'per_page' => 'required_with:page|integer|min:5|max:100',
|
||||
];
|
||||
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_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 = 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'), [
|
||||
'name' => ['=@', '=='],
|
||||
'description' => ['=@', '=='],
|
||||
'external_id' => ['=@', '=='],
|
||||
]);
|
||||
}
|
||||
|
||||
if(is_null($filter)) $filter = new Filter();
|
||||
|
||||
$filter->validate([
|
||||
'name' => 'sometimes|string',
|
||||
'description' => 'sometimes|string',
|
||||
'external_id' => 'sometimes|string',
|
||||
]);
|
||||
|
||||
$order = null;
|
||||
|
||||
if (Input::has('order'))
|
||||
{
|
||||
$order = OrderParser::parse(Input::get('order'), [
|
||||
'id',
|
||||
'name',
|
||||
'external_id'
|
||||
]);
|
||||
}
|
||||
|
||||
$data = $this->repository->getBySummit($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 getAllBySummitCSV($summit_id){
|
||||
$values = Input::all();
|
||||
$rules = [
|
||||
];
|
||||
|
||||
try {
|
||||
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_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 = PHP_INT_MAX;
|
||||
|
||||
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' => ['=@', '=='],
|
||||
'external_id' => ['=@', '=='],
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
if(is_null($filter)) $filter = new Filter();
|
||||
|
||||
$filter->validate([
|
||||
'name' => 'sometimes|string',
|
||||
'description' => 'sometimes|string',
|
||||
'external_id' => 'sometimes|string',
|
||||
]);
|
||||
|
||||
$order = null;
|
||||
|
||||
if (Input::has('order'))
|
||||
{
|
||||
$order = OrderParser::parse(Input::get('order'), [
|
||||
'id',
|
||||
'name',
|
||||
'external_id'
|
||||
]);
|
||||
}
|
||||
|
||||
$data = $this->repository->getBySummit($summit, new PagingInfo($page, $per_page), $filter, $order);
|
||||
|
||||
$filename = "ticket-types-" . date('Ymd');
|
||||
$list = $data->toArray();
|
||||
return $this->export
|
||||
(
|
||||
'csv',
|
||||
$filename,
|
||||
$list['data'],
|
||||
[
|
||||
'created' => new EpochCellFormatter,
|
||||
'last_edited' => 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -421,6 +421,12 @@ Route::group([
|
||||
});
|
||||
});
|
||||
|
||||
// ticket types
|
||||
Route::group(['prefix' => 'ticket-types'], function () {
|
||||
Route::get('', 'OAuth2SummitsTicketTypesApiController@getAllBySummit');
|
||||
Route::get('csv', 'OAuth2SummitsTicketTypesApiController@getAllBySummitCSV');
|
||||
});
|
||||
|
||||
// external orders
|
||||
Route::group(['prefix' => 'external-orders'], function () {
|
||||
Route::get('{external_order_id}', 'OAuth2SummitApiController@getExternalOrder');
|
||||
|
@ -16,13 +16,14 @@
|
||||
* Class SummitTicketTypeSerializer
|
||||
* @package ModelSerializers
|
||||
*/
|
||||
class SummitTicketTypeSerializer extends SilverStripeSerializer
|
||||
final class SummitTicketTypeSerializer extends SilverStripeSerializer
|
||||
{
|
||||
protected static $array_mappings = array
|
||||
(
|
||||
protected static $array_mappings = [
|
||||
'Name' => 'name:json_string',
|
||||
'Description' => 'description:json_string',
|
||||
);
|
||||
'ExternalId' => 'external_id:json_string',
|
||||
'SummitId' => 'summit_id:json_int',
|
||||
];
|
||||
|
||||
/**
|
||||
* @param null $expand
|
||||
|
@ -12,11 +12,28 @@
|
||||
* limitations under the License.
|
||||
**/
|
||||
use models\utils\IBaseRepository;
|
||||
use utils\Filter;
|
||||
use utils\Order;
|
||||
use utils\PagingInfo;
|
||||
use utils\PagingResponse;
|
||||
/**
|
||||
* Interface ISummitTicketTypeRepository
|
||||
* @package models\summit
|
||||
*/
|
||||
interface ISummitTicketTypeRepository 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
|
||||
);
|
||||
}
|
@ -30,6 +30,18 @@ class SummitTicketType extends SilverstripeBaseModel
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Description", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $description;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="ExternalId", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $external_id;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
@ -62,23 +74,18 @@ class SummitTicketType extends SilverstripeBaseModel
|
||||
$this->description = $description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="Description", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $description;
|
||||
|
||||
/**
|
||||
* @ORM\Column(name="ExternalId", type="string")
|
||||
* @var string
|
||||
*/
|
||||
private $external_id;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getExternalId(){return $this->external_id; }
|
||||
|
||||
/**
|
||||
* @param string $external_id
|
||||
*/
|
||||
public function setExternalId($external_id)
|
||||
{
|
||||
$this->external_id = $external_id;
|
||||
}
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
@ -22,7 +22,6 @@ use utils\Filter;
|
||||
use utils\Order;
|
||||
use utils\PagingInfo;
|
||||
use utils\PagingResponse;
|
||||
|
||||
/**
|
||||
* Class DoctrineSummitEventTypeRepository
|
||||
* @package App\Repositories\Summit
|
||||
|
@ -12,8 +12,14 @@
|
||||
* limitations under the License.
|
||||
**/
|
||||
use App\Repositories\SilverStripeDoctrineRepository;
|
||||
use Doctrine\ORM\Tools\Pagination\Paginator;
|
||||
use models\summit\ISummitTicketTypeRepository;
|
||||
use models\summit\Summit;
|
||||
use models\summit\SummitTicketType;
|
||||
use utils\Filter;
|
||||
use utils\Order;
|
||||
use utils\PagingInfo;
|
||||
use utils\PagingResponse;
|
||||
/**
|
||||
* Class DoctrineSummitTicketTypeRepository
|
||||
* @package App\Repositories\Summit
|
||||
@ -29,4 +35,81 @@ final class DoctrineSummitTicketTypeRepository
|
||||
{
|
||||
return SummitTicketType::class;
|
||||
}
|
||||
|
||||
protected function getFilterMappings()
|
||||
{
|
||||
return [
|
||||
'name' => 'tt.name:json_string',
|
||||
'description' => 'tt.description:json_string',
|
||||
'external_id' => 'tt.external_id:json_string',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function getOrderMappings()
|
||||
{
|
||||
return [
|
||||
'name' => 'tt.name',
|
||||
'id' => 'tt.id',
|
||||
'external_id' => 'tt.external_id',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @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("tt")
|
||||
->from(SummitTicketType::class, "tt")
|
||||
->leftJoin('tt.summit', 's')
|
||||
->where("s.id = :summit_id");
|
||||
|
||||
$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("tt.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
|
||||
);
|
||||
}
|
||||
}
|
34
app/Services/Model/AbstractService.php
Normal file
34
app/Services/Model/AbstractService.php
Normal file
@ -0,0 +1,34 @@
|
||||
<?php namespace App\Services\Model;
|
||||
/**
|
||||
* 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 libs\utils\ITransactionService;
|
||||
/**
|
||||
* Class AbstractService
|
||||
* @package App\Services\Model
|
||||
*/
|
||||
abstract class AbstractService
|
||||
{
|
||||
/**
|
||||
* @var ITransactionService
|
||||
*/
|
||||
protected $tx_service;
|
||||
|
||||
/**
|
||||
* AbstractService constructor.
|
||||
* @param ITransactionService $tx_service
|
||||
*/
|
||||
public function __construct(ITransactionService $tx_service)
|
||||
{
|
||||
$this->tx_service = $tx_service;
|
||||
}
|
||||
}
|
@ -25,12 +25,13 @@ use models\summit\Summit;
|
||||
use models\summit\SummitAttendee;
|
||||
use models\summit\SummitAttendeeTicket;
|
||||
use services\apis\IEventbriteAPI;
|
||||
|
||||
/**
|
||||
* Class AttendeeService
|
||||
* @package App\Services\Model
|
||||
*/
|
||||
final class AttendeeService implements IAttendeeService
|
||||
final class AttendeeService
|
||||
extends AbstractService
|
||||
implements IAttendeeService
|
||||
{
|
||||
|
||||
/**
|
||||
@ -53,11 +54,6 @@ final class AttendeeService implements IAttendeeService
|
||||
*/
|
||||
private $ticket_repository;
|
||||
|
||||
/**
|
||||
* @var ITransactionService
|
||||
*/
|
||||
private $tx_service;
|
||||
|
||||
/**
|
||||
* @var IEventbriteAPI
|
||||
*/
|
||||
@ -74,12 +70,12 @@ final class AttendeeService implements IAttendeeService
|
||||
ITransactionService $tx_service
|
||||
)
|
||||
{
|
||||
parent::__construct($tx_service);
|
||||
$this->attendee_repository = $attendee_repository;
|
||||
$this->ticket_repository = $ticket_repository;
|
||||
$this->member_repository = $member_repository;
|
||||
$this->ticket_type_repository = $ticket_type_repository;
|
||||
$this->eventbrite_api = $eventbrite_api;
|
||||
$this->tx_service = $tx_service;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -18,7 +18,9 @@ use models\main\IFolderRepository;
|
||||
* Class FolderService
|
||||
* @package App\Services\Model
|
||||
*/
|
||||
final class FolderService implements IFolderService
|
||||
final class FolderService
|
||||
extends AbstractService
|
||||
implements IFolderService
|
||||
{
|
||||
|
||||
/**
|
||||
@ -26,11 +28,6 @@ final class FolderService implements IFolderService
|
||||
*/
|
||||
private $folder_repository;
|
||||
|
||||
/**
|
||||
* @var ITransactionService
|
||||
*/
|
||||
private $tx_service;
|
||||
|
||||
/**
|
||||
* FolderService constructor.
|
||||
* @param IFolderRepository $folder_repository
|
||||
@ -38,8 +35,8 @@ final class FolderService implements IFolderService
|
||||
*/
|
||||
public function __construct(IFolderRepository $folder_repository, ITransactionService $tx_service)
|
||||
{
|
||||
parent::__construct($tx_service);
|
||||
$this->folder_repository = $folder_repository;
|
||||
$this->tx_service = $tx_service;
|
||||
}
|
||||
|
||||
/**
|
||||
|
18
app/Services/Model/ISummitTicketTypeService.php
Normal file
18
app/Services/Model/ISummitTicketTypeService.php
Normal file
@ -0,0 +1,18 @@
|
||||
<?php namespace App\Services\Model;
|
||||
/**
|
||||
* 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.
|
||||
**/
|
||||
|
||||
interface ISummitTicketTypeService
|
||||
{
|
||||
|
||||
}
|
@ -22,16 +22,14 @@ use DateTime;
|
||||
* Class MemberService
|
||||
* @package App\Services\Model
|
||||
*/
|
||||
final class MemberService implements IMemberService
|
||||
final class MemberService
|
||||
extends AbstractService
|
||||
implements IMemberService
|
||||
{
|
||||
/**
|
||||
* @var IOrganizationRepository
|
||||
*/
|
||||
private $organization_repository;
|
||||
/**
|
||||
* @var ITransactionService
|
||||
*/
|
||||
private $tx_service;
|
||||
|
||||
/**
|
||||
* MemberService constructor.
|
||||
@ -44,8 +42,8 @@ final class MemberService implements IMemberService
|
||||
ITransactionService $tx_service
|
||||
)
|
||||
{
|
||||
parent::__construct($tx_service);
|
||||
$this->organization_repository = $organization_repository;
|
||||
$this->tx_service = $tx_service;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
use App\Events\PresentationMaterialDeleted;
|
||||
use App\Events\PresentationMaterialUpdated;
|
||||
use App\Services\Model\AbstractService;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use models\exceptions\EntityNotFoundException;
|
||||
use models\exceptions\ValidationException;
|
||||
@ -27,18 +28,15 @@ use libs\utils\ITransactionService;
|
||||
* Class PresentationService
|
||||
* @package services\model
|
||||
*/
|
||||
final class PresentationService implements IPresentationService
|
||||
final class PresentationService
|
||||
extends AbstractService
|
||||
implements IPresentationService
|
||||
{
|
||||
/**
|
||||
* @var ISummitEventRepository
|
||||
*/
|
||||
private $presentation_repository;
|
||||
|
||||
/**
|
||||
* @var ITransactionService
|
||||
*/
|
||||
private $tx_service;
|
||||
|
||||
/**
|
||||
* @var IPresentationVideoFactory
|
||||
*/
|
||||
@ -51,9 +49,9 @@ final class PresentationService implements IPresentationService
|
||||
ITransactionService $tx_service
|
||||
)
|
||||
{
|
||||
parent::__construct($tx_service);
|
||||
$this->presentation_repository = $presentation_repository;
|
||||
$this->video_factory = $video_factory;
|
||||
$this->tx_service = $tx_service;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,18 +25,15 @@ use models\summit\Summit;
|
||||
* Class RSVPTemplateService
|
||||
* @package App\Services\Model
|
||||
*/
|
||||
final class RSVPTemplateService implements IRSVPTemplateService
|
||||
final class RSVPTemplateService
|
||||
extends AbstractService
|
||||
implements IRSVPTemplateService
|
||||
{
|
||||
/**
|
||||
* @var IRSVPTemplateRepository
|
||||
*/
|
||||
private $rsvp_template_repository;
|
||||
|
||||
/**
|
||||
* @var ITransactionService
|
||||
*/
|
||||
private $tx_service;
|
||||
|
||||
/**
|
||||
* RSVPTemplateService constructor.
|
||||
* @param IRSVPTemplateRepository $rsvp_template_repository
|
||||
@ -44,8 +41,8 @@ final class RSVPTemplateService implements IRSVPTemplateService
|
||||
*/
|
||||
public function __construct(IRSVPTemplateRepository $rsvp_template_repository, ITransactionService $tx_service)
|
||||
{
|
||||
parent::__construct($tx_service);
|
||||
$this->rsvp_template_repository = $rsvp_template_repository;
|
||||
$this->tx_service = $tx_service;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -13,6 +13,7 @@
|
||||
**/
|
||||
use App\Models\Foundation\Summit\Factories\PresentationSpeakerSummitAssistanceConfirmationRequestFactory;
|
||||
use App\Models\Foundation\Summit\Repositories\IPresentationSpeakerSummitAssistanceConfirmationRequestRepository;
|
||||
use App\Services\Model\AbstractService;
|
||||
use App\Services\Model\IFolderService;
|
||||
use Illuminate\Http\UploadedFile;
|
||||
use libs\utils\ITransactionService;
|
||||
@ -39,7 +40,9 @@ use App\Http\Utils\FileUploader;
|
||||
* Class SpeakerService
|
||||
* @package services\model
|
||||
*/
|
||||
final class SpeakerService implements ISpeakerService
|
||||
final class SpeakerService
|
||||
extends AbstractService
|
||||
implements ISpeakerService
|
||||
{
|
||||
/**
|
||||
* @var ISpeakerRepository
|
||||
@ -71,17 +74,11 @@ final class SpeakerService implements ISpeakerService
|
||||
*/
|
||||
private $email_creation_request_repository;
|
||||
|
||||
/**
|
||||
* @var ITransactionService
|
||||
*/
|
||||
private $tx_service;
|
||||
|
||||
/**
|
||||
* @var IPresentationSpeakerSummitAssistanceConfirmationRequestRepository
|
||||
*/
|
||||
private $speakers_assistance_repository;
|
||||
|
||||
|
||||
/**
|
||||
* SpeakerService constructor.
|
||||
* @param ISpeakerRepository $speaker_repository
|
||||
@ -105,6 +102,7 @@ final class SpeakerService implements ISpeakerService
|
||||
ITransactionService $tx_service
|
||||
)
|
||||
{
|
||||
parent::__construct($tx_service);
|
||||
$this->speaker_repository = $speaker_repository;
|
||||
$this->member_repository = $member_repository;
|
||||
$this->folder_service = $folder_service;
|
||||
@ -112,7 +110,6 @@ final class SpeakerService implements ISpeakerService
|
||||
$this->registration_code_repository = $registration_code_repository;
|
||||
$this->email_creation_request_repository = $email_creation_request_repository;
|
||||
$this->speakers_assistance_repository = $speakers_assistance_repository;
|
||||
$this->tx_service = $tx_service;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -17,6 +17,7 @@ use App\Events\SummitEventTypeUpdated;
|
||||
use App\Models\Foundation\Summit\Factories\SummitEventTypeFactory;
|
||||
use App\Models\Foundation\Summit\Repositories\IDefaultSummitEventTypeRepository;
|
||||
use App\Models\Foundation\Summit\Repositories\ISummitEventTypeRepository;
|
||||
use App\Services\Model\AbstractService;
|
||||
use App\Services\Model\ISummitEventTypeService;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use libs\utils\ITransactionService;
|
||||
@ -28,14 +29,10 @@ use models\summit\SummitEventType;
|
||||
* Class SummitEventTypeService
|
||||
* @package App\Services
|
||||
*/
|
||||
final class SummitEventTypeService implements ISummitEventTypeService
|
||||
final class SummitEventTypeService
|
||||
extends AbstractService
|
||||
implements ISummitEventTypeService
|
||||
{
|
||||
|
||||
/**
|
||||
* @var ITransactionService
|
||||
*/
|
||||
private $tx_service;
|
||||
|
||||
/**
|
||||
* @var ISummitEventTypeRepository
|
||||
*/
|
||||
@ -59,7 +56,7 @@ final class SummitEventTypeService implements ISummitEventTypeService
|
||||
ITransactionService $tx_service
|
||||
)
|
||||
{
|
||||
$this->tx_service = $tx_service;
|
||||
parent::__construct($tx_service);
|
||||
$this->repository = $repository;
|
||||
$this->default_event_types_repository = $default_event_types_repository;
|
||||
}
|
||||
|
@ -51,18 +51,15 @@ use models\summit\SummitVenueRoom;
|
||||
* Class SummitLocationService
|
||||
* @package App\Services\Model
|
||||
*/
|
||||
final class SummitLocationService implements ILocationService
|
||||
final class SummitLocationService
|
||||
extends AbstractService
|
||||
implements ILocationService
|
||||
{
|
||||
/**
|
||||
* @var ISummitLocationRepository
|
||||
*/
|
||||
private $location_repository;
|
||||
|
||||
/**
|
||||
* @var ITransactionService
|
||||
*/
|
||||
private $tx_service;
|
||||
|
||||
/**
|
||||
* @var IGeoCodingAPI
|
||||
*/
|
||||
@ -88,10 +85,10 @@ final class SummitLocationService implements ILocationService
|
||||
ITransactionService $tx_service
|
||||
)
|
||||
{
|
||||
parent::__construct($tx_service);
|
||||
$this->location_repository = $location_repository;
|
||||
$this->geo_coding_api = $geo_coding_api;
|
||||
$this->folder_service = $folder_service;
|
||||
$this->tx_service = $tx_service;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,7 +32,9 @@ use services\model\ISummitPromoCodeService;
|
||||
* Class SummitPromoCodeService
|
||||
* @package App\Services\Model
|
||||
*/
|
||||
final class SummitPromoCodeService implements ISummitPromoCodeService
|
||||
final class SummitPromoCodeService
|
||||
extends AbstractService
|
||||
implements ISummitPromoCodeService
|
||||
{
|
||||
/**
|
||||
* @var ISummitRegistrationPromoCodeRepository
|
||||
@ -59,11 +61,6 @@ final class SummitPromoCodeService implements ISummitPromoCodeService
|
||||
*/
|
||||
private $email_creation_request_repository;
|
||||
|
||||
/**
|
||||
* @var ITransactionService
|
||||
*/
|
||||
private $tx_service;
|
||||
|
||||
/**
|
||||
* SummitPromoCodeService constructor.
|
||||
* @param ISummitRegistrationPromoCodeRepository $promo_code_repository
|
||||
@ -83,12 +80,12 @@ final class SummitPromoCodeService implements ISummitPromoCodeService
|
||||
ITransactionService $tx_service
|
||||
)
|
||||
{
|
||||
parent::__construct($tx_service);
|
||||
$this->promo_code_repository = $promo_code_repository;
|
||||
$this->member_repository = $member_repository;
|
||||
$this->company_repository = $company_repository;
|
||||
$this->speaker_repository = $speaker_repository;
|
||||
$this->email_creation_request_repository = $email_creation_request_repository;
|
||||
$this->tx_service = $tx_service;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -17,6 +17,7 @@ use App\Events\MyScheduleAdd;
|
||||
use App\Events\MyScheduleRemove;
|
||||
use App\Http\Utils\FileUploader;
|
||||
use App\Models\Utils\IntervalParser;
|
||||
use App\Services\Model\AbstractService;
|
||||
use App\Services\Model\IFolderService;
|
||||
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
|
||||
use GuzzleHttp\Exception\ClientException;
|
||||
@ -71,7 +72,9 @@ use DateInterval;
|
||||
* Class SummitService
|
||||
* @package services\model
|
||||
*/
|
||||
final class SummitService implements ISummitService
|
||||
final class SummitService
|
||||
extends AbstractService
|
||||
implements ISummitService
|
||||
{
|
||||
|
||||
/**
|
||||
@ -79,10 +82,6 @@ final class SummitService implements ISummitService
|
||||
*/
|
||||
const MIN_EVENT_MINUTES = 5;
|
||||
|
||||
/**
|
||||
* @var ITransactionService
|
||||
*/
|
||||
private $tx_service;
|
||||
|
||||
/**
|
||||
* @var ISummitEventRepository
|
||||
@ -184,6 +183,7 @@ final class SummitService implements ISummitService
|
||||
ITransactionService $tx_service
|
||||
)
|
||||
{
|
||||
parent::__construct($tx_service);
|
||||
$this->event_repository = $event_repository;
|
||||
$this->speaker_repository = $speaker_repository;
|
||||
$this->entity_events_repository = $entity_events_repository;
|
||||
@ -197,7 +197,6 @@ final class SummitService implements ISummitService
|
||||
$this->folder_service = $folder_service;
|
||||
$this->company_repository = $company_repository;
|
||||
$this->group_repository = $group_repository;
|
||||
$this->tx_service = $tx_service;
|
||||
}
|
||||
|
||||
/**
|
||||
|
24
app/Services/Model/SummitTicketTypeService.php
Normal file
24
app/Services/Model/SummitTicketTypeService.php
Normal file
@ -0,0 +1,24 @@
|
||||
<?php namespace App\Services\Model;
|
||||
/**
|
||||
* 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 SummitTicketTypeService
|
||||
* @package App\Services\Model
|
||||
*/
|
||||
final class SummitTicketTypeService
|
||||
extends AbstractService
|
||||
implements ISummitTicketTypeService
|
||||
{
|
||||
|
||||
}
|
@ -27,18 +27,15 @@ use models\summit\Summit;
|
||||
* Class SummitTrackService
|
||||
* @package App\Services\Model
|
||||
*/
|
||||
final class SummitTrackService implements ISummitTrackService
|
||||
final class SummitTrackService
|
||||
extends AbstractService
|
||||
implements ISummitTrackService
|
||||
{
|
||||
/**
|
||||
* @var ISummitTrackRepository
|
||||
*/
|
||||
private $repository;
|
||||
|
||||
/**
|
||||
* @var ITransactionService
|
||||
*/
|
||||
private $tx_service;
|
||||
|
||||
/**
|
||||
* SummitTrackService constructor.
|
||||
* @param ISummitTrackRepository $repository
|
||||
@ -46,8 +43,8 @@ final class SummitTrackService implements ISummitTrackService
|
||||
*/
|
||||
public function __construct(ISummitTrackRepository $repository, ITransactionService $tx_service)
|
||||
{
|
||||
parent::__construct($tx_service);
|
||||
$this->repository = $repository;
|
||||
$this->tx_service = $tx_service;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,11 +21,13 @@ use App\Services\Model\ILocationService;
|
||||
use App\Services\Model\IMemberService;
|
||||
use App\Services\Model\IRSVPTemplateService;
|
||||
use App\Services\Model\ISummitEventTypeService;
|
||||
use App\Services\Model\ISummitTicketTypeService;
|
||||
use App\Services\Model\ISummitTrackService;
|
||||
use App\Services\Model\SummitLocationService;
|
||||
use App\Services\Model\MemberService;
|
||||
use App\Services\Model\RSVPTemplateService;
|
||||
use App\Services\Model\SummitPromoCodeService;
|
||||
use App\Services\Model\SummitTicketTypeService;
|
||||
use App\Services\Model\SummitTrackService;
|
||||
use App\Services\SummitEventTypeService;
|
||||
use Illuminate\Support\Facades\App;
|
||||
@ -46,7 +48,6 @@ use services\model\PresentationService;
|
||||
use services\model\SpeakerService;
|
||||
use services\model\SummitService;
|
||||
use services\utils\RedisCacheService;
|
||||
|
||||
/***
|
||||
* Class ServicesProvider
|
||||
* @package services
|
||||
@ -189,6 +190,12 @@ final class ServicesProvider extends ServiceProvider
|
||||
RSVPTemplateService::class
|
||||
);
|
||||
|
||||
App::singleton
|
||||
(
|
||||
ISummitTicketTypeService::class,
|
||||
SummitTicketTypeService::class
|
||||
);
|
||||
|
||||
App::singleton(IGeoCodingAPI::class, function(){
|
||||
return new GoogleGeoCodingAPI
|
||||
(
|
||||
|
@ -1104,6 +1104,25 @@ class ApiEndpointsSeeder extends Seeder
|
||||
sprintf(SummitScopes::WriteSummitData, $current_realm)
|
||||
],
|
||||
],
|
||||
// ticket types
|
||||
[
|
||||
'name' => 'get-ticket-types',
|
||||
'route' => '/api/v1/summits/{id}/ticket-types',
|
||||
'http_method' => 'GET',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::ReadSummitData, $current_realm),
|
||||
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'get-ticket-types-csv',
|
||||
'route' => '/api/v1/summits/{id}/ticket-types/csv',
|
||||
'http_method' => 'GET',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::ReadSummitData, $current_realm),
|
||||
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
||||
],
|
||||
],
|
||||
// track groups
|
||||
array(
|
||||
'name' => 'get-track-groups',
|
||||
|
52
tests/OAuth2TicketTypesApiTest.php
Normal file
52
tests/OAuth2TicketTypesApiTest.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?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.
|
||||
**/
|
||||
|
||||
final class OAuth2TicketTypesApiTest extends ProtectedApiTest
|
||||
{
|
||||
/**
|
||||
* @param int $summit_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function testGetTicketTypes($summit_id=24){
|
||||
$params = [
|
||||
|
||||
'id' => $summit_id,
|
||||
'page' => 1,
|
||||
'per_page' => 10,
|
||||
'order' => '+name'
|
||||
];
|
||||
|
||||
$headers = [
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
];
|
||||
|
||||
$response = $this->action(
|
||||
"GET",
|
||||
"OAuth2SummitsTicketTypesApiController@getAllBySummit",
|
||||
$params,
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
$headers
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(200);
|
||||
$ticket_types = json_decode($content);
|
||||
$this->assertTrue(!is_null($ticket_types));
|
||||
return $ticket_types;
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user