Skip to content
Snippets Groups Projects
apiPath.ts 1.96 KiB
Newer Older
import { PROJECT_ID } from '@/constants';
import { PerfectSearchParams } from '@/types/search';
import { Point } from '@/types/map';

export const apiPath = {
  getBioEntityContentsStringWithQuery: ({
    searchQuery,
    isPerfectMatch,
  }: PerfectSearchParams): string =>
    `projects/${PROJECT_ID}/models/*/bioEntities/:search?query=${searchQuery}&size=1000&perfectMatch=${isPerfectMatch}`,
  getSingleBioEntityContentsStringWithCoordinates: (
    { x, y }: Point,
    currentModelId: number,
  ): string => {
    const coordinates = [x, y].join();
    return `projects/${PROJECT_ID}/models/${currentModelId}/bioEntities:search/?coordinates=${coordinates}&count=1`;
  },
  getReactionsWithIds: (ids: number[]): string =>
    `projects/${PROJECT_ID}/models/*/bioEntities/reactions/?id=${ids.join(',')}&size=1000`,
  getDrugsStringWithQuery: (searchQuery: string): string =>
    `projects/${PROJECT_ID}/drugs:search?query=${searchQuery}`,
  getModelsString: (): string => `projects/${PROJECT_ID}/models/`,
  getChemicalsStringWithQuery: (searchQuery: string): string =>
    `projects/${PROJECT_ID}/chemicals:search?query=${searchQuery}`,
  getAllOverlaysByProjectIdQuery: (
    projectId: string,
    { publicOverlay }: { publicOverlay: boolean },
  ): string => `projects/${projectId}/overlays/?publicOverlay=${String(publicOverlay)}`,
  getAllBackgroundsByProjectIdQuery: (projectId: string): string =>
    `projects/${projectId}/backgrounds/`,
  getProjectById: (projectId: string): string => `projects/${projectId}`,
  getSessionValid: (): string => `users/isSessionValid`,
  postLogin: (): string => `doLogin`,
  getConfigurationOptions: (): string => 'configuration/options/',
  getConfiguration: (): string => 'configuration/',
  getOverlayBioEntity: ({ overlayId, modelId }: { overlayId: number; modelId: number }): string =>
    `projects/${PROJECT_ID}/overlays/${overlayId}/models/${modelId}/bioEntities/`,
  getStatisticsById: (projectId: string): string => `projects/${projectId}/statistics/`,