lockCurrency method

Future lockCurrency(
  1. dynamic paymentID
)

Implementation

Future lockCurrency(paymentID) async {
  try {
    final LockCurrencyController _lockCurrencyController = Get.find();

    dynamic response;

    response = await http.patch(
      Uri.parse(
          '${Util.END_POINT}/payments/checkout/$paymentID/currency/lock'),
      headers: <String, String>{
        'Content-Type': 'application/json; charset=UTF-8',
        'Authorization':
            'Bearer ${GlobalizerController.paymentConfig!.publicKey}',
      },
    );
    //SET THE LOCK RESPONSE STATUSCODE IN ITS CONTROLLERS
    _lockCurrencyController.statusCode = response.statusCode;
    if (response.statusCode == 201 || response.statusCode == 200) {
      return jsonDecode(response.body);
    } else if (response.statusCode == 401) {
      Get.snackbar('Unathorized', 'Check your Public Key and retry');
      return jsonDecode(response.body);
    } else if (response.statusCode == 404) {
      Get.snackbar('404 Error', 'Check the endpoint again');
      return jsonDecode(response.body);
    } else {
      debugPrint("This is the lock currency response: ${response.body}");

      Get.snackbar(
          'Error', 'Something went wrong from the API locking currency');
      debugPrint(
          'Something went wrong from the API locking currency and the status code is ${response.statusCode} and body :${response.body} ');

      return jsonDecode(response.body);
    }
  } on Exception catch (e) {
    rethrow;
  }
}