Skip to content

Commit

Permalink
♻️ Set typehint for body to array or string (#24)
Browse files Browse the repository at this point in the history
* ♻️ Set typehint for body to array or string

* ✅ Fix fixtures

---------

Co-authored-by: Mathias Bærentsen <[email protected]>
  • Loading branch information
larasmorningtrain and matbaek authored May 17, 2024
1 parent 40aa0a4 commit 399d348
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/Classes/EconomicResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -19,7 +19,7 @@ public function getStatusCode(): int
return $this->statusCode;
}

public function getBody(): mixed
public function getBody(): array|string
{
return $this->body;
}
Expand Down
11 changes: 6 additions & 5 deletions tests/Fixtures/Invoices/draft/create-request.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 10 additions & 10 deletions tests/Fixtures/Invoices/draft/create-response.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@
}
},
"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,
"sortKey": 1,
"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,
Expand Down Expand Up @@ -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",
Expand All @@ -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": {
Expand All @@ -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"
}

0 comments on commit 399d348

Please sign in to comment.