picr / php-autopilothq
PHP wrapper for interacting with the AutopilotHQ API.
Installs: 131 099
Dependents: 1
Suggesters: 0
Security: 0
Stars: 11
Watchers: 7
Forks: 22
Open Issues: 10
Requires
- php: >=5.5.9
- guzzlehttp/guzzle: ~6.0
Requires (Dev)
- codeception/aspect-mock: dev-master
- codeception/codeception: ~2.1
- phake/phake: ~2.3
- phpunit/phpunit: ~5.7
Suggests
- vlucas/phpdotenv: Allows secrets to be loaded from .env files.
This package is auto-updated.
Last update: 2024-11-12 04:01:26 UTC
README
A php library for interacting with AutopilotHQ API http://docs.autopilot.apiary.io/#.
Installation
$ composer require picr/php-autopilothq
Usage
All interaction occurs in the AutopilotManager
class.
initialize manager
$manager = new AutopilotManager($apiKey);
getContact
$manager->getContact($id|$email);
saveContact
$manager->saveContact(AutopilotContact $contact);
saveContacts
$manager->saveContacts(array $contacts);
deleteContact
$manager->deleteContact($id|$email);
unsubscribeContact
$manager->unsubscribeContact($id|$email);
subscribeContact
$manager->subscribeContact($id|$email);
updateContactEmail
$manager->updateContactEmail($oldEmail, $newEmail);
getAllLists
$manager->getAllLists();
createList
$manager->createList($list);
getListByName
$manager->getListByName($list);
deleteList
//TODO: AutopilotHQ hasn't implemented this yet $manager->deleteList($list);
getAllContactsInList
$manager->getAllContactsInList($list);
addContactToList
$manager->addContactToList($list, $id|$email);
removeContactFromList
$manager->removeContactFromList($list, $id|$email);
checkContactInList
$manager->checkContactInList($list, $id|$email);
allTriggers
$manager->allTriggers();
addContactToJourney
$manager->addContactToJourney($journey, $id|$email);
allRestHooks
$manager->allRestHooks();
deleteAllRestHooks
$manager->deleteAllRestHooks();
addRestHook
$manager->addRestHook($event, $targetUrl);
deleteRestHook
$manager->deleteRestHook($hookId);
AutopilotContact
get value
// magic method $value = $contact->$name; // getter $value = $contact->getFieldValue($name);
set value
// magic method $contact->$name = $value; // setter $contact->setFieldValue($name, $value);
unset value
// magic method unset($contact->$name); // method $contact->unsetFieldValue($name);
isset value
// magic method isset($contact->$name); // method $contact->issetFieldValue($name);
getAllContactLists
//NOTE: this only reads cached "lists" array returned for a "contact info" request $contact->getAllContactLists();
hasList
//NOTE: this only reads cached "lists" array returned for a "contact info" request $contact->hasList($list);
fill
// read array of values and populate properties // NOTE: automatically formats attributes according to AutopilotHQ's "naming convention" (doesn't really exist) $contact->fill([ 'firstName' => 'John', 'lastName' => 'Smith', 'age' => 42, ]);
toRequest
// return array ready to be pushed to the API $user = $contact->toRequest();
toArray
// return array of [ property => value ] no matter if custom or defined field $user = $contact->toArray(); /* [ * 'firstName' => 'John', * 'lastName' => 'Smith', * 'age' => 42, * ] */
jsonSerialize
// json representation of "toArray()" $user = $contact->jsonSerialze(); $user = json_encode($contact);
License
MIT