All files / src/Services/Geocode/Request GeocodeRequestFactory.js

90% Statements 9/10
50% Branches 2/4
100% Functions 1/1
90% Lines 9/10

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                      1x                                                 2x 2x   2x   2x 2x     2x   2x   2x          
import Logger from "../../../Utils/LoggerByDefault";
import GeocodeRequestREST from "./GeocodeRequestREST";
 
/**
 * Creation d'une requĂȘte
 * (Factory)
 *
 * @module GeocodeRequestFactory
 * @alias Gp.Services.Geocode.Request.GeocodeRequestFactory
 * @private
 */
var GeocodeRequestFactory = {
 
    /**
     * interface unique
     *
     * @method build
     * @static
     * @param {Object} options - options definies dans le composant Geocode
     *
     * @example
     *   var options = {
     *      // options specifiques du service
     *      geocodeMethod:
     *      query:
     *      filters:
     *      maximumResponses:
     *   };
     *   var result = GeocodeRequestFactory.build(options);
     *   if (!result) {
     *       // error...
     *   }
     * @returns {String} request
     */
    build : function (options) {
        // logger
        var logger = Logger.getLogger("GeocodeRequestFactory");
        logger.trace(["GeocodeRequestFactory::build()"]);
 
        var settings = options || {};
 
        var myReq = new GeocodeRequestREST(settings);
        Iif (!myReq.processRequestString()) {
            throw new Error("Error process request (rest) !");
        }
        var request = myReq.requestString;
 
        logger.trace(request);
 
        return request;
    }
};
 
export default GeocodeRequestFactory;