mirror of
https://github.com/maelgangloff/domain-watchdog.git
synced 2025-12-22 20:25:43 +00:00
feat: add connector api wrapper
This commit is contained in:
parent
f9c003fffb
commit
e4da5413b4
@ -14,7 +14,7 @@ export function WatchlistsList({watchlists, onDelete}: { watchlists: Watchlist[]
|
|||||||
<Card title={t`Watchlist ${watchlist.token}`} extra={<Popconfirm
|
<Card title={t`Watchlist ${watchlist.token}`} extra={<Popconfirm
|
||||||
title={t`Delete the Watchlist`}
|
title={t`Delete the Watchlist`}
|
||||||
description={t`Are you sure to delete this Watchlist?`}
|
description={t`Are you sure to delete this Watchlist?`}
|
||||||
onConfirm={() => deleteWatchlist(watchlist.token).then()}
|
onConfirm={() => deleteWatchlist(watchlist.token).then(onDelete)}
|
||||||
okText={t`Yes`}
|
okText={t`Yes`}
|
||||||
cancelText={t`No`}
|
cancelText={t`No`}
|
||||||
><DeleteFilled/> </Popconfirm>}>
|
><DeleteFilled/> </Popconfirm>}>
|
||||||
|
|||||||
36
assets/utils/api/connectors.ts
Normal file
36
assets/utils/api/connectors.ts
Normal 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
|
||||||
|
})
|
||||||
|
}
|
||||||
@ -27,7 +27,7 @@ use Symfony\Component\Uid\Uuid;
|
|||||||
normalizationContext: ['groups' => 'connector:list']
|
normalizationContext: ['groups' => 'connector:list']
|
||||||
),
|
),
|
||||||
new Post(
|
new Post(
|
||||||
routeName: 'connector_create', normalizationContext: ['groups' => 'connector:create'],
|
routeName: 'connector_create', normalizationContext: ['groups' => ['connector:create', 'connector:list']],
|
||||||
denormalizationContext: ['groups' => 'connector:create'],
|
denormalizationContext: ['groups' => 'connector:create'],
|
||||||
name: 'create'
|
name: 'create'
|
||||||
),
|
),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user