import * as path from "path";
import { AttachmentNativeBinding } 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 { Attachment: _Attachment } = bindings;

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

    constructor(bufData?: Buffer, fileName?: string) {
        super();

        const handle = new _Attachment(bufData, fileName);
        this.handle = handle;
    }

    /**
     * Part ID getter
     *
     *
     * @type {string}
     * @memberof Attachment
     */
    get partId(): string {
        return this.handle.partId;
    }

    /**
     * Part ID setter
     *
     *
     * @type {string}
     * @memberof Attachment
     */
    set partId(prtId: string) {
        this.handle.partId = prtId;
    }

    /**
     * data getter
     *
     *
     * @type {Buffer}
     * @memberof Attachment
     */
    get data(): Buffer {
        return this.handle.data;
    }

    /**
     * data setter
     *
     *
     * @type {Buffer}
     * @memberof Attachment
     */
    set data(val: Buffer) {
        this.handle.data = val;
    }

    /**
     * decodedString getter
     *
     *
     * @type {string}
     * @memberof Attachment
     */
    get decodedString(): string {
        return this.handle.decodedString;
    }

    /**
     * File name getter
     *
     *
     * @type {string}
     * @memberof Attachment
     */
    get filename(): string {
        return this.handle.filename;
    }

    /**
     * File name setter
     *
     *
     * @type {string}
     * @memberof Attachment
     */
    set filename(val: string) {
        this.handle.filename = val;
    }

    /**
     * MIME type getter
     *
     *
     * @type {string}
     * @memberof Attachment
     */
    get mimeType(): string {
        return this.handle.mimeType;
    }

    /**
     * MIME type setter
     *
     *
     * @type {string}
     * @memberof Attachment
     */
    set mimeType(val: string) {
        this.handle.mimeType = val;
    }

    /**
     * Charset getter
     *
     *
     * @type {string}
     * @memberof Attachment
     */
    get charset(): string {
        return this.handle.charset;
    }

    /**
     * Charset setter
     *
     *
     * @type {string}
     * @memberof Attachment
     */
    set charset(val: string) {
        this.handle.charset = val;
    }

    /**
     * Uniqe ID getter
     *
     *
     * @type {string}
     * @memberof Attachment
     */
    get uniqeID(): string {
        return this.handle.uniqeID;
    }

    /**
     * Uniqe ID setter
     *
     *
     * @type {string}
     * @memberof Attachment
     */
    set uniqeID(val: string) {
        this.handle.uniqeID = val;
    }

    /**
     * Content ID getter
     *
     *
     * @type {string}
     * @memberof Attachment
     */
    get contentID(): string {
        return this.handle.contentID;
    }

    /**
     * Content ID setter
     *
     *
     * @type {string}
     * @memberof Attachment
     */
    set contentID(val: string) {
        this.handle.contentID = val;
    }

    /**
     * Content location getter
     *
     *
     * @type {string}
     * @memberof Attachment
     */
    get contentLocation(): string {
        return this.handle.contentLocation;
    }

    /**
     * Content location setter
     *
     *
     * @type {string}
     * @memberof Attachment
     */
    set contentLocation(val: string) {
        this.handle.contentLocation = val;
    }

    /**
     * Content description getter
     *
     *
     * @type {string}
     * @memberof Attachment
     */
    get contentDescription(): string {
        return this.handle.contentDescription;
    }

    /**
     * Content description setter
     *
     *
     * @type {string}
     * @memberof Attachment
     */
    set contentDescription(val: string) {
        this.handle.contentDescription = val;
    }
}

export { Attachment }
