Skip to content

v2.0.0-beta.1

Pre-release
Pre-release

Choose a tag to compare

@loevgaard loevgaard released this 30 Oct 14:12
· 8 commits to 2.x since this release
0011af1

First beta of the 2.x line. Please try it out and report any issues before the stable 2.0.0.

Changes since v2.0.0-alpha.2:

⚠️ Breaking changes (vs. alpha.2)

  • Webhook action / resource are now strict enums on every read path, and unknown values fail fast (#9).
    • Inbound: WebhookEvent::$action / $resourceType are WebhookAction / WebhookResourceName. WebhookParser throws MalformedWebhookException if the SMD-Action or SMD-Resource-Type header is missing or unknown.
    • Read: the response Webhook::$action / $resourceName are enums too. An unknown value fails mapping with a MappingException, and the original strings are still available via Resource::$raw.
    • Note: webhooks()->getPage() / paginate() now throws if any webhook subscription carries an action or resource the SDK doesn't model yet.

Added

  • The resource ↔ action relationship is encoded on the enum (#9): WebhookResourceName::actions(): list<WebhookAction> and supports(WebhookAction): bool. WebhooksEndpoint::create() throws \InvalidArgumentException before sending when both resourceName and action are set but aren't a valid pair, instead of getting a 422 from the server.
  • SalesOrdersEndpoint::delete(int $id) (#10). Sends DELETE /sales_orders/{id} and mirrors WebhooksEndpoint::delete().
WebhookResourceName::Orders->supports(WebhookAction::Delete); // true
$client->salesOrders()->delete(37707008);

Upgrading from 1.x

See UPGRADE.md for the full migration guide, which covers every breaking change.

Full Changelog: v2.0.0-alpha.2...v2.0.0-beta.1