PHP code example of gbro115 / twinjet-directconnect-php

1. Go to this page and download the library: Download gbro115/twinjet-directconnect-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/ */

    

gbro115 / twinjet-directconnect-php example snippets



namespace TwinJet;

$apiToken = "YOUR_API_TOKEN";
$apiVersion = 'v1';

$directConnect = new \TwinJet\DirectConnect($apiToken, $apiVersion);

$jobStatusPayload = array(
    'api_token'=>$apiToken,
    'request_id'=>'1234'
);

$newJobPayload = array(
    'live'=>true,
    'api_token'=>$apiToken,
    'order_contact_name'=>'Joe Bloggs',
    'order_contact_phone'=>'+13333333333',
    'pick_address' => array(
        'address_name'=>'Address line 1',
        'street_address'=>'13 Wallaby Way',
        'city'=>'Montreal',
        'state'=>'QC',
        'zip_code'=>'XXXXXX',
        'contact'=>'Contact Name',
        'floor'=>'Ground floor',
        'phone_number'=>'+13333333333',
    ),
    'deliver_address' => array(
        'address_name'=>'Sherlock Holmes',
        'street_address'=>'8 Baker Street',
        'floor'=>'First floor',
        'city'=>'Montreal',
        'state'=>'QC',
        'zip_code'=>'XXXXXX',
        'contact'=>'Sherlock Holmes',
        'phone_number'=>'+13333333333',
    ),
    'ready_time' => '2020-01-17T20:33:39-05:00',
    'deliver_from_time' => '2020-01-17T20:33:39-05:00',
    'deliver_to_time' => '2020-01-17T21:03:39-05:00',
    'order_total' => 62.29,
    'payment_method' => '2',
    'special_instructions' => "Special instructions",
    'webhook_url' => 'https://callback.url',
    'external_id' => 123456
);

//$result = $directConnect->jobs()->newJob($newJobPayload);
//print_r($result);

//$result = $directConnect->jobs()->getJobStatus($jobStatusPayload);
//print_r($result);