Commit 1086facb authored by Alex Kakiris's avatar Alex Kakiris
Browse files

add /api/me client functions

parent f773314c
Loading
Loading
Loading
Loading
+26 −0
Changes for capif_frontend/src/configs/apiService.js: 26 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -589,3 +589,29 @@ export const removeRegisterConfigCategory = async ({ category_name }) => {
  }
};

// ME (user-scoped)
// Unlike the functions above, these do not wrap errors in `new Error(...)`: the axios error
// is rethrown unchanged so callers keep `error.response.status`. Here the status codes carry
// meaning (403 no CAPIF credentials, 404 not your invoker, 502 CCF failed) and the UI renders
// a different state for each. Don't "harmonise" these with the rest of the file.

export const onboardInvoker = async ({ apiInvokerInformation, notificationDestination }) => {
  const response = await axiosInstance.post('/me/invoker', {
    apiInvokerInformation,
    notificationDestination
  })

  return response.data
}

export const getMyInvokers = async () => {
  const response = await axiosInstance.get('/me/invokers')

  return response.data
}

export const discoverApis = async invokerId => {
  const response = await axiosInstance.get(`/me/invokers/${encodeURIComponent(invokerId)}/apis`)

  return response.data
}