| @@ 12-52 (lines=41) @@ | ||
| 9 | /** |
|
| 10 | * @author Ibrahim Hizeoui <[email protected]> |
|
| 11 | */ |
|
| 12 | class AutomaticCollection implements CreatableFromArray |
|
| 13 | { |
|
| 14 | /** |
|
| 15 | * @var int |
|
| 16 | */ |
|
| 17 | private $delayDays; |
|
| 18 | ||
| 19 | /** |
|
| 20 | * @var int |
|
| 21 | */ |
|
| 22 | private $amount; |
|
| 23 | ||
| 24 | public function toArray() |
|
| 25 | { |
|
| 26 | $data = []; |
|
| 27 | if ($this->delayDays !== null) { |
|
| 28 | $data['delay_days'] = $this->delayDays; |
|
| 29 | } |
|
| 30 | if ($this->amount !== null) { |
|
| 31 | $data['message'] = $this->amount; |
|
| 32 | } |
|
| 33 | ||
| 34 | return $data; |
|
| 35 | } |
|
| 36 | ||
| 37 | /** |
|
| 38 | * Create an API response object from the HTTP response from the API server. |
|
| 39 | * |
|
| 40 | * @param array $data |
|
| 41 | * |
|
| 42 | * @return self |
|
| 43 | */ |
|
| 44 | public static function createFromArray(array $data) |
|
| 45 | { |
|
| 46 | $automaticReminder = new self(); |
|
| 47 | $automaticReminder->delayDays = $data['delay_days']; |
|
| 48 | $automaticReminder->amount = $data['amount']; |
|
| 49 | ||
| 50 | return $automaticReminder; |
|
| 51 | } |
|
| 52 | } |
|
| 53 | ||
| @@ 12-52 (lines=41) @@ | ||
| 9 | /** |
|
| 10 | * @author Ibrahim Hizeoui <[email protected]> |
|
| 11 | */ |
|
| 12 | class AutomaticReminder implements CreatableFromArray |
|
| 13 | { |
|
| 14 | /** |
|
| 15 | * @var int |
|
| 16 | */ |
|
| 17 | private $delayDays; |
|
| 18 | ||
| 19 | /** |
|
| 20 | * @var string |
|
| 21 | */ |
|
| 22 | private $message; |
|
| 23 | ||
| 24 | public function toArray() |
|
| 25 | { |
|
| 26 | $data = []; |
|
| 27 | if ($this->delayDays !== null) { |
|
| 28 | $data['delay_days'] = $this->delayDays; |
|
| 29 | } |
|
| 30 | if ($this->message !== null) { |
|
| 31 | $data['message'] = $this->message; |
|
| 32 | } |
|
| 33 | ||
| 34 | return $data; |
|
| 35 | } |
|
| 36 | ||
| 37 | /** |
|
| 38 | * Create an API response object from the HTTP response from the API server. |
|
| 39 | * |
|
| 40 | * @param array $data |
|
| 41 | * |
|
| 42 | * @return self |
|
| 43 | */ |
|
| 44 | public static function createFromArray(array $data) |
|
| 45 | { |
|
| 46 | $automaticReminder = new self(); |
|
| 47 | $automaticReminder->delayDays = $data['delay_days']; |
|
| 48 | $automaticReminder->message = $data['message']; |
|
| 49 | ||
| 50 | return $automaticReminder; |
|
| 51 | } |
|
| 52 | } |
|
| 53 | ||