From 7cd86ed42993a5c82c91bd171bab91a850df0289 Mon Sep 17 00:00:00 2001 From: Miguel de la Cruz Date: Tue, 11 Jul 2023 10:21:53 +0200 Subject: [PATCH] Remove the ToMap birthday method --- README.md | 5 +++++ model/birthdays.go | 11 ----------- notification/service_telegram.go | 2 +- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index e55c522..24bb886 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/model/birthdays.go b/model/birthdays.go index cbd64d6..e4a311a 100644 --- a/model/birthdays.go +++ b/model/birthdays.go @@ -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)) diff --git a/notification/service_telegram.go b/notification/service_telegram.go index f41c9f4..0dffdb8 100644 --- a/notification/service_telegram.go +++ b/notification/service_telegram.go @@ -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) }