Private
Public Access
1
0
Files
Kordophone/server/server.go

41 lines
796 B
Go
Raw Normal View History

package server
import (
"code.severnaya.net/kordophone-mock/v2/data"
"code.severnaya.net/kordophone-mock/v2/model"
)
type Server struct {
version string
conversations []model.Conversation
}
func NewServer() *Server {
return &Server{
version: "1.0",
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
}