Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x | import Logger from "../../../Utils/LoggerByDefault"; import ErrorService from "../../../Exceptions/ErrorService"; import RouteRequestREST from "./RouteRequestREST"; /** * Creation d'une requête REST en mode POST ou GET * (Factory) * * @module RouteRequestFactory * @alias Gp.Services.Route.Request.RouteRequestFactory * @private */ var RouteRequestFactory = { /** * interface unique * * @method build * @static * @param {Object} options - options definies dans le composant Route * * @example * // utilisation avec les callback * var options = { * (...) * onSuccess : function (response) {}, * onError : function (error) {}, * // spécifique au service * startPoint : { * x : 42.1121, * y : 1.5557 * }, * endPoint : { * x : 42.1121, * y : 1.5557 * }, * provideBbox : false, * exclusions : ["bridge", "tunnel", "toll"], * distanceUnit : "km", * graph : "Voiture", * geometryInInstructions : false, * routePreference : "fastest" * }; * RouteRequestFactory.build(options); * * // utilisation sans callback * var options = {...}; * try { * var result = RouteRequestFactory.build(options); * if (! result) { throw new Error("..."):} * } catch (e) { * // todo * } * @returns {String} request */ build : function (options) { // logger var logger = Logger.getLogger("RouteRequestFactory"); logger.trace(["RouteRequestFactory::build()"]); var request = null; var settings = options || {}; // gestion des callback var bOnError = !!(options.onError !== null && typeof options.onError === "function"); var message = null; // FIXME les exceptions ne sont pas 'catchées' sur le constructeur ! var myReq = new RouteRequestREST(settings); Iif (!myReq.processRequestString()) { message = "Error process request (rest) !"; if (bOnError) { options.onError.call(options.scope, new ErrorService(message)); return; } throw new Error(message); } request = myReq.requestString; return request; } }; export default RouteRequestFactory; |