parseTokens error with complex data when using send-grid-protocol with cbmailservices #34
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
SendGrid allows you to use handlebars to render data when using dynamic templates (email type "template"). If you try to send complex (nested data) it will cause an error when parsing tokens:
As an example, here are a set of bodyTokens for a SendGrid dynamic template:
Issues
If you attempt to pass complex data you will receive an error that "complex object types cannot be converted to simple values." Since tokens are handled at send grid, skip processing if the email type is "template" and just send the values across as-is. In this case the
body
value will just be a templateID, there is no need for token replacement.Type of change
Testing
CommandBox> testbox run --noVerbose
Executing tests http://localhost:50745/test-harness/tests/runner.cfm?&recurse=true&reporter=json&verbose=false please wait...
╔═════════════════════════════════════════════════════════════════════╗
║ Passed ║ Failed ║ Errored ║ Skipped ║ Bundles ║ Suites ║ Specs ║
╠═════════════════════════════════════════════════════════════════════╣
║ 50 ║ 0 ║ 0 ║ 0 ║ 11 ║ 12 ║ 50 ║
╚═════════════════════════════════════════════════════════════════════╝
TestBox v5.0.0
CFML Engine Lucee v5.3.10.120
Duration 767ms
Labels ---