euromedica-client/lib/Api/CustomersApi.php

1537 lines
65 KiB
PHP

<?php
/**
* CustomersApi
* PHP version 7.4
*
* @category Class
* @package Europharmacy\EuromedicaClient
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
/**
* Euromedica Two Web Api
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: v1
* Contact: development@europharmacy.gr
* Generated by: https://openapi-generator.tech
* Generator version: 7.12.0
*/
/**
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
namespace Europharmacy\EuromedicaClient\Api;
use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\ConnectException;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Psr7\MultipartStream;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\RequestOptions;
use Europharmacy\EuromedicaClient\ApiException;
use Europharmacy\EuromedicaClient\Configuration;
use Europharmacy\EuromedicaClient\HeaderSelector;
use Europharmacy\EuromedicaClient\ObjectSerializer;
/**
* CustomersApi Class Doc Comment
*
* @category Class
* @package Europharmacy\EuromedicaClient
* @author OpenAPI Generator team
* @link https://openapi-generator.tech
*/
class CustomersApi
{
/**
* @var ClientInterface
*/
protected $client;
/**
* @var Configuration
*/
protected $config;
/**
* @var HeaderSelector
*/
protected $headerSelector;
/**
* @var int Host index
*/
protected $hostIndex;
/** @var string[] $contentTypes **/
public const contentTypes = [
'apiCustomersGet' => [
'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:
if ('\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse' !== '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()
),
$statusCode,
$response->getHeaders(),
$content
);
}
}
}
return [
ObjectSerializer::deserialize($content, '\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 404:
if ('\Europharmacy\EuromedicaClient\Model\ProblemDetails' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\Europharmacy\EuromedicaClient\Model\ProblemDetails' !== '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()
),
$statusCode,
$response->getHeaders(),
$content
);
}
}
}
return [
ObjectSerializer::deserialize($content, '\Europharmacy\EuromedicaClient\Model\ProblemDetails', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse' !== '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()
),
$statusCode,
$response->getHeaders(),
$content
);
}
}
}
return [
ObjectSerializer::deserialize($content, '\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 401:
if ('\Europharmacy\EuromedicaClient\Model\ProblemDetails' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\Europharmacy\EuromedicaClient\Model\ProblemDetails' !== '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()
),
$statusCode,
$response->getHeaders(),
$content
);
}
}
}
return [
ObjectSerializer::deserialize($content, '\Europharmacy\EuromedicaClient\Model\ProblemDetails', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 403:
if ('\Europharmacy\EuromedicaClient\Model\ProblemDetails' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\Europharmacy\EuromedicaClient\Model\ProblemDetails' !== '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()
),
$statusCode,
$response->getHeaders(),
$content
);
}
}
}
return [
ObjectSerializer::deserialize($content, '\Europharmacy\EuromedicaClient\Model\ProblemDetails', []),
$response->getStatusCode(),
$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()
);
}
$returnType = '\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($returnType !== '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()
),
$statusCode,
$response->getHeaders(),
$content
);
}
}
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 404:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\Europharmacy\EuromedicaClient\Model\ProblemDetails',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 401:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\Europharmacy\EuromedicaClient\Model\ProblemDetails',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 403:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\Europharmacy\EuromedicaClient\Model\ProblemDetails',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
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:
if ('\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse' !== '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()
),
$statusCode,
$response->getHeaders(),
$content
);
}
}
}
return [
ObjectSerializer::deserialize($content, '\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 404:
if ('\Europharmacy\EuromedicaClient\Model\ProblemDetails' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\Europharmacy\EuromedicaClient\Model\ProblemDetails' !== '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()
),
$statusCode,
$response->getHeaders(),
$content
);
}
}
}
return [
ObjectSerializer::deserialize($content, '\Europharmacy\EuromedicaClient\Model\ProblemDetails', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('string' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('string' !== '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()
),
$statusCode,
$response->getHeaders(),
$content
);
}
}
}
return [
ObjectSerializer::deserialize($content, 'string', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 401:
if ('\Europharmacy\EuromedicaClient\Model\ProblemDetails' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\Europharmacy\EuromedicaClient\Model\ProblemDetails' !== '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()
),
$statusCode,
$response->getHeaders(),
$content
);
}
}
}
return [
ObjectSerializer::deserialize($content, '\Europharmacy\EuromedicaClient\Model\ProblemDetails', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 403:
if ('\Europharmacy\EuromedicaClient\Model\ProblemDetails' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\Europharmacy\EuromedicaClient\Model\ProblemDetails' !== '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()
),
$statusCode,
$response->getHeaders(),
$content
);
}
}
}
return [
ObjectSerializer::deserialize($content, '\Europharmacy\EuromedicaClient\Model\ProblemDetails', []),
$response->getStatusCode(),
$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()
);
}
$returnType = '\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($returnType !== '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()
),
$statusCode,
$response->getHeaders(),
$content
);
}
}
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 404:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\Europharmacy\EuromedicaClient\Model\ProblemDetails',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'string',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 401:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\Europharmacy\EuromedicaClient\Model\ProblemDetails',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 403:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\Europharmacy\EuromedicaClient\Model\ProblemDetails',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
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:
if ('\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse' !== '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()
),
$statusCode,
$response->getHeaders(),
$content
);
}
}
}
return [
ObjectSerializer::deserialize($content, '\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 400:
if ('\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse' !== '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()
),
$statusCode,
$response->getHeaders(),
$content
);
}
}
}
return [
ObjectSerializer::deserialize($content, '\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 401:
if ('\Europharmacy\EuromedicaClient\Model\ProblemDetails' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\Europharmacy\EuromedicaClient\Model\ProblemDetails' !== '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()
),
$statusCode,
$response->getHeaders(),
$content
);
}
}
}
return [
ObjectSerializer::deserialize($content, '\Europharmacy\EuromedicaClient\Model\ProblemDetails', []),
$response->getStatusCode(),
$response->getHeaders()
];
case 403:
if ('\Europharmacy\EuromedicaClient\Model\ProblemDetails' === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ('\Europharmacy\EuromedicaClient\Model\ProblemDetails' !== '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()
),
$statusCode,
$response->getHeaders(),
$content
);
}
}
}
return [
ObjectSerializer::deserialize($content, '\Europharmacy\EuromedicaClient\Model\ProblemDetails', []),
$response->getStatusCode(),
$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()
);
}
$returnType = '\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse';
if ($returnType === '\SplFileObject') {
$content = $response->getBody(); //stream goes to serializer
} else {
$content = (string) $response->getBody();
if ($returnType !== '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()
),
$statusCode,
$response->getHeaders(),
$content
);
}
}
}
return [
ObjectSerializer::deserialize($content, $returnType, []),
$response->getStatusCode(),
$response->getHeaders()
];
} catch (ApiException $e) {
switch ($e->getCode()) {
case 200:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 400:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\Europharmacy\EuromedicaClient\Model\CustomerPagedResponse',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 401:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\Europharmacy\EuromedicaClient\Model\ProblemDetails',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
case 403:
$data = ObjectSerializer::deserialize(
$e->getResponseBody(),
'\Europharmacy\EuromedicaClient\Model\ProblemDetails',
$e->getResponseHeaders()
);
$e->setResponseObject($data);
break;
}
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());
}
}
return $options;
}
}