checkoutReview method Null safety

  1. @override
Future<CheckoutReviewModel> checkoutReview(
  1. {required int customerId,
  2. int? paymentOptionId,
  3. int? addressId,
  4. int? loyaltyPoints,
  5. int? pickStoreID}
)
override

It's used to get final stage in checkout cycle, It's just a review contains order Items - selected payment - selected address

Implementation

@override
Future<CheckoutReviewModel> checkoutReview(
    {required int customerId,
    int? paymentOptionId,
    int? addressId,
    int? loyaltyPoints,
    int? pickStoreID}) async {
  final response = await getData(
    path: 'checkout/review',
    queryParameters: {
      "PaymentOptionID": paymentOptionId,
      "CustomerID": customerId,
      "AddressID": addressId,
      "PickStoreID": pickStoreID,
      "LoyaltyPointsRedeemed": loyaltyPoints,
    },
  );
  final result = ApiReturnResult.fromJSON(response.data);
  if (result.code == 200) {
    return CheckoutReviewModel.fromJson(result.data);
  } else {
    throw ExceptionApi(code: result.code, message: result.error?.first);
  }
}