import * as Hapi from '@hapi/hapi' ; import { IInProgressPayload , IDeclarationPayload , IRegistrationPayload , IRejectionPayload } from '@notification/features/sms/birth-handler' ; import { buildAndSendSMS , getTranslations } from '@notification/features/sms/utils' ; import { logger } from '@notification/logger' ; import { getDefaultLanguage } from '@notification/i18n/utils' ; import { messageKeys } from '@notification/i18n/messages' ; export async function sendDeathInProgressConfirmation ( request , h ) { const payload = request . payload as IInProgressPayload ; logger . info ( `Notification service sendDeathInProgressConfirmation calling sendSMS: ${ JSON . stringify ( payload ) }` ) ; const authHeader = { Authorization : request . headers . authorization } ; const message = await getTranslations ( authHeader , messageKeys . deathInProgressNotification , { trackingId : payload . trackingId , crvsOffice : payload . crvsOffice } , getDefaultLanguage ( ) ) ; await buildAndSendSMS ( request , payload . msisdn , message ) ; return h . response ( ) . code ( 200 ) ; } export async function sendDeathDeclarationConfirmation ( request , h ) { const payload = request . payload as IDeclarationPayload ; logger . info ( `Notification service sendDeathDeclarationConfirmation calling sendSMS: ${ JSON . stringify ( payload ) }` ) ; const authHeader = { Authorization : request . headers . authorization } ; const message = await getTranslations ( authHeader , messageKeys . deathDeclarationNotification , { name : payload . name , trackingId : payload . trackingId } , getDefaultLanguage ( ) ) ; await buildAndSendSMS ( request , payload . msisdn , message ) ; return h . response ( ) . code ( 200 ) ; } export async function sendDeathRegistrationConfirmation ( request , h ) { const payload = request . payload as IRegistrationPayload ; logger . info ( `Notification service sendDeathRegistrationConfirmation calling sendSMS: ${ JSON . stringify ( payload ) }` ) ; const authHeader = { Authorization : request . headers . authorization } ; const message = await getTranslations ( authHeader , messageKeys . deathRegistrationNotification , { name : payload . name , trackingId : payload . trackingId , registrationNumber : payload . registrationNumber } , getDefaultLanguage ( ) ) ; await buildAndSendSMS ( request , payload . msisdn , message ) ; return h . response ( ) . code ( 200 ) ; } export async function sendDeathRejectionConfirmation ( request , h ) { const payload = request . payload as IRejectionPayload ; logger . info ( `Notification service sendDeathRejectionConfirmation calling sendSMS: ${ JSON . stringify ( payload ) }` ) ; const authHeader = { Authorization : request . headers . authorization } ; const message = await getTranslations ( authHeader , messageKeys . deathRejectionNotification , { name : payload . name , trackingId : payload . trackingId } , getDefaultLanguage ( ) ) ; await buildAndSendSMS ( request , payload . msisdn , message ) ; return h . response ( ) . code ( 200 ) ; }