Skip to content

Commit 252f550

Browse files
committed
more examples with json query added [skip ci]
1 parent 3ab4697 commit 252f550

8 files changed

Lines changed: 331 additions & 50 deletions

docs/endpoints/CalculateAwardMilesWithTax.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,46 @@ $this->client->calculateAwardMilesWithTax($calculateAwardMilesWithTaxParameters)
1515

1616
```
1717

18+
### Example with Factory Using JSON Query
19+
20+
```php
21+
<?php
22+
23+
use TK\SDK\ValueObject\Factory\CalculateAwardMilesWithTaxParametersFactory;
24+
25+
$json =<<<JSON
26+
{
27+
"awardType": "E",
28+
"wantMoreMiles": "T",
29+
"isOneWay": "T",
30+
"departureOrigin": "IST",
31+
"departureDestination": "FRA",
32+
"departureDateDay": 12,
33+
"departureDateMonth": 11,
34+
"departureDateYear": 2017
35+
}
36+
JSON;
37+
$parameterObject = CalculateAwardMilesWithTaxParametersFactory::createFromJson($json);
38+
39+
$response = $client->calculateAwardMilesWithTax($parameterObject);
40+
41+
```
42+
43+
### Example with Factory Using An Array
44+
45+
You can build an array that is basically json_encode version of the object mentioned in the previous example.
46+
47+
```php
48+
<?php
49+
50+
use TK\SDK\ValueObject\Factory\CalculateAwardMilesWithTaxParametersFactory;
51+
52+
$parameterObject = CalculateAwardMilesWithTaxParametersFactory::createFromArray($parametersArray);
53+
54+
$response = $client->calculateAwardMilesWithTax($parameterObject);
55+
56+
```
57+
1858
### Example with ValueObjects
1959

2060
```php

docs/endpoints/CalculateFlightMiles.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,45 @@ $this->client->calculateFlightMiles($calculateFlightMilesParameters);
1515

1616
```
1717

18+
### Example with Factory Using JSON Query
19+
20+
```php
21+
<?php
22+
23+
use TK\SDK\ValueObject\Factory\CalculateFlightMilesParametersFactory;
24+
25+
$json =<<<JSON
26+
{
27+
"cabin_code": "Y",
28+
"card_type": "EP",
29+
"destination": "IST",
30+
"flightDate": "21.04.2017",
31+
"operatingFlightNumber": "TK1000",
32+
"origin": "FRA"
33+
}
34+
35+
JSON;
36+
$parameterObject = CalculateFlightMilesParametersFactory::createFromJson($json);
37+
38+
$response = $client->calculateFlightMiles($parameterObject);
39+
40+
```
41+
42+
### Example with Factory Using An Array
43+
44+
You can build an array that is basically json_encode version of the object mentioned in the previous example.
45+
46+
```php
47+
<?php
48+
49+
use TK\SDK\ValueObject\Factory\CalculateFlightMilesParametersFactory;
50+
51+
$parameterObject = CalculateFlightMilesParametersFactory::createFromArray($parametersArray);
52+
53+
$response = $client->calculateFlightMiles($parameterObject);
54+
55+
```
56+
1857
### Example with ValueObjects
1958

2059
```php

docs/endpoints/GetAvailability.md

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,102 @@ $client->getAvailability($getAvailabilityParametersObject);
1515

1616
```
1717

18+
### Example with Factory Using JSON Query
19+
20+
```php
21+
<?php
22+
23+
use TK\SDK\ValueObject\Factory\GetAvailabilityParametersFactory;
24+
25+
$json =<<<JSON
26+
{
27+
"ReducedDataIndicator":false,
28+
"RoutingType":"r",
29+
"PassengerTypeQuantity":[
30+
{
31+
"Code":"adult",
32+
"Quantity":1
33+
},
34+
{
35+
"Code":"child",
36+
"Quantity":1
37+
},
38+
{
39+
"Code":"infant",
40+
"Quantity":0
41+
}
42+
],
43+
"OriginDestinationInformation":[
44+
{
45+
"DepartureDateTime":{
46+
"WindowAfter":"P0D",
47+
"WindowBefore":"P0D",
48+
"Date":"14OCT"
49+
},
50+
"OriginLocation":{
51+
"LocationCode":"IST",
52+
"MultiAirportCityInd":true
53+
},
54+
"DestinationLocation":{
55+
"LocationCode":"ESB",
56+
"MultiAirportCityInd":true
57+
},
58+
"CabinPreferences":[
59+
{
60+
"Cabin":"ECONOMY"
61+
},
62+
{
63+
"Cabin":"BUSINESS"
64+
}
65+
]
66+
},
67+
{
68+
"DepartureDateTime":{
69+
"WindowAfter":"P0D",
70+
"WindowBefore":"P0D",
71+
"Date":"09JAN"
72+
},
73+
"OriginLocation":{
74+
"LocationCode":"ESB",
75+
"MultiAirportCityInd":false
76+
},
77+
"DestinationLocation":{
78+
"LocationCode":"IST",
79+
"MultiAirportCityInd":false
80+
},
81+
"CabinPreferences":[
82+
{
83+
"Cabin":"ECONOMY"
84+
},
85+
{
86+
"Cabin":"BUSINESS"
87+
}
88+
]
89+
}
90+
]
91+
}
92+
JSON;
93+
94+
$getAvailabilityParameters = GetAvailabilityParametersFactory::createFromJson($json);
95+
$response = $client->getAvailability($getAvailabilityParameters);
96+
97+
```
98+
99+
### Example with Factory Using An Array
100+
101+
You can build an array that is basically json_encode version of the object mentioned in the previous example.
102+
103+
```php
104+
<?php
105+
106+
use TK\SDK\ValueObject\Factory\GetAvailabilityParametersFactory;
107+
108+
$getAvailabilityParameters = GetAvailabilityParametersFactory::createFromArray($parametersArray);
109+
110+
$response = $client->getAvailability($getAvailabilityParameters);
111+
112+
```
113+
18114
### Example with ValueObjects
19115

20116
```php

docs/endpoints/GetFareFamilyList.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,45 @@ $this->client->getFareFamilyList($getFareFamilyListParameters);
1515

1616
```
1717

18+
### Example with Factory Using JSON Query
19+
20+
```php
21+
<?php
22+
23+
use TK\SDK\ValueObject\Factory\GetFareFamilyListParametersFactory;
24+
25+
$json =<<<JSON
26+
{
27+
"cabin_code": "Y",
28+
"card_type": "EP",
29+
"destination": "IST",
30+
"flightDate": "21.04.2017",
31+
"operatingFlightNumber": "TK1000",
32+
"origin": "FRA"
33+
}
34+
35+
JSON;
36+
$parameterObject = GetFareFamilyListParametersFactory::createFromJson($json);
37+
38+
$response = $client->getFareFamilyList($parameterObject);
39+
40+
```
41+
42+
### Example with Factory Using An Array
43+
44+
You can build an array that is basically json_encode version of the object mentioned in the previous example.
45+
46+
```php
47+
<?php
48+
49+
use TK\SDK\ValueObject\Factory\GetFareFamilyListParametersFactory;
50+
51+
$parameterObject = GetFareFamilyListParametersFactory::createFromArray($parametersArray);
52+
53+
$response = $client->getFareFamilyList($parameterObject);
54+
55+
```
56+
1857
### Example with ValueObjects
1958
```php
2059
<?php

docs/endpoints/GetPortList.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,39 @@ $client->getPortList($getPortListParametersObject);
1515

1616
```
1717

18+
### Example with Factory Using JSON Query
19+
20+
```php
21+
<?php
22+
23+
use TK\SDK\ValueObject\Factory\GetPortListParametersFactory;
24+
25+
$json =<<<JSON
26+
{
27+
"airlineCode": "TK",
28+
"languageCode": "TR"
29+
}
30+
JSON;
31+
$parameterObject = GetPortListParametersFactory::createFromJson($json);
32+
$response = $client->getPortList($parameterObject);
33+
34+
```
35+
36+
### Example with Factory Using An Array
37+
38+
You can build an array that is basically json_encode version of the object mentioned in the previous example.
39+
40+
```php
41+
<?php
42+
43+
use TK\SDK\ValueObject\Factory\GetPortListParametersFactory;
44+
45+
$parameterObject = GetPortListParametersFactory::createFromArray($parametersArray);
46+
47+
$response = $client->getPortList($parameterObject);
48+
49+
```
50+
1851
### Example with ValueObjects
1952

2053
```php

docs/endpoints/GetTimetable.md

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -15,48 +15,6 @@ $client->getTimetable($getTimetableParametersObject);
1515

1616
```
1717

18-
### Example with ValueObjects
19-
20-
```php
21-
<?php
22-
23-
use DateTimeImmutable;
24-
use TK\SDK\ValueObject\Location;
25-
use TK\SDK\ValueObject\DepartureDateTime;
26-
use TK\SDK\ValueObject\OriginDestinationInformation;
27-
use TK\SDK\ValueObject\AirScheduleRQ;
28-
use TK\SDK\ValueObject\GetTimetableParameters;
29-
30-
$originLocation = new Location('IST', Location::MULTIPLE_AIRPORT_TRUE);
31-
$destinationLocation = new Location('JFK', Location::MULTIPLE_AIRPORT_TRUE);
32-
$departureTime = gmdate('Y-m-d H:i:s', strtotime('+4 days'));
33-
34-
$departureDateTime = new DepartureDateTime(
35-
new DateTimeImmutable($departureTime),
36-
'P3D',
37-
'P3D'
38-
);
39-
40-
$originDestinationInformation = new OriginDestinationInformation(
41-
$departureDateTime,
42-
$originLocation,
43-
$destinationLocation
44-
);
45-
46-
$airScheduleRQ = (new AirScheduleRQ($originDestinationInformation))
47-
->withAirlineCode(AirScheduleRQ::AIRLINE_TURKISH_AIRLINES)
48-
->withDirectAndNonStopOnlyInd();
49-
50-
$getTimetableParametersObject = new GetTimetableParameters(
51-
$airScheduleRQ,
52-
GetTimetableParameters::SCHEDULE_TYPE_WEEKLY,
53-
GetTimetableParameters::TRIP_TYPE_ONE_WAY
54-
);
55-
56-
$response = $client->getTimetable($getTimetableParametersObject);
57-
58-
```
59-
6018
### Example with Factory Using JSON Query
6119

6220
```php
@@ -112,4 +70,46 @@ $getTimetableParametersObject = GetTimetableParametersFactory::createFromArray($
11270

11371
$response = $client->getTimetable($getTimetableParametersObject);
11472

115-
```
73+
```
74+
75+
### Example with ValueObjects (Recomended)
76+
77+
```php
78+
<?php
79+
80+
use DateTimeImmutable;
81+
use TK\SDK\ValueObject\Location;
82+
use TK\SDK\ValueObject\DepartureDateTime;
83+
use TK\SDK\ValueObject\OriginDestinationInformation;
84+
use TK\SDK\ValueObject\AirScheduleRQ;
85+
use TK\SDK\ValueObject\GetTimetableParameters;
86+
87+
$originLocation = new Location('IST', Location::MULTIPLE_AIRPORT_TRUE);
88+
$destinationLocation = new Location('JFK', Location::MULTIPLE_AIRPORT_TRUE);
89+
$departureTime = gmdate('Y-m-d H:i:s', strtotime('+4 days'));
90+
91+
$departureDateTime = new DepartureDateTime(
92+
new DateTimeImmutable($departureTime),
93+
'P3D',
94+
'P3D'
95+
);
96+
97+
$originDestinationInformation = new OriginDestinationInformation(
98+
$departureDateTime,
99+
$originLocation,
100+
$destinationLocation
101+
);
102+
103+
$airScheduleRQ = (new AirScheduleRQ($originDestinationInformation))
104+
->withAirlineCode(AirScheduleRQ::AIRLINE_TURKISH_AIRLINES)
105+
->withDirectAndNonStopOnlyInd();
106+
107+
$getTimetableParametersObject = new GetTimetableParameters(
108+
$airScheduleRQ,
109+
GetTimetableParameters::SCHEDULE_TYPE_WEEKLY,
110+
GetTimetableParameters::TRIP_TYPE_ONE_WAY
111+
);
112+
113+
$response = $client->getTimetable($getTimetableParametersObject);
114+
115+
```

0 commit comments

Comments
 (0)