/* eslint-disable @typescript-eslint/no-extraneous-class */
/**
 * A helper class to make sure routes user and reported by this service are consistent.
 */
export class RouteBuilder {
  /**
   * @param oid The org id.
   * @returns The path to the /folders/{oid} route.
   */
  static folders(oid: string): string {
    return `/v1/orgs/${oid}/folders`
  }

  /**
   * @returns The path to the /files/{oid} route.
   */
  static files(oid: string): string {
    return `/v1/orgs/${oid}/files`
  }

  /**
   * Used for SSE or WS to inform clients about a file being shared with the user.
   * @returns The path to the /files/access route.
   */
  static filesAccess(oid: string): string {
    return `${RouteBuilder.files(oid)}/access`
  }

  /**
   * @returns The path to the /files/{oid}/batch route.
   */
  static filesBatch(oid: string): string {
    return `${RouteBuilder.files(oid)}/batch`
  }

  /**
   * @returns The path to the /files/{oid}/[id] route.
   */
  static file(oid: string, key: string): string {
    return `${RouteBuilder.files(oid)}/${key}`
  }

  /**
   * @returns The path to the /files/{oid}/[id] route.
   */
  static fileMedia(oid: string, key: string): string {
    return `${RouteBuilder.file(oid, key)}/media`
  }

  /**
   * @returns The path to the /files/{oid}/[id]/users route.
   */
  static fileUsers(oid: string, file: string): string {
    return `${RouteBuilder.file(oid, file)}/users`
  }

  /**
   * @returns The path to the /file/{oid}/[id]/revisions route.
   */
  static fileRevisions(oid: string, file: string): string {
    return `${RouteBuilder.file(oid, file)}/revisions`
  }

  /**
   * @returns The path to the /file/{oid}/[id]/revisions route.
   */
  static fileBreadcrumbs(oid: string, file: string): string {
    return `${RouteBuilder.file(oid, file)}/breadcrumbs`
  }

  /**
   * @deprecated Not used anymore
   */
  static backend(): string {
    return '/store'
  }

  /**
   * @deprecated Not used anymore
   */
  static sessions(): string {
    return '/sessions'
  }

  /**
   * @deprecated Not used anymore
   */
  static sessionRenew(): string {
    return '/sessions/renew'
  }

  static history(): string {
    return `/history`
  }

  static historyBatchCreate(): string {
    return `/history/batch/create`
  }

  static historyBatchDelete(): string {
    return `/history/batch/delete`
  }

  static historyItem(key: string): string {
    return `/history/${key}`
  }

  static historyClear(type: 'organization' | 'project' | 'request', ...key: string[]): string {
    return `/history/clear/${type}/${key.join('/')}`
  }

  static shared(oid: string): string {
    return `/v1/orgs/${oid}/shared`
  }

  static trash(oid: string): string {
    return `/v1/orgs/${oid}/trash`
  }

  static trashItem(oid: string, trashKey: string): string {
    // GET + DELETE (link to ./delete)
    return `${RouteBuilder.trash(oid)}/${trashKey}`
  }

  static trashRestore(oid: string, trashKey: string): string {
    return `${RouteBuilder.trashItem(oid, trashKey)}/restore`
  }

  static trashEmpty(oid: string): string {
    return `${RouteBuilder.trash(oid)}/empty`
  }

  static trashBatchRestore(oid: string): string {
    return `${RouteBuilder.trash(oid)}/restore`
  }

  static trashBatchDelete(oid: string): string {
    return `${RouteBuilder.trash(oid)}/delete`
  }

  static projectExecutions(): string {
    return `/project/execution`
  }

  static projectExecution(key: string): string {
    return `/project/execution/${key}`
  }

  static projectExecutionBulkDelete(): string {
    return `/project/execution/delete`
  }

  static projectExecutionClear(scope: 'organization' | 'project' | 'folder'): string {
    return `/project/execution/clear/${scope}`
  }

  static organizations(): string {
    return '/v1/orgs'
  }

  /**
   * @deprecated Not used anymore
   */
  static authLogin(): string {
    return '/auth/login'
  }

  static authGoogle(): string {
    return '/auth/google'
  }

  static authRenew(): string {
    return '/auth/renew'
  }

  /**
   * @deprecated Not used anymore
   */
  static authProvider(provider: string): string {
    return `/auth/${provider}`
  }

  /**
   * @deprecated Not used anymore
   */
  static authToken(code: string): string {
    return `/auth/token/${code}`
  }

  static usersMe(): string {
    return '/v1/users/me'
  }

  static users(oid: string): string {
    return `/v1/orgs/${oid}/users`
  }

  static user(oid: string, key: string): string {
    return `/v1/orgs/${oid}/users/${key}`
  }
}
