Add MOTIS server

This commit is contained in:
2025-05-05 01:00:45 +02:00
parent 5f63e312c9
commit 8680f56006
9 changed files with 6829 additions and 17 deletions

View File

@@ -34,7 +34,7 @@ type BBCDailyResult struct {
Distance *int64 `json:"distance"`
PickupLatitude *float64 `json:"pickup_latitude"`
PickupLongitude *float64 `json:"pickup_longitude"`
PickupDatetime time.Time `json:"pickup_datetime"`
PickupDatetime *string `json:"pickup_datetime"`
DropoffLatitude *float64 `json:"dropoff_latitude"`
DropoffLongitude *float64 `json:"dropoff_longitude"`
DropoffDatetime *string `json:"dropoff_datetime"`
@@ -95,6 +95,12 @@ func (api *BBCDailyCarpoolAPI) GetDriverJourneys(
Currency: &r.Price.Currency,
}
}
i, err := strconv.ParseInt(*r.PickupDatetime, 10, 64)
if err != nil {
log.Error().Err(err).Msg("error in string ot int conversion")
}
pd := time.Unix(i, 0)
pickupDatetime := ocss.OCSSTime(pd)
driverJourney := ocss.DriverJourney{
DriverTrip: ocss.DriverTrip{
Driver: ocss.User{
@@ -117,7 +123,7 @@ func (api *BBCDailyCarpoolAPI) GetDriverJourneys(
},
JourneySchedule: ocss.JourneySchedule{
ID: r.ID,
PassengerPickupDate: ocss.OCSSTime(r.PickupDatetime),
PassengerPickupDate: pickupDatetime,
WebUrl: r.WebURL,
},
AvailableSteats: r.AvailableSeats,
@@ -160,8 +166,6 @@ func blablacarDailySearch(url string, access_token string, departure_latitude fl
q.Add("departure_timedelta", fmt.Sprintf("%v", departure_timedelta.Abs().Seconds()))
req.URL.RawQuery = q.Encode()
log.Debug().Str("url", req.URL.String()).Msg("Request to BBCDaily")
resp, err := http.DefaultClient.Do(req)
if err != nil {
log.Error().Err(err).Msg("error in BBCDaily request")
@@ -176,7 +180,7 @@ func blablacarDailySearch(url string, access_token string, departure_latitude fl
if err2 != nil {
log.Error().Err(err2).Msg("error reading json string")
}
log.Error().Err(err).Any("resp body", body).Msg("cannot read json response to blablacardaily API")
log.Error().Err(err).Bytes("resp body", body).Any("status", resp.Status).Msg("cannot read json response to blablacardaily API")
return nil, err
}

View File

@@ -0,0 +1,5 @@
package: motis
generate:
client: true
models: true
output: gen.go

4238
libs/transit/motis/gen.go Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,3 @@
package motis
//go:generate go tool oapi-codegen -config cfg.yaml openapi.yaml

File diff suppressed because it is too large Load Diff