api changes:
- GET /preorder/open - get all open preorders - added extref to preorder requests and responses, can be used to identify a specific preorder
This commit is contained in:
@@ -19,6 +19,7 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
protected function init() {
|
||||
$db = $this->db(ADDRESSDB_DBHOST, ADDRESSDB_DBUSER, ADDRESSDB_DBPASS, ADDRESSDB_DBNAME);
|
||||
|
||||
$this->addRoute("/preorder/open", "getOpenPreorders", "GET");
|
||||
$this->addRoute("/preorder", "submitPreorder", "POST");
|
||||
$this->addRoute("/preorder/:code", "getPreorder", "GET");
|
||||
$this->addRoute("/preorder/:code", "cancelPreorder", "DELETE");
|
||||
@@ -79,20 +80,62 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
//var_dump($campaign, $this->allowed_origins);exit;
|
||||
}
|
||||
|
||||
protected function getOpenPreorders() {
|
||||
$ts = $this->get['ts'];
|
||||
|
||||
$update_ts = 0;
|
||||
|
||||
if($ts) {
|
||||
if(is_numeric($ts)) {
|
||||
$update_ts = $ts;
|
||||
} else {
|
||||
$update_date = new DateTime($ts);
|
||||
if($update_date) {
|
||||
$update_ts = $update_date->format('U');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// nicht auf cluster einschränken, sondern auf partner_id
|
||||
/*
|
||||
$preorder_search = [];
|
||||
if(count($this->filter_salescluster_ids)) {
|
||||
$preorder_search['netzgebiet_id'] = $this->filter_salescluster_ids;
|
||||
}*/
|
||||
|
||||
$preorder_search = [];
|
||||
$preorder_search['partner_id'] = $this->me->address_id;
|
||||
$preorder_search['add-where'] = "AND tt_preorder.`edit` > $update_ts";
|
||||
|
||||
$return = [];
|
||||
|
||||
foreach(PreorderModel::search($preorder_search) as $preorder) {
|
||||
$return[] = $preorder->getApiArray();
|
||||
}
|
||||
|
||||
return mfResponse::Ok(["preorders" => $return]);
|
||||
|
||||
}
|
||||
|
||||
protected function getPreorder($code) {
|
||||
$code = trim(strtoupper($code));
|
||||
$code = trim($code);
|
||||
if(!$code) {
|
||||
return mfResponse::NotFound(["message" => "Preorder not found"]);
|
||||
}
|
||||
|
||||
$preorder = PreorderModel::getFirst(['ucode' => $code]);
|
||||
$preorder = PreorderModel::getFirst(['ucode' => strtoupper($code), 'partner_id' => $this->me->address_id]);
|
||||
if(!$preorder) {
|
||||
// try oan id
|
||||
$preorder = PreorderModel::getFirst(['oaid' => $code]);
|
||||
if(!$preorder) {
|
||||
return mfResponse::NotFound(["message" => "Preorder not found"]);
|
||||
}
|
||||
$preorder = PreorderModel::getFirst(['oaid' => strtolower($code), 'partner_id' => $this->me->address_id]);
|
||||
}
|
||||
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"]);
|
||||
@@ -103,12 +146,12 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
return mfResponse::NotFound(["message" => "Preorder not found"]);
|
||||
}
|
||||
|
||||
|
||||
return mfResponse::Ok($return);
|
||||
|
||||
}
|
||||
|
||||
protected function cancelPreorder($code) {
|
||||
/*
|
||||
$code = trim(strtoupper($code));
|
||||
if(!$code) {
|
||||
return mfResponse::NotFound(["message" => "Preorder not found"]);
|
||||
@@ -121,6 +164,24 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
if(!$preorder) {
|
||||
return mfResponse::NotFound(["message" => "Preorder not found or cancelled already"]);
|
||||
}
|
||||
}*/
|
||||
|
||||
$code = trim($code);
|
||||
if(!$code) {
|
||||
return mfResponse::NotFound(["message" => "Preorder not found"]);
|
||||
}
|
||||
|
||||
$preorder = PreorderModel::getFirst(['ucode' => strtoupper($code), 'partner_id' => $this->me->address_id, 'deleted' => 0, '<status_code' => 800]);
|
||||
if(!$preorder) {
|
||||
// try oan id
|
||||
$preorder = PreorderModel::getFirst(['oaid' => strtolower($code), 'partner_id' => $this->me->address_id, 'deleted' => 0, '<status_code' => 800]);
|
||||
}
|
||||
if(!$preorder) {
|
||||
// try as extref
|
||||
$preorder = PreorderModel::getFirst(['extref' => $code, 'partner_id' => $this->me->address_id, 'deleted' => 0, '<status_code' => 800]);
|
||||
}
|
||||
if(!$preorder) {
|
||||
return mfResponse::NotFound(["message" => "Preorder not found"]);
|
||||
}
|
||||
|
||||
// check if user owns preorder
|
||||
@@ -412,8 +473,9 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
} else {
|
||||
$preorder_data['is_additional_order'] = 0;
|
||||
}
|
||||
$preorder_data['technology'] = ($this->post['technology']) ? $this->post['technology'] : null;
|
||||
$preorder_data['patchposition'] = ($this->post['patchposition']) ? $this->post['patchposition'] : null;
|
||||
$preorder_data['extref'] = (trim($this->post['extref'])) ? trim($this->post['extref']) : null;
|
||||
$preorder_data['technology'] = (trim($this->post['technology'])) ? trim($this->post['technology']) : null;
|
||||
$preorder_data['patchposition'] = (trim($this->post['patchposition'])) ? trim($this->post['patchposition']) : null;
|
||||
|
||||
/*
|
||||
* setup price
|
||||
@@ -458,7 +520,7 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
*/
|
||||
foreach(['company','uid','firstname','lastname','street','housenumber','zip','city','phone','email','block','stiege','stock','tuer', 'unit_string'] as $key) {
|
||||
if(property_exists($customer, $key)) {
|
||||
$preorder_data[$key] = ($customer->$key) ? $customer->$key : null;
|
||||
$preorder_data[$key] = (trim($customer->$key)) ? trim($customer->$key) : null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -611,12 +673,20 @@ class PreorderApicontroller extends mfBaseApicontroller {
|
||||
|
||||
$return = ["code" => $preorder->ucode];
|
||||
if($preorder->oaid) {
|
||||
$return ['oaid'] = $preorder->oaid;
|
||||
$return['oaid'] = $preorder->oaid;
|
||||
}
|
||||
if($preorder->extref) {
|
||||
$return['extref'] = $preorder->extref;
|
||||
}
|
||||
if($addon_data) {
|
||||
$return["additionalData"] = $addon_data;
|
||||
}
|
||||
|
||||
$return['created'] = date("c", $preorder->create);
|
||||
$return['created_ts'] = (int)$preorder->create;
|
||||
$return['updated'] = date("c", $preorder->edit);
|
||||
$return['updated_ts'] = (int)$preorder->edit;
|
||||
|
||||
return mfResponse::Ok($return);
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ class Preorder extends mfBaseModel {
|
||||
$a = [];
|
||||
$a['code'] = strtoupper($this->ucode);
|
||||
$a['oaid'] = $this->oaid;
|
||||
$a['extref'] = $this->extref;
|
||||
$a['status'] = $this->getProperty("status")->getApiArray();
|
||||
$a['connectionType'] = $this->connection_type;
|
||||
$a['connectionCount'] = ($this->connection_count) ? (int)$this->connection_count : 1;
|
||||
@@ -119,6 +120,11 @@ class Preorder extends mfBaseModel {
|
||||
}
|
||||
}
|
||||
|
||||
$a['created'] = date("c", $this->create);
|
||||
$a['created_ts'] = (int)$this->create;
|
||||
$a['updated'] = date("c", $this->edit);
|
||||
$a['updated_ts'] = (int)$this->edit;
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ class PreorderModel {
|
||||
public $adb_hausnummer_id;
|
||||
public $adb_wohneinheit_id;
|
||||
public $oaid;
|
||||
public $extref;
|
||||
public $address_district;
|
||||
public $address_info;
|
||||
public $building_id;
|
||||
@@ -413,6 +414,13 @@ class PreorderModel {
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("extref", $filter)) {
|
||||
$extref = FronkDB::singleton()->escape($filter['extref']);
|
||||
if($extref) {
|
||||
$where .= " AND tt_preorder.extref = '$extref'";
|
||||
}
|
||||
}
|
||||
|
||||
if(array_key_exists("gemeinde", $filter)) {
|
||||
$gemeinde = FronkDB::singleton()->escape($filter['gemeinde']);
|
||||
if($gemeinde) {
|
||||
|
||||
@@ -413,11 +413,11 @@ class mfBaseApicontroller {
|
||||
if(!is_array($this->routes) || !count($this->routes)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//var_dump($params);exit;
|
||||
$params = trim($params, "/");
|
||||
$m = [];
|
||||
|
||||
if(preg_match('/\.(\w+)$/', $params, $m)) {
|
||||
if(preg_match('/\.(csv|json|html|txt)$/', $params, $m)) {
|
||||
if($m[1]) {
|
||||
$format = strtolower($m[1]);
|
||||
$params = preg_replace("/\.$format$/", "", $params);
|
||||
@@ -453,7 +453,7 @@ class mfBaseApicontroller {
|
||||
continue;
|
||||
} else {
|
||||
if($rp != $req_parts[$i]) {
|
||||
continue 2; // break out of this loop and continue outer foreach
|
||||
continue 2; // break out of this loop and continue outer foreach (try next route)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ tags:
|
||||
- name: addressdb
|
||||
description: Abfrage von GWR-Daten
|
||||
- name: preorder
|
||||
description: Informationen zum Netzgebiet und Speichern von Vorbestellungen
|
||||
description: Abfragen und Operationen zu Vorbestellungen
|
||||
paths:
|
||||
/addressdb/getClusters:
|
||||
get:
|
||||
@@ -482,6 +482,10 @@ paths:
|
||||
|
||||
---
|
||||
|
||||
Parameter `extref`: Providereigener Identifikationsstring. Wird unverändert gespeichert und kann statt `code` in `GET /preorder` und `DELETE /preorder` angegeben werden. **Darf nicht mit Dateiendung wie z.B. `.json`, `.csv` enden, da diese als Ausgabeformat interpretiert werden können**
|
||||
|
||||
---
|
||||
|
||||
Parameter `additionalData`: **(Optional)** Object für zusätzliche individuelle Daten, die in der Vorbestellung gespeichert werden. Wird in `GET /preorder` retourniert.
|
||||
|
||||
operationId: submitPreorder
|
||||
@@ -514,6 +518,13 @@ paths:
|
||||
type: string
|
||||
description: Code für Statusabfrage
|
||||
example: A1B2C3D4
|
||||
oaid:
|
||||
type: string
|
||||
description: OAID
|
||||
example: AT-9999-abcdef01
|
||||
extref:
|
||||
type: string
|
||||
description: Providereigener Identifikationsstring. Wird unverändert gespeichert und kann statt `code` in `GET /preorder` und `DELETE /preorder` angegeben werden. **Darf nicht mit Dateiendung wie z.B. `.json`, `.csv` enden, da diese als Ausgabeformat interpretiert werden können**
|
||||
additionalData:
|
||||
type: object
|
||||
description: Benutzerdefiniertes Objekt. Wird unverändert gespeichert und in `GET /preorder` wieder ausgegeben
|
||||
@@ -525,7 +536,24 @@ paths:
|
||||
value: test
|
||||
- key: another Key
|
||||
value: more value
|
||||
|
||||
created:
|
||||
type: string
|
||||
format: date-time
|
||||
description: Zeitpunkt der Anlage der Bestellung in ISO 8601 Format
|
||||
example: "2023-02-01T00:00:00+01:00"
|
||||
created_ts:
|
||||
type: int
|
||||
description: Zeitpunkt der Anlage der Bestellung in Sekunden seit der Unix Epoche
|
||||
example: 1675206000
|
||||
updated:
|
||||
type: string
|
||||
format: date-time
|
||||
description: Zeitpunkt der letzen Bearbeitung der Bestellung in ISO 8601 Format
|
||||
example: "2023-02-01T00:00:00+01:00"
|
||||
updated_ts:
|
||||
type: int
|
||||
description: Zeitpunkt der letzten Bearbeitung der Bestellung in Sekunden seit der Unix Epoche
|
||||
example: 1675206000
|
||||
'400':
|
||||
description: |
|
||||
Bad Request
|
||||
@@ -537,6 +565,25 @@ paths:
|
||||
description: Vorbestellung für diese Wohneinheit bereits vorhanden
|
||||
'404':
|
||||
description: Adresse oder Wohneinheit nicht gefunden
|
||||
/preorder/open:
|
||||
get:
|
||||
tags:
|
||||
- preorder
|
||||
summary:
|
||||
Liste offener Vorbestellungen
|
||||
description: Gibt Liste aller offener Vorbestellungen aus, Optional gefiltert nach Zeitpunkt der letzten Bearbeitung
|
||||
parameters:
|
||||
- name: ts
|
||||
in: query
|
||||
description: |
|
||||
Optional: Timestamp. Wenn gesetzt, werden Nur Bestellungen zurückgeliefert, welche ab diesem Zeitpunkt geändert wurden.
|
||||
|
||||
Format: String in ISO 8601 Format oder Integer in Sekunden seit der Unix Epoche
|
||||
required: false
|
||||
schema:
|
||||
oneOf:
|
||||
- $ref: "#/components/schemas/timestampString"
|
||||
- $ref: "#/components/schemas/timestampInt"
|
||||
/preorder/{code}:
|
||||
get:
|
||||
tags:
|
||||
@@ -547,7 +594,7 @@ paths:
|
||||
parameters:
|
||||
- name: code
|
||||
in: path
|
||||
description: code der Vorbestellung oder OAID der Wohneinheit
|
||||
description: Automatisch generierter **code** der Vorbestellung, **OAID** der Wohneinheit oder providereigene ID (**extref**)
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
@@ -569,7 +616,9 @@ paths:
|
||||
| 210 | Fiber planning | Leitungsplan in Arbeit |
|
||||
| 220 | Fiber planning finished | Leitungsplan abgeschlossen |
|
||||
| 230 | Fiber installation work assigned | Bauauftrag zugeteilt |
|
||||
| 235 | Fiber on property line | Faser an Grundstücksgrenze |
|
||||
| 240 | Fiber in building | Faser im Gebäude |
|
||||
| 245 | OTO intalled | Anschlussbox installiert |
|
||||
| 250 | ONT ready | ONT vorbereitet |
|
||||
| 260 | ONT picked up or shipped | ONT abgeholt oder versandt |
|
||||
| 300 | ONT installed | ONT in Betrieb |
|
||||
@@ -599,7 +648,7 @@ paths:
|
||||
parameters:
|
||||
- name: code
|
||||
in: path
|
||||
description: code der Vorbestellung oder OAID der Wohneinheit
|
||||
description: Automatisch generierter **code** der Vorbestellung, **OAID** der Wohneinheit oder providereigene ID (**extref**)
|
||||
required: true
|
||||
schema:
|
||||
type: string
|
||||
@@ -630,6 +679,13 @@ paths:
|
||||
description: Bestellung nicht gefunden oder bereits storniert
|
||||
components:
|
||||
schemas:
|
||||
timestampString:
|
||||
type: string
|
||||
format: date-time
|
||||
description: ISO 8601 Timestamp
|
||||
timestampInt:
|
||||
type: int
|
||||
description: Timestamp in seconds of the Unix Epoch
|
||||
Zips:
|
||||
type: array
|
||||
items:
|
||||
@@ -950,6 +1006,9 @@ components:
|
||||
preorderRequest:
|
||||
type: object
|
||||
properties:
|
||||
extref:
|
||||
type: string
|
||||
description: Providereigener Identifikationsstring. Wird unverändert gespeichert und kann statt `code` in `GET /preorder` und `DELETE /preorder` angegeben werden. **Darf nicht mit Dateiendung wie z.B. `.json`, `.csv` enden, da diese als Ausgabeformat interpretiert werden können**
|
||||
preorderType:
|
||||
type: string
|
||||
enum: [interest, provision, order]
|
||||
@@ -1203,6 +1262,9 @@ components:
|
||||
type: string
|
||||
description: Open Access ID der Wohneinheit
|
||||
example: AT-9999-abcdef01.001
|
||||
extref:
|
||||
type: string
|
||||
description: Providereigener Identifikationsstring. Wird unverändert gespeichert und kann statt `code` in `GET /preorder` und `DELETE /preorder` angegeben werden. **Darf nicht mit Dateiendung wie z.B. `.json`, `.csv` enden, da diese als Ausgabeformat interpretiert werden können**
|
||||
status:
|
||||
type: object
|
||||
properties:
|
||||
@@ -1305,7 +1367,24 @@ components:
|
||||
value: test
|
||||
- key: another Key
|
||||
value: more value
|
||||
|
||||
created:
|
||||
type: string
|
||||
format: date-time
|
||||
description: Zeitpunkt der Anlage der Bestellung in ISO 8601 Format
|
||||
example: "2023-02-01T00:00:00+01:00"
|
||||
created_ts:
|
||||
type: int
|
||||
description: Zeitpunkt der Anlage der Bestellung in Sekunden seit der Unix Epoche
|
||||
example: 1675206000
|
||||
updated:
|
||||
type: string
|
||||
format: date-time
|
||||
description: Zeitpunkt der letzen Bearbeitung der Bestellung in ISO 8601 Format
|
||||
example: "2023-02-01T00:00:00+01:00"
|
||||
updated_ts:
|
||||
type: int
|
||||
description: Zeitpunkt der letzten Bearbeitung der Bestellung in Sekunden seit der Unix Epoche
|
||||
example: 1675206000
|
||||
securitySchemes:
|
||||
api_key_header:
|
||||
type: apiKey
|
||||
|
||||
Reference in New Issue
Block a user