package entity

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 time.Time `json:"occurred_at,omitempty"`
	EventType  string    `json:"event_type,omitempty"`
	Ride       Ride      `json:"event,omitempty"`
}

// Ride entity data
type Ride struct {
	ID                  int64         `db:"ride_id" json:"-"`
	UUID                string        `db:"ride_uuid" json:"ride_uuid"`
	User                User          `db:"user" json:"user"`
	Status              RideStatus    `db:"status" json:"status"`
	Type                RideType      `db:"type" json:"type"`
	InternalID          string        `db:"internal_id" json:"internal_id"`
	RequestDate         *time.Time    `db:"request_date" json:"request_date"`
	RequestMiliseconds  *int64        `db:"request_ms" json:"request_ms"`
	GenerateDate        *time.Time    `db:"generate_date" json:"generate_date"`
	GenerateMiliseconds *int64        `db:"generate_ms" json:"generate_ms"`
	Note                string        `db:"notes" json:"notes"`
	PrimetimePercentage string        `db:"primetime_percentage" json:"primetime_percentage"`
	Passenger           RidePassenger `db:"passenger" json:"passenger"`
	Driver              RideDriver    `db:"driver" json:"driver"`
	Vehicle             RideVehicle   `db:"vehicle" json:"vehicle"`
	Route               RideRoute     `db:"route" json:"route"`
	VisitDate           *time.Time    `db:"visit_date" json:"visit_date"`
	VisitTime           *time.Time    `db:"visit_time" json:"visit_time"`
	PickupTime          *time.Time    `db:"pickup_time" json:"pickup_time"`
	Created             time.Time     `db:"create_at" json:"create_at"`
	Updated             time.Time     `db:"update_at" json:"update_at"`
	Visit               Visit         `db:"visit" json:"visit"`
	CreatedUser         User          `db:"created_user" json:"created_user"`
	TripType            TripType      `db:"trip_type" json:"trip_type"`
}

// RidePassenger entity data
type RidePassenger struct {
	ID          int64   `db:"ride_passenger_id" json:"-"`
	FirstName   string  `db:"first_name" json:"first_name"`
	LastName    string  `db:"last_name" json:"last_name"`
	ImageURL    *string `db:"image_url" json:"image_url"`
	PhoneNumber string  `db:"phone_number" json:"phone_number"`
	InternalID  *string `db:"internal_id" json:"internal_id"`
}

// RideStatus entity data
type RideStatus struct {
	ID    int64  `db:"ride_status_id" json:"-"`
	Key   string `db:"key" json:"key"`
	Value string `db:"value" json:"value"`
}

// RideStatus entity data
type TripType struct {
	ID    int64  `db:"trip_type_id" json:"-"`
	Key   string `db:"trip_type_key" json:"key"`
	Value string `db:"trip_type" json:"value"`
}

// RideType entity data
type RideType struct {
	ID    int64  `db:"ride_type_id" json:"-"`
	Key   string `db:"key" json:"key"`
	Value string `db:"value" json:"value"`
}

// RideRoute entity data
type RideRoute struct {
	ID          int64     `db:"ride_route_id" json:"-"`
	Origin      Location  `db:"origin" json:"origin"`
	Destination Location  `db:"destination" json:"destination"`
	RouteKML    *string   `db:"route_kml" json:"route_kml"`
	Distance    float64   `db:"distance" json:"distance"`
	Duration    int64     `db:"duration" json:"duration"`
	ETA         int64     `db:"eta" json:"eta"`
	Created     time.Time `db:"create_at" json:"create_at"`
	Updated     time.Time `db:"update_at" json:"update_at"`
}

// Location entity data
type Location struct {
	ID        string  `db:"id" json:"id"`
	Name      string  `db:"name" json:"name"`
	Address   string  `db:"address" json:"address"`
	Latitude  float64 `db:"lat" json:"lat"`
	Longitude float64 `db:"lng" json:"lng"`
}

// RideDriver entity data
type RideDriver struct {
	ID          int64   `db:"ride_driver_id" json:"-"`
	Name        string  `db:"name" json:"name"`
	ImageURL    *string `db:"image_url" json:"image_url"`
	PhoneNumber string  `db:"phone_number" json:"phone_number"`
	Rating      *string `db:"rating" json:"rating"`
}

// RideVehicle entity data
type RideVehicle struct {
	ID                int64  `db:"ride_vehicle_id" json:"-"`
	Color             string `db:"color" json:"color"`
	ImageURL          string `db:"image_url" json:"image_url"`
	LicensePlate      string `db:"license_plate" json:"license_plate"`
	LicensePlateState string `db:"license_plate_state" json:"license_plate_state"`
	Make              string `db:"make" json:"make"`
	Model             string `db:"model" json:"model"`
	Year              int64  `db:"year" json:"year"`
}
