Skip to content

Commit 2454f1c

Browse files
committed
Define an API to retrieve information about stop locations
1 parent 1a7fd34 commit 2454f1c

6 files changed

Lines changed: 175 additions & 4 deletions

File tree

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<?php
2+
3+
namespace Trafiklab\Common\Model\Contract;
4+
5+
use Trafiklab\Common\Model\Enum\TransportType;
6+
7+
/**
8+
* A stop location found by a FindStopLocationRequest.
9+
*
10+
* @see FindStopLocationRequest
11+
* @see FindStopLocationResponse
12+
*
13+
* @api
14+
* @package Trafiklab\Common\Model\Contract
15+
*/
16+
interface FindStopLocationEntry
17+
{
18+
/**
19+
* Get the id of this stop area.
20+
*
21+
* @return string The id of this stop area.
22+
*/
23+
public function getId(): string;
24+
25+
/**
26+
* Get the name of this stop area.
27+
*
28+
* @return string The name of this stop area.
29+
*/
30+
public function getName(): string;
31+
32+
/**
33+
* The longitude of this stop area.
34+
*
35+
* @return float The longitude of this stop area.
36+
*/
37+
public function getLongitude(): float;
38+
39+
/**
40+
* The latitude of this stop area.
41+
*
42+
* @return float The latitude of this stop area.
43+
*/
44+
public function getLatitude(): float;
45+
46+
/**
47+
* The sorting weight for this station. This can be determined by the number of vehicles stopping there, the
48+
* number of passengers, ...
49+
*
50+
* @return int The sorting weight for this station.
51+
*/
52+
public function getWeight(): int;
53+
54+
/**
55+
* Check if a certain mode of transport stops at this stop location.
56+
*
57+
* @param int $transportType The type of transport, one of the constants in TransportType
58+
*
59+
* @return bool Whether or not the specified type of traffic can stop in this point. In case an API doesn't provide
60+
* this information, it will always return true.
61+
*
62+
* @see TransportType
63+
*/
64+
public function isStopAreaForTransportType(int $transportType): bool;
65+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
<?php
2+
3+
4+
namespace Trafiklab\Common\Model\Contract;
5+
6+
/**
7+
* A FindStopLocationRequest is a request to find a certain stop area by (a part of) its name. This way a stop area ID
8+
* can obtained. These APIs are called "Platsupplag" on trafiklab.se.
9+
*
10+
* @see FindStopLocationResponse
11+
* @api
12+
* @package Trafiklab\Common\Model\Contract
13+
*/
14+
interface FindStopLocationRequest
15+
{
16+
/**
17+
* Set the station name to search after. The maximum length might be limited based on the implementation.
18+
* If the input is too long, only the first X characters will be used.
19+
*
20+
* @param string $searchQuery (A part of) the station name to search after.
21+
*/
22+
function setSearchQuery(string $searchQuery): void;
23+
24+
/**
25+
* Get the station name to search after.
26+
*
27+
* @return string The station name to search after.
28+
*/
29+
function getSearchQuery(): string;
30+
31+
/**
32+
* Set the language which is used in the response.
33+
*
34+
* @param string $language The language which is used in the response.
35+
*/
36+
function setLanguage(string $language): void;
37+
38+
/**
39+
* Get the language which is used in the response.
40+
*
41+
* @return string The language which is used in the response.
42+
*/
43+
function getLanguage(): string;
44+
45+
/**
46+
* Set the maximum number of results. The response might contain fewer results, but never more.
47+
*
48+
* @param int $maximumNumberOfResults The maximum number of results.
49+
*/
50+
function setMaxNumberOfResults(int $maximumNumberOfResults): void;
51+
52+
/**
53+
* Get the maximum number of results. The response might contain fewer results, but never more.
54+
*
55+
* @return int The maximum number of results.
56+
*/
57+
function getMaxNumberOfResults(): int;
58+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
3+
namespace Trafiklab\Common\Model\Contract;
4+
5+
use Trafiklab\Common\Internal\WebResponseImpl;
6+
7+
/**
8+
* Interface FindStopLocationResponse
9+
*
10+
* @see FindStopLocationRequest
11+
* @api
12+
* @package Trafiklab\Common\Model\Contract
13+
*/
14+
interface FindStopLocationResponse
15+
{
16+
17+
18+
/**
19+
* Get the original response from the API.
20+
*
21+
* @return WebResponse
22+
*/
23+
public function getOriginalApiResponse(): WebResponse;
24+
25+
26+
/**
27+
* An array containing the stop areas which were found.
28+
*
29+
* @return FindStopLocationEntry[]
30+
*/
31+
public function getFoundStopAreas(): array;
32+
}

src/Trafiklab/Common/Model/Contract/PublicTransportApiWrapper.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ public function setRoutePlanningApiKey(string $apiKey): void;
3737
*/
3838
public function setTimeTablesApiKey(string $apiKey): void;
3939

40+
/**
41+
* Set the API key used for finding stop locations.
42+
*
43+
* @param string $apiKey The API key to use.
44+
*/
45+
public function setFindStopLocationApiKey(string $apiKey): void;
46+
4047
/**
4148
* Get a timetable for a certain stop.
4249
*
@@ -54,4 +61,14 @@ public function getTimeTable(TimeTableRequest $timeTableRequest): TimeTableRespo
5461
* @return RoutePlanningResponse The response from the API.
5562
*/
5663
public function getRoutePlanning(RoutePlanningRequest $routePlanningRequest): RoutePlanningResponse;
64+
65+
66+
/**
67+
* Get a route-planning between two points.
68+
*
69+
* @param FindStopLocationRequest $findStopLocationRequest The request object containing the query parameters.
70+
*
71+
* @return FindStopLocationResponse The response from the API.
72+
*/
73+
public function findStopLocation(FindStopLocationRequest $findStopLocationRequest): FindStopLocationResponse;
5774
}

src/Trafiklab/Common/Model/Contract/RoutePlanningResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ interface RoutePlanningResponse
1717
/**
1818
* Get the original response from the API.
1919
*
20-
* @return WebResponseImpl
20+
* @return WebResponse
2121
*/
2222
public function getOriginalApiResponse(): WebResponse;
2323

src/Trafiklab/Common/Model/Contract/TimeTableResponse.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
namespace Trafiklab\Common\Model\Contract;
44

5-
use Trafiklab\Common\Internal\WebResponseImpl;
6-
75
/**
86
* A timetable response from a transportation API.
97
*
@@ -16,7 +14,8 @@ interface TimeTableResponse
1614
/**
1715
* Get the original response from the API.
1816
*
19-
* @return WebResponseImpl
17+
* @return WebResponse
18+
*
2019
*/
2120
public function getOriginalApiResponse(): WebResponse;
2221

0 commit comments

Comments
 (0)