import * as path from "path";

import { NodeTrustedMailcore2NativeBinding } from "../types/NodeTrustedMailcore2NativeBinding";
import { IMAPSyncResultNativeBinding } from '../types';
import { IMAPMessage } from "./IMAPMessage";

// tslint:disable-next-line: no-var-requires
let bindings: NodeTrustedMailcore2NativeBinding;
try {
    bindings = require(path.join(__dirname, "../../lib/binding/trusted_mailcore2.node"));
} catch(e) {
    bindings = require(path.join(__dirname, "../../lib/binding/trusted_mailcore2_no_crypto.node"));
}

// tslint:disable-next-line
const { IMAPSyncResult: _IMAPSyncResult } = bindings;

/**
 * IMAPSyncResult Class
 *
 * @public
 */
class IMAPSyncResult extends bindings.IMAPSyncResult {
    /**
     * Wrapping object handle
     *
     * @internal
     */
    public handle: IMAPSyncResultNativeBinding;

    constructor() {
        super();

        const handle = new _IMAPSyncResult();
        this.handle = handle;
    }

    /**
     * Get modifiedOrAddedMessages
     *
     * @type {IMAPMessage[]}
     * @memberof IMAPSyncResult
     */
    get modifiedOrAddedMessages(): IMAPMessage[] {
        return this.handle.modifiedOrAddedMessages;
    }

    /**
     * Get vanished messages
     *
     * @type {number[]}
     * @memberof IMAPSyncResult
     */
    get vanishedMessages(): number[] {
        return this.handle.vanishedMessages;
    }
}

export { IMAPSyncResult }
