Skip to content

SnapHR/php-autopilothq

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

php-autopilothq

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

About

PHP wrapper for interacting with AutopilotHQ API

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • PHP 100.0%