http://www.venditan.com/rapport
composer require venditan/rapport-client dev-master
In all the examples below, we will assume you have created a client object with the right credentials, like this:
// Create the client with your supplied client id and api key
$obj_client = new \Venditan\Rapport\Client('company', 'api-key');
// Add and configure the target recipient/user
$obj_client->addUser()->id('1955')->name('Marty')->email('marty@mcfly.com')->mobile('07019551985');
// Set-up the transaction
$obj_client->addTransaction()->id('2015')->courier('Western Union')->tracking('ELB1885');
// Set the type of event and publish
$obj_client->event('order_dispatched')->send();
It is possible to provide order details (lines, delivery address, notes) as well.
This would normally only be provided once, using the order_detail
event.
// Set-up the transaction
$obj_txn = $obj_client->addTransaction()->id('2015');
// Address
$obj_txn->deliverTo('123 Street, Town, County, POST CODE');
// Notes
$obj_txn->notes('Will be delivered by hand');
// Line. Only the description is required, other fields are optional
$obj_txn->addLine()->describe('Paul Smith Shirt')->quantity(1)->image('https://a.b.c/d.jpg')->attribute('Colour', 'Red')->attribute('Size', '12');
// Set the type of event and publish
$obj_client->event('order_detail')->send();
If your event templates support an estimated delivery date this can be sent along with your request.
The date will be included as provided so please send the date as you would like it to be displayed.
// Add and configure the target recipient/user
$obj_client->addUser()->id('1955')->name('Marty')->email('marty@mcfly.com')->mobile('07019551985');
// Set-up the transaction
$obj_client->addTransaction()->id('2015')->estimatedDelivery('10th May 2016');
// Set the type of event and publish
$obj_client->event('stock_arrived')->send();
// Add and configure the target recipient/user
$obj_client->addUser()->id('1955')->name('Marty')->email('marty@mcfly.com')->mobile('07019551985');
// Set-up the transaction (optional, useful context)
$obj_client->addTransaction()->id('2015');
// Set a service message
$obj_client->addMessage()->title('Order Update')->body('Hi Marty. I am safe in 1885.')->from('ELB');
// Set the type of event and publish
$obj_client->event('service_message')->send();
Threads exist for either transaction (order) contexts or just plain user (customer) contexts.
// Retrieve any thread for Order "2015"
$obj_client->getThreadForTransaction('2015');
OR
// Retrieve any thread for User "12345"
$obj_client->getThreadForUser('12345');
The response will be a stdClass object decoded from the following JSON structure
{
"id": "oid-2015",
"topic": "Order 2015",
"last_read": "2015-01-01 12:00:00",
"last_read_device": "Mobile, iPhone",
"messages": [
{
"title": "Order Accepted",
"message": "Thank you for your order.",
"created": "2015-01-01 12:00:00"
}
]
}
// Retrieve basic account usage data
$obj_client->getAccountUsage();
The response will be a stdClass object decoded from the following JSON structure.
More usage statistics may be added in future.
{
"this_month": {
"name": "December 2015",
"year": 2015,
"month": 12,
"sms": 199
},
"recent_months": [
{
"name": "October 2015",
"year": 2015,
"month": 10,
"sms": 117
},
...
]
}