Added GET /preorder api endpoint
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
class Preorder extends mfBaseModel {
|
||||
protected $forcestr = ['street','company','zip','phone','email','note'];
|
||||
private $status;
|
||||
private $campaign;
|
||||
private $partner;
|
||||
private $building;
|
||||
@@ -33,7 +34,78 @@ class Preorder extends mfBaseModel {
|
||||
}
|
||||
return $ucode;
|
||||
}
|
||||
|
||||
public function getApiArray() {
|
||||
if(!$this->id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$hausnummer = $this->getProperty("adb_hausnummer");
|
||||
$wohneinheit = $this->getProperty("adb_wohneinheit");
|
||||
|
||||
$a = [];
|
||||
$a['ucode'] = strtoupper($this->ucode);
|
||||
$a['oaid'] = $this->oaid;
|
||||
$a['status'] = $this->getProperty("status")->getApiArray();
|
||||
$a['connectionType'] = $this->connection_type;
|
||||
$a['connectionCount'] = ($this->connection_count) ? (int)$this->connection_count : 1;
|
||||
$a['preorderType'] = $this->type;
|
||||
$a['acceptMarketing'] = ($this->accept_marketing) ? true : false;
|
||||
$a['acceptAgb'] = ($this->accept_agb) ? true : false;
|
||||
$a['acceptDsgvo'] = ($this->accept_dsgvo) ? true : false;
|
||||
$a['acceptWithdrawal'] = ($this->accept_withdrawal) ? true : false;
|
||||
$a['address_info'] = ($this->address_info) ? $this->address_info : null;
|
||||
|
||||
$address = [];
|
||||
$address['street'] = $hausnummer->strasse->name;
|
||||
$address['housenumber'] = $hausnummer->hausnummer;
|
||||
$address['zip'] = $hausnummer->plz->plz;
|
||||
$address['city'] = $hausnummer->strasse->gemeinde->name;
|
||||
$address['district'] = $hausnummer->ortschaft->name;
|
||||
$address['bock'] = ($wohneinheit->block) ? $wohneinheit->block : null;
|
||||
$address['stock'] = ($wohneinheit->stock) ? $wohneinheit->stock : null;
|
||||
$address['stiege'] = ($wohneinheit->stiege) ? $wohneinheit->stiege : null;
|
||||
$address['tuer'] = ($wohneinheit->tuer) ? $wohneinheit->tuer : null;
|
||||
|
||||
$customer = [];
|
||||
$customer['company'] = ($this->company) ? $this->company : null;
|
||||
$customer['uid'] = ($this->uid) ? $this->uid : null;
|
||||
$customer['firstnam'] = ($this->firstname) ? $this->firstname : null;
|
||||
$customer['lastname'] = ($this->lastname) ? $this->lastname : null;
|
||||
$customer['street'] = ($this->street) ? $this->street : null;
|
||||
$customer['housenumber'] = ($this->hausnummer) ? $this->hausnummer : null;
|
||||
$customer['zip'] = ($this->plz) ? $this->plz : null;
|
||||
$customer['city'] = ($this->city) ? $this->city : null;
|
||||
$customer['bock'] = ($this->block) ? $this->block : null;
|
||||
$customer['stock'] = ($this->stock) ? $this->stock : null;
|
||||
$customer['stiege'] = ($this->stiege) ? $this->stiege : null;
|
||||
$customer['tuer'] = ($this->tuer) ? $this->tuer : null;
|
||||
$customer['phone'] = ($this->phone) ? $this->phone : null;
|
||||
$customer['email'] = ($this->email) ? $this->email : null;
|
||||
|
||||
$a['address'] = $address;
|
||||
$a['customer'] = $customer;
|
||||
|
||||
$a['addonServices'] = null;
|
||||
if($this->addon_services) {
|
||||
$addon_services = json_decode($this->addon_services);
|
||||
if(json_last_error() === JSON_ERROR_NONE) {
|
||||
$a['addonServices'] = $addon_services;
|
||||
}
|
||||
}
|
||||
|
||||
$a['additionalData'] = null;
|
||||
if($this->addon_data) {
|
||||
$addon_data = json_decode($this->addon_data);
|
||||
if(json_last_error() === JSON_ERROR_NONE) {
|
||||
$a['additionalData'] = $addon_data;
|
||||
}
|
||||
}
|
||||
|
||||
return $a;
|
||||
}
|
||||
|
||||
|
||||
public function getProperty($name) {
|
||||
if($this->$name == null) {
|
||||
|
||||
@@ -42,6 +114,17 @@ class Preorder extends mfBaseModel {
|
||||
return $this->campaign;
|
||||
}
|
||||
|
||||
if($name == "status") {
|
||||
$this->status = mfValuecache::singleton()->get("mfObjectmodel-Preorderstatus-".$this->status_id);
|
||||
if(!$this->status) {
|
||||
$this->status = new Preorderstatus($this->status_id);
|
||||
if($this->status->id) {
|
||||
mfValuecache::singleton()->set("mfObjectmodel-Preorderstatus-".$this->status_id, $this->status);
|
||||
}
|
||||
}
|
||||
return $this->status;
|
||||
}
|
||||
|
||||
if($name == "partner") {
|
||||
$this->partner = mfValuecache::singleton()->get("mfObjectmodel-Address-".$this->partner_id);
|
||||
if(!$this->partner) {
|
||||
|
||||
Reference in New Issue
Block a user