-
Notifications
You must be signed in to change notification settings - Fork 11
/
trb_advice_letter_internal_review.go
54 lines (43 loc) · 1.79 KB
/
trb_advice_letter_internal_review.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package email
import (
"bytes"
"context"
"path"
"github.com/google/uuid"
"github.com/cmsgov/easi-app/pkg/apperrors"
"github.com/cmsgov/easi-app/pkg/models"
)
// SendTRBAdviceLetterInternalReviewEmailInput contains the data needed to to send the TRB advice
// letter internal review email
type SendTRBAdviceLetterInternalReviewEmailInput struct {
TRBRequestID uuid.UUID
TRBRequestName string
TRBLeadName string
}
// trbAdviceLetterInternalReviewEmailTemplateParams contains the data needed for interpolation in
// the TRB advice letter internal review email template
type trbAdviceLetterInternalReviewEmailTemplateParams struct {
TRBLeadName string
TRBRequestName string
TRBAdminAdviceLetterLink string
}
// SendTRBAdviceLetterInternalReviewEmail sends an email to the EASI admin team indicating that an advice letter
// is ready for internal review
func (c Client) SendTRBAdviceLetterInternalReviewEmail(ctx context.Context, input SendTRBAdviceLetterInternalReviewEmailInput) error {
subject := "Advice letter for " + input.TRBRequestName + " is ready for internal review"
templateParams := trbAdviceLetterInternalReviewEmailTemplateParams{
TRBLeadName: input.TRBLeadName,
TRBRequestName: input.TRBRequestName,
TRBAdminAdviceLetterLink: c.urlFromPath(path.Join("trb", input.TRBRequestID.String(), "advice")),
}
var b bytes.Buffer
err := c.templates.trbAdviceLetterInternalReview.Execute(&b, templateParams)
if err != nil {
return &apperrors.NotificationError{Err: err, DestinationType: apperrors.DestinationTypeEmail}
}
err = c.sender.Send(ctx, []models.EmailAddress{c.config.TRBEmail}, nil, subject, b.String())
if err != nil {
return &apperrors.NotificationError{Err: err, DestinationType: apperrors.DestinationTypeEmail}
}
return nil
}