feat: add connector api wrapper

This commit is contained in:
Maël Gangloff 2024-07-29 19:04:50 +02:00
parent f9c003fffb
commit e4da5413b4
No known key found for this signature in database
GPG Key ID: 11FDC81C24A7F629
3 changed files with 38 additions and 2 deletions

View File

@ -14,7 +14,7 @@ export function WatchlistsList({watchlists, onDelete}: { watchlists: Watchlist[]
<Card title={t`Watchlist ${watchlist.token}`} extra={<Popconfirm
title={t`Delete the Watchlist`}
description={t`Are you sure to delete this Watchlist?`}
onConfirm={() => deleteWatchlist(watchlist.token).then()}
onConfirm={() => deleteWatchlist(watchlist.token).then(onDelete)}
okText={t`Yes`}
cancelText={t`No`}
><DeleteFilled/> </Popconfirm>}>

View File

@ -0,0 +1,36 @@
import {request} from "./index";
enum ConnectorProvider {
OVH = 'ovh'
}
export type Connector = {
provider: ConnectorProvider
authData: object
}
export async function getConnectors() {
const response = await request({
url: 'connectors'
})
return response.data
}
export async function postConnector(connector: Connector) {
const response = await request<Connector & { id: string }>({
method: 'POST',
url: 'connectors',
data: connector,
headers: {
"Content-Type": 'application/json'
}
})
return response.data
}
export async function deleteConnector(token: string): Promise<void> {
await request({
method: 'DELETE',
url: 'connectors/' + token
})
}

View File

@ -27,7 +27,7 @@ use Symfony\Component\Uid\Uuid;
normalizationContext: ['groups' => 'connector:list']
),
new Post(
routeName: 'connector_create', normalizationContext: ['groups' => 'connector:create'],
routeName: 'connector_create', normalizationContext: ['groups' => ['connector:create', 'connector:list']],
denormalizationContext: ['groups' => 'connector:create'],
name: 'create'
),