diff --git a/lib/Model/CustomizableModelAbstract.php b/lib/Model/CustomizableModelAbstract.php new file mode 100644 index 0000000..df34de1 --- /dev/null +++ b/lib/Model/CustomizableModelAbstract.php @@ -0,0 +1,39 @@ +customizableFields; + } + + /** + * @param mixed $customizableFields + * @return CustomizableModelAbstract + */ + public function setCustomizableFields(array $customizableFields): self + { + $this->customizableFields = $customizableFields; + return $this; + } + + /** + * @param array $customizableFields + * @return $this + */ + public function addCustomizableFields(array $customizableFields): self + { + $fields = $this->customizableFields ?? []; + $this->customizableFields = array_merge($fields, $customizableFields); + return $this; + } +} diff --git a/lib/Model/JobAdRequest.php b/lib/Model/JobAdRequest.php index 8ed3073..3cf6935 100644 --- a/lib/Model/JobAdRequest.php +++ b/lib/Model/JobAdRequest.php @@ -41,7 +41,7 @@ * @link https://openapi-generator.tech * @implements \ArrayAccess */ -class JobAdRequest implements ModelInterface, ArrayAccess, \JsonSerializable +class JobAdRequest extends CustomizableModelAbstract implements ModelInterface, ArrayAccess, \JsonSerializable { public const DISCRIMINATOR = null; @@ -253,6 +253,7 @@ public function __construct(array $data = null) { $this->setIfExists('data', $data ?? [], null); $this->setIfExists('metadata', $data ?? [], null); + parent::__construct([]); } /** diff --git a/lib/Model/JobadCommonData.php b/lib/Model/JobadCommonData.php index 4bf143e..2229595 100644 --- a/lib/Model/JobadCommonData.php +++ b/lib/Model/JobadCommonData.php @@ -41,7 +41,7 @@ * @link https://openapi-generator.tech * @implements \ArrayAccess */ -class JobadCommonData implements ModelInterface, ArrayAccess, \JsonSerializable +class JobadCommonData extends CustomizableModelAbstract implements ModelInterface, ArrayAccess, \JsonSerializable { public const DISCRIMINATOR = null; @@ -400,6 +400,7 @@ public function __construct(array $data = null) $this->setIfExists('benefits', $data ?? [], null); $this->setIfExists('expiration_date', $data ?? [], null); $this->setIfExists('status', $data ?? [], null); + parent::__construct([]); } /** diff --git a/lib/Model/JobadCommonOptionalData.php b/lib/Model/JobadCommonOptionalData.php index 2013146..1570e0e 100644 --- a/lib/Model/JobadCommonOptionalData.php +++ b/lib/Model/JobadCommonOptionalData.php @@ -41,7 +41,7 @@ * @link https://openapi-generator.tech * @implements \ArrayAccess */ -class JobadCommonOptionalData implements ModelInterface, ArrayAccess, \JsonSerializable +class JobadCommonOptionalData extends CustomizableModelAbstract implements ModelInterface, ArrayAccess, \JsonSerializable { public const DISCRIMINATOR = null; @@ -400,6 +400,7 @@ public function __construct(array $data = null) $this->setIfExists('benefits', $data ?? [], null); $this->setIfExists('expiration_date', $data ?? [], null); $this->setIfExists('status', $data ?? [], null); + parent::__construct([]); } /** diff --git a/lib/Model/PatchItemRequest.php b/lib/Model/PatchItemRequest.php index 1a33a0b..669e501 100644 --- a/lib/Model/PatchItemRequest.php +++ b/lib/Model/PatchItemRequest.php @@ -41,22 +41,22 @@ * @link https://openapi-generator.tech * @implements \ArrayAccess */ -class PatchItemRequest implements ModelInterface, ArrayAccess, \JsonSerializable +class PatchItemRequest extends CustomizableModelAbstract implements ModelInterface, ArrayAccess, \JsonSerializable { public const DISCRIMINATOR = null; /** - * The original name of the model. - * - * @var string - */ + * The original name of the model. + * + * @var string + */ protected static $openAPIModelName = 'PatchItemRequest'; /** - * Array of property to type mappings. Used for (de)serialization - * - * @var string[] - */ + * Array of property to type mappings. Used for (de)serialization + * + * @var string[] + */ protected static $openAPITypes = [ 'data' => '\OpenAPI\Client\Model\ResumeCommonData', 'metadata' => '\OpenAPI\Client\Model\Metadata', @@ -64,12 +64,12 @@ class PatchItemRequest implements ModelInterface, ArrayAccess, \JsonSerializable ]; /** - * Array of property to format mappings. Used for (de)serialization - * - * @var string[] - * @phpstan-var array - * @psalm-var array - */ + * Array of property to format mappings. Used for (de)serialization + * + * @var string[] + * @phpstan-var array + * @psalm-var array + */ protected static $openAPIFormats = [ 'data' => null, 'metadata' => null, @@ -77,21 +77,21 @@ class PatchItemRequest implements ModelInterface, ArrayAccess, \JsonSerializable ]; /** - * Array of nullable properties. Used for (de)serialization - * - * @var boolean[] - */ + * Array of nullable properties. Used for (de)serialization + * + * @var boolean[] + */ protected static array $openAPINullables = [ 'data' => false, - 'metadata' => false, - 'attachments' => false + 'metadata' => false, + 'attachments' => false ]; /** - * If a nullable field gets set to null, insert it here - * - * @var boolean[] - */ + * If a nullable field gets set to null, insert it here + * + * @var boolean[] + */ protected array $openAPINullablesSetToNull = []; /** @@ -260,17 +260,18 @@ public function __construct(array $data = null) $this->setIfExists('data', $data ?? [], null); $this->setIfExists('metadata', $data ?? [], null); $this->setIfExists('attachments', $data ?? [], null); + parent::__construct([]); } /** - * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName - * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the - * $this->openAPINullablesSetToNull array - * - * @param string $variableName - * @param array $fields - * @param mixed $defaultValue - */ + * Sets $this->container[$variableName] to the given data or to the given default Value; if $variableName + * is nullable and its value is set to null in the $fields array, then mark it as "set to null" in the + * $this->openAPINullablesSetToNull array + * + * @param string $variableName + * @param array $fields + * @param mixed $defaultValue + */ private function setIfExists(string $variableName, array $fields, $defaultValue): void { if (self::isNullable($variableName) && array_key_exists($variableName, $fields) && is_null($fields[$variableName])) { @@ -448,7 +449,7 @@ public function offsetUnset($offset): void #[\ReturnTypeWillChange] public function jsonSerialize() { - return ObjectSerializer::sanitizeForSerialization($this); + return ObjectSerializer::sanitizeForSerialization($this); } /** @@ -474,5 +475,3 @@ public function toHeaderValue() return json_encode(ObjectSerializer::sanitizeForSerialization($this)); } } - - diff --git a/lib/Model/PatchJobAdRequest.php b/lib/Model/PatchJobAdRequest.php index a816b46..c9368e4 100644 --- a/lib/Model/PatchJobAdRequest.php +++ b/lib/Model/PatchJobAdRequest.php @@ -41,7 +41,7 @@ * @link https://openapi-generator.tech * @implements \ArrayAccess */ -class PatchJobAdRequest implements ModelInterface, ArrayAccess, \JsonSerializable +class PatchJobAdRequest extends CustomizableModelAbstract implements ModelInterface, ArrayAccess, \JsonSerializable { public const DISCRIMINATOR = null; @@ -253,6 +253,7 @@ public function __construct(array $data = null) { $this->setIfExists('data', $data ?? [], null); $this->setIfExists('metadata', $data ?? [], null); + parent::__construct([]); } /** diff --git a/lib/ObjectSerializer.php b/lib/ObjectSerializer.php index 228bbb1..f724763 100644 --- a/lib/ObjectSerializer.php +++ b/lib/ObjectSerializer.php @@ -1,4 +1,5 @@ $value) { - $data[$property] = self::sanitizeForSerialization($value); + $data[$property] = self::sanitizeForSerialization(data: $value, root: false); } return $data; } @@ -100,20 +102,53 @@ public static function sanitizeForSerialization($data, $type = null, $format = n } } if (($data::isNullable($property) && $data->isNullableSetToNull($property)) || $value !== null) { - $values[$data::attributeMap()[$property]] = self::sanitizeForSerialization($value, $openAPIType, $formats[$property]); + $values[$data::attributeMap()[$property]] = self::sanitizeForSerialization(data: $value, type: $openAPIType, format: $formats[$property], root: false); + } + } + if ($root) { + if (is_subclass_of($data, CustomizableModelAbstract::class)) { + $customFields = $data->getCustomizableFields(); + if (!empty($customFields)) { + $originalValues = $values; + $customFields = self::dotNotationToNestedArray($customFields); + $values = array_merge_recursive($originalValues, $customFields); + } } } } else { - foreach($data as $property => $value) { - $values[$property] = self::sanitizeForSerialization($value); + foreach ($data as $property => $value) { + $values[$property] = self::sanitizeForSerialization(data: $value, root: false); } } + return (object)$values; } else { return (string)$data; } } + /** + * + * @param array $dotNotationArray + * @return mixed + */ + private static function dotNotationToNestedArray(array $dotNotationArray) + { + $nestedArray = []; + foreach ($dotNotationArray as $key => $value) { + $parts = explode('.', $key); + $pointer = &$nestedArray; + foreach ($parts as $part) { + if (!isset($pointer[$part])) { + $pointer[$part] = []; + } + $pointer = &$pointer[$part]; + } + $pointer = $value; + } + return $nestedArray; + } + /** * Sanitize filename by removing path. * e.g. ../../sun.gif becomes sun.gif @@ -140,7 +175,9 @@ public static function sanitizeFilename($filename) */ public static function sanitizeTimestamp($timestamp) { - if (!is_string($timestamp)) return $timestamp; + if (!is_string($timestamp)) { + return $timestamp; + } return preg_replace('/(:\d{2}.\d{6})\d*/', '$1', $timestamp); } @@ -236,7 +273,7 @@ public static function toQueryValue( } # Handle DateTime objects in query - if($openApiType === "\\DateTime" && $value instanceof \DateTime) { + if ($openApiType === "\\DateTime" && $value instanceof \DateTime) { return ["{$paramName}" => $value->format(self::$dateTimeFormat)]; } @@ -246,7 +283,9 @@ public static function toQueryValue( // since \GuzzleHttp\Psr7\Query::build fails with nested arrays // need to flatten array first $flattenArray = function ($arr, $name, &$result = []) use (&$flattenArray, $style, $explode) { - if (!is_array($arr)) return $arr; + if (!is_array($arr)) { + return $arr; + } foreach ($arr as $k => $v) { $prop = ($style === 'deepObject') ? $prop = "{$name}[{$k}]" : $k; @@ -474,7 +513,7 @@ public static function deserialize($data, $class, $httpHeaders = null) // determine file name if ( is_array($httpHeaders) - && array_key_exists('Content-Disposition', $httpHeaders) + && array_key_exists('Content-Disposition', $httpHeaders) && preg_match('/inline; filename=[\'"]?([^\'"\s]+)[\'"]?$/i', $httpHeaders['Content-Disposition'], $match) ) { $filename = Configuration::getDefaultConfiguration()->getTempFolderPath() . DIRECTORY_SEPARATOR . self::sanitizeFilename($match[1]); diff --git a/lib/inda_hr/CustomizationsApi.php b/lib/inda_hr/CustomizationsApi.php index 7150017..a3d65da 100644 --- a/lib/inda_hr/CustomizationsApi.php +++ b/lib/inda_hr/CustomizationsApi.php @@ -78,9 +78,15 @@ class CustomizationsApi 'getResumeCustomizationsGET' => [ 'application/json', ], + 'customizeJobAdsPOST' => [ + 'application/json', + ], + 'getJobAdCustomizationsGET' => [ + 'application/json', + ], ]; -/** + /** * @param ClientInterface $client * @param Configuration $config * @param HeaderSelector $selector @@ -90,7 +96,7 @@ public function __construct( ClientInterface $client = null, Configuration $config = null, HeaderSelector $selector = null, - $hostIndex = 0 + $hostIndex = 0 ) { $this->client = $client ?: new Client(); $this->config = $config ?: new Configuration(); @@ -765,6 +771,652 @@ public function getResumeCustomizationsGETRequest($indexname, string $contentTyp ); } + ########### + # JOB-ADS # + ########### + + /** + * Operation customizeResumesPOST + * + * Customize Resumes + * + * @param string $indexname indexname (required) + * @param \OpenAPI\Client\Model\CustomFields $custom_fields custom_fields (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['customizeResumesPOST'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\CustomizedFields|\OpenAPI\Client\Model\HTTPValidationError + */ + public function customizeJobAdsPOST($indexname, $custom_fields, string $contentType = self::contentTypes['customizeJobAdsPOST'][0]) + { + list($response) = $this->customizeJobAdsPOSTWithHttpInfo($indexname, $custom_fields, $contentType); + return $response; + } + + /** + * Operation customizeJobAdsPOSTWithHttpInfo + * + * Customize JobAds + * + * @param string $indexname (required) + * @param \OpenAPI\Client\Model\CustomFields $custom_fields (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['customizeJobAdsPOST'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\CustomizedFields|\OpenAPI\Client\Model\HTTPValidationError, HTTP status code, HTTP response headers (array of strings) + */ + public function customizeJobAdsPOSTWithHttpInfo($indexname, $custom_fields, string $contentType = self::contentTypes['customizeJobAdsPOST'][0]) + { + $request = $this->customizeJobAdsPOSTRequest($indexname, $custom_fields, $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(); + + 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() + ); + } + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\CustomizedFields' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\CustomizedFields' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\CustomizedFields', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 422: + if ('\OpenAPI\Client\Model\HTTPValidationError' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\HTTPValidationError' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\HTTPValidationError', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\OpenAPI\Client\Model\CustomizedFields'; + 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() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\CustomizedFields', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 422: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\HTTPValidationError', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation customizeJobAdsPOSTAsync + * + * Customize JobAds + * + * @param string $indexname (required) + * @param \OpenAPI\Client\Model\CustomFields $custom_fields (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['customizeJobAdsPOST'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function customizeJobAdsPOSTAsync($indexname, $custom_fields, string $contentType = self::contentTypes['customizeJobAdsPOST'][0]) + { + return $this->customizeJobAdsPOSTAsyncWithHttpInfo($indexname, $custom_fields, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation customizeJobAdsPOSTAsyncWithHttpInfo + * + * Customize JobAds + * + * @param string $indexname (required) + * @param \OpenAPI\Client\Model\CustomFields $custom_fields (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['customizeJobAdsPOST'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function customizeJobAdsPOSTAsyncWithHttpInfo($indexname, $custom_fields, string $contentType = self::contentTypes['customizeJobAdsPOST'][0]) + { + $returnType = '\OpenAPI\Client\Model\CustomizedFields'; + $request = $this->customizeJobAdsPOSTRequest($indexname, $custom_fields, $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 'customizeJobAdsPOST' + * + * @param string $indexname (required) + * @param \OpenAPI\Client\Model\CustomFields $custom_fields (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['customizeJobAdsPOST'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function customizeJobAdsPOSTRequest($indexname, $custom_fields, string $contentType = self::contentTypes['customizeJobAdsPOST'][0]) + { + + // verify the required parameter 'indexname' is set + if ($indexname === null || (is_array($indexname) && count($indexname) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $indexname when calling customizeJobAdsPOST' + ); + } + + // verify the required parameter 'custom_fields' is set + if ($custom_fields === null || (is_array($custom_fields) && count($custom_fields) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $custom_fields when calling customizeJobAdsPOST' + ); + } + + + $resourcePath = '/hr/v2/index/{indexname}/jobads/customize/'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($indexname !== null) { + $resourcePath = str_replace( + '{' . 'indexname' . '}', + ObjectSerializer::toPathValue($indexname), + $resourcePath + ); + } + + + $headers = $this->headerSelector->selectHeaders( + ['application/json', ], + $contentType, + $multipart + ); + + // for model (json/xml) + if (isset($custom_fields)) { + if (stripos($headers['Content-Type'], 'application/json') !== false) { + # if Content-Type contains "application/json", json_encode the body + $httpBody = \GuzzleHttp\Utils::jsonEncode(ObjectSerializer::sanitizeForSerialization($custom_fields)); + } else { + $httpBody = $custom_fields; + } + } 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 Bearer authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $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 getJobAdCustomizationsGET + * + * Get JobAd Customizations + * + * @param string $indexname indexname (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getJobAdCustomizationsGET'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return \OpenAPI\Client\Model\MappingResponse|\OpenAPI\Client\Model\HTTPValidationError + */ + public function getJobAdCustomizationsGET($indexname, string $contentType = self::contentTypes['getJobAdCustomizationsGET'][0]) + { + list($response) = $this->getJobAdCustomizationsGETWithHttpInfo($indexname, $contentType); + return $response; + } + + /** + * Operation getJobAdCustomizationsGETWithHttpInfo + * + * Get JobAd Customizations + * + * @param string $indexname (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getJobAdCustomizationsGET'] to see the possible values for this operation + * + * @throws \OpenAPI\Client\ApiException on non-2xx response + * @throws \InvalidArgumentException + * @return array of \OpenAPI\Client\Model\MappingResponse|\OpenAPI\Client\Model\HTTPValidationError, HTTP status code, HTTP response headers (array of strings) + */ + public function getJobAdCustomizationsGETWithHttpInfo($indexname, string $contentType = self::contentTypes['getJobAdCustomizationsGET'][0]) + { + $request = $this->getJobAdCustomizationsGETRequest($indexname, $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(); + + 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() + ); + } + + switch($statusCode) { + case 200: + if ('\OpenAPI\Client\Model\MappingResponse' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\MappingResponse' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\MappingResponse', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + case 422: + if ('\OpenAPI\Client\Model\HTTPValidationError' === '\SplFileObject') { + $content = $response->getBody(); //stream goes to serializer + } else { + $content = (string) $response->getBody(); + if ('\OpenAPI\Client\Model\HTTPValidationError' !== 'string') { + $content = json_decode($content); + } + } + + return [ + ObjectSerializer::deserialize($content, '\OpenAPI\Client\Model\HTTPValidationError', []), + $response->getStatusCode(), + $response->getHeaders() + ]; + } + + $returnType = '\OpenAPI\Client\Model\MappingResponse'; + 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() + ]; + + } catch (ApiException $e) { + switch ($e->getCode()) { + case 200: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\MappingResponse', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + case 422: + $data = ObjectSerializer::deserialize( + $e->getResponseBody(), + '\OpenAPI\Client\Model\HTTPValidationError', + $e->getResponseHeaders() + ); + $e->setResponseObject($data); + break; + } + throw $e; + } + } + + /** + * Operation getJobAdCustomizationsGETAsync + * + * Get JobAd Customizations + * + * @param string $indexname (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getJobAdCustomizationsGET'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getJobAdCustomizationsGETAsync($indexname, string $contentType = self::contentTypes['getJobAdCustomizationsGET'][0]) + { + return $this->getJobAdCustomizationsGETAsyncWithHttpInfo($indexname, $contentType) + ->then( + function ($response) { + return $response[0]; + } + ); + } + + /** + * Operation getJobAdCustomizationsGETAsyncWithHttpInfo + * + * Get JobAd Customizations + * + * @param string $indexname (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getJobAdCustomizationsGET'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Promise\PromiseInterface + */ + public function getJobAdCustomizationsGETAsyncWithHttpInfo($indexname, string $contentType = self::contentTypes['getJobAdCustomizationsGET'][0]) + { + $returnType = '\OpenAPI\Client\Model\MappingResponse'; + $request = $this->getJobAdCustomizationsGETRequest($indexname, $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 'getJobAdCustomizationsGET' + * + * @param string $indexname (required) + * @param string $contentType The value for the Content-Type header. Check self::contentTypes['getJobAdCustomizationsGET'] to see the possible values for this operation + * + * @throws \InvalidArgumentException + * @return \GuzzleHttp\Psr7\Request + */ + public function getJobAdCustomizationsGETRequest($indexname, string $contentType = self::contentTypes['getJobAdCustomizationsGET'][0]) + { + + // verify the required parameter 'indexname' is set + if ($indexname === null || (is_array($indexname) && count($indexname) === 0)) { + throw new \InvalidArgumentException( + 'Missing the required parameter $indexname when calling getJobAdCustomizationsGET' + ); + } + + + $resourcePath = '/hr/v2/index/{indexname}/jobads/mapping/'; + $formParams = []; + $queryParams = []; + $headerParams = []; + $httpBody = ''; + $multipart = false; + + + + // path params + if ($indexname !== null) { + $resourcePath = str_replace( + '{' . 'indexname' . '}', + ObjectSerializer::toPathValue($indexname), + $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 Bearer authentication (access token) + if (!empty($this->config->getAccessToken())) { + $headers['Authorization'] = 'Bearer ' . $this->config->getAccessToken(); + } + + $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 *