package model

import "encoding/json"

// Event: EndpointList
// ObjectType: endpoint
// ObjectName: www
// Transport: UDP
// Aor: www
// Auths: www
// OutboundAuths: www
// Contacts:
// DeviceState: Unavailable
// ActiveChannels:

// Event: EndpointList
// ObjectType: endpoint
// ObjectName: 899
// Transport:
// Aor: 899
// Auths: 899
// OutboundAuths:
// Contacts:
// DeviceState: Unavailable
// ActiveChannels:

type EndpointList struct {
	Event          string `json:"Event"`
	ObjectType     string `json:"ObjectType"`
	ObjectName     string `json:"ObjectName"`
	Transport      string `json:"Transport"`
	Aor            string `json:"Aor"`
	Auths          string `json:"Auths"`
	OutboundAuths  string `json:"OutboundAuths"`
	Contacts       string `json:"Contacts"`
	DeviceState    string `json:"DeviceState"`
	ActiveChannels string `json:"ActiveChannels"`
}

// Event: PeerEntry
// Channeltype: SIP
// ObjectName: 875
// ChanObjectType: peer
// IPaddress: -none-
// IPport: 0
// Dynamic: yes
// AutoForcerport: no
// Forcerport: yes
// AutoComedia: no
// Comedia: yes
// VideoSupport: no
// TextSupport: no
// ACL: no
// Status: UNKNOWN
// RealtimeDevice: no
// Description:
// Accountcode:
type PeerEntry struct {
	Event          string `json:"Event"`
	Channeltype    string `json:"Channeltype"`
	ObjectName     string `json:"ObjectName"`
	ChanObjectType string `json:"ChanObjectType"`
	IPaddress      string `json:"IPaddress"`
	IPport         string `json:"IPport"`
	Dynamic        string `json:"Dynamic"`
	AutoForcerport string `json:"AutoForcerport"`
	Forcerport     string `json:"Forcerport"`
	AutoComedia    string `json:"AutoComedia"`
	Status         string `json:"Status"`
	RealtimeDevice string `json:"RealtimeDevice"`
}

// Event: ContactList
// ObjectType: contact
// ObjectName: 120;@199f77999ab9abe1ec7fbe48e0b51053
// ViaAddr: 192.168.17.183
// QualifyTimeout: 30.000000
// CallId: DBnHD24ea-7MTKkYj9ewfafR0KAmWv4z
// RegServer:
// PruneOnBoot: no
// Path:
// Endpoint: 120
// ViaPort: 60442
// AuthenticateQualify: no
// Uri: sip:120@192.168.17.183:60442;ob
// QualifyFrequency: 300
// UserAgent: Telephone 1.2.6
// ExpirationTime: 1620818122
// OutboundProxy:
// Status: Reachable
// RoundtripUsec: 85040
type ContactList struct {
	Event         string `json:"Event"`
	ObjectName    string `json:"ObjectName"`
	ViaAddr       string `json:"ViaAddr"`
	Uri           string `json:"Uri"`
	RoundtripUsec string `json:"RoundtripUsec"`
}

func (list ContactList) String() string {
	data, _ := json.Marshal(list)
	return string(data)
}

// 分机状态
// Event: ExtensionStatus
// Exten: 118
// Context: channelhints_exten
// Hint: PJSIP/118,CustomPresence:118
// Status: 4
// StatusText: Unavailable
type ExtensionStatus struct {
	Event      string `json:"event"`
	Exten      string `json:"extension"`
	Context    string `json:"context"`
	Hint       string `json:"hint"`
	Status     string `json:"status"`
	StatusText string `json:"statusText"`
}
