1 <?php
2
3 namespace wataridori\ChatworkSDK;
4
5 class ChatworkMessage extends ChatworkBase
6 {
7 public $message_id = '';
8 9 10
11 public $account = null;
12 public $body = '';
13 public $send_time = '';
14 public $update_time = '';
15
16 public $chatworkApi;
17
18 public function __construct($message)
19 {
20 if (is_array($message)) {
21 foreach ($message as $key => $value) {
22 if (property_exists($this, $key)) {
23 if ($key === 'account') {
24 $this->$key = new ChatworkUser($value);
25 } else {
26 $this->$key = $value;
27 }
28 }
29 }
30 }
31
32 $this->chatworkApi = new ChatworkApi();
33 }
34
35 public function toArray()
36 {
37 return [
38 'message_id' => $this->message_id,
39 'account' => $this->account->toArray(),
40 'body' => $this->body,
41 'send_time' => $this->send_time,
42 'update_time' => $this->update_time,
43 ];
44 }
45 }
46