package viewmodel

import "time"

//WebhookResponse has the data and events from the webhook
type WebhookResponse struct {
	EventID    string      `json:"event_id,omitempty"`
	HREF       string      `json:"href,omitempty"`
	OccurredAt string      `json:"occurred_at,omitempty"`
	EventType  string      `json:"event_type,omitempty"`
	Event      RideRequest `json:"event,omitempty"`
	Ride       Ride        `json:"-"`
}

//RideRequest has the data to dispatch a ride
type RideRequest struct {
	UserUUID             string           `json:"user_uuid,omitempty"`
	UserConsent          bool             `json:"user_consent,omitempty"`
	Status               string           `json:"status,omitempty"`
	RideID               string           `json:"ride_id,omitempty"`
	RideType             string           `json:"ride_type,omitempty"`
	Origin               Location         `json:"origin,omitempty"`
	Location             Location         `json:"location,omitempty"`
	Destination          Location         `json:"destination,omitempty"`
	Passenger            UserLyft         `json:"passenger,omitempty"`
	Notes                string           `json:"external_note,omitempty"`
	RouteURL             string           `json:"route_url,omitempty"`
	ScheduledPickupRange interface{}      `json:"scheduled_pickup_range,omitempty"`
	PrimetimePercentage  string           `json:"primetime_percentage,omitempty"`
	Pickup               Location         `json:"pickup,omitempty"`
	DropOff              Location         `json:"dropoff,omitempty"`
	Vehicle              Vehicle          `json:"vehicle,omitempty"`
	Price                Price            `json:"price,omitempty"`
	Driver               UserLyft         `json:"driver,omitempty"`
	GeneratedAtMS        *int64           `json:"generated_at_ms,omitempty"`
	GeneratedAt          *time.Time       `json:"generated_at,omitempty"`
	RequestAtMS          *int64           `json:"requested_at_ms,omitempty"`
	RequestAt            *time.Time       `json:"requested_at,omitempty"`
	LineItems            []Price          `json:"line_items,omitempty"`
	BeaconColor          string           `json:"beacon_color,omitempty"`
	Charges              []Charge         `json:"charges,omitempty"`
	VisitDate            *time.Time       `json:"visit_date,omitempty"`
	VisitTime            *time.Time       `json:"visit_time,omitempty"`
	PickupTime           *time.Time       `json:"pickup_time,omitempty"`
	ReturnTime           *time.Time       `json:"return_time,omitempty"`
	Distance             float64          `json:"distance,omitempty"`
	ETA                  int64            `json:"eta,omitempty"`
	Duration             int64            `json:"duration,omitempty"`
	Visit                Visit            `json:"visit,omitempty"`
	CreateUserUUID       string           `json:"created_user_uuid,omitempty"`
	VisitExternalID      string           `json:"visit_external_id,omitempty"`
	CanCancel            []string         `json:"can_cancel,omitempty"`
	PricingDetailsURL    string           `json:"pricing_details_url,omitempty"`
	RideProfile          string           `json:"ride_profile,omitempty"`
	DistanceInMiles      float64          `json:"distance_miles,omitempty"`
	DurationInSeconds    float64          `json:"duration_seconds,omitempty"`
	CanceledBy           string           `json:"canceled_by,omitempty"`
	TripType             TripType         `json:"trip_type,omitempty"`
	Error                string           `json:"error,omitempty"`
	ErrorDescription     string           `json:"error_description,omitempty"`
	User                 User             `json:"user,omitempty"`
	Provider             ProviderResp     `json:"provider,omitempty"`
	RawProvider          ProviderResponse `json:"raw_provider,omitempty"`
}

//Charge information
type Charge struct {
	Currency      string `json:"currency,omitempty"`
	PaymentMethod string `json:"payment_method,omitempty"`
	Amount        int64  `json:"amount,omitempty"`
}

//Price information
type Price struct {
	Currency    string  `json:"currency,omitempty"`
	Amount      float64 `json:"amount,omitempty"`
	Description string  `json:"description,omitempty"`
	Type        string  `json:"type,omitempty"`
}

//Vehicle information
type Vehicle struct {
	Color             string `json:"color,omitempty"`
	Make              string `json:"make,omitempty"`
	LicensePlate      string `json:"license_plate,omitempty"`
	ImageURL          string `json:"image_url,omitempty"`
	Year              int64  `json:"year,omitempty"`
	LicensePlateState string `json:"license_plate_state,omitempty"`
	Model             string `json:"model,omitempty"`
}

//Location has the coordinates from the user
type Location struct {
	ID         string     `json:"id,omitempty"`
	Name       string     `json:"name,omitempty"`
	Latitude   float64    `json:"lat,omitempty"`
	Longitude  float64    `json:"lng,omitempty"`
	Address    string     `json:"address,omitempty"`
	ETASeconds *int64     `json:"eta_seconds,omitempty"`
	TimeMS     *int64     `json:"time_ms,omitempty"`
	Time       *time.Time `json:"time,omitempty"`
	Bearing    *float64   `json:"bearing,omitempty"`
}

//UserLyft has the personal information
type UserLyft struct {
	UserID      *string `json:"user_id,omitempty"`
	Rating      *string `json:"rating,omitempty"`
	ImageURL    *string `json:"image_url,omitempty"`
	FirstName   string  `json:"first_name,omitempty"`
	LastName    string  `json:"last_name,omitempty"`
	PhoneNumber string  `json:"phone_number,omitempty"`
}

// Ride entity data
type Ride struct {
	UUID        string     `json:"ride_uuid,omitempty"`
	InternalID  string     `json:"internal_id,omitempty"`
	User        User       `json:"user,omitempty"`
	Status      RideStatus `json:"status,omitempty"`
	Type        RideType   `json:"type,omitempty"`
	Note        string     `json:"notes,omitempty"`
	Passenger   UserLyft   `json:"passenger,omitempty"`
	Driver      UserLyft   `json:"driver,omitempty"`
	Vehicle     Vehicle    `json:"vehicle,omitempty"`
	Route       RideRoute  `json:"route,omitempty"`
	VisitDate   *time.Time `json:"visit_date,omitempty"`
	VisitTime   *time.Time `json:"visit_time,omitempty"`
	PickupTime  *time.Time `json:"pickup_time,omitempty"`
	Visit       Visit      `json:"visit,omitempty"`
	CreatedUser User       `json:"created_user,omitempty"`
	CreateAt    time.Time  `json:"create_at,omitempty"`
	UpdateAt    time.Time  `json:"update_at,omitempty"`
	TripType    TripType   `json:"trip_type,omitempty"`
}

// RideStatus entity data
type RideStatus struct {
	Key   string `json:"key,omitempty"`
	Value string `json:"value,omitempty"`
}

// TripType entity data
type TripType struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

// RideType entity data
type RideType struct {
	Key   string `json:"key,omitempty"`
	Value string `json:"value,omitempty"`
}

// RideRoute entity data
type RideRoute struct {
	Origin      Location `json:"origin,omitempty"`
	Destination Location `json:"destination,omitempty"`
	Location    Location `json:"location,omitempty"`
	RouteKML    *string  `json:"route_kml,omitempty"`
	Distance    float64  `json:"distance,omitempty"`
	Duration    int64    `json:"duration,omitempty"`
	ETA         int64    `json:"eta,omitempty"`
	Bearing     int64    `json:"bearing,omitempty"`
}
