1 <?php
2
3 namespace wataridori\ChatworkSDK;
4
5 class ChatworkUser extends ChatworkBase
6 {
7 public $account_id;
8 public $role = '';
9 public $name = '';
10 public $chatwork_id = '';
11 public $organization_id = '';
12 public $organization_name = '';
13 public $department = '';
14 public $avatar_image_url = '';
15
16 protected $chatworkApi;
17
18 19 20 21 22
23 public function __construct($account, $name = '', $avatar_image_url = '')
24 {
25 if (is_array($account)) {
26 foreach ($account as $key => $value) {
27 if (property_exists($this, $key)) {
28 $this->$key = $value;
29 }
30 }
31 } elseif (is_numeric($account)) {
32 $this->account_id = $account;
33 $this->name = $name;
34 $this->avatar_image_url = $avatar_image_url;
35 }
36
37 $this->chatworkApi = new ChatworkApi();
38 }
39
40 41 42 43 44
45 public function toArray()
46 {
47 return [
48 'account_id' => $this->account_id,
49 'role' => $this->role,
50 'name' => $this->name,
51 'chatwork_id' => $this->chatwork_id,
52 'organization_id' => $this->organization_id,
53 'organization_name' => $this->organization_name,
54 'department' => $this->department,
55 'avatar_image_url' => $this->avatar_image_url,
56 ];
57 }
58 }
59