regular routes journeys, persistent KV to store return states, ...
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
package ocss
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type Day int64
|
||||
|
||||
const (
|
||||
@@ -12,6 +17,44 @@ const (
|
||||
Sunday
|
||||
)
|
||||
|
||||
var daytoID = map[string]Day{
|
||||
"MON": Monday,
|
||||
"TUE": Tuesday,
|
||||
"WED": Wednesday,
|
||||
"THU": Thursday,
|
||||
"FRI": Friday,
|
||||
"SAT": Saturday,
|
||||
"SUN": Sunday,
|
||||
}
|
||||
|
||||
var daytoString = map[Day]string{
|
||||
Monday: "MON",
|
||||
Tuesday: "TUE",
|
||||
Wednesday: "WED",
|
||||
Thursday: "THU",
|
||||
Friday: "FRI",
|
||||
Saturday: "SAT",
|
||||
Sunday: "SUN",
|
||||
}
|
||||
|
||||
func (s Day) MarshalJSON() ([]byte, error) {
|
||||
buffer := bytes.NewBufferString(`"`)
|
||||
buffer.WriteString(daytoString[s])
|
||||
buffer.WriteString(`"`)
|
||||
return buffer.Bytes(), nil
|
||||
}
|
||||
|
||||
func (bs *Day) UnmarshalJSON(b []byte) error {
|
||||
var j string
|
||||
err := json.Unmarshal(b, &j)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
// Note that if the string cannot be found then it will be set to the zero value, 'Created' in this case.
|
||||
*bs = daytoID[j]
|
||||
return nil
|
||||
}
|
||||
|
||||
type Schedule struct {
|
||||
PassengerPickupDay *Day `json:"passengerPickupDay,omitempty"`
|
||||
|
||||
|
||||
Reference in New Issue
Block a user