{
 "openapi": "3.0.3",
 "info": {
  "title": "kuendigblitz.de API",
  "version": "1.0.0",
  "description": "Anbieter suchen, Kündigungsschreiben erzeugen, Versand per E-Mail, Fax oder Einschreiben beauftragen und verfolgen. Fehler kommen als {\"fehler\": \"...\"}, fehlende Angaben zusätzlich als \"felder\"."
 },
 "servers": [
  {
   "url": "https://kuendigblitz.de/api/v1"
  }
 ],
 "components": {
  "securitySchemes": {
   "schluessel": {
    "type": "http",
    "scheme": "bearer"
   }
  }
 },
 "security": [
  {
   "schluessel": []
  }
 ],
 "paths": {
  "/anbieter": {
   "get": {
    "summary": "Anbieter suchen",
    "security": [],
    "responses": {
     "200": {
      "description": "OK"
     }
    },
    "parameters": [
     {
      "name": "q",
      "in": "query",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "kategorie",
      "in": "query",
      "schema": {
       "type": "string",
       "enum": [
        "Telefon & Internet",
        "Streaming",
        "Strom & Gas",
        "Versicherungen",
        "Zeitungen & Zeitschriften",
        "Fitness",
        "Partnersuche",
        "Mitgliedschaften",
        "Lieferdienste",
        "Mobilität"
       ]
      }
     },
     {
      "name": "weg",
      "in": "query",
      "schema": {
       "type": "string",
       "enum": [
        "email",
        "fax",
        "brief"
       ]
      }
     }
    ]
   }
  },
  "/anbieter/{slug}": {
   "get": {
    "summary": "Anschrift, Kündigungswege und Quellen eines Anbieters",
    "security": [],
    "responses": {
     "200": {
      "description": "OK"
     }
    },
    "parameters": [
     {
      "name": "slug",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ]
   }
  },
  "/preise": {
   "get": {
    "summary": "Versandwege, Preise und was gerade buchbar ist",
    "security": [],
    "responses": {
     "200": {
      "description": "OK"
     }
    }
   }
  },
  "/pdf": {
   "post": {
    "summary": "Kündigungsschreiben als PDF, kostenlos",
    "security": [],
    "responses": {
     "200": {
      "description": "PDF",
      "content": {
       "application/pdf": {}
      }
     },
     "422": {
      "description": "Angaben unvollständig"
     }
    },
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "formular"
        ],
        "properties": {
         "formular": {
          "type": "object",
          "required": [
           "vorname",
           "nachname",
           "strasse",
           "plz",
           "ort",
           "art"
          ],
          "properties": {
           "vorname": {
            "type": "string"
           },
           "nachname": {
            "type": "string"
           },
           "strasse": {
            "type": "string"
           },
           "plz": {
            "type": "string"
           },
           "ort": {
            "type": "string"
           },
           "kundennummer": {
            "type": "string"
           },
           "vertrag": {
            "type": "string",
            "description": "z. B. Mobilfunkvertrag"
           },
           "geburtsdatum": {
            "type": "string"
           },
           "art": {
            "type": "string",
            "enum": [
             "ordentlich",
             "datum",
             "preiserhoehung",
             "umzug"
            ]
           },
           "datum": {
            "type": "string",
            "description": "bei art=datum: JJJJ-MM-TT"
           },
           "umzugsdatum": {
            "type": "string",
            "description": "bei art=umzug: JJJJ-MM-TT"
           },
           "lastschrift": {
            "type": "boolean",
            "description": "SEPA-Mandat widerrufen"
           },
           "rueckgewinnung": {
            "type": "boolean",
            "description": "Werbeanrufe untersagen"
           },
           "empfaenger": {
            "type": "object",
            "description": "nur bei /pdf: freie Anschrift. Bei Aufträgen kommt die Anschrift immer aus unseren Daten.",
            "properties": {
             "firma": {
              "type": "string"
             },
             "zusatz": {
              "type": "string"
             },
             "strasse": {
              "type": "string"
             },
             "plz": {
              "type": "string"
             },
             "ort": {
              "type": "string"
             }
            }
           }
          }
         },
         "anbieter": {
          "type": "string",
          "description": "Slug, nur für den Dateinamen"
         }
        }
       }
      }
     }
    }
   }
  },
  "/auftraege": {
   "post": {
    "summary": "Versandauftrag anlegen, Antwort enthält den Bezahllink",
    "security": [],
    "responses": {
     "200": {
      "description": "{ id, url }: url ist die Bezahlseite. Nach der Zahlung startet der Versand."
     },
     "400": {
      "description": "Weg bei diesem Anbieter nicht möglich"
     },
     "422": {
      "description": "Angaben unvollständig"
     },
     "503": {
      "description": "Weg zurzeit nicht buchbar"
     }
    },
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "formular",
         "anbieter",
         "weg",
         "email",
         "sofort"
        ],
        "properties": {
         "formular": {
          "type": "object",
          "required": [
           "vorname",
           "nachname",
           "strasse",
           "plz",
           "ort",
           "art"
          ],
          "properties": {
           "vorname": {
            "type": "string"
           },
           "nachname": {
            "type": "string"
           },
           "strasse": {
            "type": "string"
           },
           "plz": {
            "type": "string"
           },
           "ort": {
            "type": "string"
           },
           "kundennummer": {
            "type": "string"
           },
           "vertrag": {
            "type": "string",
            "description": "z. B. Mobilfunkvertrag"
           },
           "geburtsdatum": {
            "type": "string"
           },
           "art": {
            "type": "string",
            "enum": [
             "ordentlich",
             "datum",
             "preiserhoehung",
             "umzug"
            ]
           },
           "datum": {
            "type": "string",
            "description": "bei art=datum: JJJJ-MM-TT"
           },
           "umzugsdatum": {
            "type": "string",
            "description": "bei art=umzug: JJJJ-MM-TT"
           },
           "lastschrift": {
            "type": "boolean",
            "description": "SEPA-Mandat widerrufen"
           },
           "rueckgewinnung": {
            "type": "boolean",
            "description": "Werbeanrufe untersagen"
           },
           "empfaenger": {
            "type": "object",
            "description": "nur bei /pdf: freie Anschrift. Bei Aufträgen kommt die Anschrift immer aus unseren Daten.",
            "properties": {
             "firma": {
              "type": "string"
             },
             "zusatz": {
              "type": "string"
             },
             "strasse": {
              "type": "string"
             },
             "plz": {
              "type": "string"
             },
             "ort": {
              "type": "string"
             }
            }
           }
          }
         },
         "anbieter": {
          "type": "string",
          "description": "Slug aus /anbieter"
         },
         "weg": {
          "type": "string",
          "enum": [
           "email",
           "fax",
           "brief"
          ]
         },
         "email": {
          "type": "string",
          "format": "email",
          "description": "Empfänger des Nachweises"
         },
         "sofort": {
          "type": "boolean",
          "description": "muss true sein: sofortiger Versand, das Widerrufsrecht erlischt mit der Ausführung"
         }
        }
       }
      }
     }
    }
   }
  },
  "/auftraege/{id}": {
   "get": {
    "summary": "Status eines Auftrags: offen, bezahlt, sendet, gesendet, fehlgeschlagen, erstattet",
    "security": [],
    "responses": {
     "200": {
      "description": "OK"
     }
    },
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^[a-f0-9]{32}$"
      }
     }
    ]
   }
  },
  "/admin/status": {
   "get": {
    "summary": "Freigeschaltete Wege, fehlende Zugänge, Aufträge je Status, Guthaben beim Briefdienst",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "Schlüssel fehlt oder ist falsch"
     }
    }
   }
  },
  "/admin/statistik": {
   "get": {
    "summary": "Käufe und Umsatz je Tag und Weg",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "Schlüssel fehlt oder ist falsch"
     }
    },
    "parameters": [
     {
      "name": "tage",
      "in": "query",
      "schema": {
       "type": "integer",
       "default": 30
      }
     }
    ]
   }
  },
  "/admin/auftraege": {
   "get": {
    "summary": "Aufträge auflisten, neueste zuerst",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "Schlüssel fehlt oder ist falsch"
     }
    },
    "parameters": [
     {
      "name": "status",
      "in": "query",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "weg",
      "in": "query",
      "schema": {
       "type": "string"
      }
     },
     {
      "name": "limit",
      "in": "query",
      "schema": {
       "type": "integer",
       "default": 50,
       "maximum": 500
      }
     }
    ]
   },
   "post": {
    "summary": "Auftrag ohne Bezahlung anlegen und sofort versenden",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "Schlüssel fehlt oder ist falsch"
     }
    },
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "required": [
         "formular",
         "anbieter",
         "weg",
         "email"
        ],
        "properties": {
         "formular": {
          "type": "object",
          "required": [
           "vorname",
           "nachname",
           "strasse",
           "plz",
           "ort",
           "art"
          ],
          "properties": {
           "vorname": {
            "type": "string"
           },
           "nachname": {
            "type": "string"
           },
           "strasse": {
            "type": "string"
           },
           "plz": {
            "type": "string"
           },
           "ort": {
            "type": "string"
           },
           "kundennummer": {
            "type": "string"
           },
           "vertrag": {
            "type": "string",
            "description": "z. B. Mobilfunkvertrag"
           },
           "geburtsdatum": {
            "type": "string"
           },
           "art": {
            "type": "string",
            "enum": [
             "ordentlich",
             "datum",
             "preiserhoehung",
             "umzug"
            ]
           },
           "datum": {
            "type": "string",
            "description": "bei art=datum: JJJJ-MM-TT"
           },
           "umzugsdatum": {
            "type": "string",
            "description": "bei art=umzug: JJJJ-MM-TT"
           },
           "lastschrift": {
            "type": "boolean",
            "description": "SEPA-Mandat widerrufen"
           },
           "rueckgewinnung": {
            "type": "boolean",
            "description": "Werbeanrufe untersagen"
           },
           "empfaenger": {
            "type": "object",
            "description": "nur bei /pdf: freie Anschrift. Bei Aufträgen kommt die Anschrift immer aus unseren Daten.",
            "properties": {
             "firma": {
              "type": "string"
             },
             "zusatz": {
              "type": "string"
             },
             "strasse": {
              "type": "string"
             },
             "plz": {
              "type": "string"
             },
             "ort": {
              "type": "string"
             }
            }
           }
          }
         },
         "anbieter": {
          "type": "string"
         },
         "weg": {
          "type": "string",
          "enum": [
           "email",
           "fax",
           "brief"
          ]
         },
         "email": {
          "type": "string",
          "format": "email"
         }
        }
       }
      }
     }
    }
   }
  },
  "/admin/auftraege/{id}": {
   "get": {
    "summary": "Alle Angaben und der Verlauf eines Auftrags",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "Schlüssel fehlt oder ist falsch"
     }
    },
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^[a-f0-9]{32}$"
      }
     }
    ]
   }
  },
  "/admin/auftraege/{id}/wiederholen": {
   "post": {
    "summary": "Versand erneut versuchen",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "Schlüssel fehlt oder ist falsch"
     }
    },
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^[a-f0-9]{32}$"
      }
     },
     {
      "name": "trotzdem",
      "in": "query",
      "schema": {
       "type": "string",
       "enum": [
        "1"
       ]
      },
      "description": "nötig, wenn der Auftrag schon versendet ist"
     }
    ]
   }
  },
  "/admin/auftraege/{id}/erstatten": {
   "post": {
    "summary": "Zahlung über Stripe zurückgeben",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "Schlüssel fehlt oder ist falsch"
     }
    },
    "parameters": [
     {
      "name": "id",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string",
       "pattern": "^[a-f0-9]{32}$"
      }
     }
    ]
   }
  },
  "/admin/anbieter": {
   "post": {
    "summary": "Neuen Anbieter anlegen, die Seite wird neu gebaut",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "Schlüssel fehlt oder ist falsch"
     }
    },
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "slug": {
          "type": "string"
         },
         "name": {
          "type": "string"
         },
         "kategorie": {
          "type": "string"
         },
         "firma": {
          "type": "string"
         },
         "zusatz": {
          "type": "string"
         },
         "strasse": {
          "type": "string"
         },
         "plz": {
          "type": "string"
         },
         "ort": {
          "type": "string"
         },
         "fax": {
          "type": "string"
         },
         "email": {
          "type": "string"
         },
         "online_kuendigung_url": {
          "type": "string"
         },
         "hinweis": {
          "type": "string"
         },
         "email_weg": {
          "type": "boolean"
         },
         "beliebt": {
          "type": "boolean"
         },
         "quelle": {
          "type": "array",
          "items": {
           "type": "string",
           "format": "uri"
          }
         }
        },
        "required": [
         "slug",
         "name",
         "kategorie",
         "quelle"
        ]
       }
      }
     }
    }
   }
  },
  "/admin/anbieter/{slug}": {
   "patch": {
    "summary": "Anbieterdaten ändern, die Seite wird neu gebaut",
    "responses": {
     "200": {
      "description": "OK"
     },
     "401": {
      "description": "Schlüssel fehlt oder ist falsch"
     }
    },
    "parameters": [
     {
      "name": "slug",
      "in": "path",
      "required": true,
      "schema": {
       "type": "string"
      }
     }
    ],
    "requestBody": {
     "content": {
      "application/json": {
       "schema": {
        "type": "object",
        "properties": {
         "name": {
          "type": "string"
         },
         "kategorie": {
          "type": "string"
         },
         "firma": {
          "type": "string"
         },
         "zusatz": {
          "type": "string"
         },
         "strasse": {
          "type": "string"
         },
         "plz": {
          "type": "string"
         },
         "ort": {
          "type": "string"
         },
         "fax": {
          "type": "string"
         },
         "email": {
          "type": "string"
         },
         "online_kuendigung_url": {
          "type": "string"
         },
         "hinweis": {
          "type": "string"
         },
         "email_weg": {
          "type": "boolean"
         },
         "beliebt": {
          "type": "boolean"
         },
         "quelle": {
          "type": "array",
          "items": {
           "type": "string",
           "format": "uri"
          }
         }
        }
       }
      }
     }
    }
   }
  }
 }
}