import Foundation /// Body für `POST /api/v1/cards`. Aus `CardCreateSchema`. /// /// `fields` ist type-abhängig — Server validiert via /// `validateFieldsForType()`. Pflicht-Keys pro Type: /// - basic, basic-reverse: `front`, `back` /// - cloze: `text` (mit `{{cN::...}}`-Clustern) /// - typing: `front`, `answer` /// - multiple-choice: `front`, `answer` /// - image-occlusion: `image_ref`, `mask_regions` (β-4) /// - audio-front: `audio_ref`, `back` (β-4) struct CardCreateBody: Encodable { let deckId: String let type: CardType let fields: [String: String] let mediaRefs: [String]? enum CodingKeys: String, CodingKey { case deckId = "deck_id" case type case fields case mediaRefs = "media_refs" } } /// Body für `PATCH /api/v1/cards/:id`. Nur `fields` und `media_refs` — /// Type und deck_id sind immutable (Server-Schema). struct CardUpdateBody: Encodable { var fields: [String: String]? var mediaRefs: [String]? enum CodingKeys: String, CodingKey { case fields case mediaRefs = "media_refs" } } /// Hilfs-Builder für Card-Type-spezifische `fields`-Dictionaries. enum CardFieldsBuilder { static func basic(front: String, back: String) -> [String: String] { ["front": front, "back": back] } static func cloze(text: String) -> [String: String] { ["text": text] } static func typing(front: String, answer: String) -> [String: String] { ["front": front, "answer": answer] } static func multipleChoice(front: String, answer: String) -> [String: String] { ["front": front, "answer": answer] } }