getCpmDropDown method

dynamic getCpmDropDown({
  1. String? parentId,
  2. required int dropDownMasterId,
})

Implementation

getCpmDropDown({String? parentId, required int dropDownMasterId}) async {
  String requestTime = "";
  String responseTime = "";
  evdList.clear();
  await ApiClient(
    baseUrl: ApiConstant.baseUrl,
    onFetchRequestTime: (time) {
      requestTime = time;
    },
    onFetchResponseTime: (time) {
      responseTime = time;
    },
    screenName: "stockOrder",
  )
      .cpmDropDown(
    parentId: parentId,
    dropDownMasterId: dropDownMasterId,
    xUserId: SecureStorageService.readSecureData(
          SecureStorageService.xUserId,
        ) ??
        "",
  )
      .then((value) {
    Helper.logEvent(
      "RESPONSE_EVENT",
      success: true,
      endPoint: Api.cpmDropdown,
      responseDate: responseTime,
      screenName: "stockOrder",
      requestDate: requestTime,
    );
    if (value.content != null && value.content!.isNotEmpty) {
      if (dropDownMasterId == 14001) {
        reasonsdropdown.addAll(value.content ?? []);
      }

      if (dropDownMasterId == 18002) {
        evdId.value = value.content?[0].dropDownId ?? "";
      }

      if (dropDownMasterId == 18001) {
        for (var dropdown in (value.content ?? [])) {
          if (dropdown.dropDownId == evdTypeSelected.value) {
            evdModeSelected.value = dropdown?.dropDownValue ?? "";
          }
        }

        evdList.addAll(value.content ?? []);
      }
    }
  }).catchError((err) {
    Helper.logEvent(
      "RESPONSE_EVENT",
      failure: true,
      endPoint: Api.cpmDropdown,
      responseDate: responseTime,
      screenName: "stockOrder",
      requestDate: requestTime,
    );
  });
}