[ 'application/json', ], 'apiCustomersIdGet' => [ 'application/json', ], 'apiCustomersPost' => [ 'application/json-patch+json', 'application/json', '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 apiCustomersGet * * Αναζήτηση πελατών * * @param string|null $search_by_name (optional, default to '') * @param string|null $search_by_phone (optional, default to '') * @param string|null $search_by_amka (optional, default to '') * @param string|null $search_by_afm (optional, default to '') * @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['apiCustomersGet'] 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\CustomerPagedResponse|\Europharmacy\EuromedicaClient\Model\ProblemDetails|\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse|\Europharmacy\EuromedicaClient\Model\ProblemDetails|\Europharmacy\EuromedicaClient\Model\ProblemDetails */ public function apiCustomersGet($search_by_name = '', $search_by_phone = '', $search_by_amka = '', $search_by_afm = '', $page = 1, $size = 1000, string $contentType = self::contentTypes['apiCustomersGet'][0]) { list($response) = $this->apiCustomersGetWithHttpInfo($search_by_name, $search_by_phone, $search_by_amka, $search_by_afm, $page, $size, $contentType); return $response; } /** * Operation apiCustomersGetWithHttpInfo * * Αναζήτηση πελατών * * @param string|null $search_by_name (optional, default to '') * @param string|null $search_by_phone (optional, default to '') * @param string|null $search_by_amka (optional, default to '') * @param string|null $search_by_afm (optional, default to '') * @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['apiCustomersGet'] 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\CustomerPagedResponse|\Europharmacy\EuromedicaClient\Model\ProblemDetails|\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse|\Europharmacy\EuromedicaClient\Model\ProblemDetails|\Europharmacy\EuromedicaClient\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings) */ public function apiCustomersGetWithHttpInfo($search_by_name = '', $search_by_phone = '', $search_by_amka = '', $search_by_afm = '', $page = 1, $size = 1000, string $contentType = self::contentTypes['apiCustomersGet'][0]) { $request = $this->apiCustomersGetRequest($search_by_name, $search_by_phone, $search_by_amka, $search_by_afm, $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\CustomerPagedResponse', $request, $response, ); case 404: return $this->handleResponseWithDataType( '\Europharmacy\EuromedicaClient\Model\ProblemDetails', $request, $response, ); case 400: return $this->handleResponseWithDataType( '\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse', $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\CustomerPagedResponse', $request, $response, ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse', $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(), '\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse', $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 apiCustomersGetAsync * * Αναζήτηση πελατών * * @param string|null $search_by_name (optional, default to '') * @param string|null $search_by_phone (optional, default to '') * @param string|null $search_by_amka (optional, default to '') * @param string|null $search_by_afm (optional, default to '') * @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['apiCustomersGet'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function apiCustomersGetAsync($search_by_name = '', $search_by_phone = '', $search_by_amka = '', $search_by_afm = '', $page = 1, $size = 1000, string $contentType = self::contentTypes['apiCustomersGet'][0]) { return $this->apiCustomersGetAsyncWithHttpInfo($search_by_name, $search_by_phone, $search_by_amka, $search_by_afm, $page, $size, $contentType) ->then( function ($response) { return $response[0]; } ); } /** * Operation apiCustomersGetAsyncWithHttpInfo * * Αναζήτηση πελατών * * @param string|null $search_by_name (optional, default to '') * @param string|null $search_by_phone (optional, default to '') * @param string|null $search_by_amka (optional, default to '') * @param string|null $search_by_afm (optional, default to '') * @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['apiCustomersGet'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function apiCustomersGetAsyncWithHttpInfo($search_by_name = '', $search_by_phone = '', $search_by_amka = '', $search_by_afm = '', $page = 1, $size = 1000, string $contentType = self::contentTypes['apiCustomersGet'][0]) { $returnType = '\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse'; $request = $this->apiCustomersGetRequest($search_by_name, $search_by_phone, $search_by_amka, $search_by_afm, $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 'apiCustomersGet' * * @param string|null $search_by_name (optional, default to '') * @param string|null $search_by_phone (optional, default to '') * @param string|null $search_by_amka (optional, default to '') * @param string|null $search_by_afm (optional, default to '') * @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['apiCustomersGet'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function apiCustomersGetRequest($search_by_name = '', $search_by_phone = '', $search_by_amka = '', $search_by_afm = '', $page = 1, $size = 1000, string $contentType = self::contentTypes['apiCustomersGet'][0]) { $resourcePath = '/api/Customers'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $search_by_name, 'searchByName', // param base name 'string', // openApiType 'form', // style true, // explode false // required ) ?? []); // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $search_by_phone, 'searchByPhone', // param base name 'string', // openApiType 'form', // style true, // explode false // required ) ?? []); // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $search_by_amka, 'searchByAmka', // param base name 'string', // openApiType 'form', // style true, // explode false // required ) ?? []); // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( $search_by_afm, 'searchByAfm', // 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 ); } /** * Operation apiCustomersIdGet * * Προβολή πελάτη βάσει Id * * @param int $id (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiCustomersIdGet'] 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\CustomerPagedResponse|\Europharmacy\EuromedicaClient\Model\ProblemDetails|string|\Europharmacy\EuromedicaClient\Model\ProblemDetails|\Europharmacy\EuromedicaClient\Model\ProblemDetails */ public function apiCustomersIdGet($id, string $contentType = self::contentTypes['apiCustomersIdGet'][0]) { list($response) = $this->apiCustomersIdGetWithHttpInfo($id, $contentType); return $response; } /** * Operation apiCustomersIdGetWithHttpInfo * * Προβολή πελάτη βάσει Id * * @param int $id (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiCustomersIdGet'] 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\CustomerPagedResponse|\Europharmacy\EuromedicaClient\Model\ProblemDetails|string|\Europharmacy\EuromedicaClient\Model\ProblemDetails|\Europharmacy\EuromedicaClient\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings) */ public function apiCustomersIdGetWithHttpInfo($id, string $contentType = self::contentTypes['apiCustomersIdGet'][0]) { $request = $this->apiCustomersIdGetRequest($id, $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\CustomerPagedResponse', $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\CustomerPagedResponse', $request, $response, ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse', $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 apiCustomersIdGetAsync * * Προβολή πελάτη βάσει Id * * @param int $id (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiCustomersIdGet'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function apiCustomersIdGetAsync($id, string $contentType = self::contentTypes['apiCustomersIdGet'][0]) { return $this->apiCustomersIdGetAsyncWithHttpInfo($id, $contentType) ->then( function ($response) { return $response[0]; } ); } /** * Operation apiCustomersIdGetAsyncWithHttpInfo * * Προβολή πελάτη βάσει Id * * @param int $id (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiCustomersIdGet'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function apiCustomersIdGetAsyncWithHttpInfo($id, string $contentType = self::contentTypes['apiCustomersIdGet'][0]) { $returnType = '\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse'; $request = $this->apiCustomersIdGetRequest($id, $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 'apiCustomersIdGet' * * @param int $id (required) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiCustomersIdGet'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function apiCustomersIdGetRequest($id, string $contentType = self::contentTypes['apiCustomersIdGet'][0]) { // verify the required parameter 'id' is set if ($id === null || (is_array($id) && count($id) === 0)) { throw new \InvalidArgumentException( 'Missing the required parameter $id when calling apiCustomersIdGet' ); } $resourcePath = '/api/Customers/{id}'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; // path params if ($id !== null) { $resourcePath = str_replace( '{' . 'id' . '}', ObjectSerializer::toPathValue($id), $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 apiCustomersPost * * Εισαγωγή ή επεξεργασία πελάτη * * @param \Europharmacy\EuromedicaClient\Model\CustomerDto|null $customer_dto (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiCustomersPost'] 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\CustomerPagedResponse|\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse|\Europharmacy\EuromedicaClient\Model\ProblemDetails|\Europharmacy\EuromedicaClient\Model\ProblemDetails */ public function apiCustomersPost($customer_dto = null, string $contentType = self::contentTypes['apiCustomersPost'][0]) { list($response) = $this->apiCustomersPostWithHttpInfo($customer_dto, $contentType); return $response; } /** * Operation apiCustomersPostWithHttpInfo * * Εισαγωγή ή επεξεργασία πελάτη * * @param \Europharmacy\EuromedicaClient\Model\CustomerDto|null $customer_dto (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiCustomersPost'] 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\CustomerPagedResponse|\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse|\Europharmacy\EuromedicaClient\Model\ProblemDetails|\Europharmacy\EuromedicaClient\Model\ProblemDetails, HTTP status code, HTTP response headers (array of strings) */ public function apiCustomersPostWithHttpInfo($customer_dto = null, string $contentType = self::contentTypes['apiCustomersPost'][0]) { $request = $this->apiCustomersPostRequest($customer_dto, $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\CustomerPagedResponse', $request, $response, ); case 400: return $this->handleResponseWithDataType( '\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse', $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\CustomerPagedResponse', $request, $response, ); } catch (ApiException $e) { switch ($e->getCode()) { case 200: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse', $e->getResponseHeaders() ); $e->setResponseObject($data); throw $e; case 400: $data = ObjectSerializer::deserialize( $e->getResponseBody(), '\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse', $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 apiCustomersPostAsync * * Εισαγωγή ή επεξεργασία πελάτη * * @param \Europharmacy\EuromedicaClient\Model\CustomerDto|null $customer_dto (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiCustomersPost'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function apiCustomersPostAsync($customer_dto = null, string $contentType = self::contentTypes['apiCustomersPost'][0]) { return $this->apiCustomersPostAsyncWithHttpInfo($customer_dto, $contentType) ->then( function ($response) { return $response[0]; } ); } /** * Operation apiCustomersPostAsyncWithHttpInfo * * Εισαγωγή ή επεξεργασία πελάτη * * @param \Europharmacy\EuromedicaClient\Model\CustomerDto|null $customer_dto (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiCustomersPost'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Promise\PromiseInterface */ public function apiCustomersPostAsyncWithHttpInfo($customer_dto = null, string $contentType = self::contentTypes['apiCustomersPost'][0]) { $returnType = '\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse'; $request = $this->apiCustomersPostRequest($customer_dto, $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 'apiCustomersPost' * * @param \Europharmacy\EuromedicaClient\Model\CustomerDto|null $customer_dto (optional) * @param string $contentType The value for the Content-Type header. Check self::contentTypes['apiCustomersPost'] to see the possible values for this operation * * @throws \InvalidArgumentException * @return \GuzzleHttp\Psr7\Request */ public function apiCustomersPostRequest($customer_dto = null, string $contentType = self::contentTypes['apiCustomersPost'][0]) { $resourcePath = '/api/Customers'; $formParams = []; $queryParams = []; $headerParams = []; $httpBody = ''; $multipart = false; $headers = $this->headerSelector->selectHeaders( ['application/json', ], $contentType, $multipart ); // for model (json/xml) if (isset($customer_dto)) { if (stripos($headers['Content-Type'], 'application/json') !== false) { # if Content-Type contains "application/json", json_encode the body $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($customer_dto)); } else { $httpBody = $customer_dto; } } elseif (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 ); } /** * 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; } }