idfm-api/api/destinations.go

80 lines
2.0 KiB
Go
Raw Normal View History

2022-10-21 21:54:17 +00:00
package api
import (
2022-10-22 22:56:24 +00:00
"net/http"
2022-10-21 21:54:17 +00:00
"github.com/gin-gonic/gin"
)
2022-10-22 22:56:24 +00:00
type IDFMSchedule struct {
Line struct {
Id string `json:"id"`
Label string `json:"label"`
Name string `json:"name"`
ShortName string `json:"shortName"`
Companies []struct {
Id string `json:"id"`
Label string `json:"label"`
} `json:"companies"`
Network struct {
Id string `json:"id"`
Label string `json:"label"`
} `json:"network"`
Mode string `json:"mode"`
ModeLabel string `json:"modeLabel"`
Realtime bool `json:"realtime"`
UFR bool `json:"ufr"`
Visual bool `json:"visual"`
Sound bool `json:"sound"`
Color string `json:"color"`
TextColor string `json:"textColor"`
} `json:"line"`
Schedules []struct {
RouteId string `json:"routeId"`
From string `json:"from"`
To string `json:"to"`
First string `json:"first"`
Last string `json:"last"`
} `json:"schedules"`
Plans []struct {
Link string `json:"link"`
Label string `json:"label"`
} `json:"plans"`
ScheduleDocs []struct {
Link string `json:"link"`
Label string `json:"label"`
} `json:"scheduleDocs"`
CurrentIT []struct {
Id string `json:"id"`
Title string `json:"title"`
Message string `json:"message"`
ImpactStartTime IDFMTime `json:"impactStartTime"`
ImpactEndTime IDFMTime `json:"impactEndTime"`
Severity int `json:"severity"`
Type int `json:"type"`
} `json:"currentIT"`
}
type PGDestination struct {
Name string `json:"name"`
Way string `json:"way"`
}
2022-10-23 14:45:11 +00:00
func getDestinations(code string) ([]PGDestination, error) {
2024-07-26 10:47:08 +00:00
return nil, nil
2022-10-23 14:45:11 +00:00
}
2022-10-22 22:56:24 +00:00
2022-10-23 14:45:11 +00:00
func declareDestinationsRoutes(router *gin.RouterGroup) {
router.GET("/destinations/:type/:code", func(c *gin.Context) {
2024-07-26 10:47:08 +00:00
pgd, err := getDestinations(string(c.Param("code")))
2022-10-23 14:45:11 +00:00
if err != nil {
c.AbortWithStatusJSON(http.StatusInternalServerError, gin.H{"errmsg": err.Error()})
return
2022-10-22 22:56:24 +00:00
}
2022-10-21 21:54:17 +00:00
2022-10-22 22:56:24 +00:00
c.JSON(http.StatusOK, APIResult(c, map[string][]PGDestination{
"destinations": pgd,
}))
})
2022-10-21 21:54:17 +00:00
}