'use strict';

var BuildUrlUtils = 
    {
        buildUrl: function(query, options, model, fields, id) {
            var url = null;
            query = JSON.stringify(query);
            query = encodeURIComponent(query);
            if (fields) {
                fields = JSON.stringify(query);
                fields = encodeURIComponent(query);
            }
            if (options) {
                options = JSON.stringify(options);
                options = encodeURIComponent(options);
            }
            url = model.URL_PATH;
            if (id) {
                url = url + '/' + id;
            }
            url = url + '?rawQuery=' + query;
            url = (options) ? url + '&rawOptions=' + options : url;
            url = (fields) ? url + '&fields=' + fields : url;
            return url;
        },
        encode: function(obj) {
            var result;
            result = JSON.stringify(obj);
            result = encodeURIComponent(result);
            return result;
        }
    }


export { BuildUrlUtils };