requestJson method

Future requestJson(
  1. HttpMethod method,
  2. String url,
  3. ApiVersion apiVersion,
  4. {Map<String, dynamic>? parameters,
  5. String? rootElement}
)

Implementation

Future<dynamic> requestJson(
    HttpMethod method, String url, ApiVersion apiVersion,
    {Map<String, dynamic>? parameters, String? rootElement}) async {
  final response = await EasyPostRequest.executeRequest(
      config, method, url, apiVersion,
      parameters: parameters);

  dynamic json = jsonDecode(response.body);

  if (rootElement != null) {
    json = json[rootElement];
  }

  return json;
}