NAME

Sailthru::Client - Perl module for accessing Sailthru's API

SYNOPSIS

use Sailthru::Client;

# instantiate a new Sailthru::Client with an api_key and secret
$sc = Sailthru::Client->new('api_key', 'secret');

# send an email to a single email address
%vars = (
   name => "Joe Example",
   from_email => "approved_email@your_domain.com",
   your_variable => "some_value"
);
%options = ( reply_to => "your reply_to header");
$sc->send('template_name', 'example@example.com', \%vars, \%options);

DESCRIPTION

Sailthru::Client is a Perl module for accessing the Sailthru API.

Methods return a reference to a hash containing the response values. Dump the hash or read the Sailthru API documentation for which values are returned by which API calls.

http://docs.sailthru.com/api

Some options might change. Consult the Sailthru API documentation for the latest information.

METHODS

Sailthru::Client->new( $api_key, $secret, [$timeout] )

Returns a new Sailthru::Client object.

$api_key

Sailthru API key.

$secret

Sailthru API secret.

$timeout

Optional network timeout in seconds.

$sc->send( $template_name, $email, [\%vars, \%options, $schedule_time] )

Remotely send an email template to a single email address.

API docs: http://docs.sailthru.com/api/send

$template_name

The name of the template to send.

$email

The email address to send to.

\%vars

An optional hashref of the replacement vars to use in the send. Each var may be referenced as {varname} within the template itself.

\%options

An optional hashref to include a replyto header, test keys, etc. See the API documentation for details.

$schedule_time

Do not send the email immediately, but at some point in the future. Any date recognized by PHP's strtotime function is valid, but be sure to specify timezone or use a UTC time to avoid confusion. You may also use relative time.

$sc->get_send( $send_id )

Get the status of a send.

API docs: http://docs.sailthru.com/api/send

$send_id

The unique identifier of the send returned in the response from $sc->send().

$sc->get_email( $email )

Get information about a user.

API docs: http://docs.sailthru.com/api/email

$email

The email address to look up.

$sc->set_email( $email, [\%vars, \%lists, \%templates] )

Update information about a user, including adding and removing the user from lists.

API docs: http://docs.sailthru.com/api/email

$email

The email address to modify.

\%vars

An optional hashref of replacement variables you want to set or a JSON string

\%lists

An optional hashref. Each key is the name of a list and each value is 1 to subscribe the user to that list or 0 to remove the user from the list.

\%templates

An optional hashref. Each key is the name of a template, and each value is 1 to opt the user back in to template delivery or 0 to opt the user out of template delivery.

$sc->schedule_blast( $name, $list, $schedule_time, $from_name, $from_email, $subject, $content_html, $content_text, [\%options] )

Schedule a mass mail blast.

API docs: http://docs.sailthru.com/api/blast

$name

The name to give to this new blast.

$list

The mailing list name to send to.

$schedule_time

When the blast should send. Dates in the past will be scheduled for immediate delivery. Any English textual datetime format known to PHP's strtotime function is acceptable, such as 2012-03-18 23:57:22 UTC, now (immediate delivery), +3 hours (3 hours from now), or March 18, 9:30 EST. Be sure to specify a timezone if you use an exact time.

$from_name

The name to use in "From" in the email.

$from_email

The email address to use in "From". Choose from any of your verified emails.

$subject

The subject line of the email.

$content_html

The HTML format version of the email.

$content_text

The text format version of the email.

\%options

An optional hashref containing the optional parameters for a blast. See the API documentation for details.

$sc->schedule_blast_from_template( $template_name, $list, $schedule_time, [\%options] )

Schedule a mass mail blast from a template.

API docs: http://docs.sailthru.com/api/blast

$template_name

The template to copy from.

$list

The mailing list name to send to.

$schedule_time

When the blast should send. Dates in the past will be scheduled for immediate delivery. Any English textual datetime format known to PHP's strtotime function is acceptable, such as 2012-03-18 23:57:22 UTC, now (immediate delivery), +3 hours (3 hours from now), or March 18, 9:30 EST. Be sure to specify a timezone if you use an exact time.

\%options

An optional hashref containing the optional parameters for a blast. See the API documentation for details.

$sc->get_blast( $blast_id )

Get data on a single blast.

API docs: http://docs.sailthru.com/api/blast

$blast_id

The blast id returned in the response from $sc->scheduleBlast().

$sc->get_template( $template_name )

Get information about a template

API docs: http://docs.sailthru.com/api/template

$template_name

The name of the template.

$sc->api_get( $action, \%data )

This is a generic HTTP GET call to the API.

$action

The name of the API action to call.

\%data

A hashref of arguments to pass to the API.

For example, you could get information about an email with

$sc->api_get('GET', 'email', {email=>'somebody@example.com'});

$sc->api_post( $action, \%data )

This is a generic HTTP POST call to the API.

$action

The name of the API action to call.

\%data

A hashref of arguments to pass to the API.

$sc->api_delete( $action, \%data )

This is a generic HTTP DELETE call to the API.

$action

The name of the API action to call.

\%data

A hashref of arguments to pass to the API.

$sc->get_last_rate_limit_info( $action, $method )

Get the last rate limit information .

$action

The name of the API action to call.

$method

Http request type. One of GET, POST or DELETE.

return

Hash reference with three fields (limit, remaining and reset) or undef if not exists.

SEE ALSO

See the Sailthru API documentation for more details on their API.

http://docs.sailthru.com/api

AUTHOR

Finn Smith

Steve Sanbeg

Steve Miketa

Sam Gerstenzang

LICENSE AND COPYRIGHT

Copyright (C) 2012 by Finn Smith <finn@timeghost.net>

Copyright (C) 2012 by Steve Sanbeg <stevesanbeg@buzzfeed.com>

Copyright (C) 2011 by Steve Miketa <steve@sailthru.com>

Adapted from the original Sailthru::Client & Triggermail modules created by Sam Gerstenzang and Steve Miketa.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.