From e697b76235583ef122267d19c6db68a738d7b47a Mon Sep 17 00:00:00 2001 From: Hironsan Date: Thu, 4 Mar 2021 16:32:21 +0900 Subject: [PATCH] Add stats repository --- frontend/repositories/statistics/api.ts | 15 +++++++++++++++ frontend/repositories/statistics/interface.ts | 6 ++++++ 2 files changed, 21 insertions(+) create mode 100644 frontend/repositories/statistics/api.ts create mode 100644 frontend/repositories/statistics/interface.ts diff --git a/frontend/repositories/statistics/api.ts b/frontend/repositories/statistics/api.ts new file mode 100644 index 00000000..a8b6c8b2 --- /dev/null +++ b/frontend/repositories/statistics/api.ts @@ -0,0 +1,15 @@ +import ApiService from '@/services/api.service' +import { Statistics } from '@/models/statistics' +import { StatisticsRepository } from './interface' + +export class FromApiStatisticsRepository implements StatisticsRepository { + constructor( + private readonly request = ApiService + ) {} + + async fetch(projectId: string): Promise { + const url = `/projects/${projectId}/statistics` + const response = await this.request.get(url) + return Statistics.valueOf(response.data) + } +} diff --git a/frontend/repositories/statistics/interface.ts b/frontend/repositories/statistics/interface.ts new file mode 100644 index 00000000..eb067808 --- /dev/null +++ b/frontend/repositories/statistics/interface.ts @@ -0,0 +1,6 @@ +import { Statistics } from '@/models/statistics' + +export interface StatisticsRepository { + + fetch(projectId: string): Promise +}