getDenominationData method

dynamic getDenominationData()

Implementation

getDenominationData() async {
  String requestTime = DateTime.now().toString();
  await dio
      .get(
    "${ApiConstant.baseUrl}cpm-hierarchy-svc/dropDownChild?dropDownMasterId=150&status=1",
    options: Options(
      headers: {
        "Authorization": "Bearer ${SecureStorageService.readSecureData(
          SecureStorageService.accessToken,
        )}",
        'x-request-txn-id': UDID.uDID,
        'x-trace-id': UDID.uDIDTraceId,
      },
    ),
  )
      .then((value) {
    Helper.logEvent(
      "RESPONSE_EVENT",
      success: true,
      endPoint:
          "cpm-hierarchy-svc/dropDownChild?dropDownMasterId=223&order=desc&size=10&status=1",
      responseDate: DateTime.now().toString(),
      screenName: "stockOrder",
      requestDate: requestTime,
    );
    settingsResponse.SettingsResponse settingResponse =
        settingsResponse.SettingsResponse.fromJson(value.data);
    Map<String, dynamic> data = {};

    denominationList.clear();
    // settingResponse.content?.add(
    //   settingsResponse.Content(
    //     id: 00001,
    //     dropDownId: "Other",
    //     dropDownValue: "Other",
    //     dropDownMasterId: 0,
    //     parentId: null,
    //     status: 1,
    //     dropDownMasterName: "Custom Option",
    //     parentname: null,
    //   ),
    // );
    denominationList.addAll(settingResponse.content ?? []);

    for (final settings in settingResponse.content ?? []) {
      data[settings.dropDownId!] = settings.dropDownValue;
    }
    print(data);
    data.forEach((key, value) {
      String encodeData = json.encode(value);

      print("$key $encodeData");
    });
  }).catchError((err) {
    if (err is DioException) {
      UDID.setTraceId(
        err.response?.headers.map[Constants.traceIdKey]?[0] ?? "",
      );
      Helper.logEvent(
        "ERROR_EVENT",
        failure: true,
        requestDate: requestTime,
        endPoint:
            "cpm-hierarchy-svc/dropDownChild?dropDownMasterId=223&order=desc&size=10&status=1",
        responseDate: DateTime.now().toString(),
        screenName: "stockOrder",
        error: err,
      );
    }
    print(err.toString());
  });
}