Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for Dynamic Templates Implementation #657

Merged
merged 2 commits into from
Aug 15, 2018
Merged

Allow for Dynamic Templates Implementation #657

merged 2 commits into from
Aug 15, 2018

Conversation

mwillbanks
Copy link
Contributor

Fixes #648

Checklist

  • I have made a material change to the repo (functionality, testing, spelling, grammar)
  • I have read the [Contribution Guide] and my PR follows them.
  • I updated my branch with the master branch.
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation about the functionality in the appropriate .md file
  • I have added in line documentation to the code I modified

Short description of what this PR does:

  • Adds dynamic template support by adding a new helper object, new methods into the mail and personalization classes.

@thinkingserious thinkingserious added the status: code review request requesting a community code review or review from Twilio label Aug 2, 2018
@SendGridDX
Copy link

SendGridDX commented Aug 2, 2018

CLA assistant check
All committers have signed the CLA.

@thinkingserious thinkingserious added type: community enhancement feature request not on Twilio's roadmap difficulty: medium fix is medium in difficulty labels Aug 4, 2018
@thinkingserious
Copy link
Contributor

Thank you @mwillbanks!

@thinkingserious
Copy link
Contributor

cc @martijnmelchers

@thinkingserious thinkingserious added status: work in progress Twilio or the community is in the process of implementing and removed status: code review request requesting a community code review or review from Twilio labels Aug 7, 2018
@jideokus
Copy link

Hi. Thanks for working on this. Any news on this?

@mwillbanks
Copy link
Contributor Author

@jideokus I'm actually using my branch with these changes in production right now. It works pretty much the exact same way as substitutions except that you can use anything as a parameter that is JSON Serializable.

$mail->addDynamicTemplateData('arrayData', ['one', 'two', 'three']);
$mail->addDynamicTemplateData('number', 1);
$mail->addDynamicTemplateData('boolean', true);
$mail->addDynamicTemplateData('string', 'foo');

@jideokus
Copy link

Excellent. Thanks @mwillbanks. I'll take it for a spin. I have a bunch of emails waiting to be fired with this 😁

@thinkingserious thinkingserious added status: code review request requesting a community code review or review from Twilio status: work in progress Twilio or the community is in the process of implementing and removed status: work in progress Twilio or the community is in the process of implementing status: code review request requesting a community code review or review from Twilio labels Aug 14, 2018
@thinkingserious thinkingserious merged commit 9215649 into sendgrid:master Aug 15, 2018
@thinkingserious
Copy link
Contributor

Hello @mwillbanks,

Thanks again for the PR!

We want to show our appreciation by sending you some swag. Could you please fill out this form so we can send it to you? Thanks!

Team SendGrid DX

@thinkingserious
Copy link
Contributor

Here is the final diff.

@iamlucianojr
Copy link

iamlucianojr commented Aug 24, 2018

Hi, first of all, thanks @mwillbanks for your contribution!

I want to fetch all created templates from the API using as the example shows

$response = $sg->client->templates()->get();

But I guess this PR does not cover that point, did it?

@thinkingserious
Copy link
Contributor

@Luciano-Jr,

Please try the following:

<?php
require 'vendor/autoload.php'; // If you're using Composer (recommended)
// Comment out the above line if not using Composer
// require("<PATH TO>/sendgrid-php.php");
// If not using Composer, uncomment the above line and
// download sendgrid-php.zip from the latest release here,
// replacing <PATH TO> with the path to the sendgrid-php.php file,
// which is included in the download:
// https://github.com/sendgrid/sendgrid-php/releases

$apiKey = getenv('SENDGRID_API_KEY');
$sg = new \SendGrid($apiKey);
$query_params = json_decode('{"generations": "dynamic,legacy"}');
$response = $sg->client->templates()->get(null, $query_params);
print $response->statusCode() . "\n";
print $response->body() . "\n";
print_r($response->headers());

With Best Regards,

Elmer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: medium fix is medium in difficulty status: work in progress Twilio or the community is in the process of implementing type: community enhancement feature request not on Twilio's roadmap
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Dynamic Template Support
5 participants