def parseSendResponse()

in notificationworkerlambda/src/main/scala/com/gu/notifications/worker/delivery/fcm/FcmClient.scala [85:104]


  def parseSendResponse(
    notificationId: UUID, token: String, response: Try[String], requestCompletionTime: Instant
  ): Either[DeliveryException, Success] = response match {
    case Success(messageId) =>
      Right(FcmDeliverySuccess(token, messageId, requestCompletionTime))
    case Failure(e: InvalidTokenException) =>
      Left(InvalidToken(notificationId, token, e.getMessage()))
    case Failure(e: FcmServerException) =>
      Left(FailedRequest(notificationId, token, e, Option(e.details.status)))
    case Failure(e: UnknownException) =>
      Left(FailedRequest(notificationId, token, e, Option(e.details.status)))
    case Failure(e: InvalidResponseException) =>
      Left(FailedRequest(notificationId, token, e, None))
    case Failure(e: QuotaExceededException) =>
      Left(FailedRequest(notificationId, token, e, None))
    case Failure(e: FcmServerTransportException) =>
      Left(FailedRequest(notificationId, token, e, None))
    case Failure(_) =>
      Left(UnknownReasonFailedRequest(notificationId, token))
  }