27 lines
508 B
Go
27 lines
508 B
Go
package server
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"git.ctrlz.es/mgdelacroix/birthdaybot/model"
|
|
"git.ctrlz.es/mgdelacroix/birthdaybot/parser"
|
|
)
|
|
|
|
type Server struct {
|
|
config *model.Config
|
|
birthdays []*model.Birthday
|
|
}
|
|
|
|
func New(config *model.Config) (*Server, error) {
|
|
birthdays, err := parser.ParseCSV(config.BirthdayFile)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("cannot parse CSV file %s: %w", config.BirthdayFile, err)
|
|
}
|
|
|
|
server := &Server{
|
|
config: config,
|
|
birthdays: birthdays,
|
|
}
|
|
|
|
return server, nil
|
|
}
|