Problem/Motivation

When adding flexmail handler errors are thrown upon submission. It appears FlexmailWebformHandler.php does not correctly reference properties coming from flexmail API.

Steps to reproduce

  1. Setup flexmail handler select "Update contact" and submit the webform. Error is thrown "There was a problem updating ... in Flexmail".
  2. Select "do no update existing contact" in webform handler settings, submit form. Error is thrown "Can not create or retrieve user with email"

Proposed resolution

For the first issue (Updating contact):

The API return data but with a 'total' property set to 0 if no results are found.
Here we can add a check on the 'total' property to allow pass through:
if (empty($contacts) || $contacts['total'] === 0) {

For the second issue (Default submission):
It appears the code is not correctly referencing the response returned from flexmail API.

Currently:
$contactArray = \reset($contacts);

Suggested:
$contactArray = $contacts['_embedded']['item'][0];

Flexmail API documentation:
https://api.flexmail.eu/documentation/?_ga=2.103788096.1348026172.166601...

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork flexmail-3315782

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

j1mb0b created an issue. See original summary.

j1mb0b’s picture

Version: 2.x-dev » 2.0.0-alpha2
j1mb0b’s picture

Issue summary: View changes
j1mb0b’s picture

j1mb0b’s picture

Patch with updated changes.

j1mb0b’s picture

Status: Active » Needs review

  • daften committed 049c83c on 2.x
    Issue #3315782 by j1mb0b: Flexmail webform handler not matching flexmail...
daften’s picture

Status: Needs review » Needs work

This is in line with the changes in #3278677: Webform Handler can not load Handler Settings. It looks good and a quick test showed no issues after the patch, so commited. I'll release a new version asap. Thanks for the contribution!

I committed this, since it's completely broken without. But it requires an additional change. Due to the if ($contactArray) { that can fail, $contact_id could be null, there should be a safeguard for that in the code too.

Matthijs made their first commit to this issue’s fork.

matthijs’s picture

Version: 2.0.0-alpha2 » 2.0.x-dev
Status: Needs work » Needs review

A similar issue exists for the contact preferences and interests (I presumed the latter, didn't test/verified it). The MR resolves this.

  • daften committed 5bb9c50f on 2.0.x authored by Matthijs
    Issue #3315782: Flexmail webform handler not matching flexmail API...

  • daften committed 4b03bced on 2.x
    Merge remote-tracking branch 'origin/2.0.x' into 2.x
    
    * origin/2.0.x:...

  • daften committed 5bb9c50f on 2.x authored by Matthijs
    Issue #3315782: Flexmail webform handler not matching flexmail API...
daften’s picture

Status: Needs review » Needs work

I incorporated that contribution in a new release Matthijs, thanks. Putting back to needs work for the edge cases mentioned above.

  • daften committed 4b03bced on 2.0.x
    Merge remote-tracking branch 'origin/2.0.x' into 2.x
    
    * origin/2.0.x:...

  • daften committed 049c83cd on 2.0.x authored by j1mb0b
    Issue #3315782 by j1mb0b: Flexmail webform handler not matching flexmail...