package domain.model;

import domain.dto.response.CustomerResponse;

public class ExecutionResult {

    private final CustomerResponse successResponse;
    private final ErrorCode errorCode;

    // Constructor privado para éxito
    private ExecutionResult(CustomerResponse successResponse) {
        this.successResponse = successResponse;
        this.errorCode = null;
    }

    // Constructor privado para error
    private ExecutionResult(ErrorCode errorCode) {
        this.successResponse = null;
        this.errorCode = errorCode;
    }

    // --- Métodos de fábrica (Factory) ---
    public static ExecutionResult success(CustomerResponse response) {
        return new ExecutionResult(response);
    }

    public static ExecutionResult failure(ErrorCode code) {
        return new ExecutionResult(code);
    }

    // --- Métodos de comprobación ---
    public boolean isSuccess() {
        return this.successResponse != null;
    }

    public CustomerResponse getSuccessResponse() {
        return successResponse;
    }

    public ErrorCode getErrorCode() {
        return errorCode;
    }
}