All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.truelayer.java.merchantaccounts.entities.transactions.Payout Maven / Gradle / Ivy

There is a newer version: 16.0.0
Show newest version
package com.truelayer.java.merchantaccounts.entities.transactions;

import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonValue;
import com.truelayer.java.entities.CurrencyCode;
import com.truelayer.java.entities.beneficiary.Beneficiary;
import java.time.ZonedDateTime;
import java.util.Optional;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.Value;

/**
 * DTO class that represents both pending and executed payouts.
 * We're not defining explicit variants in this case based on the status field because
 * it seems that the library used for deserialization is not capable of handling more than one deserialization hints,
 * which would be required in this case to first select a DTO based on the type and then on the
 * status fields.
 */
@Value
@EqualsAndHashCode(callSuper = false)
public class Payout extends Transaction {

    Transaction.Type type = Transaction.Type.PAYOUT;

    String id;

    CurrencyCode currency;

    int amountInMinor;

    /**
     * Represents the status of the payout.
     * Either pending or executed.
     */
    Transaction.Status status;

    ZonedDateTime createdAt;

    ZonedDateTime executedAt;

    Beneficiary beneficiary;

    Payout.ContextCode contextCode;

    String payoutId;

    @JsonGetter
    public Optional getExecutedAt() {
        return Optional.ofNullable(executedAt);
    }

    @RequiredArgsConstructor
    @Getter
    public enum ContextCode {
        WITHDRAWAL("withdrawal"),
        SERVICE_PAYMENT("service_payment"),
        INTERNAL("internal");

        @JsonValue
        private final String status;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy