-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathProfile.php
More file actions
77 lines (68 loc) · 1.92 KB
/
Profile.php
File metadata and controls
77 lines (68 loc) · 1.92 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
<?php
namespace WorkOS\Resource;
use WorkOS\Resource\RoleResponse;
/**
* Class Profile.
*
* @property string $id
* @property string $email
* @property string $firstName
* @property string $lastName
* @property string $organizationId
* @property string $connectionId
* @property string $connectionType
* @property string $idpId
* @property RoleResponse|null $role
* @property array<RoleResponse>|null $roles
* @property array $groups
* @property array $rawAttributes
*/
class Profile extends BaseWorkOSResource
{
public const RESOURCE_TYPE = "profile";
public const RESOURCE_ATTRIBUTES = [
"id",
"email",
"firstName",
"lastName",
"organizationId",
"connectionId",
"connectionType",
"idpId",
"role",
"roles",
"groups",
"customAttributes",
"rawAttributes"
];
public const RESPONSE_TO_RESOURCE_KEY = [
"id" => "id",
"email" => "email",
"first_name" => "firstName",
"last_name" => "lastName",
"organization_id" => "organizationId",
"connection_id" => "connectionId",
"connection_type" => "connectionType",
"idp_id" => "idpId",
"role" => "role",
"roles" => "roles",
"groups" => "groups",
"custom_attributes" => "customAttributes",
"raw_attributes" => "rawAttributes"
];
public static function constructFromResponse($response)
{
$instance = parent::constructFromResponse($response);
if (isset($response["role"])) {
$instance->values["role"] = new RoleResponse($response["role"]["slug"]);
}
if (isset($response["roles"])) {
$roles = [];
foreach ($response["roles"] as $role) {
$roles[] = new RoleResponse($role["slug"]);
}
$instance->values["roles"] = $roles;
}
return $instance;
}
}