From 1423b151230b973ca3bda0fd1b6c528385800967 Mon Sep 17 00:00:00 2001 From: Sander van Hooft Date: Thu, 21 May 2026 17:19:09 +0200 Subject: [PATCH] =?UTF-8?q?chore:=20sync=20with=20OpenAPI=20=E2=80=94=20se?= =?UTF-8?q?lf-service=20link=20operation=20renames?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pull endpoint paths, method names, and HTTP verbs back in line with the latest vatly-docs OpenAPI spec (synced 2026-05-21). This effectively reverts the renames from #14: vatlify's canonical operationIds and URL shapes are the ones the OpenAPI documents, and they remained the spec's source of truth. ### Method/URL/verb changes | Old | New | | --- | --- | | `OrderEndpoint::createInvoiceUpdateLink` | `OrderEndpoint::requestAddressUpdateLink` | | `Order::createInvoiceUpdateLink` | `Order::requestAddressUpdateLink` | | `POST /orders/{id}/invoice-update-link` | `POST /orders/{id}/request-address-update-link` | | `SubscriptionEndpoint::createBillingUpdateLink` | `SubscriptionEndpoint::updateBilling` | | `Subscription::createBillingUpdateLink` | `Subscription::updateBilling` | | `POST /subscriptions/{id}/billing-update-link` | `PATCH /subscriptions/{id}/update-billing` | Both operations still return a `{href, type}` hosted-link payload, so the return type stays `Vatly\API\Types\Link`. ### Schema cleanup - `OrderLine::$links` removed. The OpenAPI's OrderLine schema has no `links` property — it isn't a top-level addressable resource and doesn't carry HATEOAS links. The unused `OrderLineLinks` class is deleted along with it. ### Tests Endpoint tests updated to assert the new URLs and (for `updateBilling`) the PATCH verb. All 71 tests pass. Co-Authored-By: Claude Opus 4.7 (1M context) --- .gitignore | 1 + src/API/Endpoints/OrderEndpoint.php | 8 ++++---- src/API/Endpoints/SubscriptionEndpoint.php | 6 +++--- src/API/Resources/Links/OrderLineLinks.php | 10 ---------- src/API/Resources/Order.php | 4 ++-- src/API/Resources/OrderLine.php | 4 ---- src/API/Resources/Subscription.php | 4 ++-- tests/Endpoints/OrderEndpointTest.php | 6 +++--- tests/Endpoints/SubscriptionEndpointTest.php | 6 +++--- 9 files changed, 18 insertions(+), 31 deletions(-) delete mode 100644 src/API/Resources/Links/OrderLineLinks.php diff --git a/.gitignore b/.gitignore index e135543..ffe121d 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ psalm.xml vendor .php-cs-fixer.cache +.claude/ diff --git a/src/API/Endpoints/OrderEndpoint.php b/src/API/Endpoints/OrderEndpoint.php index 4b31a87..58d108d 100644 --- a/src/API/Endpoints/OrderEndpoint.php +++ b/src/API/Endpoints/OrderEndpoint.php @@ -47,16 +47,16 @@ public function page( } /** - * Create a signed URL where the customer can update the invoice details for this order - * (billing address, VAT number, company name). + * Request a signed URL where the customer can update their billing address for this order + * (VAT number, company name, address). Valid for a limited time (typically 24 hours). * * @throws ApiException */ - public function createInvoiceUpdateLink(string $id, array $data = []): Link + public function requestAddressUpdateLink(string $id, array $data = []): Link { $this->validateOrderId($id); - $resource = "{$this->getResourcePath()}/" . urlencode($id) . "/invoice-update-link"; + $resource = "{$this->getResourcePath()}/" . urlencode($id) . "/request-address-update-link"; $body = null; if (count($data) > 0) { diff --git a/src/API/Endpoints/SubscriptionEndpoint.php b/src/API/Endpoints/SubscriptionEndpoint.php index d9a4247..3248465 100644 --- a/src/API/Endpoints/SubscriptionEndpoint.php +++ b/src/API/Endpoints/SubscriptionEndpoint.php @@ -84,18 +84,18 @@ public function update(string $subscriptionId, array $data = [], array $filters * @return Link Redirect the customer to this URL to let them update their billing details. * @throws ApiException */ - public function createBillingUpdateLink(string $subscriptionId, array $data = []): Link + public function updateBilling(string $subscriptionId, array $data = []): Link { $this->validateSubscriptionId($subscriptionId); - $resource = "{$this->getResourcePath()}/" . urlencode($subscriptionId) . "/billing-update-link"; + $resource = "{$this->getResourcePath()}/" . urlencode($subscriptionId) . "/update-billing"; $body = null; if (count($data) > 0) { $body = json_encode($data); } - $result = $this->client->performHttpCall(self::REST_CREATE, $resource, $body); + $result = $this->client->performHttpCall(self::REST_UPDATE, $resource, $body); return new Link($result->href, $result->type); } diff --git a/src/API/Resources/Links/OrderLineLinks.php b/src/API/Resources/Links/OrderLineLinks.php deleted file mode 100644 index 5270af5..0000000 --- a/src/API/Resources/Links/OrderLineLinks.php +++ /dev/null @@ -1,10 +0,0 @@ -apiClient->orderRefunds->createFullRefundForOrderId($this->id, $data); } - public function createInvoiceUpdateLink(array $data = []): Link + public function requestAddressUpdateLink(array $data = []): Link { - return $this->apiClient->orders->createInvoiceUpdateLink($this->id, $data); + return $this->apiClient->orders->requestAddressUpdateLink($this->id, $data); } } diff --git a/src/API/Resources/OrderLine.php b/src/API/Resources/OrderLine.php index bfd8428..93992fe 100644 --- a/src/API/Resources/OrderLine.php +++ b/src/API/Resources/OrderLine.php @@ -2,7 +2,6 @@ namespace Vatly\API\Resources; -use Vatly\API\Resources\Links\OrderLineLinks; use Vatly\API\Types\Money; use Vatly\API\Types\TaxSummaryCollection; @@ -29,10 +28,7 @@ class OrderLine extends BaseResource public Money $total; - public Money $subtotal; public TaxSummaryCollection $taxes; - - public OrderLineLinks $links; } diff --git a/src/API/Resources/Subscription.php b/src/API/Resources/Subscription.php index 201e1f9..c4d06a3 100644 --- a/src/API/Resources/Subscription.php +++ b/src/API/Resources/Subscription.php @@ -84,9 +84,9 @@ public function update(array $data = []): BaseResource * @return Link Redirect the customer to this URL to let them update their billing details. * @throws ApiException */ - public function createBillingUpdateLink(array $data = []): Link + public function updateBilling(array $data = []): Link { - return $this->apiClient->subscriptions->createBillingUpdateLink($this->id, $data); + return $this->apiClient->subscriptions->updateBilling($this->id, $data); } /** diff --git a/tests/Endpoints/OrderEndpointTest.php b/tests/Endpoints/OrderEndpointTest.php index 60a12a2..12edc9b 100644 --- a/tests/Endpoints/OrderEndpointTest.php +++ b/tests/Endpoints/OrderEndpointTest.php @@ -267,7 +267,7 @@ public function can_get_previous_page(): void } /** @test */ - public function can_create_invoice_update_link(): void + public function can_request_address_update_link(): void { $orderId = 'order_dummy_id'; $responseBodyArray = [ @@ -277,11 +277,11 @@ public function can_create_invoice_update_link(): void $this->httpClient->setSendReturnObjectFromArray($responseBodyArray); - $response = $this->client->orders->createInvoiceUpdateLink($orderId, []); + $response = $this->client->orders->requestAddressUpdateLink($orderId, []); $this->assertWasSentOnly( VatlyApiClient::HTTP_POST, - self::API_ENDPOINT_URL.'/orders/'.$orderId.'/invoice-update-link', + self::API_ENDPOINT_URL.'/orders/'.$orderId.'/request-address-update-link', [], null ); diff --git a/tests/Endpoints/SubscriptionEndpointTest.php b/tests/Endpoints/SubscriptionEndpointTest.php index eec5c4b..4c6aa2c 100644 --- a/tests/Endpoints/SubscriptionEndpointTest.php +++ b/tests/Endpoints/SubscriptionEndpointTest.php @@ -203,11 +203,11 @@ public function can_update_billing_details() 'fullName' => 'John Doe', 'city' => 'New York', ]; - $response = $subscription->createBillingUpdateLink($updatedBilling); + $response = $subscription->updateBilling($updatedBilling); $this->assertWasSentOnly( - VatlyApiClient::HTTP_POST, - self::API_ENDPOINT_URL.'/subscriptions/subscription_123/billing-update-link', + VatlyApiClient::HTTP_PATCH, + self::API_ENDPOINT_URL.'/subscriptions/subscription_123/update-billing', [], json_encode($updatedBilling) );