blob: b87e35b6110a25d3a3f608437630130dfbe75ebe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
package api
import (
"encoding/json"
"fmt"
"net/http"
)
type DeparturesResponse struct {
Disruptions []interface{} `json:"disruptions"`
Notes []interface{} `json:"notes"`
Departures []struct {
DisplayInformations struct {
Direction string `json:"direction"`
Code string `json:"code"`
Network string `json:"network"`
Links []interface{} `json:"links"`
Color string `json:"color"`
Name string `json:"name"`
PhysicalMode string `json:"physical_mode"`
Headsign string `json:"headsign"`
Label string `json:"label"`
Equipments []interface{} `json:"equipments"`
TextColor string `json:"text_color"`
TripShortName string `json:"trip_short_name"`
CommercialMode string `json:"commercial_mode"`
Description string `json:"description"`
} `json:"display_informations"`
StopDateTime struct {
Links []interface{} `json:"links"`
ArrivalDateTime string `json:"arrival_date_time"`
AdditionalInformations []interface{} `json:"additional_informations"`
DepartureDateTime string `json:"departure_date_time"`
BaseArrivalDateTime string `json:"base_arrival_date_time"`
BaseDepartureDateTime string `json:"base_departure_date_time"`
DataFreshness string `json:"data_freshness"`
} `json:"stop_date_time"`
} `json:"departures"`
Context struct {
Timezone string `json:"timezone"`
CurrentDatetime string `json:"current_datetime"`
} `json:"context"`
}
func (c *Client) GetDepartures() (departures *DeparturesResponse, err error) {
req, err := http.NewRequest("GET", fmt.Sprintf("%s/coverage/sncf/stop_areas/stop_area:SNCF:87723502/departures", c.baseURL), nil)
if err != nil {
return nil, err
}
resp, err := c.httpClient.Do(req)
if err != nil {
return nil, err
}
defer resp.Body.Close()
if err = json.NewDecoder(resp.Body).Decode(&departures); err != nil {
return nil, err
}
return
}
|