Skip to content

PAT-1866 Migrate sync-actions-api-php-client onto php-api-client-base#524

Open
pepamartinec wants to merge 1 commit into
mainfrom
pepa/common-api-lib-sync-actions
Open

PAT-1866 Migrate sync-actions-api-php-client onto php-api-client-base#524
pepamartinec wants to merge 1 commit into
mainfrom
pepa/common-api-lib-sync-actions

Conversation

@pepamartinec

@pepamartinec pepamartinec commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Release Notes

https://linear.app/keboola/issue/PAT-1866

Migrate sync-actions-api-php-client onto the shared keboola/php-api-client-base, matching the migrations already done for the vault, sandboxes, and git-service clients. The hand-rolled Guzzle client — its auth/retry/logging middleware stack and Symfony-validator constructor — is replaced by the base ApiClient, so transport, retries, error handling, and authentication are now shared across clients.

The public Client is renamed to SyncActionsApiClient with an unpacked constructor (individual params instead of an ApiClientConfiguration object), authenticates via the base StorageApiTokenAuthenticator, and keeps the historical default of 10 retries. Failures throw a per-client SyncActionsClientException (extends the base ClientException), formatted by a small SyncActionsErrorMessageResolver.

A sync action returns an arbitrary, component-defined payload that callers read as $response->data->whatever, so ActionResponse.data stays a deep stdClass. callAction() decodes the raw response body with json_decode(..., false) to preserve the object/array distinction — the base client's array decode would collapse {} to [] and renumber integer-keyed objects. That needs a small, backward-compatible base-lib change, included here since it's trivial: ApiClient::sendRequest() now returns the ResponseInterface instead of void (and the now-redundant private doSendRequest() is folded into it). getActions() still uses the array-based sendRequestAndMapResponse (its payload is a flat list of strings).

Key changes:

  • php-api-client-base: ApiClient::sendRequest() returns the ResponseInterface (was void; doSendRequest() merged in) — backward-compatible.
  • Rename ClientSyncActionsApiClient; delegate transport to the base ApiClient.
  • Add SyncActionsClientException + SyncActionsErrorMessageResolver.
  • callAction() decodes the raw body to a faithful stdClass; ActionResponse is a plain DTO.
  • Drop ApiClientConfiguration, StorageApiTokenAuthenticator, RetryDecider, and the local ResponseModelInterface/ClientException (now provided by the base lib).
  • Depend on keboola/php-api-client-base; drop symfony/validator and symfony/config.

Plans for customer communication

None.

Impact analysis

Breaking API change for consumers of sync-actions-api-php-client (notably connection): the exception type is renamed (Keboola\SyncActionsClient\Exception\ClientExceptionSyncActionsClientException), the constructor signature is unpacked (no ApiClientConfiguration), and the client class is renamed. Response reading ($response->data->...) is unchanged and now correct for empty/integer-keyed objects. The php-api-client-base change is backward-compatible (a void method now returns a value), so the other clients are unaffected. Requires a major sync-actions-api-php-client bump and a minor php-api-client-base bump.

Change type

Refactoring

Justification

Consolidate Keboola PHP API clients onto the shared php-api-client-base (PAT-1866).

Deployment

Merge & automatic deploy.

Rollback plan

Revert of this PR.

Post release support plan

None.

@linear

linear Bot commented Jun 22, 2026

Copy link
Copy Markdown

PAT-1866

@pepamartinec pepamartinec force-pushed the pepa/common-api-lib-sync-actions branch from d97dafc to 16ba038 Compare June 22, 2026 09:26
@pepamartinec pepamartinec changed the base branch from main to pepa/common-api-lib-send-response June 22, 2026 09:26
@pepamartinec pepamartinec force-pushed the pepa/common-api-lib-send-response branch from dad6940 to 5093d3a Compare June 22, 2026 09:55
@pepamartinec pepamartinec force-pushed the pepa/common-api-lib-sync-actions branch from 16ba038 to ce49294 Compare June 22, 2026 09:56
Replace the hand-rolled Guzzle client (auth/retry/logging middleware and a
Symfony-validator constructor) with the shared keboola/php-api-client-base.

php-api-client-base:
- ApiClient::sendRequest() now returns the ResponseInterface (was void; a
  backward-compatible widening) so clients can decode the raw body themselves.
  The now-redundant private doSendRequest() is folded into it.

sync-actions-api-php-client:
- Rename Client -> SyncActionsApiClient; delegate transport to the base ApiClient
  via StorageApiTokenAuthenticator, with unpacked constructor params. Keep the
  historical default of 10 retries.
- Add SyncActionsClientException (extends the base ClientException) and
  SyncActionsErrorMessageResolver (formats "{code}: {error}").
- callAction() decodes the raw response body to a faithful deep stdClass -- the
  base client's array decode would collapse empty/integer-keyed objects.
  ActionResponse is a plain stdClass DTO; getActions() uses the array-based
  ResponseModelInterface.
- Delete ApiClientConfiguration, StorageApiTokenAuthenticator, RetryDecider and the
  local ResponseModelInterface/ClientException (now provided by the base lib).
@pepamartinec pepamartinec force-pushed the pepa/common-api-lib-sync-actions branch from ce49294 to ffea9e6 Compare June 22, 2026 11:14
@pepamartinec pepamartinec changed the base branch from pepa/common-api-lib-send-response to main June 22, 2026 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant