fetchOndemandSettlementById method

Future<Response<RazorpayInstantSettlement>> fetchOndemandSettlementById({
  1. required String settlementId,
  2. List<String>? expand,
  3. void callback(
    1. RazorpayApiException?,
    2. Response<RazorpayInstantSettlement>?
    )?,
})

Fetch on-demand settlement by ID

@param settlementId - The unique identifier of the settlement. @param params - Expand options.

Implementation

Future<Response<RazorpayInstantSettlement>> fetchOndemandSettlementById({
  required String settlementId,
  List<String>? expand, // Use List<String>
  void Function(RazorpayApiException?, Response<RazorpayInstantSettlement>?)?
      callback,
}) async {
  if (settlementId.isEmpty) {
    throw ArgumentError('settlementId is mandatory');
  }

  final queryParams = {
    if (expand != null) 'expand[]': expand,
  };

  return api.get<RazorpayInstantSettlement>(
    {
      'url': '$BASE_URL/ondemand/$settlementId',
      'data': queryParams.isNotEmpty ? queryParams : null,
    },
    fromJsonFactory: RazorpayInstantSettlement.fromJson,
    callback: callback,
  );
}