Preorder API Update

This commit is contained in:
Frank Schubert
2024-01-05 19:29:06 +01:00
parent 7646345779
commit 74033a9354
5 changed files with 53 additions and 16 deletions

View File

@@ -1,6 +1,6 @@
<?php
namespace thetool\Api\Modules;
namespace application\Api\v1\Modules;
class ApiControllerModule {
protected $log;

View File

@@ -1,7 +1,8 @@
<?php
namespace thetool\Api\Modules\Preorder;
use thetool\Api\Modules;
//namespace thetool\Api\Modules\Preorder;
namespace application\Api\v1\Modules\Preorder;
use application\Api\v1\Modules;
require_once(APPDIR."/Api/v1/Modules/ApiControllerModule.php");
@@ -15,9 +16,9 @@ class Activation extends Modules\ApiControllerModule {
}
/*
* GET /preorder/:code/clientInstallationFinished
* POST /preorder/:code/serviceActivated
*/
public function serviceActivated($code) {
public function setServiceActive($code) {
$code = trim($code);
if(!$code) {
return \mfResponse::NotFound(["message" => "Preorder not found"]);
@@ -41,9 +42,9 @@ class Activation extends Modules\ApiControllerModule {
return \mfResponse::NotFound(["message" => "Preorder not found"]);
}
// set status to 200
if($preorder->status->code < 200) {
$new_status = \PreorderstatusModel::getFirst(["code" => 200]);
// set status to 500
if($preorder->status->code < 500) {
$new_status = \PreorderstatusModel::getFirst(["code" => 500]);
if(!$new_status) {
return \mfResponse::InternalServerError();
}

View File

@@ -1,7 +1,7 @@
<?php
namespace thetool\Api\Modules\Preorder;
use thetool\Api\Modules;
namespace application\Api\v1\Modules\Preorder;
use application\Api\v1\Modules;
require_once(APPDIR."/Api/v1/Modules/ApiControllerModule.php");

View File

@@ -3,7 +3,7 @@
require_once(APPDIR."/Api/v1/Modules/Preorder/Cif.php");
require_once(APPDIR."/Api/v1/Modules/Preorder/Activation.php");
use thetool\Api\Modules;
use application\Api\v1\Modules;
class PreorderApicontroller extends mfBaseApicontroller {
//private $filter_gemeinde_ids = [];
@@ -27,10 +27,13 @@ class PreorderApicontroller extends mfBaseApicontroller {
}
protected function registerRoutes() {
/*
* TODO: Load Api Modules automatically in mfBaseApiController
*/
$modules = [];
$moduleNames = ["Cif", "Activation"];
foreach($moduleNames as $moduleName) {
$classname = "thetool\Api\Modules\Preorder\\".$moduleName;
foreach(["Cif", "Activation"] as $moduleName) {
$classname = "application\\Api\\v1\\Modules\\Preorder\\".$moduleName;
$modules[$moduleName] = new $classname([
"get" => $this->get,
"post" => $this->post,
@@ -46,10 +49,12 @@ class PreorderApicontroller extends mfBaseApicontroller {
$this->addRoute("/preorder/customerInstallationFeedback", [$modules["Cif"], "getCifData"], "GET");
$this->addRoute("/preorder/customerInstallationFeedback", [$modules["Cif"], "userSetCif"], "POST");
$this->addRoute("/preorder/:code", "getPreorder", "GET");
$this->addRoute("/preorder/:code", "cancelPreorder", "DELETE");
$this->addRoute("/preorder/:code/clientInstallationFinished", [$modules["Cif"], "providerSetCif"], "GET");
$this->addRoute("/preorder/:code/serviceActivated", [$modules["Activation"], "setServiceActive"], "POST");
$this->addRoute("/preorder/:code", "getPreorder", "GET");
$this->addRoute("/preorder/:code", "cancelPreorder", "DELETE");
}
/*

View File

@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
use Phinx\Migration\AbstractMigration;
final class AddressdbNetzgebietAddRimoId extends AbstractMigration
{
public function up(): void
{
if($this->getEnvironment() == "thetool") {
}
if($this->getEnvironment() == "addressdb") {
$table = $this->table("Netzgebiet");
$table->addColumn("rimo_id", "string", ["null" => true, "default" => null, "limit" => 255, "after" => "extref"]);
$table->update();
}
}
public function down(): void
{
if($this->getEnvironment() == "thetool") {
}
if($this->getEnvironment() == "addressdb") {
}
}
}