Skip to content

Commit

Permalink
Merge pull request #49 from TheDMSGroup/bug/age-update
Browse files Browse the repository at this point in the history
When an age changes upon save we should update it.
  • Loading branch information
heathdutton authored Jun 4, 2018
2 parents 7b54f9d + eb2154b commit 758a9ed
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
10 changes: 6 additions & 4 deletions Integration/AgeFromBirthdateIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,12 @@ public function doEnhancement(Lead &$lead)
$birthdate = sprintf('%04d-%02d-%02d 00:00:00', $year, $month, $day);
$dob = new DateTime($birthdate);
$today = new DateTime();
$age = $today->diff($dob)->y;
$this->logger->info("calculated age is $age");

$lead->addUpdatedField('afb_age', intval($age));
$age = (int) $today->diff($dob)->y;
$prevAge = (int) $lead->getFieldValue('afb_age');
if ($age !== $prevAge) {
$this->logger->info("calculated age is $age");
$lead->addUpdatedField('afb_age', (string) $age, $prevAge);
}
}

return true;
Expand Down
2 changes: 1 addition & 1 deletion Integration/AlcazarIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ public function doEnhancement(Lead &$lead)
$alias = 'alcazar_'.strtolower($label);
if (isset($allowedAliases[$alias])) {
$default = $lead->getFieldValue($alias);
$lead->addUpdatedField($alias, $value, $default);
$lead->addUpdatedField($alias, (string) $value, $default);
}
}

Expand Down
2 changes: 1 addition & 1 deletion Integration/FourleafIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ public function doEnhancement(Lead &$lead)
$alias = 'fourleaf_'.str_replace('user_', '', $key);
if (isset($allowedAliases[$alias])) {
$default = $lead->getFieldValue($alias);
$lead->addUpdatedField($alias, $value, $default);
$lead->addUpdatedField($alias, (string) $value, $default);
}
}
$this->saveLead($lead);
Expand Down
2 changes: 1 addition & 1 deletion Integration/RandomIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function doEnhancement(Lead &$lead)
$settings = $this->getIntegrationSettings()->getFeatureSettings();

if (!$lead->getFieldValue($settings['random_field_name'])) {
$lead->addUpdatedField($settings['random_field_name'], rand(1, 100));
$lead->addUpdatedField($settings['random_field_name'], (string) rand(1, 100));
}
}

Expand Down
4 changes: 2 additions & 2 deletions Integration/XverifyIntegration.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function doEnhancement(Lead &$lead)
$persist = true;
$status = $this->getResponseStatus($response, $fieldKey);
if (!is_null($status)) {
$lead->addUpdatedField($fieldToUpdate, $status);
$lead->addUpdatedField($fieldToUpdate, (string) $status);
$this->logger->addDebug(
'XVERIFY: verification values to update: '.$fieldToUpdate.' => '.$status
);
Expand All @@ -180,7 +180,7 @@ public function doEnhancement(Lead &$lead)
$persist = true;
$status = $this->getResponseStatus($response, $fieldKey);
if (!is_null($status)) {
$lead->addUpdatedField($fieldToUpdate, $status, null);
$lead->addUpdatedField($fieldToUpdate, (string) $status, null);
$persist = true;
$this->logger->addDebug(
'XVERIFY: verification values to update: '.$fieldToUpdate.' => '.$status
Expand Down

0 comments on commit 758a9ed

Please sign in to comment.