Transit Times

Get Transit Times
HTTP Method: POST
URL: /TransitTimes
Request Parameters
Name Type Cardinality Required Description
PickupDate string One Optional Transit pickup date. If not passed, we will default to today's date. If we do not service the Origin on that date, it will be moved to the next day we do. Dates on weekends or company holidays will be moved to the next business day we service the origin.
Origin object One Required Transit origin
Properties
City string One Required Origin city
StateOrProvince string One Required Origin state or province
ZipOrPostalCode string One Required Origin zip or postal code
CountryCode string One Required Origin ISO3 Country Code
Destinations array One Required List of Destinations
Properties
Destination object One or More Required Destination object
Properties
City string One Required Destination city
StateOrProvince string One Required Destination state or province. Not required for countries without states.
ZipOrPostalCode string One Required Destination zip or postal code. Not required for countries without zip codes.
CountryCode string One Required Destination ISO3 Country Code
ApiKey string One Required The unique identifier for the user
Properties
Destination object One or More Required Destination object
Properties
City string One Destination city
StateOrProvince string One Destination state or province
ZipOrPostalCode string One Destination zip or postal code
CountryCode string One Destination country code
Response Parameters
Name Type Cardinality Description
PickupDate date One Transit time pickup date. This could be adjusted from your input if the input pickup date falls on the weekend or a company holiday as well as if your origin is only serviced on certain days of the week.
Origin object One Transit time origin
Properties
OriginPoint object One Origin service point
Properties
City string One Origin city
StateOrProvince string One Origin state or province
ZipOrPostalCode string One Origin zip or postal code
CountryCode string One Origin country code
ServiceCenter object One Origin service center information
Properties
Code string One Origin service center info code
Location string One Origin service center info location
Phone string One Origin service center info phone number
Destinations array One List of Destination objects
Properties
Destination object One or More Destination object
Properties
ServiceLevels array One
Properties
ServiceLevel object
Properties
Name string
Code string
ServiceDays integer One Number of service days to destination from origin
DeliveryDate date One Estimated Delivery Date
DestinationNotes string One Several different things can be in here:
1) A note about the pickup date being changed because of a holiday
2) A note about the pickup date being changed because the origin is only serviced on certain days
3) A note about the estimated delivery date being longer than the service days because the destination is only serviced on certain days
ServicePoint object One
Properties
City string
StateOrProvince string
ZipOrPostalCode string
CountryCode string
ServiceCenter object One
Properties
Code string
Location string
Phone string
Code integer One HTTP Status code
Errors array One Returned errors
Properties
Error object Zero or More
Properties
Property string One
ErrorMessage string One
ExceptionMessage string One
Messages array One Returned informational messages
Properties
Message string Zero or More
Example Request

require_once 'HTTP/Request2.php';
$request = new HTTP_Request2();
$request->setUrl('{baseurl}/TransitTimes');
$request->setMethod(HTTP_Request2::METHOD_POST);
$request->setConfig(array(
'follow_redirects' => TRUE
));
$request->setHeader(array(
'apiKey' => 'Your API Key',
'Content-Type' => 'application/json',
));
$request->setBody('{
\n "PickupDate": "08/17/2020",
\n "Origin": {
\n "City": "Ocala",
\n "StateOrProvince": "FL",
\n "ZipOrPostalCode": "34471",
\n "CountryCode": "USA"
\n },
\n "Destinations": [
\n {
\n "City": "Wilmington",
\n "StateOrProvince": "OH",
\n "ZipOrPostalCode": "45177",
\n "CountryCode": "USA"
\n }
\n ]
\n}');
try {
$response = $request->send();
if ($response->getStatus() == 200) {
echo $response->getBody();
}
else {
echo 'Unexpected HTTP status: ' . $response->getStatus() . ' ' .
$response->getReasonPhrase();
}
}
catch(HTTP_Request2_Exception $e) {
echo 'Error: ' . $e->getMessage();
}
using CallAPI.DataContracts;
using CallAPI.DataContracts.TransitTimes.Request;
using CallAPI.DataContracts.TransitTimes.Response;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;

namespace CallAPI
{
class TransitTimesSample
{
string apiKey = "Your API Key";
public TransitTimesResponse CalculateTransitTimes()
{
var request = new TransitTimesRequest()
{
PickupDate = DateTime.Now.ToShortDateString(),
Origin = GetOrigin(),
Destinations = GetDestinations()
};

var url = "{baseurl}/TransitTimes";

var response = new TransitTimesResponse();
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Add("apiKey", apiKey);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var apiResponse = client.PostAsJsonAsync(url, request).Result;

response = apiResponse.Content.ReadAsAsync().Result;
}

return response;
}

private ServicePoint GetOrigin()
{
var origin = new ServicePoint()
{
City = "Wilmington",
StateOrProvince = "OH",
ZipOrPostalCode = "45177",
CountryCode = "USA"
};

return origin;
}

private List GetDestinations()
{
var destination = new ServicePoint()
{
City = "Ocala",
StateOrProvince = "FL",
ZipOrPostalCode = "34471",
CountryCode = "USA"
};

var destinations = new List() { destination };

return destinations;
}
}
}
package Samples;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;

import com.fasterxml.jackson.databind.ObjectMapper;

import DataContracts.ServicePoint;
import DataContracts.TransitTimes.Request.TransitTimesRequest;
import DataContracts.TransitTimesResponse.TransitTimesResponse;

public class TransitTimesSample {
String apiKey = "Your API Key";
ObjectMapper mapper = new ObjectMapper();

public TransitTimesResponse CalculateTransitTimes() throws Exception{
TransitTimesResponse response = new TransitTimesResponse();

TransitTimesRequest request = new TransitTimesRequest();
request.PickupDate = LocalDate.now().format(DateTimeFormatter.ofPattern("MM/dd/yyyy"));
request.Origin = GetOrigin();
request.Destinations = GetDestinations();
String requestJSON = mapper.writeValueAsString(request);

String url = "{baseurl}/TransitTimes";
HttpClient httpClient = HttpClientBuilder.create().build();
HttpPost httpRequest = new HttpPost(url);
StringEntity params =new StringEntity(requestJSON);
httpRequest.addHeader("content-type", "application/json");
httpRequest.addHeader("apiKey", apiKey);
httpRequest.setEntity(params);
HttpResponse httpResponse = httpClient.execute(httpRequest);

BufferedReader rd = new BufferedReader(new InputStreamReader(httpResponse.getEntity().getContent()));

StringBuffer result = new StringBuffer();
String line = "";
while ((line = rd.readLine()) != null) {
result.append(line);
}

response = mapper.readValue(result.toString(), TransitTimesResponse.class);

return response;
}

private ServicePoint GetOrigin()
{
ServicePoint origin = new ServicePoint();
origin.City = "Wilmington";
origin.StateOrProvince = "OH";
origin.ZipOrPostalCode = "45177";
origin.CountryCode = "USA";

return origin;
}

private List GetDestinations()
{
ServicePoint destination = new ServicePoint();
destination.City = "Ocala";
destination.StateOrProvince = "FL";
destination.ZipOrPostalCode = "34471";
destination.CountryCode = "USA";

List destinations = new ArrayList();
destinations.add(destination);

return destinations;
}
}