import * as path from "path";
import { MessageHeaderNativeBinding } 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 { MessageHeader: _MessageHeader } = bindings;

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

    constructor() {
        super();

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

    /**
     * Message ID getter
     *
     *
     * @type {string}
     * @memberof MessageHeader
     */
    get messageID(): string {
        return this.handle.messageID;
    }

    /**
     * Message ID setter
     *
     *
     * @type {string}
     * @memberof MessageHeader
     */
    set messageID(msgId: string) {
        this.handle.messageID = msgId;
    }

    /**
     * inReplyTo getter
     *
     *
     * @type {string}
     * @memberof MessageHeader
     */
    get inReplyTo(): string[] {
        return this.handle.inReplyTo;
    }

    /**
     * inReplyTo setter
     *
     *
     * @type {string}
     * @memberof MessageHeader
     */
    set inReplyTo(val: string[]) {
        this.handle.inReplyTo = val;
    }

    /**
     * references getter
     *
     *
     * @type {string}
     * @memberof MessageHeader
     */
    get references(): string[] {
        return this.handle.references;
    }

    /**
     * inReplyTo setter
     *
     *
     * @type {string}
     * @memberof MessageHeader
     */
    set references(val: string[]) {
        this.handle.references = val;
    }

    /**
     * date getter
     *
     *
     * @type {Date}
     * @memberof MessageHeader
     */
    get date(): Date {
        return this.handle.date;
    }

    /**
     * date setter
     *
     *
     * @type {Date}
     * @memberof MessageHeader
     */
    set date(dateVal: Date) {
        this.handle.date = dateVal;
    }

    /**
     * receivedDate getter
     *
     *
     * @type {Date}
     * @memberof MessageHeader
     */
    get receivedDate(): Date {
        return this.handle.receivedDate;
    }

    /**
     * receivedDate setter
     *
     *
     * @type {Date}
     * @memberof MessageHeader
     */
    set receivedDate(dateVal: Date) {
        this.handle.receivedDate = dateVal;
    }

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

    /**
     * sender setter
     *
     *
     * @type {string}
     * @memberof MessageHeader
     */
    set sender(val: string) {
        this.handle.sender = val;
    }

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

    /**
     * from setter
     *
     *
     * @type {string}
     * @memberof MessageHeader
     */
    set from(val: string) {
        this.handle.from = val;
    }

    /**
     * to getter
     *
     *
     * @type {Array<string>}
     * @memberof MessageHeader
     */
    get to(): string[] {
        return this.handle.to;
    }

    /**
     * to setter
     *
     *
     * @type {Array<string>}
     * @memberof MessageHeader
     */
    set to(val: string[]) {
        this.handle.to = val;
    }

    /**
     * cc getter
     *
     *
     * @type {Array<string>}
     * @memberof MessageHeader
     */
    get cc(): string[] {
        return this.handle.cc;
    }

    /**
     * cc setter
     *
     *
     * @type {Array<string>}
     * @memberof MessageHeader
     */
    set cc(val: string[]) {
        this.handle.cc = val;
    }

    /**
     * bcc getter
     *
     *
     * @type {Array<string>}
     * @memberof MessageHeader
     */
    get bcc(): string[] {
        return this.handle.bcc;
    }

    /**
     * bcc setter
     *
     *
     * @type {Array<string>}
     * @memberof MessageHeader
     */
    set bcc(val: string[]) {
        this.handle.bcc = val;
    }

    /**
     * replyTo getter
     *
     *
     * @type {Array<string>}
     * @memberof MessageHeader
     */
    get replyTo(): string[] {
        return this.handle.replyTo;
    }

    /**
     * replyTo setter
     *
     *
     * @type {Array<string>}
     * @memberof MessageHeader
     */
    set replyTo(val: string[]) {
        this.handle.replyTo = val;
    }

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

    /**
     * subject setter
     *
     *
     * @type {string}
     * @memberof MessageHeader
     */
    set subject(val: string) {
        this.handle.subject = val;
    }

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

    /**
     * userAgent setter
     *
     *
     * @type {string}
     * @memberof MessageHeader
     */
    set userAgent(val: string) {
        this.handle.userAgent = val;
    }

    /**
     * Get all extra headers
     *
     * @return {*}  {{ [key: string]: string; }}
     * @memberof MessageHeader
     */
    extraHeaders(): { [key: string]: string; } {
        return this.handle.extraHeaders();
    }

    /**
     * Get extra header by name
     *
     * @param {string} name
     * @return {*}  {string}
     * @memberof MessageHeader
     */
    extraHeaderValueForName(name: string): string {
        return this.handle.extraHeaderValueForName(name);
    }

    /**
     * Remove extra header by name
     *
     * @param {string} name
     * @memberof MessageHeader
     */
    removeExtraHeader(name: string): void {
        return this.handle.removeExtraHeader(name);
    }

    /**
     * Set extra header
     *
     * @param {string} name
     * @param {string} value
     * @return {*}  {void}
     * @memberof MessageHeader
     */
    setExtraHeader(name: string, value: string): void {
        return this.handle.setExtraHeader(name, value);
    }
}

export { MessageHeader }
