in formstack-consents/src/main/scala/com/gu/identity/formstackconsents/IdentityClient.scala [41:55]
def handleResponseFromIdentity(response: Option[HttpResponse[String]], formstackSubmission: FormstackSubmission, newsletter: Newsletter): Option[APIGatewayProxyResponseEvent] = {
val successfulResponse = new APIGatewayProxyResponseEvent
val unsuccessfulResponse = new APIGatewayProxyResponseEvent
response match {
case Some(r) if r.is2xx =>
logger.info(s"successfully posted newsletter consent to identity: email: ${formstackSubmission.emailAddress}, newsletter: ${newsletter.consent}")
Some(successfulResponse.withStatusCode(200))
case Some(r) =>
logger.error(s"unable to post newsletter consent to identity for email: ${formstackSubmission.emailAddress}, newsletter: ${newsletter.consent}, $r")
Some(unsuccessfulResponse.withStatusCode(r.code))
case _ =>
logger.error(s"unable to connect to identity")
None
}
}