formatUrl method

String formatUrl(
  1. String url, {
  2. bool? waitForSync,
  3. bool? returnNew,
  4. bool? returnOld,
  5. bool? silent,
  6. bool? overwrite,
  7. bool? ignoreRevs,
  8. bool? mergeObjects,
  9. bool? keepNull,
})

Formats an url for the http request with parameters

Implementation

String formatUrl(String url,
    {bool? waitForSync,
    bool? returnNew,
    bool? returnOld,
    bool? silent,
    bool? overwrite,
    bool? ignoreRevs,
    bool? mergeObjects,
    bool? keepNull}) {
  var formattedUrl = '$url?';
  if (waitForSync != null && waitForSync) {
    formattedUrl += 'waitForSync=true&';
  }
  if (returnNew != null && returnNew) {
    formattedUrl += 'returnNew=true&';
  }
  if (returnOld != null && returnOld) {
    formattedUrl += 'returnOld=true&';
  }
  if (silent != null && silent) {
    formattedUrl += 'silent=true&';
  }
  if (overwrite != null && overwrite) {
    formattedUrl += 'overwrite=true&';
  }
  if (ignoreRevs != null && ignoreRevs) {
    formattedUrl += 'ignoreRevs=true&';
  }
  if (mergeObjects != null && mergeObjects) {
    formattedUrl += 'mergeObjects=true&';
  }
  if (keepNull != null && keepNull) {
    formattedUrl += 'keepNull=true&';
  }
  formattedUrl = formattedUrl.substring(0, formattedUrl.length - 1);
  return formattedUrl;
}