-
Notifications
You must be signed in to change notification settings - Fork 10
/
subscription_auth_email_builder.rb
52 lines (40 loc) · 1.09 KB
/
subscription_auth_email_builder.rb
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
class SubscriptionAuthEmailBuilder
include Callable
def initialize(address:, token:, subscriber_list:, frequency:)
@address = address
@token = token
@subscriber_list = subscriber_list
@frequency = frequency
end
def call
Email.create!(
subject: subject,
body: body,
address: address,
)
end
private
attr_reader :address, :token, :frequency, :subscriber_list
def subject
"Confirm that you want to get emails from GOV.UK"
end
def body
<<~BODY
# Click the link to confirm that you want to get emails from GOV.UK
# [Yes, I want emails about #{subscriber_list.title}](#{link})
This link will stop working after 7 days.
#{I18n.t!("emails.subscription_auth.frequency.#{frequency}")}. You can change this at any time.
If you did not request this email, you can ignore it.
Thanks
GOV.UK emails
BODY
end
def link
PublicUrls.url_for(
base_path: "/email/subscriptions/authenticate",
token: token,
topic_id: subscriber_list.slug,
frequency: frequency,
)
end
end