import * as path from "path";
import { POPMessageInfoNativeBinding } from "../types";
import { NodeTrustedMailcore2NativeBinding } from "../types/NodeTrustedMailcore2NativeBinding";

// 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 { POPMessageInfo: _POPMessageInfo } = bindings;

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

    constructor() {
        super()

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

    /**
     * Set index
     *
     * @memberof POPMessageInfo
     */
    set index(idxVal: number) {
        this.handle.index = idxVal;
    }

    /**
     * Get index
     *
     * @type {number}
     * @memberof POPMessageInfo
     */
    get index(): number {
        return this.handle.index;
    }

    /**
     * Set size
     *
     * @memberof POPMessageInfo
     */
    set size(sizeVal: number) {
        this.handle.size = sizeVal;
    }

    /**
     * Get size
     *
     * @type {number}
     * @memberof POPMessageInfo
     */
    get size(): number {
        return this.handle.size;
    }

    /**
     * Set UID
     *
     * @memberof POPMessageInfo
     */
    set UID(uidVal: string) {
        this.handle.UID = uidVal;
    }

    /**
     * Get UID
     *
     * @type {string}
     * @memberof POPMessageInfo
     */
    get UID(): string {
        return this.handle.UID;
    }
}

export { POPMessageInfo };

