WIP 2023-12-19 - Preorder API
This commit is contained in:
@@ -78,27 +78,49 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
|
|
||||||
<h3>Zustimmungen</h3>
|
<div class="row">
|
||||||
<table class="table table-sm table-striped">
|
<div class="col">
|
||||||
<tr>
|
|
||||||
<th>Zustimmung AGB:</th>
|
|
||||||
<td><?=($preorder->accept_agb) ? '<i class="fas fa-fw fa-check text-success"></i>' : '<i class="fas fa-fw fa-xmark text-danger"></i>'?></td>
|
|
||||||
</tr><tr>
|
|
||||||
<th>Zustimmung DSGVO:</th>
|
|
||||||
<td><?=($preorder->accept_dsgvo) ? '<i class="fas fa-fw fa-check text-success"></i>' : '<i class="fas fa-fw fa-xmark text-danger"></i>'?></td>
|
|
||||||
</tr><tr>
|
|
||||||
<th>Zustimmung Rücktrittsrecht:</th>
|
|
||||||
<td><?=($preorder->accept_withdrawal) ? '<i class="fas fa-fw fa-check text-success"></i>' : '<i class="fas fa-fw fa-xmark text-danger"></i>'?></td>
|
|
||||||
</tr><tr>
|
|
||||||
<th>Zustimmung Datenweitergabe:</th>
|
|
||||||
<td><?=($preorder->accept_marketing) ? '<i class="fas fa-fw fa-check text-success"></i>' : '<i class="fas fa-fw fa-xmark text-danger"></i>'?></td>
|
|
||||||
</tr><tr>
|
|
||||||
<th>Zustimmung Grabungsarbeiten:</th>
|
|
||||||
<td><?=($preorder->accept_digging) ? '<i class="fas fa-fw fa-check text-success"></i>' : '<i class="fas fa-fw fa-xmark text-danger"></i>'?></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
|
|
||||||
|
<h3>Zustimmungen</h3>
|
||||||
|
<table class="table table-sm table-striped">
|
||||||
|
<tr>
|
||||||
|
<th>Zustimmung AGB:</th>
|
||||||
|
<td><?=($preorder->accept_agb) ? '<i class="fas fa-fw fa-check text-success"></i>' : '<i class="fas fa-fw fa-xmark text-danger"></i>'?></td>
|
||||||
|
</tr><tr>
|
||||||
|
<th>Zustimmung DSGVO:</th>
|
||||||
|
<td><?=($preorder->accept_dsgvo) ? '<i class="fas fa-fw fa-check text-success"></i>' : '<i class="fas fa-fw fa-xmark text-danger"></i>'?></td>
|
||||||
|
</tr><tr>
|
||||||
|
<th>Zustimmung Rücktrittsrecht:</th>
|
||||||
|
<td><?=($preorder->accept_withdrawal) ? '<i class="fas fa-fw fa-check text-success"></i>' : '<i class="fas fa-fw fa-xmark text-danger"></i>'?></td>
|
||||||
|
</tr><tr>
|
||||||
|
<th>Zustimmung Datenweitergabe:</th>
|
||||||
|
<td><?=($preorder->accept_marketing) ? '<i class="fas fa-fw fa-check text-success"></i>' : '<i class="fas fa-fw fa-xmark text-danger"></i>'?></td>
|
||||||
|
</tr><tr>
|
||||||
|
<th>Zustimmung Grabungsarbeiten:</th>
|
||||||
|
<td><?=($preorder->accept_digging) ? '<i class="fas fa-fw fa-check text-success"></i>' : '<i class="fas fa-fw fa-xmark text-danger"></i>'?></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
|
||||||
|
<h3>Starterpaket</h3>
|
||||||
|
<table class="table table-sm table-striped">
|
||||||
|
<tr>
|
||||||
|
<th>CIF Token:</th>
|
||||||
|
<td class="text-monospace"><?=$preorder->ciftoken?></td>
|
||||||
|
</tr><tr>
|
||||||
|
<th>CIF Kabelnachbestell-Url:</th>
|
||||||
|
<td class="text-monospace"><?=$preorder->cifcableurl?></td>
|
||||||
|
</tr><tr>
|
||||||
|
<th>Starterpaket versandt:</th>
|
||||||
|
<td class="text-monospace"><?=($preorder->logistics && $preorder->logistics->sent) ? '<i class="fas fa-fw fa-check text-success"></i> '.date("d.m.Y H:i", $preorder->logistics->sent) : '<i class="fas fa-fw fa-xmark text-danger"></i>'?></td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -161,14 +161,17 @@ class ADBWohneinheit extends mfBaseModel {
|
|||||||
|
|
||||||
public function getPatchEqString() {
|
public function getPatchEqString() {
|
||||||
$patch = "";
|
$patch = "";
|
||||||
if($this->patch_cluster) {
|
|
||||||
$patch = $this->patch_cluster;
|
|
||||||
} else {
|
|
||||||
$patch = $this->getProperty("hausnummer")->netzgebiet->extref;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($this->patch_shelf) $patch .= "-".$this->patch_shelf;
|
if($this->patch_shelf) $patch .= $this->patch_shelf."-";
|
||||||
if($this->patch_module) $patch .= "-".$this->patch_module;
|
if($this->patch_module) $patch .= $this->patch_module;
|
||||||
|
|
||||||
|
if($patch) {
|
||||||
|
if($this->patch_cluster) {
|
||||||
|
$patch = $this->patch_cluster."-".$patch;
|
||||||
|
} else {
|
||||||
|
$patch = $this->getProperty("hausnummer")->netzgebiet->extref."-".$patch;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return $patch;
|
return $patch;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace thetool\Api\Modules\Preorder;
|
||||||
|
use thetool\Api\Modules;
|
||||||
|
|
||||||
|
require_once(APPDIR."/Api/v1/Modules/ApiControllerModule.php");
|
||||||
|
|
||||||
|
/*
|
||||||
|
* API Endpoints for Preorder Activation
|
||||||
|
*/
|
||||||
|
class Activation extends Modules\ApiControllerModule {
|
||||||
|
|
||||||
|
public function init() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* GET /preorder/:code/clientInstallationFinished
|
||||||
|
*/
|
||||||
|
public function serviceActivated($code) {
|
||||||
|
$code = trim($code);
|
||||||
|
if(!$code) {
|
||||||
|
return \mfResponse::NotFound(["message" => "Preorder not found"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$preorder = \PreorderModel::getFirst(['ucode' => strtoupper($code), 'partner_id' => $this->me->address_id]);
|
||||||
|
if(!$preorder) {
|
||||||
|
// try oaid
|
||||||
|
$preorder = \PreorderModel::getFirst(['oaid' => strtolower($code), 'partner_id' => $this->me->address_id], "`create` DESC");
|
||||||
|
}
|
||||||
|
if(!$preorder) {
|
||||||
|
// try as extref
|
||||||
|
$preorder = \PreorderModel::getFirst(['extref' => $code, 'partner_id' => $this->me->address_id]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$preorder) {
|
||||||
|
return \mfResponse::NotFound(["message" => "Preorder not found"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($preorder->partner_id != $this->me->address_id) {
|
||||||
|
return \mfResponse::NotFound(["message" => "Preorder not found"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// set status to 200
|
||||||
|
if($preorder->status->code < 200) {
|
||||||
|
$new_status = \PreorderstatusModel::getFirst(["code" => 200]);
|
||||||
|
if(!$new_status) {
|
||||||
|
return \mfResponse::InternalServerError();
|
||||||
|
}
|
||||||
|
$preorder->status_id = $new_status->id;
|
||||||
|
$preorder->save();
|
||||||
|
}
|
||||||
|
|
||||||
|
return \mfResponse::Ok(["message" => "Status successfully updated."]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -37,12 +37,10 @@ class Cif extends Modules\ApiControllerModule {
|
|||||||
return \mfResponse::NotFound(["message" => "Preorder not found"]);
|
return \mfResponse::NotFound(["message" => "Preorder not found"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if($preorder->partner_id != $this->me->address_id) {
|
if($preorder->partner_id != $this->me->address_id) {
|
||||||
return \mfResponse::NotFound(["message" => "Preorder not found"]);
|
return \mfResponse::NotFound(["message" => "Preorder not found"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// set status to 200
|
// set status to 200
|
||||||
if($preorder->status->code < 200) {
|
if($preorder->status->code < 200) {
|
||||||
$new_status = \PreorderstatusModel::getFirst(["code" => 200]);
|
$new_status = \PreorderstatusModel::getFirst(["code" => 200]);
|
||||||
@@ -66,10 +64,22 @@ class Cif extends Modules\ApiControllerModule {
|
|||||||
return \mfResponse::BadRequest(["message" => "ciftoken missing"]);
|
return \mfResponse::BadRequest(["message" => "ciftoken missing"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$preorder = \PreorderModel::getFirst(["ciftoken" => $this->get["ciftoken"], "partner_id" => $this->me->address_id]);
|
$preorder = \PreorderModel::getFirst(["ciftoken" => $this->get["ciftoken"]]);
|
||||||
if(!$preorder) {
|
if(!$preorder) {
|
||||||
return \mfResponse::NotFound(["message" => "Invalid ciftoken"]);
|
return \mfResponse::NotFound(["message" => "Invalid ciftoken"]);
|
||||||
}
|
}
|
||||||
|
if(!$preorder->adb_hausnummer->netzgebiet_id) {
|
||||||
|
return \mfResponse::NotFound(["message" => "Invalid ciftoken"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$network = \NetworkModel::getFirst(["adb_netzgebiet_id" => $preorder->adb_hausnummer->netzgebiet->id]);
|
||||||
|
if(!$network) {
|
||||||
|
return \mfResponse::NotFound(["message" => "Invalid ciftoken"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($network->owner_id != $this->me->address_id && $preorder->partner_id != $this->me->address_id) {
|
||||||
|
return \mfResponse::NotFound(["message" => "Invalid ciftoken"]);
|
||||||
|
}
|
||||||
|
|
||||||
$return = $preorder->getCifdataApiArray();
|
$return = $preorder->getCifdataApiArray();
|
||||||
|
|
||||||
@@ -80,16 +90,26 @@ class Cif extends Modules\ApiControllerModule {
|
|||||||
* POST /preorder/customerInstallationFeedback
|
* POST /preorder/customerInstallationFeedback
|
||||||
*/
|
*/
|
||||||
public function userSetCif() {
|
public function userSetCif() {
|
||||||
return \mfResponse::InternalServerError();
|
//return \mfResponse::InternalServerError();
|
||||||
|
|
||||||
if(!array_key_exists("ciftoken", $this->post) || !$this->post['ciftoken']) {
|
if(!array_key_exists("ciftoken", $this->post) || !$this->post['ciftoken']) {
|
||||||
return \mfResponse::BadRequest(["message" => "ciftoken missing"]);
|
return \mfResponse::BadRequest(["message" => "ciftoken missing"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
$preorder = \PreorderModel::getFirst(["ciftoken" => $this->get["ciftoken"], "partner_id" => $this->me->address_id]);
|
$preorder = \PreorderModel::getFirst(["ciftoken" => $this->get["ciftoken"]]);
|
||||||
if(!$preorder) {
|
if(!$preorder) {
|
||||||
return \mfResponse::NotFound(["message" => "Invalid ciftoken"]);
|
return \mfResponse::NotFound(["message" => "Invalid ciftoken"]);
|
||||||
}
|
}
|
||||||
|
if(!$preorder->adb_hausnummer->netzgebiet_id) {
|
||||||
|
return \mfResponse::NotFound(["message" => "Invalid ciftoken"]);
|
||||||
|
}
|
||||||
|
$network = \NetworkModel::getFirst(["adb_netzgebiet_id" => $preorder->adb_hausnummer->netzgebiet->id]);
|
||||||
|
if(!$network) {
|
||||||
|
return \mfResponse::NotFound(["message" => "Invalid ciftoken"]);
|
||||||
|
}
|
||||||
|
if($network->owner_id != $this->me->address_id && $preorder->partner_id != $this->me->address_id) {
|
||||||
|
return \mfResponse::NotFound(["message" => "Invalid ciftoken"]);
|
||||||
|
}
|
||||||
|
|
||||||
// set status to 200
|
// set status to 200
|
||||||
if($preorder->status->code < 200) {
|
if($preorder->status->code < 200) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once(APPDIR."/Api/v1/Modules/Preorder/Cif.php");
|
require_once(APPDIR."/Api/v1/Modules/Preorder/Cif.php");
|
||||||
|
require_once(APPDIR."/Api/v1/Modules/Preorder/Activation.php");
|
||||||
|
|
||||||
use thetool\Api\Modules;
|
use thetool\Api\Modules;
|
||||||
|
|
||||||
@@ -26,22 +27,29 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected function registerRoutes() {
|
protected function registerRoutes() {
|
||||||
$moduleCif = new Modules\Preorder\Cif([
|
$modules = [];
|
||||||
"get" => $this->get,
|
$moduleNames = ["Cif", "Activation"];
|
||||||
"post" => $this->post,
|
foreach($moduleNames as $moduleName) {
|
||||||
"db" => $this->db(),
|
$classname = "thetool\Api\Modules\Preorder\\".$moduleName;
|
||||||
"me" => $this->me
|
$modules[$moduleName] = new $classname([
|
||||||
]);
|
"get" => $this->get,
|
||||||
|
"post" => $this->post,
|
||||||
|
"db" => $this->db(),
|
||||||
|
"me" => $this->me
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$this->addRoute("/preorder", "submitPreorder", "POST");
|
$this->addRoute("/preorder", "submitPreorder", "POST");
|
||||||
$this->addRoute("/preorder/open", "getOpenPreorders", "GET");
|
$this->addRoute("/preorder/open", "getOpenPreorders", "GET");
|
||||||
$this->addRoute("/preorder/customerInstallationFeedback", [$moduleCif, "getCifData"], "GET");
|
$this->addRoute("/preorder/customerInstallationFeedback", [$modules["Cif"], "getCifData"], "GET");
|
||||||
$this->addRoute("/preorder/customerInstallationFeedback", [$moduleCif, "userSetCif"], "POST");
|
$this->addRoute("/preorder/customerInstallationFeedback", [$modules["Cif"], "userSetCif"], "POST");
|
||||||
|
|
||||||
$this->addRoute("/preorder/:code", "getPreorder", "GET");
|
$this->addRoute("/preorder/:code", "getPreorder", "GET");
|
||||||
$this->addRoute("/preorder/:code", "cancelPreorder", "DELETE");
|
$this->addRoute("/preorder/:code", "cancelPreorder", "DELETE");
|
||||||
$this->addRoute("/preorder/:code/clientInstallationFinished", [$moduleCif, "providerSetCif"], "GET");
|
$this->addRoute("/preorder/:code/clientInstallationFinished", [$modules["Cif"], "providerSetCif"], "GET");
|
||||||
$this->addRoute("/preorder/:code/serviceActivated", "setServiceActive", "POST");
|
$this->addRoute("/preorder/:code/serviceActivated", [$modules["Activation"], "setServiceActive"], "POST");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user