From 3557ee906f27d3ed520fc9a5160c2dfb2a994994 Mon Sep 17 00:00:00 2001 From: "workos-sdk-automation[bot]" <255426317+workos-sdk-automation[bot]@users.noreply.github.com> Date: Thu, 30 Apr 2026 20:02:52 +0000 Subject: [PATCH] feat(generated): Add new classes and fields for API key validation and dsync tokens --- .last-synced-sha | 2 +- .oagen-manifest.json | 17 ++++- lib/Resource/ApiKey.php | 1 - lib/Resource/ApiKeyCreatedData.php | 4 +- lib/Resource/ApiKeyCreatedDataOwner.php | 1 - lib/Resource/ApiKeyRevokedData.php | 4 +- lib/Resource/ApiKeyRevokedDataOwner.php | 1 - lib/Resource/ApiKeyValidationResponse.php | 4 +- .../ApiKeyValidationResponseApiKey.php | 67 +++++++++++++++++ .../ApiKeyValidationResponseApiKeyOwner.php | 37 +++++++++ lib/Resource/DirectoryUser.php | 4 + lib/Resource/DirectoryUserWithGroups.php | 6 +- lib/Resource/DsyncTokenCreated.php | 50 +++++++++++++ lib/Resource/DsyncTokenCreatedData.php | 57 ++++++++++++++ lib/Resource/DsyncTokenDeleted.php | 50 +++++++++++++ lib/Resource/DsyncTokenDeletedData.php | 57 ++++++++++++++ lib/Resource/DsyncUserUpdatedData.php | 4 + lib/Resource/EventContextActorSource.php | 1 + lib/Resource/OrganizationMembership.php | 4 + lib/Resource/Profile.php | 4 + lib/Resource/UserOrganizationMembership.php | 4 + ...UserOrganizationMembershipBaseWithUser.php | 75 +++++++++++++++++++ lib/Service/Authorization.php | 10 +-- .../api_key_validation_response_api_key.json | 17 +++++ ...key_validation_response_api_key_owner.json | 4 + tests/Fixtures/directory_user.json | 3 +- .../Fixtures/directory_user_with_groups.json | 3 +- tests/Fixtures/dsync_group_user_added.json | 3 +- .../Fixtures/dsync_group_user_added_data.json | 3 +- tests/Fixtures/dsync_group_user_removed.json | 3 +- .../dsync_group_user_removed_data.json | 3 +- tests/Fixtures/dsync_token_created.json | 35 +++++++++ tests/Fixtures/dsync_token_created_data.json | 9 +++ tests/Fixtures/dsync_token_deleted.json | 35 +++++++++ tests/Fixtures/dsync_token_deleted_data.json | 9 +++ tests/Fixtures/dsync_user_created.json | 3 +- tests/Fixtures/dsync_user_deleted.json | 3 +- tests/Fixtures/dsync_user_updated.json | 3 +- tests/Fixtures/dsync_user_updated_data.json | 3 +- tests/Fixtures/jwt_template_response.json | 2 +- .../list_directory_user_with_groups.json | 1 + .../list_user_organization_membership.json | 19 ++++- ...rganization_membership_base_list_data.json | 2 +- ...rganization_membership_base_with_user.json | 41 ++++++++++ tests/Fixtures/organization_membership.json | 17 +++++ tests/Fixtures/profile.json | 3 +- tests/Fixtures/sso_token_response.json | 3 +- tests/Fixtures/update_jwt_template.json | 2 +- .../user_organization_membership.json | 19 ++++- ...rganization_membership_base_list_data.json | 2 +- ...rganization_membership_base_with_user.json | 33 ++++++++ tests/Service/AuthorizationTest.php | 4 +- 52 files changed, 714 insertions(+), 37 deletions(-) create mode 100644 lib/Resource/ApiKeyValidationResponseApiKey.php create mode 100644 lib/Resource/ApiKeyValidationResponseApiKeyOwner.php create mode 100644 lib/Resource/DsyncTokenCreated.php create mode 100644 lib/Resource/DsyncTokenCreatedData.php create mode 100644 lib/Resource/DsyncTokenDeleted.php create mode 100644 lib/Resource/DsyncTokenDeletedData.php create mode 100644 lib/Resource/UserOrganizationMembershipBaseWithUser.php create mode 100644 tests/Fixtures/api_key_validation_response_api_key.json create mode 100644 tests/Fixtures/api_key_validation_response_api_key_owner.json create mode 100644 tests/Fixtures/dsync_token_created.json create mode 100644 tests/Fixtures/dsync_token_created_data.json create mode 100644 tests/Fixtures/dsync_token_deleted.json create mode 100644 tests/Fixtures/dsync_token_deleted_data.json create mode 100644 tests/Fixtures/list_user_organization_membership_base_with_user.json create mode 100644 tests/Fixtures/user_organization_membership_base_with_user.json diff --git a/.last-synced-sha b/.last-synced-sha index f72eb0e2..be98ab48 100644 --- a/.last-synced-sha +++ b/.last-synced-sha @@ -1 +1 @@ -92db0495807c86fbbc4d45bd266a6c1f5bcbb59c +f908f520f9fcd63dfd42ed35b7f141a65b61609b diff --git a/.oagen-manifest.json b/.oagen-manifest.json index 7dc94e72..feba7ca5 100644 --- a/.oagen-manifest.json +++ b/.oagen-manifest.json @@ -1,7 +1,7 @@ { "version": 2, "language": "php", - "generatedAt": "2026-04-28T15:07:27.545Z", + "generatedAt": "2026-04-30T20:02:41.747Z", "files": [ "lib/Resource/ActionAuthenticationDenied.php", "lib/Resource/ActionAuthenticationDeniedData.php", @@ -17,6 +17,8 @@ "lib/Resource/ApiKeyRevokedData.php", "lib/Resource/ApiKeyRevokedDataOwner.php", "lib/Resource/ApiKeyValidationResponse.php", + "lib/Resource/ApiKeyValidationResponseApiKey.php", + "lib/Resource/ApiKeyValidationResponseApiKeyOwner.php", "lib/Resource/ApiKeyWithValue.php", "lib/Resource/ApiKeyWithValueOwner.php", "lib/Resource/ApplicationCredentialsListItem.php", @@ -210,6 +212,10 @@ "lib/Resource/DsyncGroupUserAddedData.php", "lib/Resource/DsyncGroupUserRemoved.php", "lib/Resource/DsyncGroupUserRemovedData.php", + "lib/Resource/DsyncTokenCreated.php", + "lib/Resource/DsyncTokenCreatedData.php", + "lib/Resource/DsyncTokenDeleted.php", + "lib/Resource/DsyncTokenDeletedData.php", "lib/Resource/DsyncUserCreated.php", "lib/Resource/DsyncUserDeleted.php", "lib/Resource/DsyncUserUpdated.php", @@ -433,6 +439,7 @@ "lib/Resource/UserObject.php", "lib/Resource/UserOrganizationMembership.php", "lib/Resource/UserOrganizationMembershipBaseListData.php", + "lib/Resource/UserOrganizationMembershipBaseWithUser.php", "lib/Resource/UserSessionsAuthMethod.php", "lib/Resource/UserSessionsImpersonator.php", "lib/Resource/UserSessionsListItem.php", @@ -518,6 +525,8 @@ "tests/Fixtures/api_key_revoked_data.json", "tests/Fixtures/api_key_revoked_data_owner.json", "tests/Fixtures/api_key_validation_response.json", + "tests/Fixtures/api_key_validation_response_api_key.json", + "tests/Fixtures/api_key_validation_response_api_key_owner.json", "tests/Fixtures/api_key_with_value.json", "tests/Fixtures/api_key_with_value_owner.json", "tests/Fixtures/application_credentials_list_item.json", @@ -684,6 +693,10 @@ "tests/Fixtures/dsync_group_user_added_data.json", "tests/Fixtures/dsync_group_user_removed.json", "tests/Fixtures/dsync_group_user_removed_data.json", + "tests/Fixtures/dsync_token_created.json", + "tests/Fixtures/dsync_token_created_data.json", + "tests/Fixtures/dsync_token_deleted.json", + "tests/Fixtures/dsync_token_deleted_data.json", "tests/Fixtures/dsync_user_created.json", "tests/Fixtures/dsync_user_deleted.json", "tests/Fixtures/dsync_user_updated.json", @@ -781,6 +794,7 @@ "tests/Fixtures/list_user_invite.json", "tests/Fixtures/list_user_organization_membership.json", "tests/Fixtures/list_user_organization_membership_base_list_data.json", + "tests/Fixtures/list_user_organization_membership_base_with_user.json", "tests/Fixtures/list_user_sessions_list_item.json", "tests/Fixtures/list_webhook_endpoint_json.json", "tests/Fixtures/magic_auth.json", @@ -908,6 +922,7 @@ "tests/Fixtures/user_object.json", "tests/Fixtures/user_organization_membership.json", "tests/Fixtures/user_organization_membership_base_list_data.json", + "tests/Fixtures/user_organization_membership_base_with_user.json", "tests/Fixtures/user_sessions_impersonator.json", "tests/Fixtures/user_sessions_list_item.json", "tests/Fixtures/user_updated.json", diff --git a/lib/Resource/ApiKey.php b/lib/Resource/ApiKey.php index 8d5c9236..f191eeae 100644 --- a/lib/Resource/ApiKey.php +++ b/lib/Resource/ApiKey.php @@ -6,7 +6,6 @@ namespace WorkOS\Resource; -/** The API Key object if the value is valid, or `null` if invalid. */ readonly class ApiKey implements \JsonSerializable { use JsonSerializableTrait; diff --git a/lib/Resource/ApiKeyCreatedData.php b/lib/Resource/ApiKeyCreatedData.php index c6c4946b..cdd0647e 100644 --- a/lib/Resource/ApiKeyCreatedData.php +++ b/lib/Resource/ApiKeyCreatedData.php @@ -41,7 +41,7 @@ public static function fromArray(array $data): self return new self( object: $data['object'] ?? 'api_key', id: $data['id'], - owner: ApiKeyCreatedDataOwner::fromArray($data['owner']), + owner: $data['owner'], name: $data['name'], obfuscatedValue: $data['obfuscated_value'], lastUsedAt: $data['last_used_at'] ?? null, @@ -56,7 +56,7 @@ public function toArray(): array return [ 'object' => $this->object, 'id' => $this->id, - 'owner' => $this->owner->toArray(), + 'owner' => $this->owner, 'name' => $this->name, 'obfuscated_value' => $this->obfuscatedValue, 'last_used_at' => $this->lastUsedAt, diff --git a/lib/Resource/ApiKeyCreatedDataOwner.php b/lib/Resource/ApiKeyCreatedDataOwner.php index 2bd5f0e0..5bc0915d 100644 --- a/lib/Resource/ApiKeyCreatedDataOwner.php +++ b/lib/Resource/ApiKeyCreatedDataOwner.php @@ -6,7 +6,6 @@ namespace WorkOS\Resource; -/** The owner of the API key. */ readonly class ApiKeyCreatedDataOwner implements \JsonSerializable { use JsonSerializableTrait; diff --git a/lib/Resource/ApiKeyRevokedData.php b/lib/Resource/ApiKeyRevokedData.php index 7bfd84b4..42d9166d 100644 --- a/lib/Resource/ApiKeyRevokedData.php +++ b/lib/Resource/ApiKeyRevokedData.php @@ -41,7 +41,7 @@ public static function fromArray(array $data): self return new self( object: $data['object'] ?? 'api_key', id: $data['id'], - owner: ApiKeyRevokedDataOwner::fromArray($data['owner']), + owner: $data['owner'], name: $data['name'], obfuscatedValue: $data['obfuscated_value'], lastUsedAt: $data['last_used_at'] ?? null, @@ -56,7 +56,7 @@ public function toArray(): array return [ 'object' => $this->object, 'id' => $this->id, - 'owner' => $this->owner->toArray(), + 'owner' => $this->owner, 'name' => $this->name, 'obfuscated_value' => $this->obfuscatedValue, 'last_used_at' => $this->lastUsedAt, diff --git a/lib/Resource/ApiKeyRevokedDataOwner.php b/lib/Resource/ApiKeyRevokedDataOwner.php index a511766b..7dde8331 100644 --- a/lib/Resource/ApiKeyRevokedDataOwner.php +++ b/lib/Resource/ApiKeyRevokedDataOwner.php @@ -6,7 +6,6 @@ namespace WorkOS\Resource; -/** The owner of the API key. */ readonly class ApiKeyRevokedDataOwner implements \JsonSerializable { use JsonSerializableTrait; diff --git a/lib/Resource/ApiKeyValidationResponse.php b/lib/Resource/ApiKeyValidationResponse.php index 61553404..a84fa57b 100644 --- a/lib/Resource/ApiKeyValidationResponse.php +++ b/lib/Resource/ApiKeyValidationResponse.php @@ -11,14 +11,14 @@ use JsonSerializableTrait; public function __construct( - public ?ApiKey $apiKey, + public ?ApiKeyValidationResponseApiKey $apiKey, ) { } public static function fromArray(array $data): self { return new self( - apiKey: isset($data['api_key']) ? ApiKey::fromArray($data['api_key']) : null, + apiKey: isset($data['api_key']) ? ApiKeyValidationResponseApiKey::fromArray($data['api_key']) : null, ); } diff --git a/lib/Resource/ApiKeyValidationResponseApiKey.php b/lib/Resource/ApiKeyValidationResponseApiKey.php new file mode 100644 index 00000000..78cd869a --- /dev/null +++ b/lib/Resource/ApiKeyValidationResponseApiKey.php @@ -0,0 +1,67 @@ + + */ + public array $permissions, + /** An ISO 8601 timestamp. */ + public \DateTimeImmutable $createdAt, + /** An ISO 8601 timestamp. */ + public \DateTimeImmutable $updatedAt, + ) { + } + + public static function fromArray(array $data): self + { + return new self( + object: $data['object'] ?? 'api_key', + id: $data['id'], + owner: ApiKeyValidationResponseApiKeyOwner::fromArray($data['owner']), + name: $data['name'], + obfuscatedValue: $data['obfuscated_value'], + lastUsedAt: isset($data['last_used_at']) ? new \DateTimeImmutable($data['last_used_at']) : null, + permissions: $data['permissions'], + createdAt: new \DateTimeImmutable($data['created_at']), + updatedAt: new \DateTimeImmutable($data['updated_at']), + ); + } + + public function toArray(): array + { + return [ + 'object' => $this->object, + 'id' => $this->id, + 'owner' => $this->owner->toArray(), + 'name' => $this->name, + 'obfuscated_value' => $this->obfuscatedValue, + 'last_used_at' => $this->lastUsedAt?->format(\DateTimeInterface::RFC3339_EXTENDED), + 'permissions' => $this->permissions, + 'created_at' => $this->createdAt->format(\DateTimeInterface::RFC3339_EXTENDED), + 'updated_at' => $this->updatedAt->format(\DateTimeInterface::RFC3339_EXTENDED), + ]; + } +} diff --git a/lib/Resource/ApiKeyValidationResponseApiKeyOwner.php b/lib/Resource/ApiKeyValidationResponseApiKeyOwner.php new file mode 100644 index 00000000..0772ae2a --- /dev/null +++ b/lib/Resource/ApiKeyValidationResponseApiKeyOwner.php @@ -0,0 +1,37 @@ + $this->type, + 'id' => $this->id, + ]; + } +} diff --git a/lib/Resource/DirectoryUser.php b/lib/Resource/DirectoryUser.php index e8685590..365dd4bb 100644 --- a/lib/Resource/DirectoryUser.php +++ b/lib/Resource/DirectoryUser.php @@ -44,6 +44,8 @@ public function __construct( public ?string $firstName = null, /** The last name of the user. */ public ?string $lastName = null, + /** The full name of the user. */ + public ?string $name = null, /** * A list of email addresses for the user. * @var array<\WorkOS\Resource\DirectoryUserEmail>|null @@ -85,6 +87,7 @@ public static function fromArray(array $data): self updatedAt: new \DateTimeImmutable($data['updated_at']), firstName: $data['first_name'] ?? null, lastName: $data['last_name'] ?? null, + name: $data['name'] ?? null, emails: isset($data['emails']) ? array_map(fn ($item) => DirectoryUserEmail::fromArray($item), $data['emails']) : null, jobTitle: $data['job_title'] ?? null, username: $data['username'] ?? null, @@ -109,6 +112,7 @@ public function toArray(): array 'updated_at' => $this->updatedAt->format(\DateTimeInterface::RFC3339_EXTENDED), 'first_name' => $this->firstName, 'last_name' => $this->lastName, + 'name' => $this->name, 'emails' => $this->emails !== null ? array_map(fn ($item) => $item->toArray(), $this->emails) : null, 'job_title' => $this->jobTitle, 'username' => $this->username, diff --git a/lib/Resource/DirectoryUserWithGroups.php b/lib/Resource/DirectoryUserWithGroups.php index b11c7696..9a3a32fc 100644 --- a/lib/Resource/DirectoryUserWithGroups.php +++ b/lib/Resource/DirectoryUserWithGroups.php @@ -41,7 +41,7 @@ public function __construct( /** An ISO 8601 timestamp. */ public \DateTimeImmutable $updatedAt, /** - * The directory groups the user belongs to. Use the List Directory Groups endpoint with a user filter instead. + * The directory groups the user belongs to. Deprecated: starting May 1, 2026, this field returns an empty array by default for newly created teams. Existing teams currently depending on this field should migrate to the new access pattern for better throughput performance — the field is unbounded by user, so users with many group memberships produce large, slow response payloads. Use the List Directory Groups endpoint with a `user` filter to fetch a user's group memberships. * @var array<\WorkOS\Resource\DirectoryGroup> * @deprecated */ @@ -50,6 +50,8 @@ public function __construct( public ?string $firstName = null, /** The last name of the user. */ public ?string $lastName = null, + /** The full name of the user. */ + public ?string $name = null, /** * A list of email addresses for the user. * @var array<\WorkOS\Resource\DirectoryUserWithGroupsEmail>|null @@ -92,6 +94,7 @@ public static function fromArray(array $data): self groups: array_map(fn ($item) => DirectoryGroup::fromArray($item), $data['groups']), firstName: $data['first_name'] ?? null, lastName: $data['last_name'] ?? null, + name: $data['name'] ?? null, emails: isset($data['emails']) ? array_map(fn ($item) => DirectoryUserWithGroupsEmail::fromArray($item), $data['emails']) : null, jobTitle: $data['job_title'] ?? null, username: $data['username'] ?? null, @@ -117,6 +120,7 @@ public function toArray(): array 'groups' => array_map(fn ($item) => $item->toArray(), $this->groups), 'first_name' => $this->firstName, 'last_name' => $this->lastName, + 'name' => $this->name, 'emails' => $this->emails !== null ? array_map(fn ($item) => $item->toArray(), $this->emails) : null, 'job_title' => $this->jobTitle, 'username' => $this->username, diff --git a/lib/Resource/DsyncTokenCreated.php b/lib/Resource/DsyncTokenCreated.php new file mode 100644 index 00000000..d450b168 --- /dev/null +++ b/lib/Resource/DsyncTokenCreated.php @@ -0,0 +1,50 @@ + $this->id, + 'event' => $this->event, + 'data' => $this->data->toArray(), + 'created_at' => $this->createdAt->format(\DateTimeInterface::RFC3339_EXTENDED), + 'object' => $this->object, + 'context' => $this->context?->toArray(), + ]; + } +} diff --git a/lib/Resource/DsyncTokenCreatedData.php b/lib/Resource/DsyncTokenCreatedData.php new file mode 100644 index 00000000..7d0d0628 --- /dev/null +++ b/lib/Resource/DsyncTokenCreatedData.php @@ -0,0 +1,57 @@ + $this->object, + 'id' => $this->id, + 'directory_id' => $this->directoryId, + 'token_suffix' => $this->tokenSuffix, + 'created_at' => $this->createdAt->format(\DateTimeInterface::RFC3339_EXTENDED), + 'expires_at' => $this->expiresAt?->format(\DateTimeInterface::RFC3339_EXTENDED), + 'organization_id' => $this->organizationId, + ]; + } +} diff --git a/lib/Resource/DsyncTokenDeleted.php b/lib/Resource/DsyncTokenDeleted.php new file mode 100644 index 00000000..feeec752 --- /dev/null +++ b/lib/Resource/DsyncTokenDeleted.php @@ -0,0 +1,50 @@ + $this->id, + 'event' => $this->event, + 'data' => $this->data->toArray(), + 'created_at' => $this->createdAt->format(\DateTimeInterface::RFC3339_EXTENDED), + 'object' => $this->object, + 'context' => $this->context?->toArray(), + ]; + } +} diff --git a/lib/Resource/DsyncTokenDeletedData.php b/lib/Resource/DsyncTokenDeletedData.php new file mode 100644 index 00000000..4f853495 --- /dev/null +++ b/lib/Resource/DsyncTokenDeletedData.php @@ -0,0 +1,57 @@ + $this->object, + 'id' => $this->id, + 'directory_id' => $this->directoryId, + 'token_suffix' => $this->tokenSuffix, + 'created_at' => $this->createdAt->format(\DateTimeInterface::RFC3339_EXTENDED), + 'expires_at' => $this->expiresAt?->format(\DateTimeInterface::RFC3339_EXTENDED), + 'organization_id' => $this->organizationId, + ]; + } +} diff --git a/lib/Resource/DsyncUserUpdatedData.php b/lib/Resource/DsyncUserUpdatedData.php index 48ec04a7..1385ba46 100644 --- a/lib/Resource/DsyncUserUpdatedData.php +++ b/lib/Resource/DsyncUserUpdatedData.php @@ -45,6 +45,8 @@ public function __construct( public ?string $firstName = null, /** The last name of the user. */ public ?string $lastName = null, + /** The full name of the user. */ + public ?string $name = null, /** * A list of email addresses for the user. * @var array<\WorkOS\Resource\DsyncUserUpdatedDataEmail>|null @@ -88,6 +90,7 @@ public static function fromArray(array $data): self updatedAt: new \DateTimeImmutable($data['updated_at']), firstName: $data['first_name'] ?? null, lastName: $data['last_name'] ?? null, + name: $data['name'] ?? null, emails: isset($data['emails']) ? array_map(fn ($item) => DsyncUserUpdatedDataEmail::fromArray($item), $data['emails']) : null, jobTitle: $data['job_title'] ?? null, username: $data['username'] ?? null, @@ -113,6 +116,7 @@ public function toArray(): array 'updated_at' => $this->updatedAt->format(\DateTimeInterface::RFC3339_EXTENDED), 'first_name' => $this->firstName, 'last_name' => $this->lastName, + 'name' => $this->name, 'emails' => $this->emails !== null ? array_map(fn ($item) => $item->toArray(), $this->emails) : null, 'job_title' => $this->jobTitle, 'username' => $this->username, diff --git a/lib/Resource/EventContextActorSource.php b/lib/Resource/EventContextActorSource.php index 1fcc2a21..79808ce4 100644 --- a/lib/Resource/EventContextActorSource.php +++ b/lib/Resource/EventContextActorSource.php @@ -10,5 +10,6 @@ enum EventContextActorSource: string { case Api = 'api'; case Dashboard = 'dashboard'; + case AdminPortal = 'admin_portal'; case System = 'system'; } diff --git a/lib/Resource/OrganizationMembership.php b/lib/Resource/OrganizationMembership.php index c36ed72a..aa4d8f98 100644 --- a/lib/Resource/OrganizationMembership.php +++ b/lib/Resource/OrganizationMembership.php @@ -29,6 +29,8 @@ public function __construct( public \DateTimeImmutable $updatedAt, /** The primary role assigned to the user within the organization. */ public SlimRole $role, + /** The user that belongs to the organization through this membership. */ + public User $user, /** The name of the organization which the user belongs to. */ public ?string $organizationName = null, /** @@ -51,6 +53,7 @@ public static function fromArray(array $data): self createdAt: new \DateTimeImmutable($data['created_at']), updatedAt: new \DateTimeImmutable($data['updated_at']), role: SlimRole::fromArray($data['role']), + user: User::fromArray($data['user']), organizationName: $data['organization_name'] ?? null, customAttributes: $data['custom_attributes'] ?? null, ); @@ -68,6 +71,7 @@ public function toArray(): array 'created_at' => $this->createdAt->format(\DateTimeInterface::RFC3339_EXTENDED), 'updated_at' => $this->updatedAt->format(\DateTimeInterface::RFC3339_EXTENDED), 'role' => $this->role->toArray(), + 'user' => $this->user->toArray(), 'organization_name' => $this->organizationName, 'custom_attributes' => $this->customAttributes, ]; diff --git a/lib/Resource/Profile.php b/lib/Resource/Profile.php index ef0d7ba2..34b07f1d 100644 --- a/lib/Resource/Profile.php +++ b/lib/Resource/Profile.php @@ -29,6 +29,8 @@ public function __construct( public ?string $firstName, /** The user's last name. */ public ?string $lastName, + /** The user's full name. */ + public ?string $name, /** * The complete set of raw attributes returned by the identity provider. * @var array @@ -66,6 +68,7 @@ public static function fromArray(array $data): self email: $data['email'], firstName: $data['first_name'] ?? null, lastName: $data['last_name'] ?? null, + name: $data['name'] ?? null, rawAttributes: $data['raw_attributes'], role: isset($data['role']) ? SlimRole::fromArray($data['role']) : null, roles: isset($data['roles']) ? array_map(fn ($item) => SlimRole::fromArray($item), $data['roles']) : null, @@ -86,6 +89,7 @@ public function toArray(): array 'email' => $this->email, 'first_name' => $this->firstName, 'last_name' => $this->lastName, + 'name' => $this->name, 'raw_attributes' => $this->rawAttributes, 'role' => $this->role?->toArray(), 'roles' => $this->roles !== null ? array_map(fn ($item) => $item->toArray(), $this->roles) : null, diff --git a/lib/Resource/UserOrganizationMembership.php b/lib/Resource/UserOrganizationMembership.php index cfabf3d5..d6daaf00 100644 --- a/lib/Resource/UserOrganizationMembership.php +++ b/lib/Resource/UserOrganizationMembership.php @@ -29,6 +29,8 @@ public function __construct( public \DateTimeImmutable $updatedAt, /** The primary role assigned to the user within the organization. */ public SlimRole $role, + /** The user that belongs to the organization through this membership. */ + public User $user, /** The name of the organization which the user belongs to. */ public ?string $organizationName = null, /** @@ -51,6 +53,7 @@ public static function fromArray(array $data): self createdAt: new \DateTimeImmutable($data['created_at']), updatedAt: new \DateTimeImmutable($data['updated_at']), role: SlimRole::fromArray($data['role']), + user: User::fromArray($data['user']), organizationName: $data['organization_name'] ?? null, customAttributes: $data['custom_attributes'] ?? null, ); @@ -68,6 +71,7 @@ public function toArray(): array 'created_at' => $this->createdAt->format(\DateTimeInterface::RFC3339_EXTENDED), 'updated_at' => $this->updatedAt->format(\DateTimeInterface::RFC3339_EXTENDED), 'role' => $this->role->toArray(), + 'user' => $this->user->toArray(), 'organization_name' => $this->organizationName, 'custom_attributes' => $this->customAttributes, ]; diff --git a/lib/Resource/UserOrganizationMembershipBaseWithUser.php b/lib/Resource/UserOrganizationMembershipBaseWithUser.php new file mode 100644 index 00000000..82f7a8fe --- /dev/null +++ b/lib/Resource/UserOrganizationMembershipBaseWithUser.php @@ -0,0 +1,75 @@ +|null + */ + public ?array $customAttributes = null, + ) { + } + + public static function fromArray(array $data): self + { + return new self( + object: $data['object'] ?? 'organization_membership', + id: $data['id'], + userId: $data['user_id'], + organizationId: $data['organization_id'], + status: OrganizationMembershipStatus::from($data['status']), + directoryManaged: $data['directory_managed'], + createdAt: new \DateTimeImmutable($data['created_at']), + updatedAt: new \DateTimeImmutable($data['updated_at']), + user: User::fromArray($data['user']), + organizationName: $data['organization_name'] ?? null, + customAttributes: $data['custom_attributes'] ?? null, + ); + } + + public function toArray(): array + { + return [ + 'object' => $this->object, + 'id' => $this->id, + 'user_id' => $this->userId, + 'organization_id' => $this->organizationId, + 'status' => $this->status->value, + 'directory_managed' => $this->directoryManaged, + 'created_at' => $this->createdAt->format(\DateTimeInterface::RFC3339_EXTENDED), + 'updated_at' => $this->updatedAt->format(\DateTimeInterface::RFC3339_EXTENDED), + 'user' => $this->user->toArray(), + 'organization_name' => $this->organizationName, + 'custom_attributes' => $this->customAttributes, + ]; + } +} diff --git a/lib/Service/Authorization.php b/lib/Service/Authorization.php index 59d0721f..00404bbc 100644 --- a/lib/Service/Authorization.php +++ b/lib/Service/Authorization.php @@ -13,7 +13,7 @@ use WorkOS\Resource\Role; use WorkOS\Resource\RoleAssignment; use WorkOS\Resource\RoleList; -use WorkOS\Resource\UserOrganizationMembershipBaseListData; +use WorkOS\Resource\UserOrganizationMembershipBaseWithUser; class Authorization { @@ -618,7 +618,7 @@ public function deleteResourceByExternalId( * @param \WorkOS\Resource\EventsOrder $order Order the results by the creation time. Supported values are `"asc"` (ascending), `"desc"` (descending), and `"normal"` (descending with reversed cursor semantics where `before` fetches older records and `after` fetches newer records). Defaults to descending. Defaults to "desc". * @param string $permissionSlug The permission slug to filter by. Only users with this permission on the resource are returned. * @param \WorkOS\Resource\AuthorizationAssignment|null $assignment Filter by assignment type. Use "direct" for direct assignments only, or "indirect" to include inherited assignments. - * @return \WorkOS\PaginatedResponse<\WorkOS\Resource\UserOrganizationMembershipBaseListData> + * @return \WorkOS\PaginatedResponse<\WorkOS\Resource\UserOrganizationMembershipBaseWithUser> * @throws \WorkOS\Exception\WorkOSException */ public function listMembershipsForResourceByExternalId( @@ -645,7 +645,7 @@ public function listMembershipsForResourceByExternalId( method: 'GET', path: "authorization/organizations/{$organizationId}/resources/{$resourceTypeSlug}/{$externalId}/organization_memberships", query: $query, - modelClass: UserOrganizationMembershipBaseListData::class, + modelClass: UserOrganizationMembershipBaseWithUser::class, options: $options, ); } @@ -840,7 +840,7 @@ public function deleteResource( * @param \WorkOS\Resource\EventsOrder $order Order the results by the creation time. Supported values are `"asc"` (ascending), `"desc"` (descending), and `"normal"` (descending with reversed cursor semantics where `before` fetches older records and `after` fetches newer records). Defaults to descending. Defaults to "desc". * @param string $permissionSlug The permission slug to filter by. Only users with this permission on the resource are returned. * @param \WorkOS\Resource\AuthorizationAssignment|null $assignment Filter by assignment type. Use `direct` for direct assignments only, or `indirect` to include inherited assignments. - * @return \WorkOS\PaginatedResponse<\WorkOS\Resource\UserOrganizationMembershipBaseListData> + * @return \WorkOS\PaginatedResponse<\WorkOS\Resource\UserOrganizationMembershipBaseWithUser> * @throws \WorkOS\Exception\WorkOSException */ public function listMembershipsForResource( @@ -865,7 +865,7 @@ public function listMembershipsForResource( method: 'GET', path: "authorization/resources/{$resourceId}/organization_memberships", query: $query, - modelClass: UserOrganizationMembershipBaseListData::class, + modelClass: UserOrganizationMembershipBaseWithUser::class, options: $options, ); } diff --git a/tests/Fixtures/api_key_validation_response_api_key.json b/tests/Fixtures/api_key_validation_response_api_key.json new file mode 100644 index 00000000..e05b1db2 --- /dev/null +++ b/tests/Fixtures/api_key_validation_response_api_key.json @@ -0,0 +1,17 @@ +{ + "object": "api_key", + "id": "api_key_01EHZNVPK3SFK441A1RGBFSHRT", + "owner": { + "type": "organization", + "id": "org_01EHZNVPK3SFK441A1RGBFSHRT" + }, + "name": "Production API Key", + "obfuscated_value": "sk_...3456", + "last_used_at": null, + "permissions": [ + "posts:read", + "posts:write" + ], + "created_at": "2026-01-15T12:00:00.000Z", + "updated_at": "2026-01-15T12:00:00.000Z" +} diff --git a/tests/Fixtures/api_key_validation_response_api_key_owner.json b/tests/Fixtures/api_key_validation_response_api_key_owner.json new file mode 100644 index 00000000..ddbfe81d --- /dev/null +++ b/tests/Fixtures/api_key_validation_response_api_key_owner.json @@ -0,0 +1,4 @@ +{ + "type": "organization", + "id": "org_01EHZNVPK3SFK441A1RGBFSHRT" +} diff --git a/tests/Fixtures/directory_user.json b/tests/Fixtures/directory_user.json index 68d037ee..54b60741 100644 --- a/tests/Fixtures/directory_user.json +++ b/tests/Fixtures/directory_user.json @@ -33,5 +33,6 @@ } ], "created_at": "2026-01-15T12:00:00.000Z", - "updated_at": "2026-01-15T12:00:00.000Z" + "updated_at": "2026-01-15T12:00:00.000Z", + "name": "Marcelina Davis" } diff --git a/tests/Fixtures/directory_user_with_groups.json b/tests/Fixtures/directory_user_with_groups.json index d7d35220..d48e0900 100644 --- a/tests/Fixtures/directory_user_with_groups.json +++ b/tests/Fixtures/directory_user_with_groups.json @@ -48,5 +48,6 @@ "created_at": "2026-01-15T12:00:00.000Z", "updated_at": "2026-01-15T12:00:00.000Z" } - ] + ], + "name": "Marcelina Davis" } diff --git a/tests/Fixtures/dsync_group_user_added.json b/tests/Fixtures/dsync_group_user_added.json index 61c5aac6..5405b4c7 100644 --- a/tests/Fixtures/dsync_group_user_added.json +++ b/tests/Fixtures/dsync_group_user_added.json @@ -38,7 +38,8 @@ } ], "created_at": "2026-01-15T12:00:00.000Z", - "updated_at": "2026-01-15T12:00:00.000Z" + "updated_at": "2026-01-15T12:00:00.000Z", + "name": "Marcelina Davis" }, "group": { "object": "directory_group", diff --git a/tests/Fixtures/dsync_group_user_added_data.json b/tests/Fixtures/dsync_group_user_added_data.json index 5ef37883..8895262e 100644 --- a/tests/Fixtures/dsync_group_user_added_data.json +++ b/tests/Fixtures/dsync_group_user_added_data.json @@ -35,7 +35,8 @@ } ], "created_at": "2026-01-15T12:00:00.000Z", - "updated_at": "2026-01-15T12:00:00.000Z" + "updated_at": "2026-01-15T12:00:00.000Z", + "name": "Marcelina Davis" }, "group": { "object": "directory_group", diff --git a/tests/Fixtures/dsync_group_user_removed.json b/tests/Fixtures/dsync_group_user_removed.json index 3b991f47..cc50e53a 100644 --- a/tests/Fixtures/dsync_group_user_removed.json +++ b/tests/Fixtures/dsync_group_user_removed.json @@ -38,7 +38,8 @@ } ], "created_at": "2026-01-15T12:00:00.000Z", - "updated_at": "2026-01-15T12:00:00.000Z" + "updated_at": "2026-01-15T12:00:00.000Z", + "name": "Marcelina Davis" }, "group": { "object": "directory_group", diff --git a/tests/Fixtures/dsync_group_user_removed_data.json b/tests/Fixtures/dsync_group_user_removed_data.json index 5ef37883..8895262e 100644 --- a/tests/Fixtures/dsync_group_user_removed_data.json +++ b/tests/Fixtures/dsync_group_user_removed_data.json @@ -35,7 +35,8 @@ } ], "created_at": "2026-01-15T12:00:00.000Z", - "updated_at": "2026-01-15T12:00:00.000Z" + "updated_at": "2026-01-15T12:00:00.000Z", + "name": "Marcelina Davis" }, "group": { "object": "directory_group", diff --git a/tests/Fixtures/dsync_token_created.json b/tests/Fixtures/dsync_token_created.json new file mode 100644 index 00000000..9cbd9472 --- /dev/null +++ b/tests/Fixtures/dsync_token_created.json @@ -0,0 +1,35 @@ +{ + "id": "event_01EHZNVPK3SFK441A1RGBFSHRT", + "event": "dsync.token.created", + "data": { + "object": "directory_token", + "id": "directory_token_01EHWNCE74X7JSDV0X3SZ3KJNY", + "directory_id": "directory_01EHWNCE74X7JSDV0X3SZ3KJNY", + "organization_id": "org_01EHWNCE74X7JSDV0X3SZ3KJNY", + "token_suffix": "a1b2", + "created_at": "2026-01-15T12:00:00.000Z", + "expires_at": null + }, + "created_at": "2026-01-15T12:00:00.000Z", + "context": { + "google_analytics_client_id": "GA1.2.1234567890.1234567890", + "google_analytics_sessions": [ + { + "containerId": "GTM-ABCDEF", + "sessionId": "1234567890", + "sessionNumber": "1" + } + ], + "ajs_anonymous_id": "ajs_anon_01EHWNCE74X7JSDV0X3SZ3KJNY", + "client_id": "client_01EHWNCE74X7JSDV0X3SZ3KJNY", + "actor": { + "id": "user_01EHWNCE74X7JSDV0X3SZ3KJNY", + "source": "api", + "name": "Jane Doe" + }, + "previous_attributes": { + "key": {} + } + }, + "object": "event" +} diff --git a/tests/Fixtures/dsync_token_created_data.json b/tests/Fixtures/dsync_token_created_data.json new file mode 100644 index 00000000..7dd1d132 --- /dev/null +++ b/tests/Fixtures/dsync_token_created_data.json @@ -0,0 +1,9 @@ +{ + "object": "directory_token", + "id": "directory_token_01EHWNCE74X7JSDV0X3SZ3KJNY", + "directory_id": "directory_01EHWNCE74X7JSDV0X3SZ3KJNY", + "organization_id": "org_01EHWNCE74X7JSDV0X3SZ3KJNY", + "token_suffix": "a1b2", + "created_at": "2026-01-15T12:00:00.000Z", + "expires_at": null +} diff --git a/tests/Fixtures/dsync_token_deleted.json b/tests/Fixtures/dsync_token_deleted.json new file mode 100644 index 00000000..3b87ac6b --- /dev/null +++ b/tests/Fixtures/dsync_token_deleted.json @@ -0,0 +1,35 @@ +{ + "id": "event_01EHZNVPK3SFK441A1RGBFSHRT", + "event": "dsync.token.deleted", + "data": { + "object": "directory_token", + "id": "directory_token_01EHWNCE74X7JSDV0X3SZ3KJNY", + "directory_id": "directory_01EHWNCE74X7JSDV0X3SZ3KJNY", + "organization_id": "org_01EHWNCE74X7JSDV0X3SZ3KJNY", + "token_suffix": "a1b2", + "created_at": "2026-01-15T12:00:00.000Z", + "expires_at": null + }, + "created_at": "2026-01-15T12:00:00.000Z", + "context": { + "google_analytics_client_id": "GA1.2.1234567890.1234567890", + "google_analytics_sessions": [ + { + "containerId": "GTM-ABCDEF", + "sessionId": "1234567890", + "sessionNumber": "1" + } + ], + "ajs_anonymous_id": "ajs_anon_01EHWNCE74X7JSDV0X3SZ3KJNY", + "client_id": "client_01EHWNCE74X7JSDV0X3SZ3KJNY", + "actor": { + "id": "user_01EHWNCE74X7JSDV0X3SZ3KJNY", + "source": "api", + "name": "Jane Doe" + }, + "previous_attributes": { + "key": {} + } + }, + "object": "event" +} diff --git a/tests/Fixtures/dsync_token_deleted_data.json b/tests/Fixtures/dsync_token_deleted_data.json new file mode 100644 index 00000000..7dd1d132 --- /dev/null +++ b/tests/Fixtures/dsync_token_deleted_data.json @@ -0,0 +1,9 @@ +{ + "object": "directory_token", + "id": "directory_token_01EHWNCE74X7JSDV0X3SZ3KJNY", + "directory_id": "directory_01EHWNCE74X7JSDV0X3SZ3KJNY", + "organization_id": "org_01EHWNCE74X7JSDV0X3SZ3KJNY", + "token_suffix": "a1b2", + "created_at": "2026-01-15T12:00:00.000Z", + "expires_at": null +} diff --git a/tests/Fixtures/dsync_user_created.json b/tests/Fixtures/dsync_user_created.json index aa1bbc76..8ca23073 100644 --- a/tests/Fixtures/dsync_user_created.json +++ b/tests/Fixtures/dsync_user_created.json @@ -36,7 +36,8 @@ } ], "created_at": "2026-01-15T12:00:00.000Z", - "updated_at": "2026-01-15T12:00:00.000Z" + "updated_at": "2026-01-15T12:00:00.000Z", + "name": "Marcelina Davis" }, "created_at": "2026-01-15T12:00:00.000Z", "context": { diff --git a/tests/Fixtures/dsync_user_deleted.json b/tests/Fixtures/dsync_user_deleted.json index 26942d25..f702ef3a 100644 --- a/tests/Fixtures/dsync_user_deleted.json +++ b/tests/Fixtures/dsync_user_deleted.json @@ -36,7 +36,8 @@ } ], "created_at": "2026-01-15T12:00:00.000Z", - "updated_at": "2026-01-15T12:00:00.000Z" + "updated_at": "2026-01-15T12:00:00.000Z", + "name": "Marcelina Davis" }, "created_at": "2026-01-15T12:00:00.000Z", "context": { diff --git a/tests/Fixtures/dsync_user_updated.json b/tests/Fixtures/dsync_user_updated.json index 6c0266bf..27eb02f1 100644 --- a/tests/Fixtures/dsync_user_updated.json +++ b/tests/Fixtures/dsync_user_updated.json @@ -39,7 +39,8 @@ "updated_at": "2026-01-15T12:00:00.000Z", "previous_attributes": { "key": {} - } + }, + "name": "Marcelina Davis" }, "created_at": "2026-01-15T12:00:00.000Z", "context": { diff --git a/tests/Fixtures/dsync_user_updated_data.json b/tests/Fixtures/dsync_user_updated_data.json index 0073a535..79662824 100644 --- a/tests/Fixtures/dsync_user_updated_data.json +++ b/tests/Fixtures/dsync_user_updated_data.json @@ -36,5 +36,6 @@ "updated_at": "2026-01-15T12:00:00.000Z", "previous_attributes": { "key": {} - } + }, + "name": "Marcelina Davis" } diff --git a/tests/Fixtures/jwt_template_response.json b/tests/Fixtures/jwt_template_response.json index b691ce73..00ce7dab 100644 --- a/tests/Fixtures/jwt_template_response.json +++ b/tests/Fixtures/jwt_template_response.json @@ -1,6 +1,6 @@ { "object": "jwt_template", - "content": "{\"iss\": \"{{environment.id}}\", \"sub\": \"{{user.id}}\"}", + "content": "{\"urn:myapp:full_name\": \"{{user.first_name}} {{user.last_name}}\", \"urn:myapp:email\": \"{{user.email}}\"}", "created_at": "2026-01-15T12:00:00.000Z", "updated_at": "2026-01-15T12:00:00.000Z" } diff --git a/tests/Fixtures/list_directory_user_with_groups.json b/tests/Fixtures/list_directory_user_with_groups.json index 58432bad..dbb44d56 100644 --- a/tests/Fixtures/list_directory_user_with_groups.json +++ b/tests/Fixtures/list_directory_user_with_groups.json @@ -9,6 +9,7 @@ "email": "marcelina.davis@example.com", "first_name": "Marcelina", "last_name": "Davis", + "name": "Marcelina Davis", "emails": [ { "primary": true, diff --git a/tests/Fixtures/list_user_organization_membership.json b/tests/Fixtures/list_user_organization_membership.json index cdb823aa..b0764c60 100644 --- a/tests/Fixtures/list_user_organization_membership.json +++ b/tests/Fixtures/list_user_organization_membership.json @@ -3,7 +3,7 @@ { "object": "organization_membership", "id": "om_01HXYZ123456789ABCDEFGHIJ", - "user_id": "user_01EHQTV6MWP9P1F4ZXGXMC8ABB", + "user_id": "user_01E4ZCR3C56J083X43JQXF3JK5", "organization_id": "org_01EHZNVPK3SFK441A1RGBFSHRT", "status": "active", "directory_managed": false, @@ -17,6 +17,23 @@ "updated_at": "2026-01-15T12:00:00.000Z", "role": { "slug": "admin" + }, + "user": { + "object": "user", + "id": "user_01E4ZCR3C56J083X43JQXF3JK5", + "first_name": "Marcelina", + "last_name": "Davis", + "profile_picture_url": "https://workoscdn.com/images/v1/123abc", + "email": "marcelina.davis@example.com", + "email_verified": true, + "external_id": "f1ffa2b2-c20b-4d39-be5c-212726e11222", + "metadata": { + "timezone": "America/New_York" + }, + "last_sign_in_at": "2025-06-25T19:07:33.155Z", + "locale": "en-US", + "created_at": "2026-01-15T12:00:00.000Z", + "updated_at": "2026-01-15T12:00:00.000Z" } } ], diff --git a/tests/Fixtures/list_user_organization_membership_base_list_data.json b/tests/Fixtures/list_user_organization_membership_base_list_data.json index b992a1b9..25ff95c0 100644 --- a/tests/Fixtures/list_user_organization_membership_base_list_data.json +++ b/tests/Fixtures/list_user_organization_membership_base_list_data.json @@ -3,7 +3,7 @@ { "object": "organization_membership", "id": "om_01HXYZ123456789ABCDEFGHIJ", - "user_id": "user_01EHQTV6MWP9P1F4ZXGXMC8ABB", + "user_id": "user_01E4ZCR3C56J083X43JQXF3JK5", "organization_id": "org_01EHZNVPK3SFK441A1RGBFSHRT", "status": "active", "directory_managed": false, diff --git a/tests/Fixtures/list_user_organization_membership_base_with_user.json b/tests/Fixtures/list_user_organization_membership_base_with_user.json new file mode 100644 index 00000000..f6dc992a --- /dev/null +++ b/tests/Fixtures/list_user_organization_membership_base_with_user.json @@ -0,0 +1,41 @@ +{ + "data": [ + { + "object": "organization_membership", + "id": "om_01HXYZ123456789ABCDEFGHIJ", + "user_id": "user_01E4ZCR3C56J083X43JQXF3JK5", + "organization_id": "org_01EHZNVPK3SFK441A1RGBFSHRT", + "status": "active", + "directory_managed": false, + "organization_name": "Acme Corp", + "custom_attributes": { + "department": "Engineering", + "title": "Developer Experience Engineer", + "location": "Brooklyn" + }, + "created_at": "2026-01-15T12:00:00.000Z", + "updated_at": "2026-01-15T12:00:00.000Z", + "user": { + "object": "user", + "id": "user_01E4ZCR3C56J083X43JQXF3JK5", + "first_name": "Marcelina", + "last_name": "Davis", + "profile_picture_url": "https://workoscdn.com/images/v1/123abc", + "email": "marcelina.davis@example.com", + "email_verified": true, + "external_id": "f1ffa2b2-c20b-4d39-be5c-212726e11222", + "metadata": { + "timezone": "America/New_York" + }, + "last_sign_in_at": "2025-06-25T19:07:33.155Z", + "locale": "en-US", + "created_at": "2026-01-15T12:00:00.000Z", + "updated_at": "2026-01-15T12:00:00.000Z" + } + } + ], + "list_metadata": { + "before": null, + "after": null + } +} diff --git a/tests/Fixtures/organization_membership.json b/tests/Fixtures/organization_membership.json index afc05d1e..efba3046 100644 --- a/tests/Fixtures/organization_membership.json +++ b/tests/Fixtures/organization_membership.json @@ -15,5 +15,22 @@ "updated_at": "2026-01-15T12:00:00.000Z", "role": { "slug": "admin" + }, + "user": { + "object": "user", + "id": "user_01E4ZCR3C56J083X43JQXF3JK5", + "first_name": "Marcelina", + "last_name": "Davis", + "profile_picture_url": "https://workoscdn.com/images/v1/123abc", + "email": "marcelina.davis@example.com", + "email_verified": true, + "external_id": "f1ffa2b2-c20b-4d39-be5c-212726e11222", + "metadata": { + "timezone": "America/New_York" + }, + "last_sign_in_at": "2025-06-25T19:07:33.155Z", + "locale": "en-US", + "created_at": "2026-01-15T12:00:00.000Z", + "updated_at": "2026-01-15T12:00:00.000Z" } } diff --git a/tests/Fixtures/profile.json b/tests/Fixtures/profile.json index 485a13ce..2efd7924 100644 --- a/tests/Fixtures/profile.json +++ b/tests/Fixtures/profile.json @@ -25,5 +25,6 @@ }, "raw_attributes": { "key": {} - } + }, + "name": "Todd Rundgren" } diff --git a/tests/Fixtures/sso_token_response.json b/tests/Fixtures/sso_token_response.json index 757c3fb1..7d3b7695 100644 --- a/tests/Fixtures/sso_token_response.json +++ b/tests/Fixtures/sso_token_response.json @@ -29,7 +29,8 @@ }, "raw_attributes": { "key": {} - } + }, + "name": "Todd Rundgren" }, "oauth_tokens": { "provider": "GoogleOAuth", diff --git a/tests/Fixtures/update_jwt_template.json b/tests/Fixtures/update_jwt_template.json index bb613667..160996e7 100644 --- a/tests/Fixtures/update_jwt_template.json +++ b/tests/Fixtures/update_jwt_template.json @@ -1,3 +1,3 @@ { - "content": "{\"iss\": \"{{environment.id}}\", \"sub\": \"{{user.id}}\"}" + "content": "{\"urn:myapp:full_name\": \"{{user.first_name}} {{user.last_name}}\", \"urn:myapp:email\": \"{{user.email}}\"}" } diff --git a/tests/Fixtures/user_organization_membership.json b/tests/Fixtures/user_organization_membership.json index d6acfbe6..184279d9 100644 --- a/tests/Fixtures/user_organization_membership.json +++ b/tests/Fixtures/user_organization_membership.json @@ -1,7 +1,7 @@ { "object": "organization_membership", "id": "om_01HXYZ123456789ABCDEFGHIJ", - "user_id": "user_01EHQTV6MWP9P1F4ZXGXMC8ABB", + "user_id": "user_01E4ZCR3C56J083X43JQXF3JK5", "organization_id": "org_01EHZNVPK3SFK441A1RGBFSHRT", "status": "active", "directory_managed": false, @@ -15,5 +15,22 @@ "updated_at": "2026-01-15T12:00:00.000Z", "role": { "slug": "admin" + }, + "user": { + "object": "user", + "id": "user_01E4ZCR3C56J083X43JQXF3JK5", + "first_name": "Marcelina", + "last_name": "Davis", + "profile_picture_url": "https://workoscdn.com/images/v1/123abc", + "email": "marcelina.davis@example.com", + "email_verified": true, + "external_id": "f1ffa2b2-c20b-4d39-be5c-212726e11222", + "metadata": { + "timezone": "America/New_York" + }, + "last_sign_in_at": "2025-06-25T19:07:33.155Z", + "locale": "en-US", + "created_at": "2026-01-15T12:00:00.000Z", + "updated_at": "2026-01-15T12:00:00.000Z" } } diff --git a/tests/Fixtures/user_organization_membership_base_list_data.json b/tests/Fixtures/user_organization_membership_base_list_data.json index a4e9ebde..b42fdcf6 100644 --- a/tests/Fixtures/user_organization_membership_base_list_data.json +++ b/tests/Fixtures/user_organization_membership_base_list_data.json @@ -1,7 +1,7 @@ { "object": "organization_membership", "id": "om_01HXYZ123456789ABCDEFGHIJ", - "user_id": "user_01EHQTV6MWP9P1F4ZXGXMC8ABB", + "user_id": "user_01E4ZCR3C56J083X43JQXF3JK5", "organization_id": "org_01EHZNVPK3SFK441A1RGBFSHRT", "status": "active", "directory_managed": false, diff --git a/tests/Fixtures/user_organization_membership_base_with_user.json b/tests/Fixtures/user_organization_membership_base_with_user.json new file mode 100644 index 00000000..f3a20339 --- /dev/null +++ b/tests/Fixtures/user_organization_membership_base_with_user.json @@ -0,0 +1,33 @@ +{ + "object": "organization_membership", + "id": "om_01HXYZ123456789ABCDEFGHIJ", + "user_id": "user_01E4ZCR3C56J083X43JQXF3JK5", + "organization_id": "org_01EHZNVPK3SFK441A1RGBFSHRT", + "status": "active", + "directory_managed": false, + "organization_name": "Acme Corp", + "custom_attributes": { + "department": "Engineering", + "title": "Developer Experience Engineer", + "location": "Brooklyn" + }, + "created_at": "2026-01-15T12:00:00.000Z", + "updated_at": "2026-01-15T12:00:00.000Z", + "user": { + "object": "user", + "id": "user_01E4ZCR3C56J083X43JQXF3JK5", + "first_name": "Marcelina", + "last_name": "Davis", + "profile_picture_url": "https://workoscdn.com/images/v1/123abc", + "email": "marcelina.davis@example.com", + "email_verified": true, + "external_id": "f1ffa2b2-c20b-4d39-be5c-212726e11222", + "metadata": { + "timezone": "America/New_York" + }, + "last_sign_in_at": "2025-06-25T19:07:33.155Z", + "locale": "en-US", + "created_at": "2026-01-15T12:00:00.000Z", + "updated_at": "2026-01-15T12:00:00.000Z" + } +} diff --git a/tests/Service/AuthorizationTest.php b/tests/Service/AuthorizationTest.php index 69ca8f67..e4a22e54 100644 --- a/tests/Service/AuthorizationTest.php +++ b/tests/Service/AuthorizationTest.php @@ -269,7 +269,7 @@ public function testDeleteResourceByExternalId(): void public function testListMembershipsForResourceByExternalId(): void { - $fixture = $this->loadFixture('list_user_organization_membership_base_list_data'); + $fixture = $this->loadFixture('list_user_organization_membership_base_with_user'); $client = $this->createMockClient([['status' => 200, 'body' => $fixture]]); $result = $client->authorization()->listMembershipsForResourceByExternalId('test_organization_id', 'test_resource_type_slug', 'test_external_id', before: 'test_value', after: 'test_value', limit: 1, order: \WorkOS\Resource\EventsOrder::Normal, permissionSlug: 'test_value', assignment: \WorkOS\Resource\AuthorizationAssignment::Direct); $this->assertInstanceOf(\WorkOS\PaginatedResponse::class, $result); @@ -364,7 +364,7 @@ public function testDeleteResource(): void public function testListMembershipsForResource(): void { - $fixture = $this->loadFixture('list_user_organization_membership_base_list_data'); + $fixture = $this->loadFixture('list_user_organization_membership_base_with_user'); $client = $this->createMockClient([['status' => 200, 'body' => $fixture]]); $result = $client->authorization()->listMembershipsForResource('test_resource_id', before: 'test_value', after: 'test_value', limit: 1, order: \WorkOS\Resource\EventsOrder::Normal, permissionSlug: 'test_value', assignment: \WorkOS\Resource\AuthorizationAssignment::Direct); $this->assertInstanceOf(\WorkOS\PaginatedResponse::class, $result);