PHP Class SparkPost\Transmission

Inheritance: extends ResourceBase
Exibir arquivo Open project: sparkpost/php-sparkpost Class Usage Examples

Public Methods

Method Description
__construct ( SparkPost $sparkpost )
formatPayload ( array $payload ) : array Runs the given payload through the formatting functions.
post ( $payload = [], $headers = [] ) : SparkPostPromise Send post request to transmission endpoint after formatting cc, bcc, and expanding the shorthand emails.

Private Methods

Method Description
addListToRecipients ( array $payload, array $listName ) : array Loops through the given listName in the payload and adds all the recipients to the recipients list after removing their names.
formatBlindCarbonCopy ( array $payload ) : array Formats bcc list into recipients list.
formatCarbonCopy ( array $payload ) : array Formats cc list into recipients list and adds the CC header to the content.
formatShorthandRecipients ( array $payload ) : array Formats all recipients into the long form of [ "name" => "John", "email" => "[email protected]" ].
isEmail ( string $email ) Checks if a string is an email.
toAddressObject ( $address ) : array Takes the shorthand form of an email address and converts it to the long form.
toAddressString ( $address ) Takes the longhand form of an email address and converts it to the shorthand form.

Method Details

__construct() public method

public __construct ( SparkPost $sparkpost )
$sparkpost SparkPost

formatPayload() public method

Runs the given payload through the formatting functions.
public formatPayload ( array $payload ) : array
$payload array - the request body
return array - the modified request body

post() public method

Send post request to transmission endpoint after formatting cc, bcc, and expanding the shorthand emails.
public post ( $payload = [], $headers = [] ) : SparkPostPromise
return SparkPostPromise or SparkPostResponse depending on sync or async request