Json serialize models
This commit is contained in:
parent
8277de42c1
commit
877ef33f41
6 changed files with 89 additions and 4 deletions
|
|
@ -118,4 +118,17 @@ class Answer extends CrmClientModel
|
|||
$response = static::$apiInterface->call($request);
|
||||
return $response->status->equals(ApiStatus::OK());
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize this object to an array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'answer' => $this->answer
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -254,4 +254,22 @@ class ArcadiaMailDefault extends CrmClientModel
|
|||
$this->isNew = !$status;
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize this object to an array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return [
|
||||
'operation' => $this->operation,
|
||||
'support_code' => $this->support_code,
|
||||
'label_type_support' => $this->label_type_support,
|
||||
'order_date' => $this->order_date,
|
||||
'order_num' => $this->order_num,
|
||||
'state_order' => $this->state_order,
|
||||
'package_unit_weight' => $this->package_unit_weight
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -171,4 +171,21 @@ class ArcadiaMailGame extends CrmClientModel
|
|||
$this->isNew = !$status;
|
||||
return $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize this object to an array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return [
|
||||
'operation' => $this->operation,
|
||||
'support_code' => $this->support_code,
|
||||
'label_type_support' => $this->label_type_support,
|
||||
'order_date' => $this->order_date,
|
||||
'code_unique' => $this->code_unique,
|
||||
'code_on_pack' => $this->code_on_pack
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
namespace LDC\LDCCRM\Models;
|
||||
|
||||
use Exception;
|
||||
use JsonSerializable;
|
||||
use Kwaadpepper\Enum\BaseEnum;
|
||||
use LDC\LDCCRM\Enums\ArcadiaOrderType;
|
||||
use LDC\LDCCRM\Enums\Country;
|
||||
|
|
@ -21,7 +22,7 @@ use TypeError;
|
|||
* @package LDCCrmClient
|
||||
* @subpackage models
|
||||
*/
|
||||
abstract class CrmClientModel
|
||||
abstract class CrmClientModel implements JsonSerializable
|
||||
{
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -581,8 +581,29 @@ class Customer extends CrmClientModel
|
|||
if ($e->getApiError()->equals(ApiError::authFailed())) {
|
||||
return false;
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
return $response->status->equals(ApiStatus::OK());
|
||||
|
||||
/**
|
||||
* Serialize this object to an array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return [
|
||||
'hashcode' => $this->hashcode,
|
||||
'email' => $this->email,
|
||||
'firstname' => $this->firstname,
|
||||
'lastname' => $this->lastname,
|
||||
'birth_date' => $this->birth_date,
|
||||
'phone' => $this->phone,
|
||||
'address' => $this->address,
|
||||
'address2' => $this->address2,
|
||||
'city' => $this->city,
|
||||
'postcode' => $this->postcode,
|
||||
'country' => $this->country,
|
||||
'opt_in' => $this->opt_in,
|
||||
'status' => $this->status,
|
||||
'last_connection' => $this->last_connection
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -290,4 +290,19 @@ class Question extends CrmClientModel
|
|||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialize this object to an array
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return [
|
||||
'id' => $this->id,
|
||||
'question' => $this->question,
|
||||
'type' => $this->type,
|
||||
'answers' => $this->answers
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue