getRequest static method

Future getRequest(
  1. String session,
  2. dynamic api,
  3. bool test
)

Implementation

static Future getRequest(String session, api, bool test) async {
  var url = test == true
      ? Uri.parse(
          'https://uatcheckout.thawani.om/api/v1/checkout/session/$session')
      : Uri.parse(
          'https://checkout.thawani.om/api/v1/checkout/session/$session');
  http.Response response = await http.get(
    url,
    headers: {'thawani-api-key': api, 'Content-Type': 'application/json'},
  );

  try {
    if (response.statusCode == 200) {
      String data = response.body;
      var decodeData = jsonDecode(data);
      return decodeData;
    } else {
      return 'failed';
    }
  } catch (e) {
    return 'failed';
  }
}