From b4949fd8a841a0bf9a57e2020b9c5b0bc5943b28 Mon Sep 17 00:00:00 2001 From: Willy Reyno Date: Tue, 3 Mar 2026 18:55:13 +0100 Subject: [PATCH 1/3] Refactor API method to return response and add error handling Took inspiration from PaiementsAPI to complete what was missing here --- lib/Api/CommandesApi.php | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/lib/Api/CommandesApi.php b/lib/Api/CommandesApi.php index 8c7b46d..b5c51c1 100644 --- a/lib/Api/CommandesApi.php +++ b/lib/Api/CommandesApi.php @@ -967,7 +967,8 @@ public function ordersOrderIdGetRequest($order_id, $with_form_data = false, stri */ public function organizationsOrganizationSlugFormsFormTypeFormSlugItemsGet($organization_slug, $form_slug, $form_type, $from = null, $to = null, $user_search_key = null, $page_index = 1, $page_size = 20, $continuation_token = null, $tier_types = null, $item_states = null, $tier_name = null, $with_details = false, $sort_order = null, $sort_field = null, string $contentType = self::contentTypes['organizationsOrganizationSlugFormsFormTypeFormSlugItemsGet'][0]) { - $this->organizationsOrganizationSlugFormsFormTypeFormSlugItemsGetWithHttpInfo($organization_slug, $form_slug, $form_type, $from, $to, $user_search_key, $page_index, $page_size, $continuation_token, $tier_types, $item_states, $tier_name, $with_details, $sort_order, $sort_field, $contentType); + list($response) = $this->organizationsOrganizationSlugFormsFormTypeFormSlugItemsGetWithHttpInfo($organization_slug, $form_slug, $form_type, $from, $to, $user_search_key, $page_index, $page_size, $continuation_token, $tier_types, $item_states, $tier_name, $with_details, $sort_order, $sort_field, $contentType); + return $response; } /** @@ -1022,10 +1023,43 @@ public function organizationsOrganizationSlugFormsFormTypeFormSlugItemsGetWithHt $statusCode = $response->getStatusCode(); + switch($statusCode) { + case 200: + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\HelloAssoApiV5CommonModelsCommonResultsWithPaginationModelOrder', + $request, + $response, + ); + } - return [null, $statusCode, $response->getHeaders()]; + if ($statusCode < 200 || $statusCode > 299) { + throw new ApiException( + sprintf( + '[%d] Error connecting to the API (%s)', + $statusCode, + (string) $request->getUri() + ), + $statusCode, + $response->getHeaders(), + (string) $response->getBody() + ); + } + + return $this->handleResponseWithDataType( + '\OpenAPI\Client\Model\HelloAssoApiV5CommonModelsCommonResultsWithPaginationModelOrder', + $request, + $response, + ); } catch (ApiException $e) { switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\HelloAssoApiV5CommonModelsCommonResultsWithPaginationModelOrder', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + throw $e; } From b249e6b643a65049ef430664c0379260d939575e Mon Sep 17 00:00:00 2001 From: Willy Reyno Date: Tue, 3 Mar 2026 19:17:34 +0100 Subject: [PATCH 2/3] Add return type to organizationsOrganizationSlugFormsFormTypeFormSlugItemsGet --- lib/Api/CommandesApi.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Api/CommandesApi.php b/lib/Api/CommandesApi.php index b5c51c1..0d70799 100644 --- a/lib/Api/CommandesApi.php +++ b/lib/Api/CommandesApi.php @@ -961,9 +961,9 @@ public function ordersOrderIdGetRequest($order_id, $with_form_data = false, stri * @param \OpenAPI\Client\Model\HelloAssoApiV5CommonModelsEnumsSortField|null $sort_field Sort forms items by a specific field (Date or UpdateDate). Default is date (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['organizationsOrganizationSlugFormsFormTypeFormSlugItemsGet'] to see the possible values for this operation * + * @return array of \OpenAPI\Client\Model\HelloAssoApiV5CommonModelsCommonResultsWithPaginationModelOrder, HTTP status code, HTTP response headers (array of strings) * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format - * @throws \InvalidArgumentException - * @return void + * @throws \InvalidArgumentException */ public function organizationsOrganizationSlugFormsFormTypeFormSlugItemsGet($organization_slug, $form_slug, $form_type, $from = null, $to = null, $user_search_key = null, $page_index = 1, $page_size = 20, $continuation_token = null, $tier_types = null, $item_states = null, $tier_name = null, $with_details = false, $sort_order = null, $sort_field = null, string $contentType = self::contentTypes['organizationsOrganizationSlugFormsFormTypeFormSlugItemsGet'][0]) { From 163ff786df46c2d2c6f0f4557f48b857e663ed2f Mon Sep 17 00:00:00 2001 From: Willy Reyno Date: Tue, 3 Mar 2026 19:22:35 +0100 Subject: [PATCH 3/3] Fix return type annotation in CommandesApi.php Updated return type annotation for the method organizationsOrganizationSlugFormsFormTypeFormSlugItemsGet. --- lib/Api/CommandesApi.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Api/CommandesApi.php b/lib/Api/CommandesApi.php index 0d70799..f0beaf8 100644 --- a/lib/Api/CommandesApi.php +++ b/lib/Api/CommandesApi.php @@ -961,7 +961,7 @@ public function ordersOrderIdGetRequest($order_id, $with_form_data = false, stri * @param \OpenAPI\Client\Model\HelloAssoApiV5CommonModelsEnumsSortField|null $sort_field Sort forms items by a specific field (Date or UpdateDate). Default is date (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['organizationsOrganizationSlugFormsFormTypeFormSlugItemsGet'] to see the possible values for this operation * - * @return array of \OpenAPI\Client\Model\HelloAssoApiV5CommonModelsCommonResultsWithPaginationModelOrder, HTTP status code, HTTP response headers (array of strings) + * @return \OpenAPI\Client\Model\HelloAssoApiV5CommonModelsCommonResultsWithPaginationModelOrder * @throws \OpenAPI\Client\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException */