getCustumerDetails method

void getCustumerDetails(
  1. BuildContext context,
  2. String? merchantId,
  3. String? customerId
)

Implementation

void getCustumerDetails(
    BuildContext context, String? merchantId, String? customerId) async {
  try {
    // isLoading(true);
    var customerId = merchantId ?? Storage.getValue(Constants.merchantID);
    var request = {
      'api_key': await Constants.apiKey(),
      'merchant_id': customerId.toString(),
    };
    var response = await DioClient().request(
        context: context,
        api: '/merchant/customers/$customerId',
        method: Method.POST,
        params: request);

    GetCustomerResponse getCustomerResponse =
        GetCustomerResponse.fromJson(response);
    if (getCustomerResponse.status == Strings.success) {
      Storage.removeValue(Constants.customerEmail);
      Storage.saveValue(
          Constants.customerEmail, getCustomerResponse.data!.email);
    } else {
      isError(true);
      errorMessage.value = response['message'].toString().toTitleCase();
      return Utils.showSnackbar(context, Strings.error,
          response['message'].toString().toTitleCase(), AppColors.red);
    }
  } finally {
    // isLoading(false);
    // isError(false);
  }
  update();
}