callDealerDetailsApi method
Future<void>
callDealerDetailsApi(
- int dealerId, {
- required bool isDealerFlow,
})
Implementation
Future<void> callDealerDetailsApi(int dealerId,
{required bool isDealerFlow}) async {
BuildContext context = Get.context!;
// Helper.progressDialog(context, "Please wait..");
// printLogs(dio);
String requestTime = DateTime.now().toString();
await dio
.get(
'${ApiConstant.baseUrl}cpm-channel-partner-svc/partner/getMoreInfo/$dealerId',
options: Options(
headers: {
'x-request-txn-id': UDID.uDID,
'Content-Type': 'application/json',
'Authorization': "Bearer ${SecureStorageService.readSecureData(
SecureStorageService.accessToken,
)}",
},
),
)
.then((response) {
// Get.back();
if (response.data != null) {
UDID.setTraceId(response.headers.map[Constants.traceIdKey]?[0] ?? "");
Helper.logEvent(
"RESPONSE_EVENT",
success: true,
endPoint: "cpm-channel-partner-svc/partner/getMoreInfo/$dealerId",
responseDate: DateTime.now().toString(),
screenName: "orderStock",
requestDate: requestTime,
);
// print('dealerDetails$response.data');
Map<String, dynamic> data = response.data;
DealerDetailsModel model = DealerDetailsModel.fromJson(data);
storage.write("DISTRIBUTER_ID", model.profile!.parentId ?? "");
storage.write("REGION_ID", model.profile!.address!.locationId1 ?? "");
storage.write("REGION_NAME",
model.profile!.address!.locationName4 ?? ""); // region verify
storage.write("LEVEL_NAME", model.profile!.levelName ?? "");
storage.write("PARTNER_ID ", model.profile?.partnerId);
partnerId = model.profile?.partnerId ?? '';
storage.write("LEVEL_ID", model.profile!.levelId);
storage.write("ADDRESS_ID", model.profile!.address!.id ?? "");
if (isDealerFlow) {
storage.write("DEALER_LEVEL_ID", model.profile!.levelId);
}
// if (model.profile!.profileGroup != null &&
// model.profile!.profileGroup!.company != null &&
// model.profile!.profileGroup!.company!.isNotEmpty) {
// for (int i = 0;
// i < model.profile!.profileGroup!.company!.length;
// i++) {
// if (model.profile!.profileGroup!.company![i].field ==
// 'withHoldingPercentage') {
// if (model.profile!.profileGroup!.company![i].value != null) {
// List<String> taxValueCode =
// model.profile!.profileGroup!.company![i].value!.split("-");
// String taxValue = taxValueCode[1].replaceAll("%", "").trim();
// String taxCode = taxValueCode[0].trim();
// log("$taxValue $taxCode");
// storage.write("ADHOX_TAX_VALUE", taxValue);
// storage.write("ADHOX_TAX_CODE", taxValue);
// }
// }
// }
// }
}
}).catchError((error) {
ConditionalLogs().customLog("$error");
if (error is DioException) {
UDID.setTraceId(
error.response?.headers.map[Constants.traceIdKey]?[0] ?? "",
);
Helper.logEvent(
"ERROR_EVENT",
failure: true,
endPoint: "cpm-channel-partner-svc/partner/getMoreInfo/$dealerId",
requestDate: requestTime,
responseDate: DateTime.now().toString(),
screenName: "orderStock",
error: error,
);
}
// Get.back();
// Helper.messageDialog(Get.context!, "Try Again!!", error.toString());
});
}