UNPKG

bitcitawebfrontlib-ibsalut

Version:

Angular CLI project used by other Angular projects in the bitcita web project.<br />

198 lines 9.15 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); var core_1 = require("@angular/core"); var operators_1 = require("rxjs/operators"); var seccion_texto_1 = require("../data/seccion-texto"); var http_utils_service_1 = require("../..//shared/service/http-utils.service"); var message_service_1 = require("../..//shared/service/message.service"); var general_utils_service_1 = require("../..//shared/service/general-utils.service"); var idioma_1 = require("../..//shared/data/idioma"); //import * as TEXTOS_MOCK from "../data/textos-mock.json"; var CampanyaService = /** @class */ (function () { function CampanyaService(http, message, utils) { this.http = http; this.message = message; this.utils = utils; this.baseUrl = "v1/campanyas"; this.baseUrlV2 = "v2/campanyas"; this.textos = {}; console.log("CampanyaService construido"); } CampanyaService.prototype.findCampanya = function (referencia) { var url = this.baseUrl + "/" + referencia + "/?idioma=" + "" + idioma_1.Idioma.getCodigo(); return this.http.getHttpGet(url); }; /** Versión antigua: Recupera solo textos definidos sin especificar servicio. * Si se cargan los textos de esta manera se llamará el método getTexto() y no getTextoServicio(). */ CampanyaService.prototype.loadTextos = function (referencia) { var url = this.baseUrl + "/" + referencia + "/textos" + "?idioma=" + idioma_1.Idioma.getCodigo(); this._loadTextos(url); }; /** Versión nueva: Recupera todos los textos definidos, con o sin especificar servicio. * Si se cargan los textos de esta manera se llamará el método getTextoServicio() y no getTexto(). */ CampanyaService.prototype.loadTextosConServicios = function (referencia) { var url = this.baseUrlV2 + "/" + referencia + "/textos" + "?idioma=" + idioma_1.Idioma.getCodigo(); this._loadTextos(url); }; CampanyaService.prototype._loadTextos = function (url) { var _this = this; this.http.getHttpGet(url).subscribe(function (result) { result && result.forEach(function (texto) { if (!_this.textos[texto.seccion]) { _this.textos[texto.seccion] = []; } _this.textos[texto.seccion].push(texto); }); }); }; CampanyaService.prototype.getTexto = function (seccion, servicioIds) { if (seccion == null) return null; var textosSeccion = this.textos && this.textos[seccion_texto_1.SeccionTexto[seccion]]; if (!!textosSeccion) { // Mirar primero si existe un texto definido para el servicio actual if (!!servicioIds) { var textosSeccionServicio = textosSeccion.filter(function (texto) { return texto.serviciosIds.some(function (item) { return servicioIds.includes(item); }); }); if (textosSeccionServicio.length > 0) { return textosSeccionServicio[0].contenido; } } // No hay un texto por servicio: Retornar un texto general. var textosSeccionGeneral = textosSeccion.filter(function (texto) { return texto.serviciosIds == null || texto.serviciosIds.length == 0; }); if (textosSeccionGeneral.length > 0) { return textosSeccionGeneral[0].contenido; } } return null; }; CampanyaService.prototype.findServicios = function (referencia) { var url = this.baseUrl + "/" + referencia + "/servicios" + "?idioma=" + idioma_1.Idioma.getCodigo(); return this.http.getHttpGet(url); }; CampanyaService.prototype.findServicio = function (referencia, servicioId) { var url = "v1/campanyas/" + referencia + "/servicios/" + servicioId + "?idioma=" + idioma_1.Idioma.getCodigo(); return this.http.getHttpGet(url); }; CampanyaService.prototype.findSitios = function (referencia) { var url = "v1/campanyas/" + referencia + "/sitios" + "?idioma=" + idioma_1.Idioma.getCodigo(); return this.http.getHttpGet(url); }; CampanyaService.prototype.findEntidades = function (referencia, servicioId, sitioId) { var url = "v1/campanyas/" + referencia + "/entidades" + "?idioma=" + idioma_1.Idioma.getCodigo() + "&servicio=" + servicioId + "&sitio=" + sitioId + "&huecos_libres=S"; return this.http.getHttpGet(url); }; CampanyaService.prototype.findRecursosDeEntidad = function (referencia, entidadId, servicioId) { var url = "v1/campanyas/" + referencia + "/entidades/" + entidadId + "/recursos" + "?idioma=" + idioma_1.Idioma.getCodigo(); if (servicioId) { url += "&servicio=" + servicioId; } return this.http.getHttpGet(url); }; CampanyaService.prototype.findCamposDeServicio = function (referencia, servicioId) { var _this = this; var url = "v1/campanyas/" + referencia + "/servicios/" + servicioId + "/campos_solicitante" + "?idioma=" + idioma_1.Idioma.getCodigo(); return this.http.getHttpGet(url).pipe(operators_1.tap(function (respuesta) { _this.campos = respuesta; })); }; CampanyaService.prototype.findPrimerDiaHoraDisponible = function (referencia, servicioId, entidadId, sitioId, recursoId) { var url = "v1/campanyas/" + referencia + "/primer_dia_hora_disponible" + "?idioma=" + idioma_1.Idioma.getCodigo(); if (servicioId) { url += "&servicio=" + servicioId; } if (entidadId) { url += "&entidad=" + entidadId; } if (sitioId) { url += "&sitio=" + sitioId; } if (recursoId) { url += "&recurso=" + recursoId; } return this.http.getHttpGet(url); }; CampanyaService.prototype.findDiasDisponibles = function (referencia, servicioId, entidadId, sitioId, recursoId) { var url = "v1/campanyas/" + referencia + "/dias_disponibles" + "?idioma=" + idioma_1.Idioma.getCodigo(); if (servicioId) { url += "&servicio=" + servicioId; } if (entidadId) { url += "&entidad=" + entidadId; } if (sitioId) { url += "&sitio=" + sitioId; } if (recursoId) { url += "&recurso=" + recursoId; } return this.http.getHttpGet(url); }; CampanyaService.prototype.findHorasDisponibles = function (dia, referencia, servicioId, entidadId, sitioId, recursoId) { var url = "v1/campanyas/" + referencia + "/horas_disponibles" + "?idioma=" + idioma_1.Idioma.getCodigo(); if (dia) { url += "&dia=" + dia; } if (servicioId) { url += "&servicio=" + servicioId; } if (entidadId) { url += "&entidad=" + entidadId; } if (sitioId) { url += "&sitio=" + sitioId; } if (recursoId) { url += "&recurso=" + recursoId; } return this.http.getHttpGet(url); }; CampanyaService.prototype.resendSmsCita = function (referencia, nif, telefono) { var url = "v1/campanyas/" + referencia + "/citas" + "?idioma=" + idioma_1.Idioma.getCodigo() + "&nif=" + nif + "&telefono=" + telefono; return this.http.getHttpGet(url); }; CampanyaService.prototype.getCampos = function () { return this.campos; }; CampanyaService = __decorate([ core_1.Injectable(), __metadata("design:paramtypes", [http_utils_service_1.HttpUtilsService, message_service_1.MessageService, general_utils_service_1.GeneralUtils]) ], CampanyaService); return CampanyaService; }()); exports.CampanyaService = CampanyaService; //# sourceMappingURL=campanya.service.js.map