PHP code example of ajowi / sendy-fulfilment
1. Go to this page and download the library: Download ajowi/sendy-fulfilment library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ajowi / sendy-fulfilment example snippets
// config/services.php
...
'sendy' => [
'token' => env('SENDY_TOKEN'),
'endpoint_url' => env('SENDY_ENDPOINT_URL'),
],
...
php
use Ajowi\SendyFulfillment\PriceRequest;
$data = new array(
'ecommerce_order' => 'ODR-0000',
'recepient' => [
'name' => 'David Ajowi',
'email' => '[email protected] ',
'phone' => '+254 712345678'
],
'locations' => [
[
'type' => 'PICKUP',
'waypoint_id' => 'd67dbff1-4d57-4266-9c39-481c2d9c76eq',
'lat' => -1.597429319708498,
'long' => -1.597429319708498,
'name' => 'Destination'
],
[
'type' => 'DELIVERY',
'waypoint_id' => 'd67dbff1-4d57-4266-9c39-481c2d9c76eq',
'lat' => -1.597429319708498,
'long' => -1.597429319708498,
'name' => 'Destination'
]
]
);
/**
* -----------
* IMPORTANT
* -----------
* If you are not using Laravel, pass the API token/key and Endpoint URL to the constructor like so
*
* $priceRequest = new PriceRequest('SENDY_API_TOKEN', 'ENDPOINT_URL');
*
*/
$priceRequest = new PriceRequest();
$priceRequest->initialize($data);
// Do a price request
try {
$response = $priceRequest->send();
$data = $response->getData();
echo "Response data : " . print_r($data, true) . "\n";
if ($response->isSuccessful()) {
echo "Request was successful!\n";
}
} catch (\Exception $e) {
echo "Message : " . $e->getMessage() . "\n";
}