lancasters / shap-library
Library for easy integration of Lancasters SHAP
Installs: 1 190
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 9
Forks: 0
Open Issues: 0
Requires
- guzzlehttp/guzzle: ^6.3
This package is not auto-updated.
Last update: 2023-02-09 18:40:26 UTC
README
To create a new ShapLibrary and access it's methods:
$apiKey = 'Your api key for the required list"
$shapLibrary = new ShapLibrary($apiKey);
$shapLibrary->detail();
You can call the implemented methods:
Detail
Return the list of dataTypes for the given list. For example:
[ "listName" => 'Blacklisted', "listId" => 1, "ListDetails" => [ "email" ] ]
//@return array $listElements $shapLibrary->detail();
pushMessages
Push messages to SHAP. It will enqueue messages into the shap validator interface. After validation SHAP will grant credits. This method returns the amount of messages pushed to SHAP
the content of the messages array have to match to the list Datatypes. Use the details call to get information from the list.
example:
$messages = [["email" => "email@email.com"], ["email" => "email2@email.com], [...]]
//@return int $totalPushed $shapLibrary->push(array $messages);
pullMessages
Return the new messages from the list. It works based on a timestamp. It has a limit configured by server on the max amount of messages by pull. between 200 - 1000.
You will have to give a timestamp that corresponds the "from" in the incremental query. To synchronize a entire database:
GET /pull/1 ... (grab the latest timestamp) //Ordered always by timestamp so it matches the last element GET /pull/12843434 ... GET /pull/xxx until you have 0 messages as an answer
then you know that you are updated. Next time you do a get use the latest timestamp so you only collect the new messages and don't consume more credits than required.
//@return array $messages $shapLibrary->pull(int $timestamp);