Search in sources :

Example 1 with PayoutState

use of uk.gov.pay.ledger.payout.state.PayoutState in project pay-ledger by alphagov.

the class PayoutEntityFactory method create.

public PayoutEntity create(EventDigest eventDigest) {
    PayoutState digestPayoutState = eventDigest.getMostRecentSalientEventType().map(PayoutState::fromEventType).orElse(PayoutState.UNDEFINED);
    String payoutDetails = convertToPayoutDetails(eventDigest.getEventAggregate());
    PayoutEntity entity = objectMapper.convertValue(eventDigest.getEventAggregate(), PayoutEntity.class);
    entity.setState(digestPayoutState);
    entity.setCreatedDate(eventDigest.getEventCreatedDate());
    entity.setGatewayPayoutId(eventDigest.getResourceExternalId());
    entity.setServiceId(eventDigest.getServiceId());
    entity.setLive(eventDigest.isLive());
    entity.setEventCount(eventDigest.getEventCount());
    entity.setPayoutDetails(payoutDetails);
    return entity;
}
Also used : PayoutState(uk.gov.pay.ledger.payout.state.PayoutState) PayoutEntity(uk.gov.pay.ledger.payout.entity.PayoutEntity)

Aggregations

PayoutEntity (uk.gov.pay.ledger.payout.entity.PayoutEntity)1 PayoutState (uk.gov.pay.ledger.payout.state.PayoutState)1