def getEnvironmentVariable()

in payment-failure/src/main/scala/com/gu/identity/paymentfailure/Lambda.scala [12:28]


  def getEnvironmentVariable(env: String): Either[Throwable, String] =
    Either.fromOption(
      Option(System.getenv(env)),
      new Exception(s"environment variable $env not defined")
    )

  def getConfig: Either[Throwable, Config] = {
    for {
      idapiHost <- getEnvironmentVariable("idapiHost")
      brazeApiHost <- getEnvironmentVariable("brazeApiHost")
      idapiAccessToken <- getEnvironmentVariable("idapiAccessToken")
      sqsQueueUrl <- getEnvironmentVariable("sqsQueueUrl")
      brazeApiKey <- getEnvironmentVariable("brazeApiKey")
    } yield {
      Config(idapiHost, brazeApiHost, idapiAccessToken, sqsQueueUrl, brazeApiKey)
    }
  }