diff options
author | Sebastian <sebasjm@gmail.com> | 2023-01-27 15:08:03 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-01-27 15:08:25 -0300 |
commit | eebb85bef4bb6bba41533fa0ff343cf2f1995761 (patch) | |
tree | 08ac7d3197d662bd8fadc747a912023364a4f9c7 /packages/merchant-backoffice-ui/src/hooks/backend.ts | |
parent | 1b2b5d62de5888eae895db69cf6ae51dbfddb32b (diff) | |
download | wallet-core-eebb85bef4bb6bba41533fa0ff343cf2f1995761.tar.xz |
webhook api
Diffstat (limited to 'packages/merchant-backoffice-ui/src/hooks/backend.ts')
-rw-r--r-- | packages/merchant-backoffice-ui/src/hooks/backend.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/packages/merchant-backoffice-ui/src/hooks/backend.ts b/packages/merchant-backoffice-ui/src/hooks/backend.ts index a0639a4a0..3f3db2fa1 100644 --- a/packages/merchant-backoffice-ui/src/hooks/backend.ts +++ b/packages/merchant-backoffice-ui/src/hooks/backend.ts @@ -115,6 +115,11 @@ interface useBackendInstanceRequestType { position?: string, delta?: number, ) => Promise<HttpResponseOk<T>>; + webhookFetcher: <T>( + path: string, + position?: string, + delta?: number, + ) => Promise<HttpResponseOk<T>>; } interface useBackendBaseRequestType { request: <T>( @@ -274,6 +279,23 @@ export function useBackendInstanceRequest(): useBackendInstanceRequestType { [backend, token], ); + const webhookFetcher = useCallback( + function webhookFetcherImpl<T>( + path: string, + position?: string, + delta?: number, + ): Promise<HttpResponseOk<T>> { + const params: any = {}; + if (delta !== undefined) { + params.limit = delta; + } + if (position !== undefined) params.offset = position; + + return requestHandler<T>(backend, path, { params, token }); + }, + [backend, token], + ); + return { request, fetcher, @@ -283,5 +305,6 @@ export function useBackendInstanceRequest(): useBackendInstanceRequestType { tipsDetailFetcher, transferFetcher, templateFetcher, + webhookFetcher, }; } |