all method
Future<Response<RazorpayApiResponse<RazorpayAddon> > >
all({
- RazorpayPaginationOptions? params,
- void callback(
- RazorpayApiException?,
- Response<
RazorpayApiResponse< ?RazorpayAddon> >
Get all addons
@param params - Check doc for required params
Implementation
Future<Response<RazorpayApiResponse<RazorpayAddon>>> all({
RazorpayPaginationOptions? params,
void Function(
RazorpayApiException?,
Response<RazorpayApiResponse<RazorpayAddon>>?,
)? 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); // Use normalizeDate from utils
}
if (to != null) {
to = normalizeDate(to);
}
final queryParams = <String, dynamic>{
'from': from,
'to': to,
'count': count,
'skip': skip,
// Include other potential params from the input object if necessary
...?params?.toJson(), // Spread the rest of params if toJson is available
};
// Remove null values before sending
queryParams.removeWhere((key, value) => value == null);
return api.get<RazorpayApiResponse<RazorpayAddon>>(
{
'url': url,
'data': queryParams,
},
callback: callback,
// Provide the factory for the generic response and the inner item type
fromJsonFactory: (json) => RazorpayApiResponse<RazorpayAddon>.fromJson(
json,
(itemJson) => RazorpayAddon.fromJson(itemJson! as Map<String, dynamic>),
),
);
}