Skip to content

Commit

Permalink
PIN-4903 Resolved PR issues
Browse files Browse the repository at this point in the history
  • Loading branch information
nttdata-rtorsoli committed May 30, 2024
1 parent d94af22 commit 35f0e28
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,4 @@ object AgreementProcessErrors {

final case class SelfcareEntityNotFilled(className: String, field: String)
extends ComponentError("0026", s"Selfcare entity $className with field $field not filled")

final case class MissingUsersInfo(consumerId: UUID, producerId: UUID)
extends ComponentError(
"0027",
s"Some mandatory info are missing for consumer ${consumerId.toString()} and producer ${producerId.toString()}"
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import it.pagopa.interop.agreementprocess.common.system.ApplicationConfiguration
import it.pagopa.interop.agreementprocess.error.AgreementProcessErrors.{
MissingUserInfo,
StampNotFound,
MissingUsersInfo,
SelfcareIdNotFound
}
import it.pagopa.interop.agreementprocess.service.util.PDFPayload
Expand Down Expand Up @@ -124,25 +123,19 @@ final class AgreementContractCreator(

}

def getSubmissionInfo(seed: UpdateAgreementSeed, consumer: PersistentTenant, producer: PersistentTenant)(implicit
def getSubmissionInfo(seed: UpdateAgreementSeed, consumer: PersistentTenant)(implicit
contexts: Seq[(String, String)],
ec: ExecutionContext
): Future[(String, OffsetDateTime)] =
for {
submission <- seed.stamps.submission.toFuture(StampNotFound("submission"))
consumerSelfcareId <- consumer.selfcareId.toFuture(SelfcareIdNotFound(consumer.id))
producerSelfcareId <- producer.selfcareId.toFuture(SelfcareIdNotFound(producer.id))
consumerSelfcareUuid <- consumerSelfcareId.toFutureUUID
producerSelfcareUuid <- producerSelfcareId.toFutureUUID
consumerSelfcare <- selfcareV2ClientService.getInstitution(consumerSelfcareUuid).map(_.toApi)
producerSelfcare <- selfcareV2ClientService.getInstitution(producerSelfcareUuid).map(_.toApi)
(consumerApi, producerApi) <- consumerSelfcare.toFuture.zip(producerSelfcare.toFuture)
userResponse <- selfcareV2ClientService
.getUserById(consumerSelfcareUuid, consumerApi.id)
.recoverWith { case _ => selfcareV2ClientService.getUserById(producerSelfcareUuid, producerApi.id) }
submission <- seed.stamps.submission.toFuture(StampNotFound("submission"))
consumerSelfcareId <- consumer.selfcareId.toFuture(SelfcareIdNotFound(consumer.id))
consumerSelfcareUuid <- consumerSelfcareId.toFutureUUID
userResponse <- selfcareV2ClientService
.getUserById(consumerSelfcareUuid, submission.who)
.map(_.toApi)
userResponseApi <- userResponse.toFuture.recoverWith { case _ =>
Future.failed(MissingUsersInfo(consumerApi.id, producerApi.id))
userResponseApi <- userResponse.toFuture.recoverWith { case _ =>
Future.failed(MissingUserInfo(consumer.id))
}
submitter = getUserText(userResponseApi)
} yield (submitter, submission.when)
Expand All @@ -169,7 +162,7 @@ final class AgreementContractCreator(
)(implicit contexts: Seq[(String, String)], ec: ExecutionContext): Future[PDFPayload] = {
for {
(certified, declared, verified) <- getAttributeInvolved(consumer, seed)
(submitter, submissionTimestamp) <- getSubmissionInfo(seed, consumer, producer)
(submitter, submissionTimestamp) <- getSubmissionInfo(seed, consumer)
(activator, activationTimestamp) <- getActivationInfo(seed)
} yield PDFPayload(
today = offsetDateTimeSupplier.get(),
Expand Down

0 comments on commit 35f0e28

Please sign in to comment.