in membership-common/src/main/scala/com/gu/zuora/soap/Client.scala [45:75]
private def request[T <: models.Result](
action: Action[T],
authentication: Option[Authentication],
reader: Reader[T],
client: FutureHttpClient = httpClient,
)(implicit logPrefix: LogPrefix): Future[T] = {
metrics.countRequest()
val request = new Builder()
.url(apiConfig.url.toString())
.post(RequestBody.create(clientMediaType, action.xml(authentication).toString()))
.build()
if (action.enableLogging)
logger.info(
s"Zuora SOAP call in environment ${apiConfig.envName}. Request info:\n${action.prettyLogInfo}. Is authentication defined: ${authentication.isDefined}",
)
client
.execute(request)
.map { result =>
val responseBody = result.body().string()
reader.read(responseBody) match {
case Left(error) =>
logger.error(
scrub"Zuora action ${action.getClass.getSimpleName} resulted in error: CODE: ${result.code} RESPONSE BODY: $responseBody Is authentication defined: ${authentication.isDefined}",
)
throw error
case Right(obj) => obj
}
}
}