Migrate webhook commands to SDK

Merged
RO
6mo ago
+184-156

Summary

  • Migrates webhook show|create|update|delete|reactivate from the legacy HTTP client (getClient()) to the typed WebhooksService on the SDK account client.
  • webhook list uses the typed service for the no-flag case and falls back to ac.Get / ac.GetAll for --page and --all, since the SDK's Webhooks().List doesn't accept a path. (webhook deliveries was already on the SDK and is untouched.)
  • Behavior, flags, and CLI surface are unchanged — SURFACE.txt doesn't change. The e2e CRUD test in webhook_test.go continues to drive the same UX.

Notes

  • Unit tests switched to the SetTestModeWithSDK httptest-backed pattern.
  • Body assertions updated: SDK posts the typed request directly, so no more {"webhook": {...}} wrapper. URL assertions for get/update/delete drop the .json suffix to match the SDK paths (Rails accepts both forms).
  • Create no longer needs a Location follow-up — WebhooksService.Create returns the full Webhook directly.

Summary by cubic

Migrates webhook CLI commands from the legacy HTTP client to the typed SDK for better type safety with the same CLI behavior. Also fixes list paging when using --all with --page.

  • Refactors

    • Switched to SDK WebhooksService for show, create, update, delete, and reactivate.
    • list: uses Webhooks().List by default; falls back to ac.Get/ac.GetAll for --page/--all.
    • Request/response: removed "webhook" body wrapper; dropped .json paths; Create returns full Webhook (no Location follow-up); removed unused printSuccessWithLocation.
    • Tests now use SetTestModeWithSDK; assertions match new paths/payloads; errors via convertSDKError.
  • Bug Fixes

    • webhook list --all --page N now starts from page N when fetching all results; added a unit test to lock this in.