package common

import "time"

type UserConsentFromHMI struct {
	Name     string `json:"name" validate:"required,user_consent_name"`
	Accept   bool   `json:"accept"`
	DriverID string `json:"driver_id" validate:"required"`
}

type UserConsentDataRequest struct {
	UserID              string                `json:"userId"`
	ConsentAdminID      string                `json:"consentAdminId"`
	Email               string                `json:"email,omitempty"`
	Phone               string                `json:"phone,omitempty"`
	VehicleIdNum        string                `json:"vehicleIdNum"`
	ConsentName         string                `json:"consentName"`
	ConsentAction       string                `json:"consentAction"`
	PreviousAction      string                `json:"previousAction,omitempty"`
	DataSubjectCategory string                `json:"dataSubjectCategory"`
	Channel             string                `json:"channel"`
	GuestUser           *UserConsentGuestUser `json:"guestUser,omitempty"`
}

type UserConsentGuestUser struct {
	ConsentAdminID      string `json:"consentAdminId"`
	ConsentName         string `json:"consentName"`
	ConsentAction       string `json:"consentAction"`
	PreviousAction      string `json:"previousAction"`
	DataSubjectCategory string `json:"dataSubjectCategory"`
}

type UserConsentDataResponse struct {
	UserID              string    `json:"userId"`
	ConsentAdminID      string    `json:"consentAdminId"`
	Email               string    `json:"email"`
	Phone               string    `json:"phone"`
	VehicleIdNum        string    `json:"vehicleIdNum"`
	ConsentName         string    `json:"consentName"`
	ConsentAction       string    `json:"consentAction"`
	PreviousAction      string    `json:"previousAction"`
	DataSubjectCategory string    `json:"dataSubjectCategory"`
	ConsentRegisteredAt time.Time `json:"consentRegisteredAt"`
	Channel             string    `json:"channel"`
	ValidFrom           string    `json:"validFrom"`
	ValidTo             string    `json:"validTo"`
}

type UserConsentByVehicleNumberRequest struct {
	VehicleNumber string `json:"vehicleNumber"`
}

type UserConsentDataTrexMsg struct {
	UserID              string `json:"driver_id"`
	ConsentAdminID      string `json:"consent_admin_id"`
	VehicleIdNum        string `json:"vin"`
	ConsentName         string `json:"name"`
	ConsentAction       string `json:"action"`
	DataSubjectCategory string `json:"data_subject_category"`
	Channel             string `json:"channel"`
}

func BuildUserConsentTrexMessage(ucd UserConsentDataResponse) UserConsentDataTrexMsg {
	return UserConsentDataTrexMsg{
		VehicleIdNum:        ucd.VehicleIdNum,
		ConsentName:         ucd.ConsentName,
		ConsentAction:       ucd.ConsentAction,
		Channel:             ucd.Channel,
		DataSubjectCategory: ucd.DataSubjectCategory,
		ConsentAdminID:      ucd.ConsentAdminID,
		UserID:              ucd.UserID,
	}
}
