| 3 | import type { CardRepository } from './CardRepository' |
| 4 | |
| 5 | export class ApiCardRepository implements CardRepository { |
| 6 | async getAll(collectionId: string): Promise<Card[]> { |
| 7 | const result = await FlashcardsService.readCards({ collectionId }) |
| 8 | return result.data |
| 9 | } |
| 10 | |
| 11 | async getById(collectionId: string, id: string): Promise<Card | null> { |
| 12 | try { |
| 13 | return await FlashcardsService.readCard({ cardId: id, collectionId }) |
| 14 | } catch (e) { |
| 15 | return null |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | async create(collectionId: string, data: CardCreate): Promise<Card> { |
| 20 | return FlashcardsService.createCard({ collectionId, requestBody: data }) |
| 21 | } |
| 22 | |
| 23 | async update(collectionId: string, id: string, data: CardUpdate): Promise<Card> { |
| 24 | return FlashcardsService.updateCard({ cardId: id, collectionId, requestBody: data }) |
| 25 | } |
| 26 | |
| 27 | async delete(collectionId: string, id: string): Promise<void> { |
| 28 | await FlashcardsService.deleteCard({ cardId: id, collectionId }) |
| 29 | } |
| 30 | } |
nothing calls this directly
no outgoing calls
no test coverage detected