in membership-attribute-service/app/services/AccountDetailsFromZuora.scala [136:177]
private def getAccountDetailsParallel(
contactAndSubscription: ContactAndSubscription,
)(implicit logPrefix: LogPrefix): SimpleEitherT[(PaymentDetails, ZuoraRestService.AccountSummary, Option[String])] = {
metrics.measureDurationEither("getAccountDetailsParallel") {
// Run all these api calls in parallel to improve response times
val paymentDetailsFuture =
paymentDetailsForSubscription
.getPaymentDetails(contactAndSubscription)
.map(Right(_))
.recover { case x =>
Left(s"error retrieving payment details for subscription: ${contactAndSubscription.subscription.subscriptionNumber}. Reason: $x")
}
val accountSummaryFuture =
zuoraRestService
.getAccount(contactAndSubscription.subscription.accountId)
.map(_.toEither)
.recover { case x =>
Left(
s"error receiving account summary for subscription: ${contactAndSubscription.subscription.subscriptionNumber} " +
s"with account id ${contactAndSubscription.subscription.accountId}. Reason: $x",
)
}
val effectiveCancellationDateFuture =
zuoraRestService
.getCancellationEffectiveDate(contactAndSubscription.subscription.subscriptionNumber)
.map(_.toEither)
.recover { case x =>
Left(
s"Failed to fetch effective cancellation date: ${contactAndSubscription.subscription.subscriptionNumber} " +
s"with account id ${contactAndSubscription.subscription.accountId}. Reason: $x",
)
}
for {
paymentDetails <- SimpleEitherT(paymentDetailsFuture)
accountSummary <- SimpleEitherT(accountSummaryFuture)
effectiveCancellationDate <- SimpleEitherT(effectiveCancellationDateFuture)
} yield (paymentDetails, accountSummary, effectiveCancellationDate)
}
}