getPurchaseOrderHistory method

Future<List<POHistory>> getPurchaseOrderHistory({
  1. required String poNumber,
  2. String acceptableType = 'L',
  3. Options? getPurchaseConfirmationOptions,
})

Implementation

Future<List<POHistory>> getPurchaseOrderHistory({
  required String poNumber,
  String acceptableType = 'L',
  Options? getPurchaseConfirmationOptions,
}) async {
  try {
    Response<Json> response = await _deliveryApiProvider
        .getPurchaseOrderHistory(
          poNumber: poNumber,
          getPurchaseConfirmationOptions: getPurchaseConfirmationOptions,
        );

    List<Json> jsonList = List.from(response.data!['results']);

    return jsonList
        .map(POHistory.fromJson)
        .where((p) => p.histType == acceptableType)
        .toList();
  } catch (_) {
    return [];
  }
}