You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
620 B

2 years ago
  1. import ApiService from '@/services/api.service'
  2. import { Catalog } from '~/domain/models/upload/catalog'
  3. function toModel(item: { [key: string]: any }): Catalog {
  4. return new Catalog(
  5. item.name,
  6. item.example,
  7. item.properties,
  8. item.task_id,
  9. item.display_name,
  10. item.accept_types
  11. )
  12. }
  13. export class APICatalogRepository {
  14. constructor(private readonly request = ApiService) {}
  15. async list(projectId: string): Promise<Catalog[]> {
  16. const url = `/projects/${projectId}/catalog`
  17. const response = await this.request.get(url)
  18. return response.data.map((item: any) => toModel(item))
  19. }
  20. }