"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 __assign = (this && this.__assign) || function () {
    __assign = Object.assign || function(t) {
        for (var s, i = 1, n = arguments.length; i < n; i++) {
            s = arguments[i];
            for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
                t[p] = s[p];
        }
        return t;
    };
    return __assign.apply(this, arguments);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
    function verb(n) { return function (v) { return step([n, v]); }; }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (g && (g = 0, op[0] && (_ = 0)), _) try {
            if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
            if (y = 0, t) op = [op[0] & 2, t.value];
            switch (op[0]) {
                case 0: case 1: t = op; break;
                case 4: _.label++; return { value: op[1], done: false };
                case 5: _.label++; y = op[1]; op = [0]; continue;
                case 7: op = _.ops.pop(); _.trys.pop(); continue;
                default:
                    if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
                    if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
                    if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
                    if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
                    if (t[2]) _.ops.pop();
                    _.trys.pop(); continue;
            }
            op = body.call(thisArg, _);
        } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
        if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
    }
};
Object.defineProperty(exports, "__esModule", { value: true });
var lodash_1 = require("lodash");
var BringgException_1 = require("../../Core/BringgException");
var RouteGenerator_1 = require("../../Core/RouteGenerator");
var PubSubEvents_1 = require("../../Services/PubSubEvents");
var PubSubService_1 = require("../../Services/PubSubService");
var Route_1 = require("../../Services/Route");
var keyset_pagination_consts_1 = require("../../utils/consts/keyset-pagination.consts");
var User_consts_1 = require("../User.consts");
var ROUTES = {
    GET: new Route_1.Route('/users/{:userId}', 0 /* HttpMethod.GET */),
    GET_ALL: new Route_1.Route('/users/', 0 /* HttpMethod.GET */),
    GET_ALL_DRIVERS: new Route_1.Route('/users/drivers', 0 /* HttpMethod.GET */),
    GET_USERS_WITH_USER_TYPE: new Route_1.Route('/user_types/{:userTypeId}/users', 0 /* HttpMethod.GET */),
    GET_DRIVERS_BY_TEAM: new Route_1.Route('/teams/{:teamId}/users', 0 /* HttpMethod.GET */),
    MAKE_ADMIN: new Route_1.Route('/users/{:userId}/admin', 1 /* HttpMethod.POST */),
    CREATE_USER: new Route_1.Route('/users/', 1 /* HttpMethod.POST */),
    INVITE: new Route_1.Route('/users/{:userId}/reinvite', 1 /* HttpMethod.POST */),
    TOTAL_TASKS: new Route_1.Route('/users/{:userId}/tasks/count', 0 /* HttpMethod.GET */),
    TOTAL_EMPLOYEES: new Route_1.Route('/users/count', 0 /* HttpMethod.GET */),
    TOTAL_DRIVERS: new Route_1.Route('/users/drivers/count', 0 /* HttpMethod.GET */),
    UNLOCK: new Route_1.Route('/users/{:userId}/unlock', 1 /* HttpMethod.POST */),
    INVITE_VIA_EMAIL: new Route_1.Route('/users/{:userId}/reinvite_via_email', 1 /* HttpMethod.POST */),
    VALIDATE_PHONE: new Route_1.Route('/api/user/validate_phone', 0 /* HttpMethod.GET */),
    CLOSED_TASKS: new Route_1.Route('/users/{:userId}/tasks/closed_tasks', 0 /* HttpMethod.GET */),
    UPDATE: new Route_1.Route('/users/{:id}', 3 /* HttpMethod.PATCH */),
    DELETE: new Route_1.Route('/users/{:id}', 4 /* HttpMethod.DELETE */),
    GET_PROFILE_IMAGE: new Route_1.Route('/users/{:userId}/profile_image', 0 /* HttpMethod.GET */),
    MESSAGE_DRIVER: new Route_1.Route('/announcement/user/{:userId}', 2 /* HttpMethod.PUT */),
    DRIVER_COST: new Route_1.Route('/users/{:userId}/driver_cost', 0 /* HttpMethod.GET */),
    GENERATE_RESET_PASSWORD_TOKEN: new Route_1.Route('/users/generate_reset_password_token', 1 /* HttpMethod.POST */)
};
var UsersService = /** @class */ (function (_super) {
    __extends(UsersService, _super);
    function UsersService(session, store) {
        var _this = _super.call(this, session.config.getApiEndpoint(), session) || this;
        _this.store = store;
        return _this;
    }
    UsersService.prototype.create = function (user) {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
                            route: ROUTES.CREATE_USER,
                            extractor: User_consts_1.userExtractor,
                            exceptionProducer: BringgException_1.BringgException.serviceException('Could not create user'),
                            payload: user
                        })];
                    case 1: return [2 /*return*/, _a.sent()];
                }
            });
        });
    };
    UsersService.prototype.getDriversByTeam = function (teamId) {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
                            route: ROUTES.GET_DRIVERS_BY_TEAM,
                            extractor: User_consts_1.defaultExtractor,
                            exceptionProducer: BringgException_1.BringgException.serviceException('Could not get drivers'),
                            routeParams: { teamId: teamId }
                        })];
                    case 1: return [2 /*return*/, _a.sent()];
                }
            });
        });
    };
    UsersService.prototype.get = function (userId) {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
                            route: ROUTES.GET,
                            extractor: User_consts_1.defaultExtractor,
                            exceptionProducer: BringgException_1.BringgException.serviceException(function () { return "Could not get user ".concat(userId); }),
                            routeParams: { userId: userId }
                        })];
                    case 1: return [2 /*return*/, _a.sent()];
                }
            });
        });
    };
    UsersService.prototype.getMany = function (_a, commonOptions) {
        var usersIds = _a.usersIds, _b = _a.page, page = _b === void 0 ? 1 : _b, _c = _a.limit, limit = _c === void 0 ? 50 : _c;
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_d) {
                return [2 /*return*/, new RouteGenerator_1.Request(this, ROUTES.GET_ALL)
                        .withQueryString({ ids: usersIds, page: page, limit: limit })
                        .withExtractor(function (response) { return ({ has_next_page: response.has_next_page, users: response.users }); })
                        .setException('Could not get users by ids')
                        .withCommonOptions(commonOptions)
                        .invoke()];
            });
        });
    };
    UsersService.prototype.getAll = function (page, limit) {
        if (page === void 0) { page = 1; }
        if (limit === void 0) { limit = 50; }
        return __awaiter(this, void 0, void 0, function () {
            var response;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
                            route: ROUTES.GET_ALL,
                            extractor: function (response) { return ({ has_next_page: response.has_next_page, users: response.users }); },
                            exceptionProducer: BringgException_1.BringgException.serviceException('Could not get users'),
                            queryString: { page: page, limit: limit }
                        })];
                    case 1:
                        response = _a.sent();
                        return [2 /*return*/, response];
                }
            });
        });
    };
    UsersService.prototype.getAllKeysetPagination = function (request) {
        return __awaiter(this, void 0, void 0, function () {
            var limit, page_action, cursor, response;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        limit = request.limit, page_action = request.page_action, cursor = request.cursor;
                        return [4 /*yield*/, this.handleAuthorizedRequest({
                                route: ROUTES.GET_ALL,
                                extractor: function (response) { return ({
                                    next_page_cursor: response.next_page_cursor,
                                    previous_page_cursor: response.previous_page_cursor,
                                    users: response.users
                                }); },
                                exceptionProducer: BringgException_1.BringgException.serviceException('Could not get users'),
                                queryString: { pgver: keyset_pagination_consts_1.KEYSET_PAGINATION_VER, limit: limit, page_action: page_action, cursor: cursor }
                            })];
                    case 1:
                        response = _a.sent();
                        return [2 /*return*/, response];
                }
            });
        });
    };
    UsersService.prototype.invite = function (userId) {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
                            route: ROUTES.INVITE,
                            extractor: User_consts_1.userExtractor,
                            exceptionProducer: BringgException_1.BringgException.serviceException(function () { return "Could not invite user with id: ".concat(userId); }),
                            routeParams: { userId: userId }
                        })];
                    case 1: return [2 /*return*/, _a.sent()];
                }
            });
        });
    };
    UsersService.prototype.unlock = function (userId) {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
                            route: ROUTES.UNLOCK,
                            extractor: User_consts_1.successExtractor,
                            exceptionProducer: BringgException_1.BringgException.serviceException(function () { return "Could not unlock user with id: ".concat(userId); }),
                            routeParams: { userId: userId }
                        })];
                    case 1: return [2 /*return*/, _a.sent()];
                }
            });
        });
    };
    UsersService.prototype.assignedTasksCount = function (userId) {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
                            route: ROUTES.TOTAL_TASKS,
                            extractor: User_consts_1.countExtractor,
                            exceptionProducer: BringgException_1.BringgException.serviceException(function () { return "Could not get task count for user with id: ".concat(userId); }),
                            routeParams: { userId: userId }
                        })];
                    case 1: return [2 /*return*/, _a.sent()];
                }
            });
        });
    };
    UsersService.prototype.totalEmployeesCount = function () {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
                            route: ROUTES.TOTAL_EMPLOYEES,
                            extractor: User_consts_1.countExtractor,
                            exceptionProducer: BringgException_1.BringgException.serviceException(function () { return 'Could not get total employee count'; })
                        })];
                    case 1: return [2 /*return*/, _a.sent()];
                }
            });
        });
    };
    UsersService.prototype.totalDriversCount = function () {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
                            route: ROUTES.TOTAL_DRIVERS,
                            extractor: User_consts_1.countExtractor,
                            exceptionProducer: BringgException_1.BringgException.serviceException(function () { return 'Could not get total drivers count'; })
                        })];
                    case 1: return [2 /*return*/, _a.sent()];
                }
            });
        });
    };
    UsersService.prototype.inviteByEmail = function (userId) {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
                            route: ROUTES.INVITE_VIA_EMAIL,
                            extractor: User_consts_1.userExtractor,
                            exceptionProducer: BringgException_1.BringgException.serviceException(function () { return "Could not invite user with id: ".concat(userId); }),
                            routeParams: { userId: userId }
                        })];
                    case 1: return [2 /*return*/, _a.sent()];
                }
            });
        });
    };
    UsersService.prototype.validatePhone = function (phone) {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
                            route: ROUTES.VALIDATE_PHONE,
                            extractor: function (response) { return response.phone_valid; },
                            exceptionProducer: BringgException_1.BringgException.serviceException(function () { return "Phone is not valid: ".concat(phone); }),
                            queryString: { phone: phone }
                        })];
                    case 1: return [2 /*return*/, _a.sent()];
                }
            });
        });
    };
    UsersService.prototype.closedTasks = function (userId, page) {
        if (page === void 0) { page = 0; }
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
                            route: ROUTES.CLOSED_TASKS,
                            extractor: User_consts_1.defaultExtractor,
                            exceptionProducer: BringgException_1.BringgException.serviceException(function () { return "Could not get tasks for user: ".concat(userId); }),
                            routeParams: { userId: userId },
                            queryString: { page: page }
                        })];
                    case 1: return [2 /*return*/, _a.sent()];
                }
            });
        });
    };
    UsersService.prototype.update = function (id, userDelta) {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
                            route: ROUTES.UPDATE,
                            extractor: User_consts_1.userExtractor,
                            exceptionProducer: BringgException_1.BringgException.serviceException(function () { return "Could not update user: ".concat(id); }),
                            payload: __assign({ id: id }, userDelta),
                            routeParams: { id: id }
                        })];
                    case 1: return [2 /*return*/, _a.sent()];
                }
            });
        });
    };
    UsersService.prototype.getAllAdminsAndDispatchers = function (request) {
        return __awaiter(this, void 0, void 0, function () {
            var limit, page_action, cursor, scopes, response;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        limit = request.limit, page_action = request.page_action, cursor = request.cursor;
                        scopes = [User_consts_1.UsersScopes.DISPATCHERS, User_consts_1.UsersScopes.ADMINS];
                        return [4 /*yield*/, this.handleAuthorizedRequest({
                                route: ROUTES.GET_ALL,
                                extractor: function (response) { return ({
                                    next_page_cursor: response.next_page_cursor,
                                    previous_page_cursor: response.previous_page_cursor,
                                    users: response.users
                                }); },
                                exceptionProducer: BringgException_1.BringgException.serviceException('Could not get admins and dispatchers'),
                                queryString: { pgver: keyset_pagination_consts_1.KEYSET_PAGINATION_VER, scopes: scopes, limit: limit, page_action: page_action, cursor: cursor }
                            })];
                    case 1:
                        response = _a.sent();
                        return [2 /*return*/, response];
                }
            });
        });
    };
    UsersService.prototype.getAllDrivers = function (request) {
        return __awaiter(this, void 0, void 0, function () {
            var limit, page_action, cursor, options, scopes;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        limit = request.limit, page_action = request.page_action, cursor = request.cursor, options = request.options;
                        scopes = [];
                        if ((0, lodash_1.get)(options, 'onlyCustomers')) {
                            scopes.push(User_consts_1.UsersScopes.CUSTOMERS);
                        }
                        else {
                            scopes.push(User_consts_1.UsersScopes.DRIVERS);
                        }
                        if (options.onlyOnlineDriver) {
                            scopes.push(User_consts_1.UsersScopes.MARKED_AS_ONLINE);
                        }
                        return [4 /*yield*/, this.handleAuthorizedRequest({
                                route: ROUTES.GET_ALL,
                                extractor: function (response) { return ({
                                    next_page_cursor: response.next_page_cursor,
                                    previous_page_cursor: response.previous_page_cursor,
                                    users: response.users
                                }); },
                                exceptionProducer: BringgException_1.BringgException.serviceException('Could not get drivers'),
                                queryString: { pgver: keyset_pagination_consts_1.KEYSET_PAGINATION_VER, scopes: scopes, limit: limit, page_action: page_action, cursor: cursor }
                            })];
                    case 1: return [2 /*return*/, _a.sent()];
                }
            });
        });
    };
    UsersService.prototype.delete = function (id) {
        return __awaiter(this, void 0, void 0, function () {
            var result;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
                            route: ROUTES.DELETE,
                            extractor: User_consts_1.successExtractor,
                            exceptionProducer: BringgException_1.BringgException.serviceException(function () { return "Could not delete user: ".concat(id); }),
                            routeParams: { id: id }
                        })];
                    case 1:
                        result = _a.sent();
                        return [2 /*return*/, result];
                }
            });
        });
    };
    UsersService.prototype.getProfileImage = function (userId) {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
                            route: ROUTES.GET_PROFILE_IMAGE,
                            extractor: function (response) { return response.profile_image; },
                            exceptionProducer: BringgException_1.BringgException.serviceException(function () { return "Could not get user's ".concat(userId, " profile image"); }),
                            routeParams: { userId: userId }
                        })];
                    case 1: return [2 /*return*/, _a.sent()];
                }
            });
        });
    };
    UsersService.prototype.messageDriver = function (userId, message) {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
                            route: ROUTES.MESSAGE_DRIVER,
                            extractor: function (response) { return response.announcement_id; },
                            exceptionProducer: BringgException_1.BringgException.serviceException(function () { return "Could not message to user ".concat(userId); }),
                            payload: { user_id: userId, message: message },
                            routeParams: { userId: userId }
                        })];
                    case 1: return [2 /*return*/, _a.sent()];
                }
            });
        });
    };
    UsersService.prototype.getDriverCost = function (userId) {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
                            route: ROUTES.DRIVER_COST,
                            extractor: function (response) { return response; },
                            exceptionProducer: BringgException_1.BringgException.serviceException(function () { return "Could not get cost to user ".concat(userId); }),
                            routeParams: { userId: userId }
                        })];
                    case 1: return [2 /*return*/, _a.sent()];
                }
            });
        });
    };
    UsersService.prototype.byUserType = function (userTypeId) {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
                            route: ROUTES.GET_USERS_WITH_USER_TYPE,
                            extractor: User_consts_1.usersExtractor,
                            exceptionProducer: BringgException_1.BringgException.serviceException('Could not get users'),
                            routeParams: { userTypeId: userTypeId }
                        })];
                    case 1: return [2 /*return*/, _a.sent()];
                }
            });
        });
    };
    UsersService.prototype.makeAdmin = function (userId) {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
                            route: ROUTES.MAKE_ADMIN,
                            extractor: User_consts_1.userExtractor,
                            exceptionProducer: BringgException_1.BringgException.serviceException(function () { return "Could not set admin on userId: ".concat(userId); }),
                            routeParams: { userId: userId }
                        })];
                    case 1: return [2 /*return*/, _a.sent()];
                }
            });
        });
    };
    UsersService.prototype.fetchAllPages = function (fn, options) {
        var _a;
        return __awaiter(this, void 0, void 0, function () {
            var result, hasMore, cursor, _b, values, hasMoreInPage, nextCursor;
            return __generator(this, function (_c) {
                switch (_c.label) {
                    case 0:
                        result = [];
                        hasMore = true;
                        cursor = undefined;
                        _c.label = 1;
                    case 1:
                        if (!hasMore) return [3 /*break*/, 3];
                        if ((_a = options === null || options === void 0 ? void 0 : options.signal) === null || _a === void 0 ? void 0 : _a.aborted) {
                            throw new Error('Aborted');
                        }
                        return [4 /*yield*/, fn(cursor)];
                    case 2:
                        _b = _c.sent(), values = _b.values, hasMoreInPage = _b.hasMore, nextCursor = _b.nextCursor;
                        result = result.concat(values);
                        hasMore = hasMoreInPage;
                        cursor = nextCursor;
                        return [3 /*break*/, 1];
                    case 3: return [2 /*return*/, result];
                }
            });
        });
    };
    UsersService.prototype.attachSubscriptions = function () {
        var _this = this;
        this.subscribeToEvent(PubSubEvents_1.DELETE_EMPLOYEE, function (user) {
            _this.store.removeFromStore(user.user_id);
        });
        this.subscribeToEvent(PubSubEvents_1.EMPLOYEE_UPDATE_EVENT, function (user) {
            _this.store.updateInStore(user);
        });
        this.subscribeToEvent(PubSubEvents_1.NEW_EMPLOYEE, function (user) {
            _this.store.addToStore(user);
        });
    };
    UsersService.prototype.generateResetPasswordToken = function (email) {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.handleAuthorizedRequest({
                            route: ROUTES.GENERATE_RESET_PASSWORD_TOKEN,
                            extractor: function (response) { return response.reset_password_token; },
                            payload: { email: email },
                            exceptionProducer: BringgException_1.BringgException.serviceException(function () { return 'Could not generate token'; })
                        })];
                    case 1: return [2 /*return*/, _a.sent()];
                }
            });
        });
    };
    return UsersService;
}(PubSubService_1.PubSubService));
exports.default = UsersService;
//# sourceMappingURL=UsersService.js.map