@@ -8,7 +8,7 @@ import { Context } from 'aws-lambda';
8
8
import { EnvironmentVariablesService } from '../lib/environment-variables-service' ;
9
9
import { CompactConfigurationClient } from '../lib/compact-configuration-client' ;
10
10
import { JurisdictionClient } from '../lib/jurisdiction-client' ;
11
- import { EmailNotificationService } from '../lib/email' ;
11
+ import { EmailNotificationService , EncumbranceNotificationService } from '../lib/email' ;
12
12
import { EmailNotificationEvent , EmailNotificationResponse } from '../lib/models/email-notification-service-event' ;
13
13
14
14
const environmentVariables = new EnvironmentVariablesService ( ) ;
@@ -22,6 +22,7 @@ interface LambdaProperties {
22
22
23
23
export class Lambda implements LambdaInterface {
24
24
private readonly emailService : EmailNotificationService ;
25
+ private readonly encumbranceService : EncumbranceNotificationService ;
25
26
26
27
constructor ( props : LambdaProperties ) {
27
28
const compactConfigurationClient = new CompactConfigurationClient ( {
@@ -41,6 +42,14 @@ export class Lambda implements LambdaInterface {
41
42
compactConfigurationClient : compactConfigurationClient ,
42
43
jurisdictionClient : jurisdictionClient
43
44
} ) ;
45
+
46
+ this . encumbranceService = new EncumbranceNotificationService ( {
47
+ logger : logger ,
48
+ sesClient : props . sesClient ,
49
+ s3Client : props . s3Client ,
50
+ compactConfigurationClient : compactConfigurationClient ,
51
+ jurisdictionClient : jurisdictionClient
52
+ } ) ;
44
53
}
45
54
46
55
/**
@@ -77,8 +86,8 @@ export class Lambda implements LambdaInterface {
77
86
if ( ! event . jurisdiction ) {
78
87
throw new Error ( 'Missing required jurisdiction field.' ) ;
79
88
}
80
- if ( ! event . templateVariables . privilegeId
81
- || ! event . templateVariables . providerFirstName
89
+ if ( ! event . templateVariables . privilegeId
90
+ || ! event . templateVariables . providerFirstName
82
91
|| ! event . templateVariables . providerLastName ) {
83
92
throw new Error ( 'Missing required template variables for privilegeDeactivationJurisdictionNotification template.' ) ;
84
93
}
@@ -135,6 +144,170 @@ export class Lambda implements LambdaInterface {
135
144
event . specificEmails
136
145
) ;
137
146
break ;
147
+ case 'licenseEncumbranceProviderNotification' :
148
+ if ( ! event . templateVariables . providerFirstName
149
+ || ! event . templateVariables . providerLastName
150
+ || ! event . templateVariables . encumberedJurisdiction
151
+ || ! event . templateVariables . licenseType
152
+ || ! event . templateVariables . effectiveStartDate ) {
153
+ throw new Error ( 'Missing required template variables for licenseEncumbranceProviderNotification template.' ) ;
154
+ }
155
+ await this . encumbranceService . sendLicenseEncumbranceProviderNotificationEmail (
156
+ event . compact ,
157
+ event . specificEmails || [ ] ,
158
+ event . templateVariables . providerFirstName ,
159
+ event . templateVariables . providerLastName ,
160
+ event . templateVariables . encumberedJurisdiction ,
161
+ event . templateVariables . licenseType ,
162
+ event . templateVariables . effectiveStartDate
163
+ ) ;
164
+ break ;
165
+ case 'licenseEncumbranceStateNotification' :
166
+ if ( ! event . jurisdiction ) {
167
+ throw new Error ( 'Missing required jurisdiction field for licenseEncumbranceStateNotification template.' ) ;
168
+ }
169
+ if ( ! event . templateVariables . providerFirstName
170
+ || ! event . templateVariables . providerLastName
171
+ || ! event . templateVariables . providerId
172
+ || ! event . templateVariables . encumberedJurisdiction
173
+ || ! event . templateVariables . licenseType
174
+ || ! event . templateVariables . effectiveStartDate ) {
175
+ throw new Error ( 'Missing required template variables for licenseEncumbranceStateNotification template.' ) ;
176
+ }
177
+ await this . encumbranceService . sendLicenseEncumbranceStateNotificationEmail (
178
+ event . compact ,
179
+ event . jurisdiction ,
180
+ event . templateVariables . providerFirstName ,
181
+ event . templateVariables . providerLastName ,
182
+ event . templateVariables . providerId ,
183
+ event . templateVariables . encumberedJurisdiction ,
184
+ event . templateVariables . licenseType ,
185
+ event . templateVariables . effectiveStartDate
186
+ ) ;
187
+ break ;
188
+ case 'licenseEncumbranceLiftingProviderNotification' :
189
+ if ( ! event . templateVariables . providerFirstName
190
+ || ! event . templateVariables . providerLastName
191
+ || ! event . templateVariables . liftedJurisdiction
192
+ || ! event . templateVariables . licenseType
193
+ || ! event . templateVariables . effectiveLiftDate ) {
194
+ throw new Error ( 'Missing required template variables for licenseEncumbranceLiftingProviderNotification template.' ) ;
195
+ }
196
+ await this . encumbranceService . sendLicenseEncumbranceLiftingProviderNotificationEmail (
197
+ event . compact ,
198
+ event . specificEmails || [ ] ,
199
+ event . templateVariables . providerFirstName ,
200
+ event . templateVariables . providerLastName ,
201
+ event . templateVariables . liftedJurisdiction ,
202
+ event . templateVariables . licenseType ,
203
+ event . templateVariables . effectiveLiftDate
204
+ ) ;
205
+ break ;
206
+ case 'licenseEncumbranceLiftingStateNotification' :
207
+ if ( ! event . jurisdiction ) {
208
+ throw new Error ( 'Missing required jurisdiction field for licenseEncumbranceLiftingStateNotification template.' ) ;
209
+ }
210
+ if ( ! event . templateVariables . providerFirstName
211
+ || ! event . templateVariables . providerLastName
212
+ || ! event . templateVariables . providerId
213
+ || ! event . templateVariables . liftedJurisdiction
214
+ || ! event . templateVariables . licenseType
215
+ || ! event . templateVariables . effectiveLiftDate ) {
216
+ throw new Error ( 'Missing required template variables for licenseEncumbranceLiftingStateNotification template.' ) ;
217
+ }
218
+ await this . encumbranceService . sendLicenseEncumbranceLiftingStateNotificationEmail (
219
+ event . compact ,
220
+ event . jurisdiction ,
221
+ event . templateVariables . providerFirstName ,
222
+ event . templateVariables . providerLastName ,
223
+ event . templateVariables . providerId ,
224
+ event . templateVariables . liftedJurisdiction ,
225
+ event . templateVariables . licenseType ,
226
+ event . templateVariables . effectiveLiftDate
227
+ ) ;
228
+ break ;
229
+ case 'privilegeEncumbranceProviderNotification' :
230
+ if ( ! event . templateVariables . providerFirstName
231
+ || ! event . templateVariables . providerLastName
232
+ || ! event . templateVariables . encumberedJurisdiction
233
+ || ! event . templateVariables . licenseType
234
+ || ! event . templateVariables . effectiveStartDate ) {
235
+ throw new Error ( 'Missing required template variables for privilegeEncumbranceProviderNotification template.' ) ;
236
+ }
237
+ await this . encumbranceService . sendPrivilegeEncumbranceProviderNotificationEmail (
238
+ event . compact ,
239
+ event . specificEmails || [ ] ,
240
+ event . templateVariables . providerFirstName ,
241
+ event . templateVariables . providerLastName ,
242
+ event . templateVariables . encumberedJurisdiction ,
243
+ event . templateVariables . licenseType ,
244
+ event . templateVariables . effectiveStartDate
245
+ ) ;
246
+ break ;
247
+ case 'privilegeEncumbranceStateNotification' :
248
+ if ( ! event . jurisdiction ) {
249
+ throw new Error ( 'Missing required jurisdiction field for privilegeEncumbranceStateNotification template.' ) ;
250
+ }
251
+ if ( ! event . templateVariables . providerFirstName
252
+ || ! event . templateVariables . providerLastName
253
+ || ! event . templateVariables . providerId
254
+ || ! event . templateVariables . encumberedJurisdiction
255
+ || ! event . templateVariables . licenseType
256
+ || ! event . templateVariables . effectiveStartDate ) {
257
+ throw new Error ( 'Missing required template variables for privilegeEncumbranceStateNotification template.' ) ;
258
+ }
259
+ await this . encumbranceService . sendPrivilegeEncumbranceStateNotificationEmail (
260
+ event . compact ,
261
+ event . jurisdiction ,
262
+ event . templateVariables . providerFirstName ,
263
+ event . templateVariables . providerLastName ,
264
+ event . templateVariables . providerId ,
265
+ event . templateVariables . encumberedJurisdiction ,
266
+ event . templateVariables . licenseType ,
267
+ event . templateVariables . effectiveStartDate
268
+ ) ;
269
+ break ;
270
+ case 'privilegeEncumbranceLiftingProviderNotification' :
271
+ if ( ! event . templateVariables . providerFirstName
272
+ || ! event . templateVariables . providerLastName
273
+ || ! event . templateVariables . liftedJurisdiction
274
+ || ! event . templateVariables . licenseType
275
+ || ! event . templateVariables . effectiveLiftDate ) {
276
+ throw new Error ( 'Missing required template variables for privilegeEncumbranceLiftingProviderNotification template.' ) ;
277
+ }
278
+ await this . encumbranceService . sendPrivilegeEncumbranceLiftingProviderNotificationEmail (
279
+ event . compact ,
280
+ event . specificEmails || [ ] ,
281
+ event . templateVariables . providerFirstName ,
282
+ event . templateVariables . providerLastName ,
283
+ event . templateVariables . liftedJurisdiction ,
284
+ event . templateVariables . licenseType ,
285
+ event . templateVariables . effectiveLiftDate
286
+ ) ;
287
+ break ;
288
+ case 'privilegeEncumbranceLiftingStateNotification' :
289
+ if ( ! event . jurisdiction ) {
290
+ throw new Error ( 'Missing required jurisdiction field for privilegeEncumbranceLiftingStateNotification template.' ) ;
291
+ }
292
+ if ( ! event . templateVariables . providerFirstName
293
+ || ! event . templateVariables . providerLastName
294
+ || ! event . templateVariables . providerId
295
+ || ! event . templateVariables . liftedJurisdiction
296
+ || ! event . templateVariables . licenseType
297
+ || ! event . templateVariables . effectiveLiftDate ) {
298
+ throw new Error ( 'Missing required template variables for privilegeEncumbranceLiftingStateNotification template.' ) ;
299
+ }
300
+ await this . encumbranceService . sendPrivilegeEncumbranceLiftingStateNotificationEmail (
301
+ event . compact ,
302
+ event . jurisdiction ,
303
+ event . templateVariables . providerFirstName ,
304
+ event . templateVariables . providerLastName ,
305
+ event . templateVariables . providerId ,
306
+ event . templateVariables . liftedJurisdiction ,
307
+ event . templateVariables . licenseType ,
308
+ event . templateVariables . effectiveLiftDate
309
+ ) ;
310
+ break ;
138
311
case 'multipleRegistrationAttemptNotification' :
139
312
if ( ! event . specificEmails ?. length ) {
140
313
throw new Error ( 'No recipients found for multiple registration attempt notification email' ) ;
0 commit comments