journeys.go 4.2 KB
Newer Older
Arnaud Delcasse's avatar
Arnaud Delcasse committed
1 2 3 4 5 6
package rdex

import "time"

// RDEXJourney is the carpooling journey base type of the RDEX protocol
type RDEXJourney struct {
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
	UUID              string              `json:"uuid"`
	Operator          string              `json:"operator"`
	Origin            string              `json:"origin"`
	URL               *string             `json:"url,omitempty"`
	Driver            *RDEXPerson         `json:"driver,omitempty"`
	Passenger         *RDEXPerson         `json:"passenger,omitempty"`
	From              RDEXGeography       `json:"from"`
	To                RDEXGeography       `json:"to"`
	Distance          int64               `json:"distance"`
	Duration          time.Duration       `json:"duration"`
	Route             *string             `json:"route,omitempty"`
	NumberOfWaypoints *int                `json:"number_of_waypoints,omitempty"`
	Waypoints         *[]RDEXGeography    `json:"waypoints,omitempty"`
	Cost              RDEXCost            `json:"cost"`
	Details           *string             `json:"details,omitempty"`
	Vehicle           *RDEXVehicle        `json:"vehicle,omitempty"`
	Frequency         string              `json:"frequency"` // punctual or regular
	Type              string              `json:"type"`      // one-way or round-trip
	Realtime          *ConvertibleBoolean `json:"real_time,omitempty"`
	Stopped           *ConvertibleBoolean `json:"stopped,omitempty"`
	Days              RDEXDays            `json:"days"`
	Outward           RDEXSchedule        `json:"outward"`
	Return            *RDEXSchedule       `json:"return,omitempty"`
Arnaud Delcasse's avatar
Arnaud Delcasse committed
30 31 32 33
}

// RDEXPerson defines a driver or a passenger
type RDEXPerson struct {
34 35 36 37 38
	UUID  *string            `json:"uuid,omitempty"`
	Alias *string            `json:"alias,omitempty"`
	Image *string            `json:"image,omitempty"`
	Seats *int               `json:"seats,omitempty"`
	State ConvertibleBoolean `json:"state,omitempty"`
Arnaud Delcasse's avatar
Arnaud Delcasse committed
39 40 41 42
}

// RDEXGeography is a geographical point used in From, To or Waypoints
type RDEXGeography struct {
43 44 45 46 47 48 49 50 51 52
	Address      string              `json:"address"`
	City         string              `json:"city"`
	Postalcode   string              `json:"postalcode,omitempty"`
	Country      string              `json:"country,omitempty"`
	Latitude     float64             `json:"latitude"`
	Longitude    float64             `json:"longitude"`
	StepDistance int64               `json:"step_distance,omitempty"`
	StepDuration time.Duration       `json:"step_duration,omitempty"`
	Type         string              `json:"type,omitempty"` // pick-up or drop-point
	Mandatory    *ConvertibleBoolean `json:"mandatory,omitempty"`
Arnaud Delcasse's avatar
Arnaud Delcasse committed
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
}

// RDEXCost is the cost of the journey, either fixed or variable
type RDEXCost struct {
	Fixed    float64 `json:"fixed,omitempty"`
	Variable float64 `json:"variable,omitempty"`
}

// RDEXVehicle is the vehicle description
type RDEXVehicle struct {
	VehicleImage string `json:"vehicle_image,omitempty"`
	Model        string `json:"model,omitempty"`
	Color        string `json:"color,omitempty"`
}

// RDEXDays defines which days of the week the journey happens
type RDEXDays struct {
70 71 72 73 74 75 76
	Monday    ConvertibleBoolean `json:"monday"`
	Tuesday   ConvertibleBoolean `json:"tuesday"`
	Wednesday ConvertibleBoolean `json:"wednesday"`
	Thursday  ConvertibleBoolean `json:"thursday"`
	Friday    ConvertibleBoolean `json:"friday"`
	Saturday  ConvertibleBoolean `json:"saturday"`
	Sunday    ConvertibleBoolean `json:"sunday"`
Arnaud Delcasse's avatar
Arnaud Delcasse committed
77 78 79 80
}

// RDEXSchedule is used to define outward and return datetimes
type RDEXSchedule struct {
81 82 83 84 85 86 87 88 89
	MinDate   string          `json:"mindate" schema:"mindate"`
	MaxDate   string          `json:"maxdate" schema:"maxdate"`
	Monday    *RDEXTimeLimits `json:"monday,omitempty"`
	Tuesday   *RDEXTimeLimits `json:"tuesday,omitempty"`
	Wednesday *RDEXTimeLimits `json:"wednesday,omitempty"`
	Thursday  *RDEXTimeLimits `json:"thursday,omitempty"`
	Friday    *RDEXTimeLimits `json:"friday,omitempty"`
	Saturday  *RDEXTimeLimits `json:"saturday,omitempty"`
	Sunday    *RDEXTimeLimits `json:"sunday,omitempty"`
Arnaud Delcasse's avatar
Arnaud Delcasse committed
90 91 92 93 94 95 96
}

// RDEXTimeLimits defines the minimum time and maximum time for the journey in a day
type RDEXTimeLimits struct {
	MinTime string `json:"mintime"`
	MaxTime string `json:"maxtime"`
}