/* 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 to patch file access.
   */
  static filesAccess(oid: string, fid: string): string {
    return `${RouteBuilder.file(oid, fid)}/access`
  }

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

  /**
   * @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'
  }

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

  static organizationUsers(oid: string): string {
    return `${this.organization(oid)}/users`
  }

  static organizationUserBatch(oid: string): string {
    return `${this.organization(oid)}/users/batch/read`
  }

  static organizationUser(oid: string, key: string): string {
    return `${this.organization(oid)}/users/${key}`
  }

  static organizationUserDeactivate(oid: string, key: string): string {
    return `${this.organization(oid)}/users/${key}/deactivate`
  }

  static organizationUserActivate(oid: string, key: string): string {
    return `${this.organization(oid)}/users/${key}/activate`
  }

  /**
   * @deprecated Use `organizationUsers` instead.
   */
  static users(oid: string): string {
    return `${this.organization(oid)}/users`
  }

  /**
   * @deprecated Use `organizationUser` instead.
   */
  static user(oid: string, key: string): string {
    return `${this.organization(oid)}/users/${key}`
  }

  static invitations(oid: string): string {
    return `${this.organization(oid)}/invitations`
  }

  static invitation(oid: string, id: string): string {
    return `${this.invitations(oid)}/${id}`
  }

  static findInvitation(): string {
    return `${this.organizations()}/find-invitation`
  }

  static declineInvitation(oid: string, id: string): string {
    return `${this.invitation(oid, id)}/decline`
  }

  static resendInvitation(oid: string, id: string): string {
    return `${this.invitation(oid, id)}/resend`
  }

  /**
   * @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 dataCatalog(): string {
    return '/v1/datacatalog'
  }

  static dataCatalogStatus(domainId: string): string {
    return `${RouteBuilder.dataCatalog()}/status/${domainId}`
  }

  static dataCatalogEntry(domainId: string): string {
    return `${RouteBuilder.dataCatalog()}/${domainId}`
  }

  static dataCatalogEntryVersions(entryId: string): string {
    return `${RouteBuilder.dataCatalogEntry(entryId)}/versions`
  }

  static dataCatalogDependencies(): string {
    return `${RouteBuilder.dataCatalog()}/dependencies`
  }

  static dataCatalogVersion(entryId: string, version: string): string {
    return `${RouteBuilder.dataCatalogEntry(entryId)}/${version}`
  }

  static dataCatalogDeprecate(entryId: string): string {
    return `${RouteBuilder.dataCatalogEntry(entryId)}/deprecate`
  }

  static dataCatalogUnpublish(entryId: string): string {
    return `${RouteBuilder.dataCatalogEntry(entryId)}/unpublish`
  }

  static dataCatalogVersionDeprecate(entryId: string, version: string): string {
    return `${RouteBuilder.dataCatalogVersion(entryId, version)}/deprecate`
  }

  static dataCatalogVersionUnpublish(entryId: string, version: string): string {
    return `${RouteBuilder.dataCatalogVersion(entryId, version)}/unpublish`
  }

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

  static group(oid: string, gid: string): string {
    return `/v1/orgs/${oid}/groups/${gid}`
  }

  static groupUsers(oid: string, gid: string): string {
    return `/v1/orgs/${oid}/groups/${gid}/users`
  }
}
