request method

Future<Response> request()

Make the request

Implementation

Future<Response> request() async {
  final Client client = Client();
  try {
    switch (type) {
      case RestfulRequest.get_:
        {
          return await client.get(
            Uri.parse(url),
            headers: headers,
          );
        }
      case RestfulRequest.post_:
        {
          return await client.post(
            Uri.parse(url),
            headers: headers,
            body: body,
          );
        }
      case RestfulRequest.put_:
        {
          return await client.put(
            Uri.parse(url),
            headers: headers,
            body: body,
          );
        }
      case RestfulRequest.delete_:
        {
          return await client.delete(
            Uri.parse(url),
            headers: headers,
          );
        }
      case RestfulRequest.patch_:
        {
          return await client.patch(
            Uri.parse(url),
            headers: headers,
            body: body,
          );
        }
    }
  } catch (e, stack) {
    return Response('$e', 500,
        headers: <String, String>{'x-fhir-stack': stack.toString()});
  }
}