package model

import (
	"crm-api/pkg/utils"
	"encoding/json"
)

type MeetMeListRooms struct {
	Activity   string `json:"activity"`
	Conference string `json:"conference"`
	Creation   string `json:"creation"`
	Event      string `json:"event"`
	Locked     string `json:"locked"`
	Marked     string `json:"marked"`
	Parties    string `json:"parties"`
}

type MeetmeList struct {
	Admin             string `json:"admin"`
	CallerIDName      string `json:"callerIDName"`
	CallerIDNum       string `json:"callerIDNumber"`
	Channel           string `json:"channel"`
	Conference        string `json:"conference"`
	ConnectedLineName string `json:"connectedLineName"`
	ConnectedLineNum  string `json:"connectedLineNumber"`
	Event             string `json:"event"`
	MarkedUser        string `json:"markedUser"`
	Muted             string `json:"muted"`
	Role              string `json:"role"`
	Talking           string `json:"talking"`
	UserNumber        string `json:"user"`
}

func (data *MeetmeList) MarshalJSON() ([]byte, error) {
	type Alias MeetmeList

	muted := utils.YesToOn(data.Muted)
	talking := utils.YesToOn(data.Talking)

	return json.Marshal(&struct {
		Talking string `json:"talking"`
		Muted   string `json:"muted"`
		*Alias
	}{
		Muted:   muted,
		Talking: talking,
		Alias:   (*Alias)(data),
	})
}

type MeetmeEnd struct {
	Event     string `json:"event"`
	Meetme    string `json:"meetme"`
	Timestamp string `json:"timestamp"`
}

type Meetme struct {
	CallerIDName      string `json:"callerIDName"`
	CallerIDNum       string `json:"callerIDNumber"`
	Channel           string `json:"channel"`
	ChannelState      string `json:"channelState"`
	ConnectedLineName string `json:"connectedLineName"`
	ConnectedLineNum  string `json:"connectedLineNumber"`
	Duration          string `json:"duration"`
	Context           string `json:"context"`
	Event             string `json:"event"`
	Exten             string `json:"exten"`
	Meetme            string `json:"meetme"`
	Priority          string `json:"priority"`
	Privilege         string `json:"privilege"`
	Timestamp         string `json:"timestamp"`
	User              string `json:"user"`
	Status            string `json:"status"`
}

type MeetmeJoin Meetme
type MeetmeLeave Meetme
type MeetmeMute Meetme
type MeetmeTalkRequest Meetme
type MeetmeTalking Meetme
