[ 'application/json', ], 'apiProductsDataboxBarcodePost' => [ 'application/json', ], 'apiProductsGet' => [ 'application/json', ], ]; /** * @param ClientInterface $client * @param Configuration $config * @param HeaderSelector $selector * @param int $hostIndex (Optional) host index to select the list of hosts if defined in the OpenAPI spec */ public function __construct( ?ClientInterface $client = null, ?Configuration $config = null, ?HeaderSelector $selector = null, int $hostIndex = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: Configuration::getDefaultConfiguration(); $this->headerSelector = $selector ?: new HeaderSelector(); $this->hostIndex = $hostIndex; } /** * Set the host index * * @param int $hostIndex Host index (required) */ public function setHostIndex($hostIndex): void { $this->hostIndex = $hostIndex; } /** * Get the host index * * @return int Host index */ public function getHostIndex() { return $this->hostIndex; } /** * @return Configuration */ public function getConfig() { return $this->config; } /** * Operation apiProductsBarcodeGet * * Αναζήτηση βάσει barcode * * @param string $barcode (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiProductsBarcodeGet'] to see the possible values for this operation * * @throws \Europharmacy\EuromedicaClient\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return \Europharmacy\EuromedicaClient\Model\ProductDto|\Europharmacy\EuromedicaClient\Model\ProblemDetails|string|\Europharmacy\EuromedicaClient\Model\ProblemDetails|\Europharmacy\EuromedicaClient\Model\ProblemDetails */ public function apiProductsBarcodeGet($barcode, string $contentType = self::contentTypes['apiProductsBarcodeGet'][0]) { list($response) = $this->apiProductsBarcodeGetWithHttpInfo($barcode, $contentType); return $response; } /** * Operation apiProductsBarcodeGetWithHttpInfo * * Αναζήτηση βάσει barcode * * @param string $barcode (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiProductsBarcodeGet'] to see the possible values for this operation * * @throws \Europharmacy\EuromedicaClient\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return array of \Europharmacy\EuromedicaClient\Model\ProductDto|\Europharmacy\EuromedicaClient\Model\ProblemDetails|string|\Europharmacy\EuromedicaClient\Model\ProblemDetails|\Europharmacy\EuromedicaClient\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings) */ public function apiProductsBarcodeGetWithHttpInfo($barcode, string $contentType = self::contentTypes['apiProductsBarcodeGet'][0]) { $request = $this->apiProductsBarcodeGetRequest($barcode, $contentType); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null ); } $statusCode = $response->getStatusCode(); switch($statusCode) { case 200: return $this->handleResponseWithDataType( '\Europharmacy\EuromedicaClient\Model\ProductDto', $request, $response, ); case 404: return $this->handleResponseWithDataType( '\Europharmacy\EuromedicaClient\Model\ProblemDetails', $request, $response, ); case 400: return $this->handleResponseWithDataType( 'string', $request, $response, ); case 401: return $this->handleResponseWithDataType( '\Europharmacy\EuromedicaClient\Model\ProblemDetails', $request, $response, ); case 403: return $this->handleResponseWithDataType( '\Europharmacy\EuromedicaClient\Model\ProblemDetails', $request, $response, ); } 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( '\Europharmacy\EuromedicaClient\Model\ProductDto', $request, $response, ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\Europharmacy\EuromedicaClient\Model\ProductDto', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 404: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\Europharmacy\EuromedicaClient\Model\ProblemDetails', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 400: $data = ObjectSerializer::deserialize( $e->getResponseBody(), 'string', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 401: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\Europharmacy\EuromedicaClient\Model\ProblemDetails', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 403: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\Europharmacy\EuromedicaClient\Model\ProblemDetails', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; } throw $e; } } /** * Operation apiProductsBarcodeGetAsync * * Αναζήτηση βάσει barcode * * @param string $barcode (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiProductsBarcodeGet'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function apiProductsBarcodeGetAsync($barcode, string $contentType = self::contentTypes['apiProductsBarcodeGet'][0]) { return $this->apiProductsBarcodeGetAsyncWithHttpInfo($barcode, $contentType) ->then( function ($response) { return $response[0]; } ); } /** * Operation apiProductsBarcodeGetAsyncWithHttpInfo * * Αναζήτηση βάσει barcode * * @param string $barcode (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiProductsBarcodeGet'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function apiProductsBarcodeGetAsyncWithHttpInfo($barcode, string $contentType = self::contentTypes['apiProductsBarcodeGet'][0]) { $returnType = '\Europharmacy\EuromedicaClient\Model\ProductDto'; $request = $this->apiProductsBarcodeGetRequest($barcode, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { $content = json_decode($content); } } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; }, function ($exception) { $response = $exception->getResponse(); $statusCode = $response->getStatusCode(); throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri() ), $statusCode, $response->getHeaders(), (string) $response->getBody() ); } ); } /** * Create request for operation 'apiProductsBarcodeGet' * * @param string $barcode (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiProductsBarcodeGet'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function apiProductsBarcodeGetRequest($barcode, string $contentType = self::contentTypes['apiProductsBarcodeGet'][0]) { // verify the required parameter 'barcode' is set if ($barcode === null || (is_array($barcode) && count($barcode) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $barcode when calling apiProductsBarcodeGet' ); } $resourcePath = '/api/Products/{barcode}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($barcode !== null) { $resourcePath = str_replace( '{' . 'barcode' . '}', ObjectSerializer::toPathValue($barcode), $resourcePath ); } $headers = $this->headerSelector->selectHeaders( ['application/json', ], $contentType, $multipart ); // for model (json/xml) if (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValueItem ]; } } // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); } } // this endpoint requires HTTP basic authentication if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $operationHost = $this->config->getHost(); $query = ObjectSerializer::buildQuery($queryParams); return new Request( 'GET', $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } /** * Operation apiProductsDataboxBarcodePost * * @param string $barcode barcode (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiProductsDataboxBarcodePost'] to see the possible values for this operation * * @throws \Europharmacy\EuromedicaClient\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return \Europharmacy\EuromedicaClient\Model\ProductDto|\Europharmacy\EuromedicaClient\Model\ProblemDetails|string|\Europharmacy\EuromedicaClient\Model\ProblemDetails|\Europharmacy\EuromedicaClient\Model\ProblemDetails */ public function apiProductsDataboxBarcodePost($barcode, string $contentType = self::contentTypes['apiProductsDataboxBarcodePost'][0]) { list($response) = $this->apiProductsDataboxBarcodePostWithHttpInfo($barcode, $contentType); return $response; } /** * Operation apiProductsDataboxBarcodePostWithHttpInfo * * @param string $barcode (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiProductsDataboxBarcodePost'] to see the possible values for this operation * * @throws \Europharmacy\EuromedicaClient\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return array of \Europharmacy\EuromedicaClient\Model\ProductDto|\Europharmacy\EuromedicaClient\Model\ProblemDetails|string|\Europharmacy\EuromedicaClient\Model\ProblemDetails|\Europharmacy\EuromedicaClient\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings) */ public function apiProductsDataboxBarcodePostWithHttpInfo($barcode, string $contentType = self::contentTypes['apiProductsDataboxBarcodePost'][0]) { $request = $this->apiProductsDataboxBarcodePostRequest($barcode, $contentType); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null ); } $statusCode = $response->getStatusCode(); switch($statusCode) { case 200: return $this->handleResponseWithDataType( '\Europharmacy\EuromedicaClient\Model\ProductDto', $request, $response, ); case 404: return $this->handleResponseWithDataType( '\Europharmacy\EuromedicaClient\Model\ProblemDetails', $request, $response, ); case 400: return $this->handleResponseWithDataType( 'string', $request, $response, ); case 401: return $this->handleResponseWithDataType( '\Europharmacy\EuromedicaClient\Model\ProblemDetails', $request, $response, ); case 403: return $this->handleResponseWithDataType( '\Europharmacy\EuromedicaClient\Model\ProblemDetails', $request, $response, ); } 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( '\Europharmacy\EuromedicaClient\Model\ProductDto', $request, $response, ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\Europharmacy\EuromedicaClient\Model\ProductDto', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 404: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\Europharmacy\EuromedicaClient\Model\ProblemDetails', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 400: $data = ObjectSerializer::deserialize( $e->getResponseBody(), 'string', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 401: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\Europharmacy\EuromedicaClient\Model\ProblemDetails', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 403: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\Europharmacy\EuromedicaClient\Model\ProblemDetails', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; } throw $e; } } /** * Operation apiProductsDataboxBarcodePostAsync * * @param string $barcode (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiProductsDataboxBarcodePost'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function apiProductsDataboxBarcodePostAsync($barcode, string $contentType = self::contentTypes['apiProductsDataboxBarcodePost'][0]) { return $this->apiProductsDataboxBarcodePostAsyncWithHttpInfo($barcode, $contentType) ->then( function ($response) { return $response[0]; } ); } /** * Operation apiProductsDataboxBarcodePostAsyncWithHttpInfo * * @param string $barcode (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiProductsDataboxBarcodePost'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function apiProductsDataboxBarcodePostAsyncWithHttpInfo($barcode, string $contentType = self::contentTypes['apiProductsDataboxBarcodePost'][0]) { $returnType = '\Europharmacy\EuromedicaClient\Model\ProductDto'; $request = $this->apiProductsDataboxBarcodePostRequest($barcode, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { $content = json_decode($content); } } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; }, function ($exception) { $response = $exception->getResponse(); $statusCode = $response->getStatusCode(); throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri() ), $statusCode, $response->getHeaders(), (string) $response->getBody() ); } ); } /** * Create request for operation 'apiProductsDataboxBarcodePost' * * @param string $barcode (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiProductsDataboxBarcodePost'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function apiProductsDataboxBarcodePostRequest($barcode, string $contentType = self::contentTypes['apiProductsDataboxBarcodePost'][0]) { // verify the required parameter 'barcode' is set if ($barcode === null || (is_array($barcode) && count($barcode) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $barcode when calling apiProductsDataboxBarcodePost' ); } $resourcePath = '/api/Products/Databox/{Barcode}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($barcode !== null) { $resourcePath = str_replace( '{' . 'Barcode' . '}', ObjectSerializer::toPathValue($barcode), $resourcePath ); } $headers = $this->headerSelector->selectHeaders( ['application/json', ], $contentType, $multipart ); // for model (json/xml) if (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValueItem ]; } } // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); } } // this endpoint requires HTTP basic authentication if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $operationHost = $this->config->getHost(); $query = ObjectSerializer::buildQuery($queryParams); return new Request( 'POST', $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } /** * Operation apiProductsGet * * Αναζήτηση ειδών * * @param string|null $search_text Αναζήτηση είδους βάσει ονομασίας/barcode , μπορεί να είναι και κενό (optional) * @param bool|null $search_meds Αναζήτηση φαρμάκων (optional, default to true) * @param bool|null $search_user_items Αναζήτηση παραφαρμάκων (optional, default to true) * @param bool|null $visibly_web Αν έχει τιμή θα επιστρέφει όσα πληρούν τη συνθήκη (Αυτόματα εξαιρεί τα φάρμακα) (optional) * @param \DateTime|null $modified_after Αν έχει τιμή θα επιστρέφει όσα έχουν τροποποιηθεί μετά την επιλεγμένη ημερομηνία π.χ. (2024-3-12 12:01) (optional) * @param int|null $page (optional, default to 1) * @param int|null $size (optional, default to 1000) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiProductsGet'] to see the possible values for this operation * * @throws \Europharmacy\EuromedicaClient\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return \Europharmacy\EuromedicaClient\Model\ProductDtoPagedResponse|\Europharmacy\EuromedicaClient\Model\ProblemDetails|string|\Europharmacy\EuromedicaClient\Model\ProblemDetails|\Europharmacy\EuromedicaClient\Model\ProblemDetails */ public function apiProductsGet($search_text = null, $search_meds = true, $search_user_items = true, $visibly_web = null, $modified_after = null, $page = 1, $size = 1000, string $contentType = self::contentTypes['apiProductsGet'][0]) { list($response) = $this->apiProductsGetWithHttpInfo($search_text, $search_meds, $search_user_items, $visibly_web, $modified_after, $page, $size, $contentType); return $response; } /** * Operation apiProductsGetWithHttpInfo * * Αναζήτηση ειδών * * @param string|null $search_text Αναζήτηση είδους βάσει ονομασίας/barcode , μπορεί να είναι και κενό (optional) * @param bool|null $search_meds Αναζήτηση φαρμάκων (optional, default to true) * @param bool|null $search_user_items Αναζήτηση παραφαρμάκων (optional, default to true) * @param bool|null $visibly_web Αν έχει τιμή θα επιστρέφει όσα πληρούν τη συνθήκη (Αυτόματα εξαιρεί τα φάρμακα) (optional) * @param \DateTime|null $modified_after Αν έχει τιμή θα επιστρέφει όσα έχουν τροποποιηθεί μετά την επιλεγμένη ημερομηνία π.χ. (2024-3-12 12:01) (optional) * @param int|null $page (optional, default to 1) * @param int|null $size (optional, default to 1000) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiProductsGet'] to see the possible values for this operation * * @throws \Europharmacy\EuromedicaClient\ApiException on non-2xx response or if the response body is not in the expected format * @throws \InvalidArgumentException * @return array of \Europharmacy\EuromedicaClient\Model\ProductDtoPagedResponse|\Europharmacy\EuromedicaClient\Model\ProblemDetails|string|\Europharmacy\EuromedicaClient\Model\ProblemDetails|\Europharmacy\EuromedicaClient\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings) */ public function apiProductsGetWithHttpInfo($search_text = null, $search_meds = true, $search_user_items = true, $visibly_web = null, $modified_after = null, $page = 1, $size = 1000, string $contentType = self::contentTypes['apiProductsGet'][0]) { $request = $this->apiProductsGetRequest($search_text, $search_meds, $search_user_items, $visibly_web, $modified_after, $page, $size, $contentType); try { $options = $this->createHttpClientOption(); try { $response = $this->client->send($request, $options); } catch (RequestException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), $e->getResponse() ? $e->getResponse()->getHeaders() : null, $e->getResponse() ? (string) $e->getResponse()->getBody() : null ); } catch (ConnectException $e) { throw new ApiException( "[{$e->getCode()}] {$e->getMessage()}", (int) $e->getCode(), null, null ); } $statusCode = $response->getStatusCode(); switch($statusCode) { case 200: return $this->handleResponseWithDataType( '\Europharmacy\EuromedicaClient\Model\ProductDtoPagedResponse', $request, $response, ); case 404: return $this->handleResponseWithDataType( '\Europharmacy\EuromedicaClient\Model\ProblemDetails', $request, $response, ); case 400: return $this->handleResponseWithDataType( 'string', $request, $response, ); case 401: return $this->handleResponseWithDataType( '\Europharmacy\EuromedicaClient\Model\ProblemDetails', $request, $response, ); case 403: return $this->handleResponseWithDataType( '\Europharmacy\EuromedicaClient\Model\ProblemDetails', $request, $response, ); } 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( '\Europharmacy\EuromedicaClient\Model\ProductDtoPagedResponse', $request, $response, ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\Europharmacy\EuromedicaClient\Model\ProductDtoPagedResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 404: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\Europharmacy\EuromedicaClient\Model\ProblemDetails', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 400: $data = ObjectSerializer::deserialize( $e->getResponseBody(), 'string', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 401: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\Europharmacy\EuromedicaClient\Model\ProblemDetails', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 403: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\Europharmacy\EuromedicaClient\Model\ProblemDetails', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; } throw $e; } } /** * Operation apiProductsGetAsync * * Αναζήτηση ειδών * * @param string|null $search_text Αναζήτηση είδους βάσει ονομασίας/barcode , μπορεί να είναι και κενό (optional) * @param bool|null $search_meds Αναζήτηση φαρμάκων (optional, default to true) * @param bool|null $search_user_items Αναζήτηση παραφαρμάκων (optional, default to true) * @param bool|null $visibly_web Αν έχει τιμή θα επιστρέφει όσα πληρούν τη συνθήκη (Αυτόματα εξαιρεί τα φάρμακα) (optional) * @param \DateTime|null $modified_after Αν έχει τιμή θα επιστρέφει όσα έχουν τροποποιηθεί μετά την επιλεγμένη ημερομηνία π.χ. (2024-3-12 12:01) (optional) * @param int|null $page (optional, default to 1) * @param int|null $size (optional, default to 1000) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiProductsGet'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function apiProductsGetAsync($search_text = null, $search_meds = true, $search_user_items = true, $visibly_web = null, $modified_after = null, $page = 1, $size = 1000, string $contentType = self::contentTypes['apiProductsGet'][0]) { return $this->apiProductsGetAsyncWithHttpInfo($search_text, $search_meds, $search_user_items, $visibly_web, $modified_after, $page, $size, $contentType) ->then( function ($response) { return $response[0]; } ); } /** * Operation apiProductsGetAsyncWithHttpInfo * * Αναζήτηση ειδών * * @param string|null $search_text Αναζήτηση είδους βάσει ονομασίας/barcode , μπορεί να είναι και κενό (optional) * @param bool|null $search_meds Αναζήτηση φαρμάκων (optional, default to true) * @param bool|null $search_user_items Αναζήτηση παραφαρμάκων (optional, default to true) * @param bool|null $visibly_web Αν έχει τιμή θα επιστρέφει όσα πληρούν τη συνθήκη (Αυτόματα εξαιρεί τα φάρμακα) (optional) * @param \DateTime|null $modified_after Αν έχει τιμή θα επιστρέφει όσα έχουν τροποποιηθεί μετά την επιλεγμένη ημερομηνία π.χ. (2024-3-12 12:01) (optional) * @param int|null $page (optional, default to 1) * @param int|null $size (optional, default to 1000) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiProductsGet'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function apiProductsGetAsyncWithHttpInfo($search_text = null, $search_meds = true, $search_user_items = true, $visibly_web = null, $modified_after = null, $page = 1, $size = 1000, string $contentType = self::contentTypes['apiProductsGet'][0]) { $returnType = '\Europharmacy\EuromedicaClient\Model\ProductDtoPagedResponse'; $request = $this->apiProductsGetRequest($search_text, $search_meds, $search_user_items, $visibly_web, $modified_after, $page, $size, $contentType); return $this->client ->sendAsync($request, $this->createHttpClientOption()) ->then( function ($response) use ($returnType) { if ($returnType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); if ($returnType !== 'string') { $content = json_decode($content); } } return [ ObjectSerializer::deserialize($content, $returnType, []), $response->getStatusCode(), $response->getHeaders() ]; }, function ($exception) { $response = $exception->getResponse(); $statusCode = $response->getStatusCode(); throw new ApiException( sprintf( '[%d] Error connecting to the API (%s)', $statusCode, $exception->getRequest()->getUri() ), $statusCode, $response->getHeaders(), (string) $response->getBody() ); } ); } /** * Create request for operation 'apiProductsGet' * * @param string|null $search_text Αναζήτηση είδους βάσει ονομασίας/barcode , μπορεί να είναι και κενό (optional) * @param bool|null $search_meds Αναζήτηση φαρμάκων (optional, default to true) * @param bool|null $search_user_items Αναζήτηση παραφαρμάκων (optional, default to true) * @param bool|null $visibly_web Αν έχει τιμή θα επιστρέφει όσα πληρούν τη συνθήκη (Αυτόματα εξαιρεί τα φάρμακα) (optional) * @param \DateTime|null $modified_after Αν έχει τιμή θα επιστρέφει όσα έχουν τροποποιηθεί μετά την επιλεγμένη ημερομηνία π.χ. (2024-3-12 12:01) (optional) * @param int|null $page (optional, default to 1) * @param int|null $size (optional, default to 1000) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiProductsGet'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function apiProductsGetRequest($search_text = null, $search_meds = true, $search_user_items = true, $visibly_web = null, $modified_after = null, $page = 1, $size = 1000, string $contentType = self::contentTypes['apiProductsGet'][0]) { if ($size !== null && $size > 1000) { throw new \InvalidArgumentException('invalid value for "$size" when calling ProductsApi.apiProductsGet, must be smaller than or equal to 1000.'); } if ($size !== null && $size < 1) { throw new \InvalidArgumentException('invalid value for "$size" when calling ProductsApi.apiProductsGet, must be bigger than or equal to 1.'); } $resourcePath = '/api/Products'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $search_text, 'searchText', // param base name 'string', // openApiType 'form', // style true, // explode false // required ) ?? []); // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $search_meds, 'searchMeds', // param base name 'boolean', // openApiType 'form', // style true, // explode false // required ) ?? []); // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $search_user_items, 'searchUserItems', // param base name 'boolean', // openApiType 'form', // style true, // explode false // required ) ?? []); // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $visibly_web, 'visiblyWeb', // param base name 'boolean', // openApiType 'form', // style true, // explode false // required ) ?? []); // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $modified_after, 'modifiedAfter', // param base name 'string', // openApiType 'form', // style true, // explode false // required ) ?? []); // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $page, 'page', // param base name 'integer', // openApiType 'form', // style true, // explode false // required ) ?? []); // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $size, 'size', // param base name 'integer', // openApiType 'form', // style true, // explode false // required ) ?? []); $headers = $this->headerSelector->selectHeaders( ['application/json', ], $contentType, $multipart ); // for model (json/xml) if (count($formParams) > 0) { if ($multipart) { $multipartContents = []; foreach ($formParams as $formParamName => $formParamValue) { $formParamValueItems = is_array($formParamValue) ? $formParamValue : [$formParamValue]; foreach ($formParamValueItems as $formParamValueItem) { $multipartContents[] = [ 'name' => $formParamName, 'contents' => $formParamValueItem ]; } } // for HTTP post (form) $httpBody = new MultipartStream($multipartContents); } elseif (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the form parameters $httpBody = \GuzzleHttp\Utils::jsonEncode($formParams); } else { // for HTTP post (form) $httpBody = ObjectSerializer::buildQuery($formParams); } } // this endpoint requires HTTP basic authentication if (!empty($this->config->getUsername()) || !(empty($this->config->getPassword()))) { $headers['Authorization'] = 'Basic ' . base64_encode($this->config->getUsername() . ":" . $this->config->getPassword()); } $defaultHeaders = []; if ($this->config->getUserAgent()) { $defaultHeaders['User-Agent'] = $this->config->getUserAgent(); } $headers = array_merge( $defaultHeaders, $headerParams, $headers ); $operationHost = $this->config->getHost(); $query = ObjectSerializer::buildQuery($queryParams); return new Request( 'GET', $operationHost . $resourcePath . ($query ? "?{$query}" : ''), $headers, $httpBody ); } /** * Create http client option * * @throws \RuntimeException on file opening failure * @return array of http client options */ protected function createHttpClientOption() { $options = []; if ($this->config->getDebug()) { $options[RequestOptions::DEBUG] = fopen($this->config->getDebugFile(), 'a'); if (!$options[RequestOptions::DEBUG]) { throw new \RuntimeException('Failed to open the debug file: ' . $this->config->getDebugFile()); } } if ($this->config->getCertFile()) { $options[RequestOptions::CERT] = $this->config->getCertFile(); } if ($this->config->getKeyFile()) { $options[RequestOptions::SSL_KEY] = $this->config->getKeyFile(); } return $options; } private function handleResponseWithDataType( string $dataType, RequestInterface $request, ResponseInterface $response ): array { if ($dataType === '\SplFileObject') { $content = $response->getBody(); //stream goes to serializer } else { $content = (string) $response->getBody(); if ($dataType !== 'string') { try { $content = json_decode($content, false, 512, JSON_THROW_ON_ERROR); } catch (\JsonException $exception) { throw new ApiException( sprintf( 'Error JSON decoding server response (%s)', $request->getUri() ), $response->getStatusCode(), $response->getHeaders(), $content ); } } } return [ ObjectSerializer::deserialize($content, $dataType, []), $response->getStatusCode(), $response->getHeaders() ]; } private function responseWithinRangeCode( string $rangeCode, int $statusCode ): bool { $left = (int) ($rangeCode[0].'00'); $right = (int) ($rangeCode[0].'99'); return $statusCode >= $left && $statusCode <= $right; } }