Skip to content

Commit

Permalink
Merge pull request #471 from infinum/hotfix/talentlyft
Browse files Browse the repository at this point in the history
  • Loading branch information
iruzevic authored Dec 11, 2024
2 parents fc887da + 2d4a69a commit 9016077
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 15 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a CHANGELOG](https://keepachangelog.com/).

## [5.6.2]

### Fixed

- Broken Talentlyft integration if we have custom fields.

## [5.6.1]

### Fixed
Expand Down Expand Up @@ -848,6 +854,7 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a

- Initial production release.

[5.6.2]: https://github.com/infinum/eightshift-forms/compare/5.6.1...5.6.2
[5.6.1]: https://github.com/infinum/eightshift-forms/compare/5.6.0...5.6.1
[5.6.0]: https://github.com/infinum/eightshift-forms/compare/5.5.1...5.6.0
[5.5.1]: https://github.com/infinum/eightshift-forms/compare/5.5.0...5.5.1
Expand Down
2 changes: 1 addition & 1 deletion eightshift-forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Description: Eightshift Forms is a complete form builder plugin that utilizes modern Block editor features with multiple third-party integrations, bringing your project to a new level.
* Author: WordPress team @Infinum
* Author URI: https://eightshift.com/
* Version: 5.6.1
* Version: 5.6.2
* Text Domain: eightshift-forms
*
* @package EightshiftForms
Expand Down
7 changes: 1 addition & 6 deletions src/Integrations/Talentlyft/Talentlyft.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ private function getFields(array $data, string $formId): array
continue;
}

$customType = $item['FieldLocationType'] ?? '';
$key = $item['Key'] ?? '';

$type = $item['Type'] ?? '';
Expand All @@ -129,12 +128,8 @@ private function getFields(array $data, string $formId): array
$name = isset($item['Id']) ? "q_{$item['Id']}" : '';
}

if ($customType === 'ScreeningQuestions') {
$internalType = 'Answers';
}

if (empty($key)) {
$internalType = 'CustomFieldAnswers';
$internalType = 'customField';
}

if (!$name) {
Expand Down
29 changes: 21 additions & 8 deletions src/Integrations/Talentlyft/TalentlyftClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,6 @@ private function prepareParams(array $params, string $formId): array
// Map enrichment data.
$params = $this->enrichment->mapEnrichmentFields($params);

$output = [];

// Filter params.
$filterName = UtilsHooksHelper::getFilterName(['integrations', SettingsTalentlyft::SETTINGS_TYPE_KEY, 'prePostParams']);
if (\has_filter($filterName)) {
Expand All @@ -398,6 +396,9 @@ private function prepareParams(array $params, string $formId): array
// Remove unecesery params.
$params = UtilsGeneralHelper::removeUneceseryParamFields($params);

$output = [];
$outputCustom = [];

foreach ($params as $param) {
$name = $param['name'] ?? '';
if (!$name) {
Expand All @@ -415,15 +416,14 @@ private function prepareParams(array $params, string $formId): array
$name = \preg_replace('/^q_/', '', $name);

switch ($typeCustom) {
case 'Answers':
case 'CustomFieldAnswers':
case 'customField':
if (\in_array($type, ['radio', 'select', 'checkbox'], true)) {
$output[$typeCustom][] = [
$outputCustom[] = [
'Id' => (int) $name,
'Choices' => \explode(UtilsConfig::DELIMITER, $value),
];
} else {
$output[$typeCustom][] = [
$outputCustom[] = [
'Id' => (int) $name,
'Body' => $value,
];
Expand All @@ -440,6 +440,12 @@ private function prepareParams(array $params, string $formId): array
}
}

if ($outputCustom) {
// Due to poor API design we need to send custom fields in two different ways.
$output['CustomFieldAnswers'] = $outputCustom;
$output['Answers'] = $outputCustom;
}

return $output;
}

Expand All @@ -453,6 +459,7 @@ private function prepareParams(array $params, string $formId): array
private function prepareFiles(array $files): array
{
$output = [];
$outputCustom = [];

foreach ($files as $items) {
$name = $items['name'] ?? '';
Expand All @@ -473,8 +480,8 @@ private function prepareFiles(array $files): array
$fileName = UtilsUploadHelper::getFileNameFromPath($file);

switch ($typeCustom) {
case 'answers':
$output['Answers'][] = [
case 'customField':
$outputCustom[] = [
'Id' => (int) $name,
'File' => [
'FileName' => $fileName,
Expand All @@ -496,6 +503,12 @@ private function prepareFiles(array $files): array
}
}

if ($outputCustom) {
// Due to poor API design we need to send custom fields in two different ways.
$output['CustomFieldAnswers'] = $outputCustom;
$output['Answers'] = $outputCustom;
}

return $output;
}

Expand Down

0 comments on commit 9016077

Please sign in to comment.