package common

import (
	"time"

	"github.com/fiskerinc/cloud-services/pkg/common/dbbasemodel"
	"github.com/google/uuid"
)

type Subscription struct {
	ID                 int64     `json:"-" pg:",pk"`
	SubscriptionTypeID uuid.UUID `json:"-" pg:"type:uuid" validate:"required"`
	CarToDriverID      int64     `json:"-" validate:"required,max=256"`
	Name               string    `json:"name" validate:"required,max=256"`
	Destination        string    `json:"destination" validate:"required,max=10"`
	Expires            time.Time `json:"expires"`
	dbbasemodel.DBModelBase
}

type MobileSubscriptionUpdate struct {
	VIN           string         `json:"vin"`
	Subscriptions []Subscription `json:"subscriptions"`
}

func (m *MobileSubscriptionUpdate) Clear() {
	for i := range m.Subscriptions {
		sub := &m.Subscriptions[i]
		sub.ClearDates()
	}
}

type HMISubscriptionUpdate struct {
	DriverID      string         `json:"driver_id"`
	Subscriptions []Subscription `json:"subscriptions"`
}

func (h *HMISubscriptionUpdate) Clear() {
	for i := range h.Subscriptions {
		sub := &h.Subscriptions[i]
		sub.ClearDates()
	}
}
