-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
public API: Add a
api/v1/lines/
endpoint
completes #1074 This endpoint returns an array of all lines available in Transition.
- Loading branch information
Showing
5 changed files
with
141 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
lines: | ||
type: array | ||
items: | ||
type: object | ||
required: | ||
- id | ||
- name | ||
- longname | ||
- agency_id | ||
- mode | ||
properties: | ||
id: | ||
type: string | ||
description: Identifier of this line, used sometimes in other objects to identify this line, for example in the scenarios' `only_lines` and `except_lines` fields. | ||
example: 29829bef-39fd-481b-86ee-9d781146352d | ||
name: | ||
type: string | ||
description: Name of this line | ||
example: L1 | ||
longname: | ||
type: string | ||
description: Longname of this line | ||
example: Street This and That | ||
agency_id: | ||
type: string | ||
description: Identifier of the agency that operates this line | ||
example: 29829bef-39fd-481b-86ee-9d781146352d | ||
mode: | ||
type: string | ||
description: The transport mode of this line | ||
example: bus | ||
category: | ||
type: string | ||
description: The category of this line, ie A, B, C, etc. | ||
example: C |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
packages/transition-backend/src/api/public/LinesAPIResponse.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright 2024, Polytechnique Montreal and contributors | ||
* | ||
* This file is licensed under the MIT License. | ||
* License text available at https://opensource.org/licenses/MIT | ||
*/ | ||
import APIResponseBase from './APIResponseBase'; | ||
import { LineAttributes } from 'transition-common/lib/services/line/Line'; | ||
|
||
export type LinesAPIResponseFormat = Array<{ | ||
id: string; | ||
name: string; | ||
longname: string; | ||
agency_id: string; | ||
mode: string; | ||
category?: string; | ||
}>; | ||
|
||
export default class LinesAPIResponse extends APIResponseBase<LinesAPIResponseFormat, LineAttributes[]> { | ||
protected createResponse(input: LineAttributes[]): LinesAPIResponseFormat { | ||
return input.map((line: LineAttributes) => ({ | ||
id: line.id, | ||
name: line.shortname!, | ||
longname: line.longname, | ||
agency_id: line.agency_id, | ||
mode: line.mode, | ||
category: line.category | ||
})); | ||
} | ||
} |