Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
* [#438](https://github.com/workos/workos-php/pull/438) fix(generated): regenerate from spec

**Features**
* **[pipes](https://workos.com/docs/reference/pipes)**:
* Added `connected_account_id` to `DataIntegrationsVendCredentialsRequest`
* Added `connected_account_id` to `DataIntegrationsGetUserTokenRequest`
* Added parameter `UserManagementDataProviders.getUserDataInstallation.connected_account_id`
* Changed errors for endpoint `GET /user_management/users/{user_id}/connected_accounts/{slug}`
* Added parameter `UserManagementDataProviders.updateUserDataInstallation.connected_account_id`
* Changed errors for endpoint `PUT /user_management/users/{user_id}/connected_accounts/{slug}`
* Added parameter `UserManagementDataProviders.deleteUserDataInstallation.connected_account_id`
* Changed errors for endpoint `DELETE /user_management/users/{user_id}/connected_accounts/{slug}`
* Added `connected_accounts` to `DataIntegrationsListResponseData`
* Changed errors for endpoint `PUT /data-integrations/{slug}`
* Changed errors for endpoint `PUT /data-integrations/{slug}/api-key`
* Changed errors for endpoint `PUT /data-integrations/{slug}/client-credentials`
* Changed errors for endpoint `POST /data-integrations/{slug}/credentials`
* Changed errors for endpoint `POST /data-integrations/{provider}/token`
2 changes: 1 addition & 1 deletion .last-synced-sha
Original file line number Diff line number Diff line change
@@ -1 +1 @@
edb560e2be3f54b668ea8d11fa5a060c87ab5087
6fba233c50a5b651b2df7b859b75bfe715bc825a
4 changes: 4 additions & 0 deletions lib/Resource/DataIntegrationsGetUserTokenRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public function __construct(
public string $userId,
/** An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter to scope the connection to a specific organization. */
public ?string $organizationId = null,
/** A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select a specific connection when the user has several for this provider. */
public ?string $connectedAccountId = null,
) {
}

Expand All @@ -23,6 +25,7 @@ public static function fromArray(array $data): self
return new self(
userId: $data['user_id'],
organizationId: $data['organization_id'] ?? null,
connectedAccountId: $data['connected_account_id'] ?? null,
);
}

Expand All @@ -31,6 +34,7 @@ public function toArray(): array
return [
'user_id' => $this->userId,
'organization_id' => $this->organizationId,
'connected_account_id' => $this->connectedAccountId,
];
}
}
2 changes: 1 addition & 1 deletion lib/Resource/DataIntegrationsListResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public function __construct(
/** Indicates this is a list response. */
public string $object,
/**
* A list of [providers](https://workos.com/docs/reference/pipes/provider), each including a [`connected_account`](https://workos.com/docs/reference/pipes/connected-account) field with the user's connection status.
* A list of [providers](https://workos.com/docs/reference/pipes/provider), each including the legacy `connected_account` field and the additive `connected_accounts` collection.
* @var array<\WorkOS\Resource\DataIntegrationsListResponseData>
*/
public array $data,
Expand Down
7 changes: 7 additions & 0 deletions lib/Resource/DataIntegrationsListResponseData.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public function __construct(
public string $updatedAt,
/** The user's [connected account](https://workos.com/docs/reference/pipes/connected-account) for this provider, or `null` if the user has not connected. */
public ?DataIntegrationsListResponseDataConnectedAccount $connectedAccount,
/**
* The user's connected accounts for this provider in the requested ownership context.
* @var array<\WorkOS\Resource\DataIntegrationsListResponseDataConnectedAccount>
*/
public array $connectedAccounts,
/**
* The authentication methods supported by this provider (`oauth`, `api_key`, `client_credentials`, or a combination). Defaults to `["oauth"]` if absent.
* @var array<\WorkOS\Resource\DataIntegrationAuthMethods>|null
Expand All @@ -61,6 +66,7 @@ public static function fromArray(array $data): self
createdAt: $data['created_at'],
updatedAt: $data['updated_at'],
connectedAccount: isset($data['connected_account']) ? DataIntegrationsListResponseDataConnectedAccount::fromArray($data['connected_account']) : null,
connectedAccounts: array_map(fn ($item) => DataIntegrationsListResponseDataConnectedAccount::fromArray($item), $data['connected_accounts']),
authMethods: isset($data['auth_methods']) ? array_map(fn ($item) => DataIntegrationAuthMethods::from($item), $data['auth_methods']) : null,
);
}
Expand All @@ -80,6 +86,7 @@ public function toArray(): array
'created_at' => $this->createdAt,
'updated_at' => $this->updatedAt,
'connected_account' => $this->connectedAccount?->toArray(),
'connected_accounts' => array_map(fn ($item) => $item->toArray(), $this->connectedAccounts),
'auth_methods' => $this->authMethods !== null ? array_map(fn ($item) => $item->value, $this->authMethods) : null,
];
}
Expand Down
4 changes: 4 additions & 0 deletions lib/Resource/DataIntegrationsVendCredentialsRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public function __construct(
public string $userId,
/** An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter to scope the connection to a specific organization. */
public ?string $organizationId = null,
/** A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select a specific connection when the user has several for this provider. */
public ?string $connectedAccountId = null,
) {
}

Expand All @@ -23,6 +25,7 @@ public static function fromArray(array $data): self
return new self(
userId: $data['user_id'],
organizationId: $data['organization_id'] ?? null,
connectedAccountId: $data['connected_account_id'] ?? null,
);
}

Expand All @@ -31,6 +34,7 @@ public function toArray(): array
return [
'user_id' => $this->userId,
'organization_id' => $this->organizationId,
'connected_account_id' => $this->connectedAccountId,
];
}
}
14 changes: 14 additions & 0 deletions lib/Service/Pipes.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,18 +293,21 @@ public function updateDataIntegrationClientCredentials(
* @param string $slug The identifier of the integration.
* @param string $userId A [User](https://workos.com/docs/reference/authkit/user) identifier.
* @param string|null $organizationId An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter to scope the connection to a specific organization.
* @param string|null $connectedAccountId A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select a specific connection when the user has several for this provider.
* @return \WorkOS\Resource\DataIntegrationCredentialsResponse
* @throws \WorkOS\Exception\WorkOSException
*/
public function createDataIntegrationCredential(
string $slug,
string $userId,
?string $organizationId = null,
?string $connectedAccountId = null,
?\WorkOS\RequestOptions $options = null,
): \WorkOS\Resource\DataIntegrationCredentialsResponse {
$body = array_filter([
'user_id' => $userId,
'organization_id' => $organizationId,
'connected_account_id' => $connectedAccountId,
], fn ($v) => $v !== null);
$response = $this->client->request(
method: 'POST',
Expand All @@ -322,18 +325,21 @@ public function createDataIntegrationCredential(
* @param string $provider The identifier of the integration.
* @param string $userId A [User](https://workos.com/docs/reference/authkit/user) identifier.
* @param string|null $organizationId An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter to scope the connection to a specific organization.
* @param string|null $connectedAccountId A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select a specific connection when the user has several for this provider.
* @return \WorkOS\Resource\DataIntegrationAccessTokenResponse
* @throws \WorkOS\Exception\WorkOSException
*/
public function getAccessToken(
string $provider,
string $userId,
?string $organizationId = null,
?string $connectedAccountId = null,
?\WorkOS\RequestOptions $options = null,
Comment on lines 333 to 337

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Positional Calls Now Fail

If existing clients pass RequestOptions positionally, inserting $connectedAccountId before $options binds that object to a ?string parameter. Because strict types are enabled, calls such as getAccessToken($provider, $userId, null, $options) now throw a TypeError. The same breaking change affects all five modified public Pipes methods.

Knowledge Base Used:

Prompt To Fix With AI
This is a comment left during a code review.
Path: lib/Service/Pipes.php
Line: 333-337

Comment:
**Positional Calls Now Fail**

If existing clients pass `RequestOptions` positionally, inserting `$connectedAccountId` before `$options` binds that object to a `?string` parameter. Because strict types are enabled, calls such as `getAccessToken($provider, $userId, null, $options)` now throw a `TypeError`. The same breaking change affects all five modified public Pipes methods.

**Knowledge Base Used:**
- [Application and data integrations](https://app.greptile.com/workos/-/custom-context/knowledge-base/workos/workos-php/-/docs/integrations.md)
- [Connect and data integrations](https://app.greptile.com/workos/-/custom-context/knowledge-base/workos/workos-php/-/docs/connect-and-data-integrations.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

): \WorkOS\Resource\DataIntegrationAccessTokenResponse {
$body = array_filter([
'user_id' => $userId,
'organization_id' => $organizationId,
'connected_account_id' => $connectedAccountId,
], fn ($v) => $v !== null);
$response = $this->client->request(
method: 'POST',
Expand All @@ -351,17 +357,20 @@ public function getAccessToken(
* @param string $userId A [User](https://workos.com/docs/reference/authkit/user) identifier.
* @param string $slug The slug identifier of the provider (e.g., `github`, `slack`, `notion`).
* @param string|null $organizationId An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter if the connection is scoped to an organization.
* @param string|null $connectedAccountId A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select a specific connection when the user has several for this provider.
* @return \WorkOS\Resource\ConnectedAccount
* @throws \WorkOS\Exception\WorkOSException
*/
public function getUserConnectedAccount(
string $userId,
string $slug,
?string $organizationId = null,
?string $connectedAccountId = null,
?\WorkOS\RequestOptions $options = null,
): \WorkOS\Resource\ConnectedAccount {
$query = array_filter([
'organization_id' => $organizationId,
'connected_account_id' => $connectedAccountId,
], fn ($v) => $v !== null);
$response = $this->client->request(
method: 'GET',
Expand Down Expand Up @@ -426,6 +435,7 @@ public function createUserConnectedAccount(
* @param array<string>|null $scopes The OAuth scopes granted for this connection.
* @param \WorkOS\Resource\PipeConnectedAccountState|null $state Explicitly set the state of the connected account. When omitted, the state is derived from the token combination provided.
* @param string|null $organizationId An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter if the connection is scoped to an organization.
* @param string|null $connectedAccountId A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select the connection to update.
* @return \WorkOS\Resource\ConnectedAccount
* @throws \WorkOS\Exception\WorkOSException
*/
Expand All @@ -438,6 +448,7 @@ public function updateUserConnectedAccount(
?array $scopes = null,
?\WorkOS\Resource\PipeConnectedAccountState $state = null,
?string $organizationId = null,
?string $connectedAccountId = null,
Comment on lines 448 to +451

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Update Drops Account Selector

updateUserConnectedAccount accepts $connectedAccountId but sends it in neither the PUT body nor the query, unlike the matching get and delete operations. When a user has multiple accounts for a provider, the API cannot select the requested account and may reject the ambiguous update or modify the legacy/default account instead.

Knowledge Base Used:

Prompt To Fix With AI
This is a comment left during a code review.
Path: lib/Service/Pipes.php
Line: 448-451

Comment:
**Update Drops Account Selector**

`updateUserConnectedAccount` accepts `$connectedAccountId` but sends it in neither the PUT body nor the query, unlike the matching get and delete operations. When a user has multiple accounts for a provider, the API cannot select the requested account and may reject the ambiguous update or modify the legacy/default account instead.

**Knowledge Base Used:**
- [Application and data integrations](https://app.greptile.com/workos/-/custom-context/knowledge-base/workos/workos-php/-/docs/integrations.md)
- [Connect and data integrations](https://app.greptile.com/workos/-/custom-context/knowledge-base/workos/workos-php/-/docs/connect-and-data-integrations.md)

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

?\WorkOS\RequestOptions $options = null,
): \WorkOS\Resource\ConnectedAccount {
$body = array_filter([
Expand All @@ -463,17 +474,20 @@ public function updateUserConnectedAccount(
* @param string $userId A [User](https://workos.com/docs/reference/authkit/user) identifier.
* @param string $slug The slug identifier of the provider (e.g., `github`, `slack`, `notion`).
* @param string|null $organizationId An [Organization](https://workos.com/docs/reference/organization) identifier. Optional parameter if the connection is scoped to an organization.
* @param string|null $connectedAccountId A [connected account](https://workos.com/docs/reference/pipes/connected-account) identifier. Use this to select the connection to delete.
* @return void
* @throws \WorkOS\Exception\WorkOSException
*/
public function deleteUserConnectedAccount(
string $userId,
string $slug,
?string $organizationId = null,
?string $connectedAccountId = null,
?\WorkOS\RequestOptions $options = null,
): void {
$query = array_filter([
'organization_id' => $organizationId,
'connected_account_id' => $connectedAccountId,
], fn ($v) => $v !== null);
$this->client->request(
method: 'DELETE',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"user_id": "user_01EHZNVPK3SFK441A1RGBFSHRT",
"organization_id": "org_01EHZNVPK3SFK441A1RGBFSHRT"
"organization_id": "org_01EHZNVPK3SFK441A1RGBFSHRT",
"connected_account_id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT"
}
28 changes: 27 additions & 1 deletion tests/Fixtures/data_integrations_list_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,33 @@
"organizationId": "test_organizationId",
"createdAt": "test_createdAt",
"updatedAt": "test_updatedAt"
}
},
"connected_accounts": [
{
"object": "connected_account",
"id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT",
"user_id": "user_01EHZNVPK3SFK441A1RGBFSHRT",
"organization_id": null,
"scopes": [
"repo",
"user:email"
],
"auth_method": "oauth",
"api_key_last_4": null,
"client_id": "3MVG9dZJodJWxft2VoStSCVwPFsx0eDcpVc",
"client_secret_last_4": "cdef",
"config": {
"instance_url": "https://example.my.salesforce.com"
},
"state": "connected",
"created_at": "2024-01-16T14:20:00.000Z",
"updated_at": "2024-01-16T14:20:00.000Z",
"userlandUserId": "test_userlandUserId",
"organizationId": "test_organizationId",
"createdAt": "test_createdAt",
"updatedAt": "test_updatedAt"
}
]
}
]
}
28 changes: 27 additions & 1 deletion tests/Fixtures/data_integrations_list_response_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,31 @@
"organizationId": "test_organizationId",
"createdAt": "test_createdAt",
"updatedAt": "test_updatedAt"
}
},
"connected_accounts": [
{
"object": "connected_account",
"id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT",
"user_id": "user_01EHZNVPK3SFK441A1RGBFSHRT",
"organization_id": null,
"scopes": [
"repo",
"user:email"
],
"auth_method": "oauth",
"api_key_last_4": null,
"client_id": "3MVG9dZJodJWxft2VoStSCVwPFsx0eDcpVc",
"client_secret_last_4": "cdef",
"config": {
"instance_url": "https://example.my.salesforce.com"
},
"state": "connected",
"created_at": "2024-01-16T14:20:00.000Z",
"updated_at": "2024-01-16T14:20:00.000Z",
"userlandUserId": "test_userlandUserId",
"organizationId": "test_organizationId",
"createdAt": "test_createdAt",
"updatedAt": "test_updatedAt"
}
]
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"user_id": "user_01EHZNVPK3SFK441A1RGBFSHRT",
"organization_id": "org_01EHZNVPK3SFK441A1RGBFSHRT"
"organization_id": "org_01EHZNVPK3SFK441A1RGBFSHRT",
"connected_account_id": "data_installation_01EHZNVPK3SFK441A1RGBFSHRT"
}