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) );