43 lines
832 B
Go
43 lines
832 B
Go
package server
|
|
|
|
import (
|
|
"code.severnaya.net/kordophone-mock/v2/data"
|
|
"code.severnaya.net/kordophone-mock/v2/model"
|
|
)
|
|
|
|
const VERSION = "Kordophone-2.0"
|
|
|
|
type Server struct {
|
|
version string
|
|
conversations []model.Conversation
|
|
}
|
|
|
|
func NewServer() *Server {
|
|
return &Server{
|
|
version: VERSION,
|
|
conversations: []model.Conversation{},
|
|
}
|
|
}
|
|
|
|
func (s *Server) Version() string {
|
|
return s.version
|
|
}
|
|
|
|
func (s *Server) Conversations() []model.Conversation {
|
|
return s.conversations
|
|
}
|
|
|
|
func (s *Server) AddConversation(c model.Conversation) {
|
|
s.conversations = append(s.conversations, c)
|
|
}
|
|
|
|
func (s *Server) PopulateWithTestData() {
|
|
numConversations := 100
|
|
cs := make([]model.Conversation, numConversations)
|
|
for i := 0; i < numConversations; i++ {
|
|
cs[i] = data.GenerateRandomConversation()
|
|
}
|
|
|
|
s.conversations = cs
|
|
}
|