Skip to content
This repository has been archived by the owner on Aug 18, 2023. It is now read-only.

New class to support templates API calls #74

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

digitalpianism
Copy link

I had the need to use the PHP SDK to do API to the Templates endpoint: https://apidocs.klaviyo.com/reference/templates

As this wasn't supported, I wrote the library class.

@digitalpianism
Copy link
Author

Code examples:

#return a list of all email templates in your account
$client->templates->getAllTemplates();

#create a new email template
$client->templates->createNewTemplate('Template Name', 'Template HTML');

#update an email template
$client->templates->updateTemplate('Template ID', 'New Template Name', 'New Template HTML');

#delete an email template
$client->templates->deleteTemplate('Template ID');

#clone a template
$client->templates->cloneTemplate('Template ID', 'Cloned Template Name');

#render a template
#context is a string e.g. { "name" : "George Washington", "state" : "VA" }
$client->templates->renderTemplate('Template ID', 'Template Context');

#render and send a template
#recipients details can be string, or JSON encoded array of objects with "email" and "name" keys.
#e.g. [email protected] OR [{"name":"Abraham Lincoln","email":"[email protected]"}]
$client->templates->sendTemplate('Template ID', 'From Email', 'From Name', 'Email Subject', 'Recipient Details', 'Template Context');

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant