package dto

import "time"

type ContactBaseAttributes struct {
	Email       string `json:"email,omitempty" validate:"omitempty,email"`
	SSOEmail    string `json:"sso_email,omitempty" validate:"omitempty,email"`
	IsAdmin     *bool  `json:"is_admin,omitempty"`
	Username    string `json:"username,omitempty" validate:"omitempty,max=100"`
	FirstName   string `json:"first_name,omitempty" validate:"omitempty,max=100"`
	LastName    string `json:"last_name,omitempty" validate:"omitempty,max=100"`
	MobilePhone string `json:"mobile_phone,omitempty" validate:"omitempty,max=32"`
	Timezone    string `json:"timezone,omitempty" validate:"omitempty,max=64"`
	FileUUID    string `json:"file_uuid,omitempty" validate:"omitempty,max=64"`
	SortKey     *int   `json:"sortkey"`
	IsActive    *bool  `json:"is_active,omitempty"`
}

type PilotProfileAttributes struct {
	PilotCategory           string     `json:"pilot_category,omitempty" validate:"omitempty,oneof=regular freelance dry_lease"`
	ShortName               string     `json:"short_name,omitempty" validate:"omitempty,max=120"`
	LicenseNo               string     `json:"license_no,omitempty" validate:"omitempty,max=120"`
	LicenseIssuedAt         *time.Time `json:"license_issued_at,omitempty"`
	LicenseExpiredAt        *time.Time `json:"license_expired_at,omitempty"`
	TechnicianLicenseNo     string     `json:"technician_license_no,omitempty" validate:"omitempty,max=120"`
	HasIFRQualification     *bool      `json:"has_ifr_qualification,omitempty"`
	IsChiefPilot            *bool      `json:"is_chief_pilot,omitempty"`
	DULBaseIDs              []string   `json:"dul_base_ids,omitempty" validate:"omitempty,dive,uuid" swaggerignore:"true"`
	DULBase                 []DULBase  `json:"dul_base,omitempty"`
	TotalFlightMinutes      *int       `json:"total_flight_minutes,omitempty"`
	ResponsiblePilotMinutes *int       `json:"responsible_pilot_minutes,omitempty"`
	SecondPilotMinutes      *int       `json:"second_pilot_minutes,omitempty"`
	DoubleCommandMinutes    *int       `json:"double_command_minutes,omitempty"`
	FlightInstructorMinutes *int       `json:"flight_instructor_minutes,omitempty"`
	NightFlightMinutes      *int       `json:"night_flight_minutes,omitempty"`
	IFRFlightMinutes        *int       `json:"ifr_flight_minutes,omitempty"`
	Location                string     `json:"location,omitempty" validate:"omitempty,max=255"`
	Postcode                string     `json:"postcode,omitempty" validate:"omitempty,max=32"`
	StreetLine              string     `json:"street_line,omitempty" validate:"omitempty,max=255"`
	Note                    string     `json:"note,omitempty"`
	WeightKG                *float64   `json:"weight_kg,omitempty"`
}

type DULBase struct {
	ID       string `json:"id" example:"0197f3b2-c4d8-4b12-a1f9-c1de23456789"`
	Name     string `json:"name" example:"Halim Base"`
	Category string `json:"category" example:"hems"`
}

type DoctorProfileAttributes struct {
	ShortName         string `json:"short_name,omitempty" validate:"omitempty,max=120"`
	Specialization    string `json:"specialization,omitempty" validate:"omitempty,max=120"`
	SubSpecialization string `json:"sub_specialization,omitempty" validate:"omitempty,max=120"`
	IsChiefPhysician  *bool  `json:"is_chief_physician,omitempty"`
	Location          string `json:"location,omitempty" validate:"omitempty,max=255"`
	Postcode          string `json:"postcode,omitempty" validate:"omitempty,max=32"`
	StreetLine        string `json:"street_line,omitempty" validate:"omitempty,max=255"`
	Note              string `json:"note,omitempty"`
}

type AirRescuerProfileAttributes struct {
	ShortName                string `json:"short_name,omitempty" validate:"omitempty,max=120"`
	ResponsibleFlightRescuer *bool  `json:"responsible_flight_rescuer,omitempty"`
	Location                 string `json:"location,omitempty" validate:"omitempty,max=255"`
	Postcode                 string `json:"postcode,omitempty" validate:"omitempty,max=32"`
	StreetLine               string `json:"street_line,omitempty" validate:"omitempty,max=255"`
	Note                     string `json:"note,omitempty"`
}

type TechnicianProfileAttributes struct {
	ShortName               string `json:"short_name,omitempty" validate:"omitempty,max=120"`
	LicenseNo               string `json:"license_no,omitempty" validate:"omitempty,max=120"`
	IsChiefTechnician       *bool  `json:"is_chief_technician,omitempty"`
	IsResponsibleComplaints *bool  `json:"is_responsible_complaints,omitempty"`
	Location                string `json:"location,omitempty" validate:"omitempty,max=255"`
	Postcode                string `json:"postcode,omitempty" validate:"omitempty,max=32"`
	StreetLine              string `json:"street_line,omitempty" validate:"omitempty,max=255"`
	Note                    string `json:"note,omitempty"`
}

type FlightAssistantProfileAttributes struct {
	ShortName  string `json:"short_name,omitempty" validate:"omitempty,max=120"`
	Location   string `json:"location,omitempty" validate:"omitempty,max=255"`
	Postcode   string `json:"postcode,omitempty" validate:"omitempty,max=32"`
	StreetLine string `json:"street_line,omitempty" validate:"omitempty,max=255"`
	Note       string `json:"note,omitempty"`
}

type StaffProfileAttributes struct {
	ShortName  string `json:"short_name,omitempty" validate:"omitempty,max=120"`
	RoleLabel  string `json:"role_label,omitempty" validate:"omitempty,max=120"`
	Location   string `json:"location,omitempty" validate:"omitempty,max=255"`
	Postcode   string `json:"postcode,omitempty" validate:"omitempty,max=32"`
	StreetLine string `json:"street_line,omitempty" validate:"omitempty,max=255"`
	Note       string `json:"note,omitempty"`
}

type ContactCreateAttributes struct {
	RoleID  string   `json:"role_id,omitempty" example:"0195f6f8-0f8d-7e3e-b8f2-8abff9b5c1d1"`
	RoleIDs []string `json:"role_ids,omitempty" example:"0195f6f8-0f8d-7e3e-b8f2-8abff9b5c1d1,0195f6f8-0f8d-7e3e-b8f2-8abff9b5c1d2"`
	ContactBaseAttributes
	AirRescuer      *AirRescuerProfileAttributes      `json:"air_rescuer,omitempty"`
	Doctor          *DoctorProfileAttributes          `json:"doctor,omitempty"`
	FlightAssistant *FlightAssistantProfileAttributes `json:"flight_assistant,omitempty"`
	Pilot           *PilotProfileAttributes           `json:"pilot,omitempty"`
	Staff           *StaffProfileAttributes           `json:"staff,omitempty"`
	Technician      *TechnicianProfileAttributes      `json:"technician,omitempty"`
}

type ContactCreateData struct {
	Type       string                  `json:"type" validate:"required" example:"contact_create"`
	Attributes ContactCreateAttributes `json:"attributes" validate:"required"`
}

type ContactCreateRequest struct {
	Data ContactCreateData `json:"data" validate:"required"`
}

type PilotProfileUpdateAttributes struct {
	PilotCategory           *string    `json:"pilot_category,omitempty" validate:"omitempty,oneof=regular freelance dry_lease"`
	ShortName               *string    `json:"short_name,omitempty" validate:"omitempty,max=120"`
	LicenseNo               *string    `json:"license_no,omitempty" validate:"omitempty,max=120"`
	LicenseIssuedAt         *time.Time `json:"license_issued_at,omitempty"`
	LicenseExpiredAt        *time.Time `json:"license_expired_at,omitempty"`
	TechnicianLicenseNo     *string    `json:"technician_license_no,omitempty" validate:"omitempty,max=120"`
	HasIFRQualification     *bool      `json:"has_ifr_qualification,omitempty"`
	IsChiefPilot            *bool      `json:"is_chief_pilot,omitempty"`
	DULBaseIDs              []string   `json:"dul_base_ids,omitempty" validate:"omitempty,dive,uuid" swaggerignore:"true"`
	DULBase                 []DULBase  `json:"dul_base,omitempty"`
	TotalFlightMinutes      *int       `json:"total_flight_minutes,omitempty"`
	ResponsiblePilotMinutes *int       `json:"responsible_pilot_minutes,omitempty"`
	SecondPilotMinutes      *int       `json:"second_pilot_minutes,omitempty"`
	DoubleCommandMinutes    *int       `json:"double_command_minutes,omitempty"`
	FlightInstructorMinutes *int       `json:"flight_instructor_minutes,omitempty"`
	NightFlightMinutes      *int       `json:"night_flight_minutes,omitempty"`
	IFRFlightMinutes        *int       `json:"ifr_flight_minutes,omitempty"`
	Location                *string    `json:"location,omitempty" validate:"omitempty,max=255"`
	Postcode                *string    `json:"postcode,omitempty" validate:"omitempty,max=32"`
	StreetLine              *string    `json:"street_line,omitempty" validate:"omitempty,max=255"`
	Note                    *string    `json:"note,omitempty"`
	WeightKG                *float64   `json:"weight_kg,omitempty"`
}

type DoctorProfileUpdateAttributes struct {
	ShortName         *string `json:"short_name,omitempty" validate:"omitempty,max=120"`
	Specialization    *string `json:"specialization,omitempty" validate:"omitempty,max=120"`
	SubSpecialization *string `json:"sub_specialization,omitempty" validate:"omitempty,max=120"`
	IsChiefPhysician  *bool   `json:"is_chief_physician,omitempty"`
	Location          *string `json:"location,omitempty" validate:"omitempty,max=255"`
	Postcode          *string `json:"postcode,omitempty" validate:"omitempty,max=32"`
	StreetLine        *string `json:"street_line,omitempty" validate:"omitempty,max=255"`
	Note              *string `json:"note,omitempty"`
}

type AirRescuerProfileUpdateAttributes struct {
	ShortName                *string `json:"short_name,omitempty" validate:"omitempty,max=120"`
	ResponsibleFlightRescuer *bool   `json:"responsible_flight_rescuer,omitempty"`
	Location                 *string `json:"location,omitempty" validate:"omitempty,max=255"`
	Postcode                 *string `json:"postcode,omitempty" validate:"omitempty,max=32"`
	StreetLine               *string `json:"street_line,omitempty" validate:"omitempty,max=255"`
	Note                     *string `json:"note,omitempty"`
}

type TechnicianProfileUpdateAttributes struct {
	ShortName               *string `json:"short_name,omitempty" validate:"omitempty,max=120"`
	LicenseNo               *string `json:"license_no,omitempty" validate:"omitempty,max=120"`
	IsChiefTechnician       *bool   `json:"is_chief_technician,omitempty"`
	IsResponsibleComplaints *bool   `json:"is_responsible_complaints,omitempty"`
	Location                *string `json:"location,omitempty" validate:"omitempty,max=255"`
	Postcode                *string `json:"postcode,omitempty" validate:"omitempty,max=32"`
	StreetLine              *string `json:"street_line,omitempty" validate:"omitempty,max=255"`
	Note                    *string `json:"note,omitempty"`
}

type FlightAssistantProfileUpdateAttributes struct {
	ShortName  *string `json:"short_name,omitempty" validate:"omitempty,max=120"`
	Location   *string `json:"location,omitempty" validate:"omitempty,max=255"`
	Postcode   *string `json:"postcode,omitempty" validate:"omitempty,max=32"`
	StreetLine *string `json:"street_line,omitempty" validate:"omitempty,max=255"`
	Note       *string `json:"note,omitempty"`
}

type StaffProfileUpdateAttributes struct {
	ShortName  *string `json:"short_name,omitempty" validate:"omitempty,max=120"`
	RoleLabel  *string `json:"role_label,omitempty" validate:"omitempty,max=120"`
	Location   *string `json:"location,omitempty" validate:"omitempty,max=255"`
	Postcode   *string `json:"postcode,omitempty" validate:"omitempty,max=32"`
	StreetLine *string `json:"street_line,omitempty" validate:"omitempty,max=255"`
	Note       *string `json:"note,omitempty"`
}

type ContactUpdateAttributes struct {
	RoleID          *string                                 `json:"role_id,omitempty" example:"0195f6f8-0f8d-7e3e-b8f2-8abff9b5c1d1"`
	RoleIDs         []string                                `json:"role_ids,omitempty" example:"0195f6f8-0f8d-7e3e-b8f2-8abff9b5c1d1,0195f6f8-0f8d-7e3e-b8f2-8abff9b5c1d2"`
	Email           *string                                 `json:"email,omitempty" validate:"omitempty,email"`
	SSOEmail        *string                                 `json:"sso_email,omitempty" validate:"omitempty,email"`
	IsAdmin         *bool                                   `json:"is_admin,omitempty"`
	Username        *string                                 `json:"username,omitempty" validate:"omitempty,max=100"`
	FirstName       *string                                 `json:"first_name,omitempty" validate:"omitempty,max=100"`
	LastName        *string                                 `json:"last_name,omitempty" validate:"omitempty,max=100"`
	MobilePhone     *string                                 `json:"mobile_phone,omitempty" validate:"omitempty,max=32"`
	Timezone        *string                                 `json:"timezone,omitempty" validate:"omitempty,max=64"`
	FileUUID        *string                                 `json:"file_uuid,omitempty" validate:"omitempty,max=64"`
	SortKey         NullInt                                 `json:"sortkey,omitempty" swaggertype:"integer"`
	IsActive        *bool                                   `json:"is_active,omitempty"`
	AirRescuer      *AirRescuerProfileUpdateAttributes      `json:"air_rescuer,omitempty"`
	Doctor          *DoctorProfileUpdateAttributes          `json:"doctor,omitempty"`
	FlightAssistant *FlightAssistantProfileUpdateAttributes `json:"flight_assistant,omitempty"`
	Pilot           *PilotProfileUpdateAttributes           `json:"pilot,omitempty"`
	Staff           *StaffProfileUpdateAttributes           `json:"staff,omitempty"`
	Technician      *TechnicianProfileUpdateAttributes      `json:"technician,omitempty"`
}

type ContactUpdateData struct {
	Type       string                  `json:"type" validate:"required" example:"contact_update"`
	Attributes ContactUpdateAttributes `json:"attributes" validate:"required"`
}

type ContactUpdateRequest struct {
	Data ContactUpdateData `json:"data" validate:"required"`
}

type ContactListQuery struct {
	Role          string `query:"role" validate:"omitempty,oneof=pilot doctor air_rescuer technician flight_assistant staff"`
	PilotCategory string `query:"pilot_category" validate:"omitempty,oneof=regular freelance dry_lease"`
	Search        string `query:"search"`
	Sort          string `query:"sort"`
	Limit         int    `query:"limit" validate:"omitempty,min=1,max=200"`
	Offset        int    `query:"offset" validate:"omitempty,min=0"`
}

type ContactListItem struct {
	ID            string `json:"id"`
	CreatedBy     string `json:"created_by,omitempty"`
	UpdatedBy     string `json:"updated_by,omitempty"`
	CreatedAt     string `json:"created_at,omitempty"`
	UpdatedAt     string `json:"updated_at,omitempty"`
	RoleCode      string `json:"role_code"`
	RoleName      string `json:"role_name"`
	PilotCategory string `json:"pilot_category,omitempty"`
	Username      string `json:"username,omitempty"`
	Email         string `json:"email"`
	IsAdmin       bool   `json:"is_admin"`
	FirstName     string `json:"first_name"`
	LastName      string `json:"last_name"`
	ShortName     string `json:"short_name,omitempty"`
	LicenseNo     string `json:"license_no,omitempty"`
	Location      string `json:"location,omitempty"`
	MobilePhone   string `json:"mobile_phone,omitempty"`
	SortKey       *int   `json:"sortkey"`
	Note          string `json:"note,omitempty"`
	IsActive      bool   `json:"is_active"`
	SetPassword   bool   `json:"set_password"`
}

type ContactBaseRole struct {
	BaseID   string `json:"base_id"`
	BaseName string `json:"base_name"`
	RoleCode string `json:"role_code"`
}

type ContactRole struct {
	ID       string `json:"id"`
	RoleCode string `json:"role_code"`
	RoleName string `json:"role_name"`
}

type ContactListAttributes struct {
	Email           string                            `json:"email,omitempty"`
	Username        string                            `json:"username,omitempty"`
	FirstName       string                            `json:"first_name,omitempty"`
	LastName        string                            `json:"last_name,omitempty"`
	MobilePhone     string                            `json:"mobile_phone,omitempty"`
	IsAdmin         bool                              `json:"is_admin"`
	IsActive        bool                              `json:"is_active"`
	SetPassword     bool                              `json:"set_password"`
	SortKey         *int                              `json:"sortkey"`
	SSOEmail        *string                           `json:"sso_email"`
	CreatedAt       string                            `json:"created_at,omitempty"`
	CreatedBy       string                            `json:"created_by,omitempty"`
	UpdatedAt       string                            `json:"updated_at,omitempty"`
	UpdatedBy       string                            `json:"updated_by,omitempty"`
	BaseRoles       []ContactBaseRole                 `json:"base_roles"`
	RoleCode        string                            `json:"role_code,omitempty"`
	RoleName        string                            `json:"role_name,omitempty"`
	Roles           []ContactRole                     `json:"roles"`
	PilotCategory   string                            `json:"pilot_category,omitempty"`
	ShortName       string                            `json:"short_name,omitempty"`
	LicenseNo       string                            `json:"license_no,omitempty"`
	Location        string                            `json:"location,omitempty"`
	Note            string                            `json:"note,omitempty"`
	Pilot           *PilotProfileAttributes           `json:"pilot,omitempty"`
	Doctor          *DoctorProfileAttributes          `json:"doctor,omitempty"`
	AirRescuer      *AirRescuerProfileAttributes      `json:"air_rescuer,omitempty"`
	Technician      *TechnicianProfileAttributes      `json:"technician,omitempty"`
	FlightAssistant *FlightAssistantProfileAttributes `json:"flight_assistant,omitempty"`
	Staff           *StaffProfileAttributes           `json:"staff,omitempty"`
}

type ContactListResponse struct {
	Data []struct {
		Type       string                `json:"type" example:"contact"`
		ID         string                `json:"id" example:"019dcce4-f15e-7685-8e4c-76f8ad20594b"`
		Attributes ContactListAttributes `json:"attributes"`
	} `json:"data"`
	Meta struct {
		Total  int64 `json:"total"`
		Limit  int   `json:"limit"`
		Offset int   `json:"offset"`
	} `json:"meta"`
}

type ContactDataTableResponse struct {
	Data []ContactListItem `json:"data"`
	Meta struct {
		Draw            int   `json:"draw" example:"1"`
		RecordsTotal    int64 `json:"records_total" example:"120"`
		RecordsFiltered int64 `json:"records_filtered" example:"12"`
	} `json:"meta"`
}

type SensitiveActionRequiredResponse struct {
	Data struct {
		Type       string `json:"type" example:"pin_verification_required"`
		Attributes struct {
			Required bool   `json:"required" example:"true"`
			Action   string `json:"action"`
			Method   string `json:"method" example:"pin"`
			Status   int    `json:"status" example:"202"`
		} `json:"attributes"`
	} `json:"data"`
}

type ContactStatusUpdateData struct {
	Type       string `json:"type" validate:"required,eq=contact_status_update"`
	Attributes struct {
		IsActive bool `json:"is_active"`
	} `json:"attributes" validate:"required"`
}

type ContactStatusUpdateRequest struct {
	Data ContactStatusUpdateData `json:"data" validate:"required"`
}

type ContactRoleUpdateData struct {
	Type       string `json:"type" validate:"required,eq=contact_role_update"`
	Attributes struct {
		RoleCode string `json:"role_code" validate:"required,oneof=pilot doctor air_rescuer technician flight_assistant staff"`
	} `json:"attributes" validate:"required"`
}

type ContactRoleUpdateRequest struct {
	Data ContactRoleUpdateData `json:"data" validate:"required"`
}

type ContactPilotCategoryUpdateData struct {
	Type       string `json:"type" validate:"required,eq=contact_pilot_category_update"`
	Attributes struct {
		PilotCategory string `json:"pilot_category" validate:"required,oneof=regular freelance dry_lease"`
	} `json:"attributes" validate:"required"`
}

type ContactPilotCategoryUpdateRequest struct {
	Data ContactPilotCategoryUpdateData `json:"data" validate:"required"`
}

type ContactLicenseUpdateData struct {
	Type       string `json:"type" validate:"required,eq=contact_license_update"`
	Attributes struct {
		LicenseNo *string `json:"license_no,omitempty"`
	} `json:"attributes" validate:"required"`
}

type ContactLicenseUpdateRequest struct {
	Data ContactLicenseUpdateData `json:"data" validate:"required"`
}

type ContactChiefFlagsUpdateData struct {
	Type       string `json:"type" validate:"required,eq=contact_chief_flags_update"`
	Attributes struct {
		IsChiefPilot             *bool `json:"is_chief_pilot,omitempty"`
		IsChiefPhysician  *bool `json:"is_chief_physician,omitempty"`
		IsChiefTechnician *bool `json:"is_chief_technician,omitempty"`
	} `json:"attributes" validate:"required"`
}

type ContactChiefFlagsUpdateRequest struct {
	Data ContactChiefFlagsUpdateData `json:"data" validate:"required"`
}

type ContactResponsibleComplaintsData struct {
	Type       string `json:"type" validate:"required,eq=contact_responsible_complaints_update"`
	Attributes struct {
		IsResponsibleComplaints bool `json:"is_responsible_complaints"`
	} `json:"attributes" validate:"required"`
}

type ContactResponsibleComplaintsRequest struct {
	Data ContactResponsibleComplaintsData `json:"data" validate:"required"`
}

type ContactBulkUpdateData struct {
	Type       string `json:"type" validate:"required,eq=contact_bulk_update" example:"contact_bulk_update"`
	Attributes struct {
		UserIDs  []string `json:"user_ids" validate:"required,min=1,dive,required" example:"0195f6f8-0f8d-7e3e-b8f2-8abff9b5c1d1"`
		IsActive bool     `json:"is_active" example:"true"`
	} `json:"attributes" validate:"required"`
}

type ContactBulkUpdateRequest struct {
	Data ContactBulkUpdateData `json:"data" validate:"required"`
}

type ContactSimpleSuccessResponse struct {
	Data struct {
		Type       string `json:"type"`
		Attributes struct {
			Updated bool  `json:"updated,omitempty"`
			Deleted bool  `json:"deleted,omitempty"`
			Count   int64 `json:"count,omitempty"`
		} `json:"attributes"`
	} `json:"data"`
}
