-
Notifications
You must be signed in to change notification settings - Fork 11
/
help_report_a_problem.go
40 lines (32 loc) · 1.17 KB
/
help_report_a_problem.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package email
import (
"bytes"
"context"
"github.com/cmsgov/easi-app/pkg/apperrors"
"github.com/cmsgov/easi-app/pkg/models"
)
// SendReportAProblemEmailInput contains the data submitted by the user to the "report a problem" help form
type SendReportAProblemEmailInput struct {
IsAnonymous bool
ReporterName string
ReporterEmail string
CanBeContacted bool
EasiService string
WhatWereYouDoing string
WhatWentWrong string
HowSevereWasTheProblem string
}
// SendReportAProblemEmail sends an email to the EASI team containing a user's request for help
func (c Client) SendReportAProblemEmail(ctx context.Context, input SendReportAProblemEmailInput) error {
subject := "EASi Problem Report"
var b bytes.Buffer
err := c.templates.helpReportAProblem.Execute(&b, input)
if err != nil {
return &apperrors.NotificationError{Err: err, DestinationType: apperrors.DestinationTypeEmail}
}
err = c.sender.Send(ctx, []models.EmailAddress{c.config.EASIHelpEmail}, nil, subject, b.String())
if err != nil {
return &apperrors.NotificationError{Err: err, DestinationType: apperrors.DestinationTypeEmail}
}
return nil
}