-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathDirectoryUser.php
More file actions
84 lines (75 loc) · 2.55 KB
/
DirectoryUser.php
File metadata and controls
84 lines (75 loc) · 2.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
namespace WorkOS\Resource;
/**
* Class DirectoryUser.
*/
class DirectoryUser extends BaseWorkOSResource
{
public const RESOURCE_TYPE = "directory_usr";
public const RESOURCE_ATTRIBUTES = [
"id",
"rawAttributes",
"customAttributes",
"firstName",
"email",
/**
* @deprecated 4.22.0 Will be removed in a future major version.
* Enable the `emails` custom attribute in dashboard and pull from customAttributes instead.
* See https://workos.com/docs/directory-sync/attributes/custom-attributes/auto-mapped-attributes for details.
*/
"emails",
/**
* @deprecated 4.22.0 Will be removed in a future major version.
* Enable the `username` custom attribute in dashboard and pull from customAttributes instead.
* See https://workos.com/docs/directory-sync/attributes/custom-attributes/auto-mapped-attributes for details.
*/
"username",
"lastName",
/**
* @deprecated 4.22.0 Will be removed in a future major version.
* Enable the `job_title` custom attribute in dashboard and pull from customAttributes instead.
* See https://workos.com/docs/directory-sync/attributes/custom-attributes/auto-mapped-attributes for details.
*/
"jobTitle",
"state",
"idpId",
"groups",
"directoryId",
"organizationId"
];
public const RESPONSE_TO_RESOURCE_KEY = [
"id" => "id",
"raw_attributes" => "rawAttributes",
"custom_attributes" => "customAttributes",
"first_name" => "firstName",
"email" => "email",
"emails" => "emails",
"username" => "username",
"last_name" => "lastName",
"job_title" => "jobTitle",
"state" => "state",
"idp_id" => "idpId",
"groups" => "groups",
"directory_id" => "directoryId",
"organization_id" => "organizationId"
];
/**
* @deprecated 4.22.0 Use `email` property instead.
*
* @return string|null The primary email address if found, null otherwise
*/
public function primaryEmail()
{
$msg = "'primaryEmail' is deprecated. Please use 'email' instead.";
trigger_error($msg, E_USER_DEPRECATED);
$response = $this;
if (count($response->raw["emails"]) == 0) {
return;
};
foreach ($response->raw["emails"] as $value) {
if ($value["primary"] == true) {
return $value["value"];
};
};
}
}