Remove the ToMap birthday method

This commit is contained in:
Miguel de la Cruz 2023-07-11 10:21:53 +02:00
parent 1918740563
commit 7cd86ed429
3 changed files with 6 additions and 12 deletions

View file

@ -24,6 +24,11 @@ Template Format, and has the following properties available:
- `.MonthOfBirth`: the month that the person was born, as number.
- `.DayOfBirth`: the day that the person was born, as number.
There are as well some functions available to be used:
- `getYeardsOld`: receives the year that a user was born, and returns
how old the user is getting.
### Pictures
Alongside the notification for each birthday, the bot can send a

View file

@ -19,17 +19,6 @@ func (b *Birthday) Filename() string {
return fmt.Sprintf("%d_%d_%d_%s.png", b.YearOfBirth, b.MonthOfBirth, b.DayOfBirth, b.Phone)
}
func (b *Birthday) ToMap() map[string]any {
return map[string]any{
"Name": b.Name,
"Email": b.Email,
"Phone": b.Phone,
"YearOfBirth": b.YearOfBirth,
"MonthOfBirth": b.MonthOfBirth,
"DayOfBirth": b.DayOfBirth,
}
}
func NewBirthdayFromRecord(record []string) (*Birthday, error) {
if len(record) != 4 {
return nil, fmt.Errorf("invalid length %d for record", len(record))

View file

@ -43,7 +43,7 @@ func (tns *TelegramNotificationService) Notify(birthday *model.Birthday, templat
var msgText string
if template != nil {
var stringBuffer bytes.Buffer
if err := template.Execute(&stringBuffer, birthday.ToMap()); err != nil {
if err := template.Execute(&stringBuffer, birthday); err != nil {
return fmt.Errorf("cannot execute template for birthday: %w", err)
}