function parseBody (request, indentString, trimField) {
  if (request.body) {
    switch (request.body.mode) {
      case 'urlencoded':
        return parseFormData(request.body.toJSON(), indentString, trimField);
      case 'raw':
        return indentString + `.body(${JSON.stringify(request.body.toString())})\n`;

      case 'graphql':
        // eslint-disable-next-line no-case-declarations
        let query = request.body.graphql ? request.body.graphql.query : '',
          graphqlVariables;
        try {
          graphqlVariables = JSON.parse(request.body.graphql ? request.body.graphql.variables : '{}');
        }
        catch (e) {
          graphqlVariables = {};
        }
        return indentString + `.body("${sanitize(JSON.stringify({
          query: query || '',
          variables: graphqlVariables
        }), trimField)}")\n`;
      case 'formdata':
        var formDataContent = parseFormData(request.body.toJSON(), indentString, trimField);
        if (!formDataContent.includes('.field("file", new File')) {
          formDataContent = indentString + '.multiPartContent()\n' + formDataContent;
        }
        return formDataContent;
      case 'file':
        return indentString + '.body("<file contents here>")\n';
      default:
        return '';
    }
  }
  return '';
}
/**
 * parses body from request object based on mode provided by request body and
 * returns codesnippet in java unirest
 *
 * @param {Object} request - postman request object, more information can be found in postman collection sdk
 * @param {String} indentString - value for indentation
 * @param {Boolean} trimField - whether to trim fields of body of the request
 * @returns {String} - body string parsed from request object
 */
parses body from request object based on mode provided by request body and
returns codesnippet in java unirest

@param {Object} request - postman request object, more information can be found in postman collection sdk
@param {String} indentString - value for indentation
@param {Boolean} trimField - whether to trim fields of body of the request
@returns {String} - body string parsed from request object
parses body from request object based on mode provided by request body and returns codesnippet in java unirest @param { Object } request - postman request object more information can be found in postman collection sdk @param { String } indentString - value for indentation @param { Boolean } trimField - whether to trim fields of body of the request @returns { String } - body string parsed from request object
function parseBody (request, indentString, trimField) {
  if (request.body) {
    switch (request.body.mode) {
      case 'urlencoded':
        return parseFormData(request.body.toJSON(), indentString, trimField);
      case 'raw':
        return indentString + `.body(${JSON.stringify(request.body.toString())})\n`;
      case 'graphql':
        let query = request.body.graphql ? request.body.graphql.query : '',
          graphqlVariables;
        try {
          graphqlVariables = JSON.parse(request.body.graphql ? request.body.graphql.variables : '{}');
        }
        catch (e) {
          graphqlVariables = {};
        }
        return indentString + `.body("${sanitize(JSON.stringify({
          query: query || '',
          variables: graphqlVariables
        }), trimField)}")\n`;
      case 'formdata':
        var formDataContent = parseFormData(request.body.toJSON(), indentString, trimField);
        if (!formDataContent.includes('.field("file", new File')) {
          formDataContent = indentString + '.multiPartContent()\n' + formDataContent;
        }
        return formDataContent;
      case 'file':
        return indentString + '.body("<file contents here>")\n';
      default:
        return '';
    }
  }
  return '';
}
function parseBody ( request , indentString , trimField ) { if ( request . body ) { switch ( request . body . mode ) { case 'urlencoded' : return parseFormData ( request . body . toJSON ( ) , indentString , trimField ) ; case 'raw' : return indentString + ` ${ JSON . stringify ( request . body . toString ( ) ) } \n ` ; case 'graphql' : let query = request . body . graphql ? request . body . graphql . query : '' , graphqlVariables ; try { graphqlVariables = JSON . parse ( request . body . graphql ? request . body . graphql . variables : '{}' ) ; } catch ( e ) { graphqlVariables = { } ; } return indentString + ` ${ sanitize ( JSON . stringify ( { query : query || '' , variables : graphqlVariables } ) , trimField ) } \n ` ; case 'formdata' : var formDataContent = parseFormData ( request . body . toJSON ( ) , indentString , trimField ) ; if ( ! formDataContent . includes ( '.field("file", new File' ) ) { formDataContent = indentString + '.multiPartContent()\n' + formDataContent ; } return formDataContent ; case 'file' : return indentString + '.body("<file contents here>")\n' ; default : return '' ; } } return '' ; }
parses body from request object based on mode provided by request body and
 returns codesnippet in java unirest
parses body from request object based on mode provided by request body and returns codesnippet in java unirest
// eslint-disable-next-line no-case-declarations