Added endpoints to get RSVP question template metadata
GET /api/v1/summits/{id}/rsvp-templates/questions/metadata Change-Id: Ide18c7312f991cd15ffc0d6d1b173762cf53c7b3
This commit is contained in:
parent
ca95b77816
commit
7c502e93ef
@ -218,6 +218,21 @@ final class OAuth2SummitRSVPTemplatesApiController extends OAuth2ProtectedContro
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @return mixed
|
||||
*/
|
||||
public function getRSVPTemplateQuestionsMetadata($summit_id){
|
||||
$summit = SummitFinderStrategyFactory::build($this->summit_repository, $this->resource_server_context)->find($summit_id);
|
||||
if (is_null($summit)) return $this->error404();
|
||||
|
||||
return $this->ok
|
||||
(
|
||||
$this->rsvp_template_repository->getQuestionsMetadata($summit)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $summit_id
|
||||
* @param $template_id
|
||||
|
@ -172,6 +172,11 @@ Route::group([
|
||||
// rsvp templates
|
||||
Route::group(['prefix' => 'rsvp-templates'], function () {
|
||||
Route::get('', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2SummitRSVPTemplatesApiController@getAllBySummit']);
|
||||
|
||||
Route::group(['prefix' => 'questions'], function () {
|
||||
Route::get('metadata', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2SummitRSVPTemplatesApiController@getRSVPTemplateQuestionsMetadata']);
|
||||
});
|
||||
|
||||
Route::post('', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2SummitRSVPTemplatesApiController@addRSVPTemplate']);
|
||||
Route::group(['prefix' => '{template_id}'], function () {
|
||||
Route::get('', [ 'middleware' => 'auth.user:administrators|summit-front-end-administrators', 'uses' => 'OAuth2SummitRSVPTemplatesApiController@getRSVPTemplate']);
|
||||
|
@ -27,4 +27,15 @@ class RSVPCheckBoxListQuestionTemplate extends RSVPMultiValueQuestionTemplate
|
||||
public function getClassName(){
|
||||
return self::ClassName;
|
||||
}
|
||||
|
||||
public static $metadata = [
|
||||
'class_name' => self::ClassName,
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getMetadata(){
|
||||
return array_merge(RSVPMultiValueQuestionTemplate::getMetadata(), self::$metadata);
|
||||
}
|
||||
}
|
@ -102,4 +102,19 @@ class RSVPDropDownQuestionTemplate extends RSVPMultiValueQuestionTemplate
|
||||
$this->is_multiselect = false;
|
||||
$this->is_country_selector = false;
|
||||
}
|
||||
|
||||
|
||||
public static $metadata = [
|
||||
'use_chosen_plugin' => 'boolean',
|
||||
'is_multiselect' => 'boolean',
|
||||
'is_country_selector' => 'boolean',
|
||||
'class_name' => self::ClassName,
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getMetadata(){
|
||||
return array_merge(RSVPMultiValueQuestionTemplate::getMetadata(), self::$metadata);
|
||||
}
|
||||
}
|
@ -50,5 +50,16 @@ class RSVPLiteralContentQuestionTemplate extends RSVPQuestionTemplate
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
public static $metadata = [
|
||||
'content' => 'string',
|
||||
'class_name' => self::ClassName,
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getMetadata(){
|
||||
return array_merge(RSVPQuestionTemplate::getMetadata(), self::$metadata);
|
||||
}
|
||||
|
||||
}
|
@ -27,4 +27,15 @@ class RSVPMemberEmailQuestionTemplate extends RSVPTextBoxQuestionTemplate
|
||||
public function getClassName(){
|
||||
return self::ClassName;
|
||||
}
|
||||
|
||||
public static $metadata = [
|
||||
'class_name' => self::ClassName,
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getMetadata(){
|
||||
return array_merge(RSVPTextBoxQuestionTemplate::getMetadata(), self::$metadata);
|
||||
}
|
||||
}
|
@ -27,4 +27,15 @@ class RSVPMemberFirstNameQuestionTemplate extends RSVPTextBoxQuestionTemplate
|
||||
public function getClassName(){
|
||||
return self::ClassName;
|
||||
}
|
||||
|
||||
public static $metadata = [
|
||||
'class_name' => self::ClassName,
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getMetadata(){
|
||||
return array_merge(RSVPTextBoxQuestionTemplate::getMetadata(), self::$metadata);
|
||||
}
|
||||
}
|
@ -27,4 +27,15 @@ class RSVPMemberLastNameQuestionTemplate extends RSVPTextBoxQuestionTemplate
|
||||
public function getClassName(){
|
||||
return self::ClassName;
|
||||
}
|
||||
|
||||
public static $metadata = [
|
||||
'class_name' => self::ClassName,
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getMetadata(){
|
||||
return array_merge(RSVPTextBoxQuestionTemplate::getMetadata(), self::$metadata);
|
||||
}
|
||||
}
|
@ -104,7 +104,23 @@ class RSVPMultiValueQuestionTemplate extends RSVPQuestionTemplate
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName(){
|
||||
return 'RSVPMultiValueQuestionTemplate';
|
||||
return self::ClassName;
|
||||
}
|
||||
|
||||
const ClassName = 'RSVPMultiValueQuestionTemplate';
|
||||
|
||||
public static $metadata = [
|
||||
'empty_string' => 'string',
|
||||
'values' => 'array',
|
||||
'default_value_id' => 'integer',
|
||||
'class_name' => self::ClassName,
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getMetadata(){
|
||||
return array_merge(RSVPQuestionTemplate::getMetadata(), self::$metadata);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -197,4 +197,20 @@ class RSVPQuestionTemplate extends SilverstripeBaseModel implements IOrderable
|
||||
$this->order = 0;
|
||||
}
|
||||
|
||||
public static $metadata = [
|
||||
'name' => 'string',
|
||||
'label' => 'string',
|
||||
'is_mandatory' => 'boolean',
|
||||
'is_read_only' => 'boolean',
|
||||
'template_id' => 'integer',
|
||||
'order' => 'integer'
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getMetadata(){
|
||||
return self::$metadata;
|
||||
}
|
||||
|
||||
}
|
@ -27,4 +27,15 @@ class RSVPRadioButtonListQuestionTemplate extends RSVPMultiValueQuestionTemplate
|
||||
public function getClassName(){
|
||||
return self::ClassName;
|
||||
}
|
||||
|
||||
public static $metadata = [
|
||||
'class_name' => self::ClassName,
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getMetadata(){
|
||||
return array_merge(RSVPMultiValueQuestionTemplate::getMetadata(), self::$metadata);
|
||||
}
|
||||
}
|
@ -46,6 +46,20 @@ class RSVPSingleValueTemplateQuestion extends RSVPQuestionTemplate
|
||||
* @return string
|
||||
*/
|
||||
public function getClassName(){
|
||||
return 'RSVPSingleValueTemplateQuestion';
|
||||
return self::ClassName;
|
||||
}
|
||||
|
||||
const ClassName = 'RSVPSingleValueTemplateQuestion';
|
||||
|
||||
public static $metadata = [
|
||||
'initial_value' => 'string',
|
||||
'class_name' => self::ClassName,
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getMetadata(){
|
||||
return array_merge(RSVPQuestionTemplate::getMetadata(), self::$metadata);
|
||||
}
|
||||
}
|
@ -27,4 +27,15 @@ class RSVPTextAreaQuestionTemplate extends RSVPSingleValueTemplateQuestion
|
||||
public function getClassName(){
|
||||
return self::ClassName;
|
||||
}
|
||||
|
||||
public static $metadata = [
|
||||
'class_name' => self::ClassName,
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getMetadata(){
|
||||
return array_merge(RSVPSingleValueTemplateQuestion::getMetadata(), self::$metadata);
|
||||
}
|
||||
}
|
@ -27,4 +27,15 @@ class RSVPTextBoxQuestionTemplate extends RSVPSingleValueTemplateQuestion
|
||||
public function getClassName(){
|
||||
return self::ClassName;
|
||||
}
|
||||
|
||||
public static $metadata = [
|
||||
'class_name' => self::ClassName,
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getMetadata(){
|
||||
return array_merge(RSVPSingleValueTemplateQuestion::getMetadata(), self::$metadata);
|
||||
}
|
||||
}
|
@ -38,4 +38,10 @@ interface IRSVPTemplateRepository extends IBaseRepository
|
||||
Order $order = null
|
||||
);
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @return mixed
|
||||
*/
|
||||
public function getQuestionsMetadata(Summit $summit);
|
||||
|
||||
}
|
@ -11,7 +11,16 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPCheckBoxListQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPDropDownQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPLiteralContentQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPMemberEmailQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPMemberFirstNameQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPMemberLastNameQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPRadioButtonListQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPTextAreaQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Events\RSVP\RSVPTextBoxQuestionTemplate;
|
||||
use App\Models\Foundation\Summit\Repositories\IRSVPTemplateRepository;
|
||||
use App\Repositories\SilverStripeDoctrineRepository;
|
||||
use Doctrine\ORM\Tools\Pagination\Paginator;
|
||||
@ -112,4 +121,23 @@ final class DoctrineRSVPTemplateRepository
|
||||
$data
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Summit $summit
|
||||
* @return array
|
||||
*/
|
||||
public function getQuestionsMetadata(Summit $summit)
|
||||
{
|
||||
return [
|
||||
RSVPMemberEmailQuestionTemplate::getMetadata(),
|
||||
RSVPMemberFirstNameQuestionTemplate::getMetadata(),
|
||||
RSVPMemberLastNameQuestionTemplate::getMetadata(),
|
||||
RSVPTextBoxQuestionTemplate::getMetadata(),
|
||||
RSVPTextAreaQuestionTemplate::getMetadata(),
|
||||
RSVPCheckBoxListQuestionTemplate::getMetadata(),
|
||||
RSVPRadioButtonListQuestionTemplate::getMetadata(),
|
||||
RSVPDropDownQuestionTemplate::getMetadata(),
|
||||
RSVPLiteralContentQuestionTemplate::getMetadata(),
|
||||
];
|
||||
}
|
||||
}
|
@ -746,6 +746,14 @@ class ApiEndpointsSeeder extends Seeder
|
||||
sprintf(SummitScopes::WriteRSVPTemplateData, $current_realm)
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'get-rsvp-template-question-metadata',
|
||||
'route' => '/api/v1/summits/{id}/rsvp-templates/questions/metadata',
|
||||
'http_method' => 'GET',
|
||||
'scopes' => [
|
||||
sprintf(SummitScopes::ReadAllSummitData, $current_realm)
|
||||
],
|
||||
],
|
||||
[
|
||||
'name' => 'update-rsvp-template',
|
||||
'route' => '/api/v1/summits/{id}/rsvp-templates/{template_id}',
|
||||
|
@ -48,6 +48,37 @@ final class OAuth2SummitRSVPTemplateApiTest extends ProtectedApiTest
|
||||
return $rsvp_templates;
|
||||
}
|
||||
|
||||
public function testGetSummitRSVPTemplateQuestionsMetadata($summit_id = 23)
|
||||
{
|
||||
$params = [
|
||||
'id' => $summit_id,
|
||||
];
|
||||
|
||||
$headers =
|
||||
[
|
||||
"HTTP_Authorization" => " Bearer " . $this->access_token,
|
||||
"CONTENT_TYPE" => "application/json"
|
||||
];
|
||||
|
||||
$response = $this->action
|
||||
(
|
||||
"GET",
|
||||
"OAuth2SummitRSVPTemplatesApiController@getRSVPTemplateQuestionsMetadata",
|
||||
$params,
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
$headers
|
||||
);
|
||||
|
||||
$content = $response->getContent();
|
||||
$this->assertResponseStatus(200);
|
||||
|
||||
$metadata = json_decode($content);
|
||||
$this->assertTrue(!is_null($metadata));
|
||||
return $metadata;
|
||||
}
|
||||
|
||||
public function testGetRSVPTemplateById($summit_id = 23){
|
||||
|
||||
$templates = $this->testGetSummitRSVPTemplates($summit_id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user