def sendConsentToIdentity()

in formstack-consents/src/main/scala/com/gu/identity/formstackconsents/IdentityClient.scala [80:91]


  def sendConsentToIdentity(formstackSubmission: FormstackSubmission): Option[APIGatewayProxyResponseEvent] = {
    val newsletterOpt = newsletters.find(n => n.formId == formstackSubmission.formId)

    if (checkHasOptedIn(formstackSubmission)) {
      newsletterOpt.flatMap { newsletter => {
        val response = updateConsent(formstackSubmission, newsletter)
        handleResponseFromIdentity(response, formstackSubmission, newsletter)
      }}
    } else {
      None // form is not submitted due to missing consent opt in requirements
    }
  }