Added level filter to get scheduled events
Endpoint Change-Id: Ie47c2771589e0df78fb0a6cf0c765a712daaf3cd
This commit is contained in:
parent
e5b161a997
commit
17baf70f8c
@ -74,10 +74,18 @@ abstract class RetrieveSummitEventsStrategy
|
||||
* @return null|Filter
|
||||
*/
|
||||
protected function buildFilter(){
|
||||
$filter = null;
|
||||
|
||||
if (Input::has('filter')) {
|
||||
$filter = FilterParser::parse(Input::get('filter'), $this->getValidFilters());
|
||||
}
|
||||
|
||||
if(is_null($filter)) $filter = new Filter();
|
||||
|
||||
$filter_validator_rules = $this->getFilterValidatorRules();
|
||||
if(count($filter_validator_rules)) {
|
||||
$filter->validate($filter_validator_rules);
|
||||
}
|
||||
|
||||
return $filter;
|
||||
}
|
||||
|
||||
@ -119,6 +127,7 @@ abstract class RetrieveSummitEventsStrategy
|
||||
'abstract' => ['=@', '=='],
|
||||
'social_summary' => ['=@', '=='],
|
||||
'tags' => ['=@', '=='],
|
||||
'level' => ['=@', '=='],
|
||||
'start_date' => ['>', '<', '<=', '>=', '=='],
|
||||
'end_date' => ['>', '<', '<=', '>=', '=='],
|
||||
'summit_type_id' => ['=='],
|
||||
@ -132,4 +141,27 @@ abstract class RetrieveSummitEventsStrategy
|
||||
'id' => ['=='],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
protected function getFilterValidatorRules():array{
|
||||
return [
|
||||
'title' => 'sometimes|string',
|
||||
'abstract' => 'sometimes|string',
|
||||
'social_summary' => 'sometimes|string',
|
||||
'tags' => 'sometimes|string',
|
||||
'level' => 'sometimes|string',
|
||||
'speaker' => 'sometimes|string',
|
||||
'speaker_email' => 'sometimes|string',
|
||||
'start_date' => 'sometimes|date_format:U',
|
||||
'end_date' => 'sometimes|date_format:U',
|
||||
'summit_type_id' => 'sometimes|integer',
|
||||
'event_type_id' => 'sometimes|integer',
|
||||
'track_id' => 'sometimes|integer',
|
||||
'speaker_id' => 'sometimes|integer',
|
||||
'location_id' => 'sometimes|integer',
|
||||
'id' => 'sometimes|integer',
|
||||
];
|
||||
}
|
||||
}
|
@ -37,6 +37,13 @@ class Presentation extends SummitEvent
|
||||
const SelectionStatus_Unaccepted = 'unaccepted';
|
||||
const SelectionStatus_Alternate = 'alternate';
|
||||
|
||||
const BeginnerLevel = 'Beginner';
|
||||
const IntermediateLevel = 'Intermediate';
|
||||
const AdvancedLevel = 'Advanced';
|
||||
const NALevel = 'N/A';
|
||||
|
||||
const ValidLevels = [self::BeginnerLevel, self::IntermediateLevel, self::AdvancedLevel, self::NALevel];
|
||||
|
||||
/**
|
||||
* Defines the phase that a presentation has been created, but
|
||||
* no information has been saved to it.
|
||||
@ -231,9 +238,13 @@ class Presentation extends SummitEvent
|
||||
|
||||
/**
|
||||
* @param string $level
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function setLevel($level)
|
||||
public function setLevel(string $level):void
|
||||
{
|
||||
if(!in_array($level, self::ValidLevels))
|
||||
throw new ValidationException(sprintf("Level %s is invalid.", $level));
|
||||
|
||||
$this->level = $level;
|
||||
}
|
||||
|
||||
@ -278,7 +289,7 @@ class Presentation extends SummitEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* @return PresentationSpeaker[]
|
||||
* @return ArrayCollection
|
||||
*/
|
||||
public function getSpeakers()
|
||||
{
|
||||
|
@ -84,6 +84,7 @@ final class DoctrineSummitEventRepository
|
||||
'id' => 'e.id:json_int',
|
||||
'title' => 'e.title:json_string',
|
||||
'abstract' => 'e.abstract:json_string',
|
||||
'level' => 'p.level:json_string',
|
||||
'social_summary' => 'e.social_summary:json_string',
|
||||
'published' => 'e.published',
|
||||
'start_date' => 'e.start_date:datetime_epoch',
|
||||
|
@ -612,6 +612,39 @@ final class OAuth2SummitEventsApiTest extends ProtectedApiTest
|
||||
$this->assertTrue(!is_null($events));
|
||||
}
|
||||
|
||||
public function testGetScheduledEventsBySummitAndLevel($summit_id = 27, $level = 'N/A')
|
||||
{
|
||||
$params = [
|
||||
|
||||
'id' => $summit_id,
|
||||
'expand' => 'feedback,location,location.venue,location.floor',
|
||||
'filter' => [
|
||||
"level=={$level}"
|
||||
]
|
||||
];
|
||||
|
||||
$headers = [
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
];
|
||||
|
||||
$response = $this->action
|
||||
(
|
||||
"GET",
|
||||
"OAuth2SummitEventsApiController@getScheduledEvents",
|
||||
$params,
|
||||
array(),
|
||||
array(),
|
||||
array(),
|
||||
$headers
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(200);
|
||||
|
||||
$events = json_decode($content);
|
||||
$this->assertTrue(!is_null($events));
|
||||
}
|
||||
|
||||
public function testGetORSpeakers($summit_id=24)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user