build method

Request build()

Implementation

Request build() {
  var url = this.url;
  if (method == 'GET') {
    url = url.replace(
      queryParameters: parameters.mapValues(encode).mapValues(jsonEncode),
    );
  }
  var request = Request(method, url)..headers.addAll(headers);
  if (method == 'POST') {
    request.body = jsonEncode({
      'params': parameters.mapValues(encode),
      'context': context.mapValues(encode),
    });
  } else if (context.isNotEmpty) {
    request.headers['x-api-context'] = jsonEncode(context.mapValues(encode));
  }
  return request;
}