PHP code example of codificar / delivery-api-php
1. Go to this page and download the library: Download codificar/delivery-api-php 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/ */
codificar / delivery-api-php example snippets
ivery = new Delivery\Client();
ivery = new Delivery\Client(
$base_url,
['headers' => ['MEU_HEADER_CUSTOMIZADO' => 'VALOR HEADER CUSTOMIZADO']]
);
$options = [
'institution_id' => <USER_ID:INT>,
'token' => <TOKEN:STRING>,
'provider_type' => <PROVIDER_TYPE:INT>,
'payment_mode' => <PAYMENT_MODE:INT>,
'return_to_start' => <BOOLEAN>,
'points' => array(
array(
'title' => <POINT_A:STRING>,
'action_type' => <ACTION_TYPE:INT>,
'action' => <ACTION:STRING>,
'collect_value' => <COLLECT_VALUE:FLOAT>,
'change' => <CHANGE:FLOAT>,
'form_of_receipt' => <FORM_OF_RECEIPT:INT('Dinheiro'=1, 'Maquina'=4, 'None'=0)>,
'collect_pictures' => <BOOLEAN>,
'collect_signature' => <BOOLEAN>,
'geometry' => array(
'location' => array(
'lat' => <LATITUDE:FLOAT>,
'lng' => <LONGITUTDE:FLOAT>
)
),
'address' => <FULL_ADDRESS:STRING>
),
array(
'title' => <POINT_B:STRING>,
'action_type' => <ACTION_TYPE:INT>,
'action' => <ACTION:STRING>,
'collect_value' => <COLLECT_VALUE:FLOAT>,
'change' => <CHANGE:FLOAT>,
'form_of_receipt' => <FORM_OF_RECEIPT:INT('Dinheiro'=1, 'Maquina'=4, 'None'=0)>,
'collect_pictures' => <BOOLEAN>,
'collect_signature' => <BOOLEAN>,
'order_id' => <ORDER_ID>,
'geometry' => array(
'location' => array(
'lat' => <LATITUDE:FLOAT>,
'lng' => <LONGITUTDE:FLOAT>
)
),
'address' => <FULL_ADDRESS:STRING>
),
),
];
$delivery = new Delivery\Client();
$request = $delivery->ride()->create($options);
$options = [
'institution_id' => <USER_ID:INT>,
'token' => <TOKEN:STRING>,
'request_id' => <REQUEST_ID:INT>,
'reason' => <REASON:STRING>
];
$delivery = new Delivery\Client();
$request = $delivery->ride()->cancel($options);
$options = [
'institution_id' => <USER_ID:INT>,
'token' => <TOKEN:STRING>,
'provider_type' => <PROVIDER_TYPE:INT>,
'payment_mode' => <PAYMENT_MODE:INT>,
'return_to_start' => <BOOLEAN>,
'points' => array(
array(
'title' => <POINT_A:STRING>,
'action_type' => <ACTION_TYPE:INT>,
'action' => <ACTION:STRING>,
'collect_value' => <COLLECT_VALUE:FLOAT>,
'change' => <CHANGE:FLOAT>,
'form_of_receipt' => <FORM_OF_RECEIPT:STRING>('Dinheiro'=1, 'Maquina'=4, 'None'=0)>,
'collect_pictures' => <BOOLEAN|DEFAULT: false>,
'collect_signature' => <BOOLEAN|DEFAULT: false>,
'geometry' => array(
'location' => array(
'lat' => <LATITUDE:FLOAT>,
'lng' => <LONGITUTDE:FLOAT>
)
),
'address' => <FULL_ADDRESS:STRING>
),
array(
'title' => <POINT_B:STRING>,
'action_type' => <ACTION_TYPE:INT>,
'action' => <ACTION:STRING>,
'collect_value': <COLLECT_VALUE:INT>,
'change': <NULL>,
'form_of_receipt': <FORM_OF_RECEIPT:STRING>('Dinheiro'=1, 'Maquina'=4, 'None'=0)>,
'collect_pictures': <BOOLEAN|DEFAULT: false>,
'collect_signature': <BOOLEAN|DEFAULT: false>,
'geometry' => array(
'location' => array(
'lat' => <LATITUDE:FLOAT>,
'lng' => <LONGITUTDE:FLOAT>
)
),
'address' => <FULL_ADDRESS:STRING>
),
)
];
$delivery = new Delivery\Client();
$estimate = $delivery->ride()->estimate($options);
$options = [
'institution_id' => <USER_ID:INT>,
'token' => <TOKEN:STRING>,
'id' => <ID_CORRIDA:INT>,
];
$delivery = new Delivery\Client();
$estimate = $delivery->ride()->details($options);
$delivery = new Delivery\Client();
$estimate = $delivery->ride()->resend(['request_id' => <ID>]);
$options = [
"person" => <TYPE_PERSON:INT('Física'=1, 'Jurídica'=2)>,
"show_key_if_exists" => <BOOLEAN|DEFAULT: false>,
"user" => [
"name" => <NAME:STRING>,
"document" => <NUMBER_DOCUMENT:STRING>,
"email" => <EMAIL:STRING>,
"phone" => <FULL_PHONE:STRING>,
"password" => <PASSWORD:STRING>,
"passwordRepeat" => <PASSWORD_REPEAT:STRING>,
"acknowledgement" => <ACKNOWLEDGEMENT:STRING>,
],
"address" => [
"street" => <STREET_STORE:STRING>,
"zip_code" => <ZIP_CODE:STRING>,
"state" => <STATE:STRING>,
"district" => <DISTRICT:STRING>,
"city" => <CITY:STRING>,
"country" => <COUNTRY:STRING>,
"complement" => <COMPLEMENT:STRING>,
"number" => <NUMBER:STRING>
]
];
php
$options = [
"person" => <TYPE_PERSON:INT('Física'=1, 'Jurídica'=2)>,
"show_key_if_exists" => <BOOLEAN|DEFAULT: false>,
"institution" => [
"name" => <NAME:STRING>,
"social_reason" => <SOCIAL_REASON:STRING>,
"document" => <NUMBER_DOCUMENT:STRING>,
"responsible" => <RESPONSIBLE:STRING>,
"responsible_position" => <RESPONSIBLE_POSITION:STRING>,
"email" => <EMAIL:STRING>,
"phone" => <FULL_PHONE:STRING>,
"acknowledgement" => <ACKNOWLEDGEMENT:STRING>,
],
"admin" => [
"username" => <USERNAME:STRING>,
"password" => <PASSWORD:STRING>,
"passwordRepeat" => <PASSWORD_REPEAT:STRING>,
],
"address" => [
"street" => <STREET_STORE:STRING>,
"zip_code" => <ZIP_CODE:STRING>,
"state" => <STATE:STRING>,
"district" => <DISTRICT:STRING>,
"city" => <CITY:STRING>,
"country" => <COUNTRY:STRING>,
"complement" => <COMPLEMENT:STRING>,
"number" => <NUMBER:STRING>
]
];
php
$delivery = new Delivery\Client();
$request = $delivery->store()->create($options);