Ziwako Docs
ZiwakoGuide développeurSDK @ziwako/client

Scopes de scan

Scopes liés aux scans via @ziwako/client — CRUD et ajout de services.

La ressource ScanScopes définit les scopes (périmètres) rattachés à un scan : elle permet de regrouper des services accessibles depuis un même QR code.

  • Factory : getScanScopes() (@ziwako/client/axios)
  • Types : ScanScope, ScanScopeResponse, CreateScanScopeBody, UpdateScanScopeBody, AddServiceToScopeBody
  • Endpoints : POST /scan_scopes, GET /scan_scopes/{id}, PUT /scan_scopes/{id}, PUT /scan_scopes/{id}/add_service
import { configure, getScanScopes } from '@ziwako/client/axios';
configure({ accessToken: '...' });
const scanScopes = getScanScopes();

createScanScope

Crée un scope rattaché à un scan.

Signature : createScanScope(createScanScopeBody?: CreateScanScopeBody) → Promise<ScanScopeResponse>

const response = await scanScopes.createScanScope({
    scanId: '64b8f2...',
    name: 'Menu restaurant',
});
console.log(response.data?.id);
import { useCreateScanScope } from '@ziwako/client/react-query';

const mutation = useCreateScanScope();
mutation.mutate({ data: { scanId: '64b8f2...', name: 'Menu restaurant' } });

getScanScope

Récupère un scope par son id.

Signature : getScanScope(id: string) → Promise<ScanScopeResponse>

const response = await scanScopes.getScanScope('64b8f2...');
console.log(response.data?.services);
import { useGetScanScope } from '@ziwako/client/react-query';

const { data } = useGetScanScope(scopeId);

updateScanScope

Met à jour un scope (nom, services, configuration).

Signature : updateScanScope(id: string, updateScanScopeBody?: UpdateScanScopeBody) → Promise<ScanScope>

await scanScopes.updateScanScope(scopeId, { name: 'Menu du midi' });
import { useUpdateScanScope } from '@ziwako/client/react-query';

const mutation = useUpdateScanScope();
mutation.mutate({ id: scopeId, data: { name: 'Menu du midi' } });

addServiceToScope

Ajoute un service au scope.

Signature : addServiceToScope(id: string, addServiceToScopeBody?: AddServiceToScopeBody) → Promise<ScanScopeResponse>

await scanScopes.addServiceToScope(scopeId, { serviceId: '64b8f2...' });
import { useAddServiceToScope } from '@ziwako/client/react-query';

const mutation = useAddServiceToScope();
mutation.mutate({ id: scopeId, data: { serviceId: '64b8f2...' } });