// Package status holds functions that interact with the status of the server
package status

import (
	"time"

	"git.stinnesbeck.com/nils/artifacts/api"
)

// Announcements is used to display messages and when they were created
type Announcements struct {
	Message   string    `json:"message"`
	CreatedAt time.Time `json:"created_at"`
}

// ServerStatus is a struct that holds info on a server
type ServerStatus struct {
	Status           string          `json:"status"`
	Version          string          `json:"version"`
	CharactersOnline int             `json:"characters_online"`
	Announcements    []Announcements `json:"announcements"`
	LastWipe         string          `json:"last_wipe"`
	NextWipe         string          `json:"next_wipe"`
}

// Get tries to retrieve the status of the server
func Get() (ServerStatus, error) {
	return api.Get[ServerStatus]("/", nil)
}