Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Qe 795 rest api publication access start expire (#3776)
* Dev: API uses JSON DateTime format * Dev: Add REST API /site-settings endpoint
- Loading branch information
1 parent
c93378f
commit 1f7a2af
Showing
15 changed files
with
191 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
use LimeSurvey\Api\Command\V1\{ | ||
SiteSettings | ||
}; | ||
|
||
use LimeSurvey\Api\Rest\V1\SchemaFactory\SchemaFactorySiteSettings; | ||
|
||
$rest = []; | ||
|
||
$rest['v1/site-settings'] = [ | ||
'GET' => [ | ||
'description' => 'Site Settings', | ||
'commandClass' => SiteSettings::class, | ||
'params' => [], | ||
'responses' => [ | ||
'success' => [ | ||
'code' => 200, | ||
'description' => 'Success', | ||
'content' => null, | ||
'schema' => (new SchemaFactorySiteSettings)->make() | ||
] | ||
] | ||
] | ||
]; | ||
|
||
return $rest; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace LimeSurvey\Api\Command\V1; | ||
|
||
use Yii; | ||
use LimeSurvey\Api\Command\{ | ||
CommandInterface, | ||
Request\Request, | ||
Response\Response, | ||
Response\ResponseFactory | ||
}; | ||
|
||
/** | ||
* Site Settings | ||
* | ||
* Site settings are different from global settings | ||
* because this endpoint is public. | ||
*/ | ||
class SiteSettings implements CommandInterface | ||
{ | ||
protected ResponseFactory $responseFactory; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param ResponseFactory $responseFactory | ||
*/ | ||
public function __construct(ResponseFactory $responseFactory) | ||
{ | ||
$this->responseFactory = $responseFactory; | ||
} | ||
|
||
/** | ||
* Run settings command | ||
* | ||
* @param Request $request | ||
* @return Response | ||
*/ | ||
public function run(Request $request) | ||
{ | ||
return $this->responseFactory | ||
->makeSuccess([ | ||
'siteName' => Yii::app()->getConfig('sitename'), | ||
'timezone' => date_default_timezone_get() | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
application/libraries/Api/Rest/V1/SchemaFactory/SchemaFactorySiteSettings.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace LimeSurvey\Api\Rest\V1\SchemaFactory; | ||
|
||
use GoldSpecDigital\ObjectOrientedOAS\Objects\Schema; | ||
use GoldSpecDigital\ObjectOrientedOAS\Contracts\SchemaContract; | ||
|
||
class SchemaFactorySiteSettings | ||
{ | ||
/** | ||
* @param \GoldSpecDigital\ObjectOrientedOAS\Contracts\SchemaContract $properties | ||
*/ | ||
public function make(SchemaContract ...$properties): Schema | ||
{ | ||
return Schema::create()->title('Site Settings') | ||
->description('Site Settings') | ||
->type(Schema::TYPE_OBJECT) | ||
->properties( | ||
Schema::string('siteName')->default(null), | ||
Schema::string('timezone')->default(null), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.