LeKoala\SparkPost\Api\SparkPostApiClient
A really simple SparkPost api client
- Author: LeKoala <thomas@lekoala.be>
Synopsis
class SparkPostApiClient
{
- // constants
- const CLIENT_VERSION = '0.2';
- const API_ENDPOINT = 'https://api.sparkpost.com/api/v1';
- const API_ENDPOINT_EU = 'https://api.eu.sparkpost.com/api/v1';
- const METHOD_GET = "GET";
- const METHOD_POST = "POST";
- const METHOD_PUT = "PUT";
- const METHOD_DELETE = "DELETE";
- const DATETIME_FORMAT = 'Y-m-d\TH:i';
- const TYPE_MESSAGE = 'message_event';
- const TYPE_ENGAGEMENT = 'track_event';
- const TYPE_GENERATION = 'gen_event';
- const TYPE_UNSUBSCRIBE = 'unsubscribe_event';
- const TYPE_RELAY = 'relay_event';
- const EVENT_DELIVERY = 'delivery';
- const EVENT_BOUNCE = 'bounce';
- const EVENT_INJECTION = 'injection';
- const EVENT_SMS_STATUS = 'sms_status';
- const EVENT_SPAM_COMPLAINT = 'spam_complaint';
- const EVENT_OUT_OF_BAND = 'out_of_band';
- const EVENT_POLICY_REJECTION = 'policy_rejection';
- const EVENT_DELAY = 'delay';
- const EVENT_OPEN = 'open';
- const EVENT_CLICK = 'click';
- const EVENT_GEN_FAILURE = 'generation_failure';
- const EVENT_GEN_REJECTION = 'generation_rejection';
- const EVENT_LIST_UNSUB = 'list_unsubscribe';
- const EVENT_LINK_UNSUB = 'link_unsubscribe';
- const EVENT_RELAY_INJECTION = 'relay_injection';
- const EVENT_RELAY_REJECTION = 'relay_rejection';
- const EVENT_RELAY_DELIVERY = 'relay_delivery';
- const EVENT_RELAY_TEMPFAIL = 'relay_tempfail';
- const EVENT_RELAY_PERMFAIL = 'relay_permfail';
- // members
- protected $key;
- protected boolean $euEndpoint = false;
- protected string $verboseLog = '';
- protected callable $logger;
- protected array $results = ;
- protected $subaccount;
- protected array $curlOpts = ;
- // methods
- public void __construct()
- public array getDefaultCurlOptions()
- public mixed getCurlOption()
- public mixed setCurlOption()
- public string getKey()
- public void setKey()
- public string getEuEndpoint()
- public void setEuEndpoint()
- public string getVerboseLog()
- public type getLogger()
- public void setLogger()
- public int getSubaccount()
- public void setSubaccount()
- protected mixed setMappedValue()
- protected array mapData()
- public array createTransmission()
- public array getTransmission()
- public array deleteTransmission()
- public array listTransmissions()
- public array searchMessageEvents()
- public array searchEvents()
- public array createWebhook()
- public type createSimpleWebhook()
- public array listAllWebhooks()
- public array getWebhook()
- public array updateWebhook()
- public array deleteWebhook()
- public array validateWebhook()
- public array webhookBatchStatus()
- public array getSampleEvents()
- public array createSendingDomain()
- public array createSimpleSendingDomain()
- public array listAllSendingDomains()
- public array getSendingDomain()
- public array verifySendingDomain()
- public array updateSendingDomain()
- public array deleteSendingDomain()
- public array createInboundDomain()
- public array listInboundDomains()
- public array getInboundDomain()
- public array deleteInboundDomain()
- public array createRelayWebhook()
- public array listRelayWebhooks()
- public array getRelayWebhook()
- public array updateRelayWebhook()
- public array deleteRelayWebhook()
- public string createValidDatetime()
- public array buildAddress()
- public array buildAddressFromString()
- public array buildRecipient()
- protected array makeRequest()
- public array getResults()
- public array getLastResult()
Constants
Name | Value |
---|---|
CLIENT_VERSION | '0.2' |
API_ENDPOINT | 'https://api.sparkpost.com/api/v1' |
API_ENDPOINT_EU | 'https://api.eu.sparkpost.com/api/v1' |
METHOD_GET | "GET" |
METHOD_POST | "POST" |
METHOD_PUT | "PUT" |
METHOD_DELETE | "DELETE" |
DATETIME_FORMAT | 'Y-m-d\TH:i' |
TYPE_MESSAGE | 'message_event' |
TYPE_ENGAGEMENT | 'track_event' |
TYPE_GENERATION | 'gen_event' |
TYPE_UNSUBSCRIBE | 'unsubscribe_event' |
TYPE_RELAY | 'relay_event' |
EVENT_DELIVERY | 'delivery' |
EVENT_BOUNCE | 'bounce' |
EVENT_INJECTION | 'injection' |
EVENT_SMS_STATUS | 'sms_status' |
EVENT_SPAM_COMPLAINT | 'spam_complaint' |
EVENT_OUT_OF_BAND | 'out_of_band' |
EVENT_POLICY_REJECTION | 'policy_rejection' |
EVENT_DELAY | 'delay' |
EVENT_OPEN | 'open' |
EVENT_CLICK | 'click' |
EVENT_GEN_FAILURE | 'generation_failure' |
EVENT_GEN_REJECTION | 'generation_rejection' |
EVENT_LIST_UNSUB | 'list_unsubscribe' |
EVENT_LINK_UNSUB | 'link_unsubscribe' |
EVENT_RELAY_INJECTION | 'relay_injection' |
EVENT_RELAY_REJECTION | 'relay_rejection' |
EVENT_RELAY_DELIVERY | 'relay_delivery' |
EVENT_RELAY_TEMPFAIL | 'relay_tempfail' |
EVENT_RELAY_PERMFAIL | 'relay_permfail' |
Members
protected
- $curlOpts
—
array
Client options - $euEndpoint
—
boolean
Is eu endpoint ? - $key
—
string
Your api key - $logger
—
LeKoala\SparkPost\Api\callable
A callback to log results - $results
—
array
Results from the api - $subaccount
—
int
The ID of the subaccount to use - $verboseLog
—
string
Curl verbose log
Methods
protected
- makeRequest() — Make a request to the api using curl
- mapData() — Map data using a given mapping array
- setMappedValue() — Helper that handles dot notation
public
- __construct() — Create a new instance of the SparkPostApiClient
- buildAddress() — Build an address object
- buildAddressFromString() — Build an address object from a RFC 822 email string
- buildRecipient() — Build a recipient
- createInboundDomain() — Create an inbound domain
- createRelayWebhook() — Create a relay webhook
- createSendingDomain() — Create a sending domain
- createSimpleSendingDomain() — A simpler call to the api
- createSimpleWebhook() — A simpler call to the api
- createTransmission() — Create a transmission
- createValidDatetime() — Create a valid date for the API
- createWebhook() — Create a webhook by providing a webhooks object as the POST request body.
- deleteInboundDomain() — Delete an inbound domain
- deleteRelayWebhook() — Delete a relay webhook
- deleteSendingDomain() — Delete a sending domain
- deleteTransmission() — Delete a transmission
- deleteWebhook() — Delete a webhook
- getCurlOption() — Get an option
- getDefaultCurlOptions() — Get default options
- getEuEndpoint() — Get the use of eu endpoint
- getInboundDomain() — Get details of an inbound domain
- getKey() — Get the current api key
- getLastResult() — Get last result
- getLogger() — Get the logger
- getRelayWebhook() — Get the details of a relay webhook
- getResults() — Get all results from the api
- getSampleEvents() — List an example of the event data that will be posted by a Webhook for the specified events.
- getSendingDomain() — Get a sending domain
- getSubaccount() — Get subaccount id
- getTransmission() — Get the detail of a transmission
- getVerboseLog() — Get verbose log
- getWebhook() — Get a webhook
- listAllSendingDomains() — List all sending domains
- listAllWebhooks() — List all webhooks
- listInboundDomains() — List all inbound domains
- listRelayWebhooks() — List all relay webhooks
- listTransmissions() — List tranmssions
- searchEvents() — Search for Message Events
- searchMessageEvents() — Search message events
- setCurlOption() — Set an option
- setEuEndpoint() — Set the use of eu endpoint
- setKey() — Set the current api key
- setLogger() — Set a logging method
- setSubaccount() — Set subaccount id
- updateRelayWebhook() — Update a relay webhook
- updateSendingDomain() — Update a sending domain
- updateWebhook() — Update a webhook
- validateWebhook() — Validate a webhook
- verifySendingDomain() — Verify a sending domain - This will ask SparkPost to check if SPF and DKIM are valid
- webhookBatchStatus() — Retrieve status information regarding batches that have been generated for the given webhook by specifying its id in the URI path. Status information includes the successes of batches that previously failed to reach the webhook's target URL and batches that are currently in a failed state.