From 399d34883ca24af5e5d690ec5c24b457bdc97eca Mon Sep 17 00:00:00 2001 From: larasmorningtrain <86046759+larasmorningtrain@users.noreply.github.com> Date: Fri, 17 May 2024 10:15:14 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Set=20typehint=20for=20bod?= =?UTF-8?q?y=20to=20array=20or=20string=20(#24)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * ♻️ Set typehint for body to array or string * ✅ Fix fixtures --------- Co-authored-by: Mathias Bærentsen --- src/Classes/EconomicResponse.php | 4 ++-- .../Invoices/draft/create-request.json | 11 +++++----- .../Invoices/draft/create-response.json | 20 +++++++++---------- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/Classes/EconomicResponse.php b/src/Classes/EconomicResponse.php index cb06692..649a7d8 100644 --- a/src/Classes/EconomicResponse.php +++ b/src/Classes/EconomicResponse.php @@ -8,7 +8,7 @@ class EconomicResponse protected array|string $body; - public function __construct(int $statusCode, mixed $body) + public function __construct(int $statusCode, array|string $body) { $this->statusCode = $statusCode; $this->body = $body; @@ -19,7 +19,7 @@ public function getStatusCode(): int return $this->statusCode; } - public function getBody(): mixed + public function getBody(): array|string { return $this->body; } diff --git a/tests/Fixtures/Invoices/draft/create-request.json b/tests/Fixtures/Invoices/draft/create-request.json index 5185078..c666793 100644 --- a/tests/Fixtures/Invoices/draft/create-request.json +++ b/tests/Fixtures/Invoices/draft/create-request.json @@ -2,29 +2,30 @@ "currency": "DKK", "customer": { "customerNumber": 1, - "self": "https://restapi.e-conomic.com/customers/1" + "self": "https:\/\/restapi.e-conomic.com\/customers\/1" }, "date": "2024-02-13T12:20:18+00:00", "layout": { "layoutNumber": 14, - "self": "https://restapi.e-conomic.com/layouts/14" + "self": "https:\/\/restapi.e-conomic.com\/layouts\/14" }, "paymentTerms": { "paymentTermsNumber": 1, - "self": "https://restapi.e-conomic.com/payment-terms/1" + "self": "https:\/\/restapi.e-conomic.com\/payment-terms\/1" }, "recipient": { "name": "John Doe", "vatZone": { "vatZoneNumber": 1, - "self": "https://restapi.e-conomic.com/vat-zones/1" + "self": "https:\/\/restapi.e-conomic.com\/vat-zones\/1" } }, "lines": [ { "description": "T-shirt - Size L", "product": { - "productNumber": "1" + "productNumber": "1", + "self": "https:\/\/restapi.e-conomic.com\/products\/1" }, "quantity": 1, "unitNetPrice": 500 diff --git a/tests/Fixtures/Invoices/draft/create-response.json b/tests/Fixtures/Invoices/draft/create-response.json index 20a4b05..1560dfd 100644 --- a/tests/Fixtures/Invoices/draft/create-response.json +++ b/tests/Fixtures/Invoices/draft/create-response.json @@ -6,10 +6,10 @@ } }, "templates": { - "bookingInstructions": "https://restapi.e-conomic.com/invoices/drafts/424/templates/booking-instructions", - "self": "https://restapi.e-conomic.com/invoices/drafts/424/templates" + "bookingInstructions": "https:\/\/restapi.e-conomic.com\/invoices\/drafts\/424\/templates\/booking-instructions", + "self": "https:\/\/restapi.e-conomic.com\/invoices\/drafts\/424\/templates" }, - "attachment": "https://restapi.e-conomic.com/invoices/drafts/424/attachment", + "attachment": "https:\/\/restapi.e-conomic.com\/invoices\/drafts\/424\/attachment", "lines": [ { "lineNumber": 1, @@ -17,7 +17,7 @@ "description": "T-shirt - Size L", "product": { "productNumber": "1", - "self": "https://restapi.e-conomic.com/products/1" + "self": "https:\/\/restapi.e-conomic.com\/products\/1" }, "quantity": 1.00, "unitNetPrice": 500.00, @@ -46,11 +46,11 @@ "daysOfCredit": 8, "name": "Netto 8 dage", "paymentTermsType": "net", - "self": "https://restapi.e-conomic.com/payment-terms/1" + "self": "https:\/\/restapi.e-conomic.com\/payment-terms\/1" }, "customer": { "customerNumber": 1, - "self": "https://restapi.e-conomic.com/customers/1" + "self": "https:\/\/restapi.e-conomic.com\/customers\/1" }, "recipient": { "name": "John Doe", @@ -59,7 +59,7 @@ "vatZoneNumber": 1, "enabledForCustomer": true, "enabledForSupplier": true, - "self": "https://restapi.e-conomic.com/vat-zones/1" + "self": "https:\/\/restapi.e-conomic.com\/vat-zones\/1" } }, "notes": { @@ -69,11 +69,11 @@ }, "layout": { "layoutNumber": 14, - "self": "https://restapi.e-conomic.com/layouts/14" + "self": "https:\/\/restapi.e-conomic.com\/layouts\/14" }, "pdf": { - "download": "https://restapi.e-conomic.com/invoices/drafts/424/pdf" + "download": "https:\/\/restapi.e-conomic.com\/invoices\/drafts\/424\/pdf" }, "lastUpdated": "2024-02-13T12:20:00Z", - "self": "https://restapi.e-conomic.com/invoices/drafts/424" + "self": "https:\/\/restapi.e-conomic.com\/invoices\/drafts\/424" }