From 780dc74749d44ac54d9ed988366d8e4f3a3d7138 Mon Sep 17 00:00:00 2001 From: "WoutervanderLoop.nl" Date: Wed, 3 Jan 2024 14:11:23 +0100 Subject: [PATCH] Fix Upload form. Refs: #43 #44 --- src/Client.php | 9 ++++++++- src/OpenApi/ClientGenerator.php | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Client.php b/src/Client.php index 08e5fb1..2560f46 100644 --- a/src/Client.php +++ b/src/Client.php @@ -1577,6 +1577,7 @@ public function getInvoiceRequests(?string $shipmentId = null, ?int $page = 1, ? /** * Uploads an invoice associated with shipment id. * @param string $shipmentId The id of the shipment associated with the invoice. + * @param string $invoice * @return Model\ProcessStatus|null * @throws Exception\ConnectException when an error occurred in the HTTP connection. * @throws Exception\ResponseException when an unexpected response was received. @@ -1584,10 +1585,16 @@ public function getInvoiceRequests(?string $shipmentId = null, ?int $page = 1, ? * @throws Exception\RateLimitException when the throttling limit has been reached for the API user. * @throws Exception\Exception when something unexpected went wrong. */ - public function uploadInvoice(string $shipmentId): ?Model\ProcessStatus + public function uploadInvoice(string $shipmentId, string $invoice): ?Model\ProcessStatus { $url = "retailer/shipments/invoices/{$shipmentId}"; $options = [ + 'multipart' => [ + [ + 'name' => 'invoice', + 'contents' => \GuzzleHttp\Psr7\Utils::tryFopen($invoice, 'r'), + ], + ], 'produces' => 'application/vnd.retailer.v10+json', 'consumes' => 'application/json', ]; diff --git a/src/OpenApi/ClientGenerator.php b/src/OpenApi/ClientGenerator.php index 9ad827a..388a16f 100644 --- a/src/OpenApi/ClientGenerator.php +++ b/src/OpenApi/ClientGenerator.php @@ -344,7 +344,7 @@ protected function extractArguments(array $methodDefinition): array } $argsWithoutDefault[] = $argument; - } elseif (array_key_first($methodDefinition['requestBody']['content']) == 'multipart/form-data') { + } else { foreach ($requestBody['schema']['properties'] as $propName => $property) { $argument = [ 'default' => null,