This method retrieves schedule info. It lists all flights in requested route and operation days in a week.
See the API documentation page on Turkish Airlines Developer Portal
$client->getTimetable($getTimetableParametersObject);<?php
use TK\API\ValueObject\Factory\GetTimetableParametersFactory;
$jsonQuery =<<<JSON
{
"OTA_AirScheduleRQ":{
"OriginDestinationInformation":{
"DepartureDateTime":{
"WindowAfter":"P3D",
"WindowBefore":"P3D",
"Date":"2017-10-14"
},
"OriginLocation":{
"LocationCode":"IST",
"MultiAirportCityInd":true
},
"DestinationLocation":{
"LocationCode":"ESB",
"MultiAirportCityInd":false
}
},
"AirlineCode":"TK",
"FlightTypePref":{
"DirectAndNonStopOnlyInd":true
}
},
"returnDate":"2017-10-20",
"scheduleType":"W",
"tripType":"R"
}
JSON;
$getTimetableParametersObject = GetTimetableParametersFactory::createFromJson($jsonQuery);
$response = $client->getTimetable($getTimetableParametersObject);You can build an array that is basically json_encode version of the object mentioned in the previous example.
<?php
use TK\API\ValueObject\Factory\GetTimetableParametersFactory;
$getTimetableParametersObject = GetTimetableParametersFactory::createFromArray($parametersArray);
$response = $client->getTimetable($getTimetableParametersObject);<?php
use DateTimeImmutable;
use TK\API\ValueObject\Location;
use TK\API\ValueObject\DepartureDateTime;
use TK\API\ValueObject\OriginDestinationInformation;
use TK\API\ValueObject\AirScheduleRQ;
use TK\API\ValueObject\GetTimetableParameters;
$originLocation = new Location('IST', Location::MULTIPLE_AIRPORT_TRUE);
$destinationLocation = new Location('JFK', Location::MULTIPLE_AIRPORT_TRUE);
$departureTime = gmdate('Y-m-d H:i:s', strtotime('+4 days'));
$departureDateTime = new DepartureDateTime(
new DateTimeImmutable($departureTime),
'P3D',
'P3D'
);
$originDestinationInformation = new OriginDestinationInformation(
$departureDateTime,
$originLocation,
$destinationLocation
);
$airScheduleRQ = (new AirScheduleRQ($originDestinationInformation))
->withAirlineCode(AirScheduleRQ::AIRLINE_TURKISH_AIRLINES)
->withDirectAndNonStopOnlyInd();
$getTimetableParametersObject = new GetTimetableParameters(
$airScheduleRQ,
GetTimetableParameters::SCHEDULE_TYPE_WEEKLY,
GetTimetableParameters::TRIP_TYPE_ONE_WAY
);
$response = $client->getTimetable($getTimetableParametersObject);