all method

Get all paymentLinks

@param params - Check doc for required params.

Implementation

Future<Response<RazorpayPaymentLinkListResponse>> all({
  RazorpayPaginationOptions? params,
  void Function(
    RazorpayApiException?,
    Response<RazorpayPaymentLinkListResponse>?,
  )? callback,
}) async {
  const url = BASE_URL;
  var from = params?.from;
  var to = params?.to;
  final count = params?.count ?? 10;
  final skip = params?.skip ?? 0;

  if (from != null) {
    from = normalizeDate(from);
  }
  if (to != null) {
    to = normalizeDate(to);
  }

  final queryParams = {
    'from': from,
    'to': to,
    'count': count,
    'skip': skip,
    // Include other potential params from the input object if necessary
    ...?params?.toJson(),
  };
  queryParams.removeWhere((key, value) => value == null);

  // Note: JS returns { payment_links: [...] }. Use specific model.
  return api.get<RazorpayPaymentLinkListResponse>(
    {
      'url': url,
      'data': queryParams,
    },
    callback: callback,
    fromJsonFactory: RazorpayPaymentLinkListResponse.fromJson,
  );
}