getSubscriptionDetailAsync function

Future<GetSubscriptionDetail?> getSubscriptionDetailAsync(
  1. BuildContext context,
  2. String languageCode,
  3. String refererKey,
  4. GetDetailRequestModel model,
)

Implementation

Future<GetSubscriptionDetail?> getSubscriptionDetailAsync(BuildContext context,
    String languageCode, String refererKey, GetDetailRequestModel model) async {
  final url = Uri.parse(AppConfig.getDetailUrl);
  GetSubscriptionDetail? responseData;
  try {
    final response = await http.post(url,
        headers: {
          "Content-Type": "application/json",
          "token": AppConfig.token,
          "X-referrer-Key": refererKey
        },
        body: jsonEncode({"subscription_no": model.subscriptionNo}));

    if (response.statusCode == 200) {
      responseData = getSubscriptionDetailFromJson(response.body);
      debugPrint(responseData.toString());
    } else {
      debugPrint(response.body);
      B24DirectDebitSdk.showErrorMessage(
          // ignore: use_build_context_synchronously
          context,
          languageCode,
          errorNoData,
          errorNoDataKh);
    }
  } catch (ex) {
    debugPrint(ex.toString());
  }
  return responseData;
}