initial commit
This commit is contained in:
57
interoperability/ocss/journeys.go
Normal file
57
interoperability/ocss/journeys.go
Normal file
@@ -0,0 +1,57 @@
|
||||
package ocss
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
type JourneyScheduleType int64
|
||||
|
||||
const (
|
||||
Planned JourneyScheduleType = iota
|
||||
Dynamic
|
||||
Line
|
||||
)
|
||||
|
||||
func (t JourneyScheduleType) MarshalJSON() ([]byte, error) {
|
||||
types := map[JourneyScheduleType]string{
|
||||
Planned: "\"PLANNED\"",
|
||||
Dynamic: "\"DYNAMIC\"",
|
||||
Line: "\"Line\"",
|
||||
}
|
||||
|
||||
return []byte(types[t]), nil
|
||||
}
|
||||
|
||||
type JSONTime time.Time
|
||||
|
||||
func (t JSONTime) MarshalJSON() ([]byte, error) {
|
||||
//do your serializing here
|
||||
stamp := fmt.Sprintf("%v", time.Time(t).Unix())
|
||||
return []byte(stamp), nil
|
||||
}
|
||||
|
||||
type JourneySchedule struct {
|
||||
ID *string `json:"id,omitempty"`
|
||||
PassengerPickupDate JSONTime `json:"passengerPickupDate"`
|
||||
PassengerDepartureDate *JSONTime `json:"passengerDepartureDate,omitempty"`
|
||||
DriverDepartureDate *JSONTime `json:"driverDepartureDate,omitempty"`
|
||||
WebUrl *string `json:"webUrl,omitempty"`
|
||||
Type JourneyScheduleType `json:"type"`
|
||||
}
|
||||
|
||||
type DriverJourney struct {
|
||||
DriverTrip
|
||||
JourneySchedule
|
||||
|
||||
AvailableSteats *int `json:"requestedSeats,omitempty"`
|
||||
Price *Price `json:"price,omitempty"`
|
||||
}
|
||||
|
||||
type PassengerJourney struct {
|
||||
PassengerTrip
|
||||
JourneySchedule
|
||||
|
||||
//TODO how to handle requested driverDepartureDate
|
||||
RequestedSteats *int64 `json:"requestedSeats,omitempty"`
|
||||
}
|
||||
Reference in New Issue
Block a user