"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        if (typeof b !== "function" && b !== null)
            throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.extractor = void 0;
var Entity_1 = require("../../Core/Entity");
var StoreEntity_1 = __importDefault(require("../../Core/StoreEntity"));
var extractor = function (response) { return response.planned_routes; };
exports.extractor = extractor;
var Routes = {
    GET_PLANNED_ROUTES_BY_TEAM: '/teams/{:teamId}/planned_routes',
    GET_BATCH_BY_TEAM_IDS: '/planned_routes/batch_get',
    GET_BATCH: '/planned_routes/batch_get_by_ids',
    POST_CONFLICT_PLANNED_ROUTES: '/data-query-service/conflicting-planned-routes'
};
var PlannedRoutesEntity = /** @class */ (function (_super) {
    __extends(PlannedRoutesEntity, _super);
    function PlannedRoutesEntity(session) {
        return _super.call(this, {
            session: session,
            entityName: 'planned_routes',
            routes: [Entity_1.BaseRoutes.GetAll]
        }) || this;
    }
    PlannedRoutesEntity.prototype.getAll = function () {
        return this.getAllOrFetch(null, exports.extractor, exports.extractor);
    };
    PlannedRoutesEntity.prototype.getAllByTeam = function (teamId, commonOptions) {
        if (commonOptions === void 0) { commonOptions = {}; }
        return this.service.routeGenerator
            .get(Routes.GET_PLANNED_ROUTES_BY_TEAM)
            .withCommonOptions(commonOptions)
            .withExtractor(exports.extractor)
            .setException("Could not fetch planned routes of the team #".concat(teamId))
            .withRouteParams({ teamId: teamId })
            .invoke();
    };
    PlannedRoutesEntity.prototype.getBatch = function (ids, commonOptions) {
        if (commonOptions === void 0) { commonOptions = {}; }
        return this.service.routeGenerator
            .get(Routes.GET_BATCH)
            .withCommonOptions(commonOptions)
            .withExtractor(exports.extractor)
            .setException("Could not fetch planned routes with ids ".concat(ids.toString()))
            .withQueryString({ ids: ids })
            .invoke();
    };
    PlannedRoutesEntity.prototype.getBatchByTeamIds = function (team_ids, commonOptions) {
        if (commonOptions === void 0) { commonOptions = {}; }
        return this.service.routeGenerator
            .get(Routes.GET_BATCH_BY_TEAM_IDS)
            .withCommonOptions(commonOptions)
            .withExtractor(exports.extractor)
            .setException("Could not fetch planned routes for the teams ".concat(team_ids.toString()))
            .withQueryString({ team_ids: team_ids })
            .invoke();
    };
    PlannedRoutesEntity.prototype.conflictPlannedRoutes = function (run_id) {
        return this.service.routeGenerator.post(Routes.POST_CONFLICT_PLANNED_ROUTES).withPayload({ run_id: run_id }).invoke();
    };
    return PlannedRoutesEntity;
}(StoreEntity_1.default));
exports.default = PlannedRoutesEntity;
//# sourceMappingURL=PlannedRoutesEntity.js.map