lib/utilities/RequestConverter.js
function convertRequest(request, functionName, config) {
    var url = '';
    var result;
    if (!request.url) {
        if (!request._unboundRequest && !request.collection) {
            ErrorHelper.parameterCheck(request.collection, 'DynamicsWebApi.' + functionName, "request.collection");
        }
        if (request.collection) {
            ErrorHelper.stringParameterCheck(request.collection, 'DynamicsWebApi.' + functionName, "request.collection");
            url = request.collection;

            //add alternate key feature
            if (request.key) {
                request.key = ErrorHelper.keyParameterCheck(request.key, 'DynamicsWebApi.' + functionName, "request.key");
            }
            else if (request.id) {
                request.key = ErrorHelper.guidParameterCheck(request.id, 'DynamicsWebApi.' + functionName, "request.id");
            }

            if (request.key) {
                url += "(" + request.key + ")";
            }
        }

        if (request._additionalUrl) {
            if (url) {
                url += '/';
            }
            url += request._additionalUrl;
        }

        result = convertRequestOptions(request, functionName, url, '&', config);
        if (request.fetchXml) {
            ErrorHelper.stringParameterCheck(request.fetchXml, 'DynamicsWebApi.' + functionName, "request.fetchXml");
            result.url += "?fetchXml=" + encodeURIComponent(request.fetchXml);
        }
        else
            if (result.query) {
                result.url += "?" + result.query;
            }
    }
    else {
        ErrorHelper.stringParameterCheck(request.url, 'DynamicsWebApi.' + functionName, "request.url");
        url = request.url.replace(config.webApiUrl, '');
        result = convertRequestOptions(request, functionName, url, '&', config);
    }

    if (request.hasOwnProperty('async') && request.async != null) {
        ErrorHelper.boolParameterCheck(request.async, 'DynamicsWebApi.' + functionName, "request.async");
        result.async = request.async;
    }
    else {
        result.async = true;
    }

    return { url: result.url, headers: result.headers, async: result.async };
}
function convertRequest(request, functionName, config) {
    var url = '';
    var result;
    if (!request.url) {
        if (!request._unboundRequest && !request.collection) {
            ErrorHelper.parameterCheck(request.collection, 'DynamicsWebApi.' + functionName, "request.collection");
        }
        if (request.collection) {
            ErrorHelper.stringParameterCheck(request.collection, 'DynamicsWebApi.' + functionName, "request.collection");
            url = request.collection;

            //add alternate key feature
            if (request.key) {
                request.key = ErrorHelper.keyParameterCheck(request.key, 'DynamicsWebApi.' + functionName, "request.key");
            }
            else if (request.id) {
                request.key = ErrorHelper.guidParameterCheck(request.id, 'DynamicsWebApi.' + functionName, "request.id");
            }

            if (request.key) {
                url += "(" + request.key + ")";
            }
        }

        if (request._additionalUrl) {
            if (url) {
                url += '/';
            }
            url += request._additionalUrl;
        }

        result = convertRequestOptions(request, functionName, url, '&', config);
        if (request.fetchXml) {
            ErrorHelper.stringParameterCheck(request.fetchXml, 'DynamicsWebApi.' + functionName, "request.fetchXml");
            result.url += "?fetchXml=" + encodeURIComponent(request.fetchXml);
        }
        else
            if (result.query) {
                result.url += "?" + result.query;
            }
    }
    else {
        ErrorHelper.stringParameterCheck(request.url, 'DynamicsWebApi.' + functionName, "request.url");
        url = request.url.replace(config.webApiUrl, '');
        result = convertRequestOptions(request, functionName, url, '&', config);
    }

    if (request.hasOwnProperty('async') && request.async != null) {
        ErrorHelper.boolParameterCheck(request.async, 'DynamicsWebApi.' + functionName, "request.async");
        result.async = request.async;
    }
    else {
        result.async = true;
    }

    return { url: result.url, headers: result.headers, async: result.async };
}
function convertRequest ( request , functionName , config ) { var url = '' ; var result ; if ( ! request . url ) { if ( ! request . _unboundRequest && ! request . collection ) { ErrorHelper . parameterCheck ( request . collection , 'DynamicsWebApi.' + functionName , "request.collection" ) ; } if ( request . collection ) { ErrorHelper . stringParameterCheck ( request . collection , 'DynamicsWebApi.' + functionName , "request.collection" ) ; url = request . collection ; //add alternate key feature if ( request . key ) { request . key = ErrorHelper . keyParameterCheck ( request . key , 'DynamicsWebApi.' + functionName , "request.key" ) ; } else if ( request . id ) { request . key = ErrorHelper . guidParameterCheck ( request . id , 'DynamicsWebApi.' + functionName , "request.id" ) ; } if ( request . key ) { url += "(" + request . key + ")" ; } } if ( request . _additionalUrl ) { if ( url ) { url += '/' ; } url += request . _additionalUrl ; } result = convertRequestOptions ( request , functionName , url , '&' , config ) ; if ( request . fetchXml ) { ErrorHelper . stringParameterCheck ( request . fetchXml , 'DynamicsWebApi.' + functionName , "request.fetchXml" ) ; result . url += "?fetchXml=" + encodeURIComponent ( request . fetchXml ) ; } else if ( result . query ) { result . url += "?" + result . query ; } } else { ErrorHelper . stringParameterCheck ( request . url , 'DynamicsWebApi.' + functionName , "request.url" ) ; url = request . url . replace ( config . webApiUrl , '' ) ; result = convertRequestOptions ( request , functionName , url , '&' , config ) ; } if ( request . hasOwnProperty ( 'async' ) && request . async != null ) { ErrorHelper . boolParameterCheck ( request . async , 'DynamicsWebApi.' + functionName , "request.async" ) ; result . async = request . async ; } else { result . async = true ; } return { url : result . url , headers : result . headers , async : result . async } ; }
Converts a request object to URL link

@param {Object} request - Request object
@param {string} [functionName] - Name of the function that converts a request (for Error Handling only)
@param {Object} [config] - DynamicsWebApi config
@returns {ConvertedRequest} Converted request
Converts a request object to URL link