Skip to main content

Checking Early Withdrawal Enable

The isEarlyWithdrawalEnabled method checks whether early withdrawals are allowed for a given insurance pool. This can help users determine if they can withdraw their funds before the standard withdrawal period.

Usage

import kohin from "./kohinInstance";

const earlyWithdrawalResponse = await kohin.isEarlyWithdrawalEnabled();

if (earlyWithdrawalResponse.success) {
console.log(
"Early Withdrawal Enabled:",
earlyWithdrawalResponse.isEarlyWithdrawalEnabled
);
} else {
console.error(
"Error checking early withdrawal enablement:",
earlyWithdrawalResponse.error
);
}

Return Value

The isEarlyWithdrawalEnabled method returns an object with the following structure:

{
success: boolean; // Indicates if the operation was successful
error?: string; // Error message if the operation failed
isEarlyWithdrawalEnabled?: boolean; // True if early withdrawal is enabled, false otherwise
}

Error Handling

Here's how you can handle errors while checking early withdrawal enablement:

try {
const res = await kohin.isEarlyWithdrawalEnabled();

if (res.success) {
console.log("Early Withdrawal Enabled:", res.isEarlyWithdrawalEnabled);
} else {
console.error("Error checking early withdrawal enablement:", res.error);
}
} catch (error: any) {
console.error("Unexpected error while checking early withdrawal:", error);
}

Example Response

Success Response:

{
"success": true,
"isEarlyWithdrawalEnabled": true
}

Error Response:

{
"success": false,
"error": "Unable to check early withdrawal enablement."
}