fetch method
Future<Response<RazorpayWebhook> >
fetch({
- required String webhookId,
- required String accountId,
- void callback(
- RazorpayApiException?,
- Response<
RazorpayWebhook> ?
Fetches a webhook (Only Partner context supported in JS?) Assuming fetch only works for partner accounts based on JS code structure.
@param webhookId - The unique identifier of the webhook. @param accountId - The unique identifier of the partner account.
Implementation
Future<Response<RazorpayWebhook>> fetch({
required String webhookId,
required String accountId, // Required for partner context
void Function(RazorpayApiException?, Response<RazorpayWebhook>?)? callback,
}) async {
if (webhookId.isEmpty) {
throw ArgumentError('webhookId is required');
}
if (accountId.isEmpty) {
// If fetch should work for merchant context, remove this check and adjust URL logic
throw ArgumentError(
'accountId is required for fetching webhooks in partner context',
);
}
return api.get<RazorpayWebhook>(
{
'version': 'v2',
'url': '$BASE_URL/$accountId$WEBHOOKS_BASE/$webhookId',
},
fromJsonFactory: RazorpayWebhook.fromJson,
callback: callback,
);
}