in formstack-consents/src/main/scala/com/gu/identity/formstackconsents/Lambda.scala [40:52]
def handler(event: APIGatewayProxyRequestEvent): APIGatewayProxyResponseEvent = {
(for {
formstackSubmission <- decodeFormstackSubmission(event.getBody)
config <- getConfig
_ <- verifySecretKey(config.formstackSharedSecret, formstackSubmission.handshakeKey)
identityClient = new IdentityClient(config)
response <- identityClient.sendConsentToIdentity(formstackSubmission)
} yield response).getOrElse{
val invalidResponse = new APIGatewayProxyResponseEvent
logger.error("lambda unsuccessful")
invalidResponse.withStatusCode(500)
}
}