contactlab / contacthub-sdk-php
Php SDK for ContactHub
Installs: 1 023
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 11
Forks: 1
Open Issues: 3
Requires
- php: >=5.5
- guzzlehttp/guzzle: ^6.2
- ramsey/uuid: ^3.6
Requires (Dev)
This package is auto-updated.
Last update: 2020-08-25 12:12:21 UTC
README
PHP SDK for the ContactHub API.
Installation
composer require contactlab/contacthub-sdk-php
Documentation
Documentation can be found in the the docs directory.
Quick start
Create customer
use ContactHub\ContactHub; $contactHub = new ContactHub('TOKEN', 'WORKSPACE_ID', 'NODE_ID'); $customer = [ 'externalId' => 'externalId', 'base' => [ 'firstName' => 'First Name', 'lastName' => 'Lastddd Name', 'contacts' => [ 'email' => 'email@example.com' ] ], 'extra' => 'extra string', 'tags' => [ 'auto' => ['autotag'], 'manual' => ['manualtag'] ], 'enabled' => true ]; $contactHub->addCustomer($customer);
Retrieve Customers
use ContactHub\ContactHub; use ContactHub\GetCustomersOptions; $contactHub = new ContactHub('TOKEN', 'WORKSPACE_ID', 'NODE_ID'); $options = GetCustomersOptions::create() ->withExternalId('58ede74e05d14') ->withFields(['base.firstName']); $customers = $contactHub->getCustomers($options);
Create Event
use ContactHub\ContactHub; $contactHub = new ContactHub('TOKEN', 'WORKSPACE_ID', 'NODE_ID'); $event = [ 'type' => EventType::VIEWED_PAGE, 'context' => EventContext::MOBILE, 'properties' => [ 'url' => 'http://ecommerce.event.url' ], 'date' => date('c') ]; $contactHub->addEventByCustomerId('a_customer_id', $event);
Query Builder
use ContactHub\ContactHub; use ContactHub\GetCustomersOptions; use ContactHub\QueryBuilder; use ContactHub\QueryBuilder\CombinedQuery; use ContactHub\QueryBuilder\Condition\AtomicCondition; use ContactHub\QueryBuilder\Condition\CompositeCondition; use ContactHub\QueryBuilder\SimpleQuery; $simpleWithAtomicCondition = SimpleQuery::with(AtomicCondition::where('firstName' , 'IS_NOT_NULL')); $simpleWithCompositeCondition = SimpleQuery::with( CompositeCondition::where( 'OR', AtomicCondition::where('base.lastName', 'IS', 'Giovanni'), AtomicCondition::where('base.lastName', 'IS', 'Giacomo') ) ); $combined = CombinedQuery::with('OR', $simpleWithCompositeCondition, $simpleWithAtomicCondition); $query = QueryBuilder::createQuery($combined, 'named_query'); $contactHub = new ContactHub('TOKEN', 'WORKSPACE_ID', 'NODE_ID'); $options = GetCustomersOptions::create()->withQuery($query->build()); $customers = $contactHub->getCustomers($options);