Home Manual Reference Source Repository

es2015/LineSources/index.js

export var LineSourceType;
(function (LineSourceType) {
    LineSourceType.USER = 'user';
    LineSourceType.GROUP = 'group';
    LineSourceType.ROOM = 'room';
})(LineSourceType || (LineSourceType = {}));
/* eslint-enable no-unused-vars, space-infix-ops */
/**
 * Line Source
 * @see https://devdocs.line.me/en/#common-fields
 */
export class LineSource {
    /* eslint-enable no-undef */
    /** @ignore */
    constructor({ type }) {
        /**
         * Identifier for the type of source.
         * @type {string}
         */
        this.type = type;
    }
    /** @ignore */
    static createFromObject(params) {
        switch (params.type) {
            case LineSourceType.USER: {
                return new UserSource(params);
            }
            case LineSourceType.GROUP: {
                return new GroupSource(params);
            }
            case LineSourceType.ROOM: {
                return new RoomSource(params);
            }
            default: {
                return new LineSource({ type: params.type });
            }
        }
    }
}
/**
 * @see https://devdocs.line.me/en/#source-user
 */
export class UserSource extends LineSource {
    /* eslint-enable no-undef */
    /** @ignore */
    constructor({ type, userId }) {
        super({ type });
        /**
         * ID of the source user.
         * @type {string}
         */
        this.userId = userId;
    }
}
/**
 * @see https://devdocs.line.me/en/#source-group
 */
export class GroupSource extends LineSource {
    /* eslint-enable no-undef */
    /** @ignore */
    constructor({ type, groupId }) {
        super({ type });
        /**
         * ID of the source group.
         * @type {string}
         */
        this.groupId = groupId;
    }
}
/**
 * @see https://devdocs.line.me/en/#source-room
 */
export class RoomSource extends LineSource {
    /* eslint-enable no-undef */
    /** @ignore */
    constructor({ type, roomId }) {
        super({ type });
        /**
         * ID of the source room.
         * @type {string}
         */
        this.roomId = roomId;
    }
}