{
  "openapi": "3.1.0",
  "info": {
    "title": "Playstate public API",
    "version": "1.0.0",
    "description": "Public endpoints for license status, Sparkle updates, and the hosted checkout flow."
  },
  "servers": [
    {
      "url": "https://playstateapp.com"
    }
  ],
  "paths": {
    "/api/licenses/status": {
      "post": {
        "summary": "Check license status",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "id"
                ],
                "properties": {
                  "id": {
                    "type": "string",
                    "format": "uuid"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "License status",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LicenseStatus"
                }
              }
            }
          },
          "400": {
            "description": "Invalid license identifier"
          }
        }
      }
    },
    "/api/appcast": {
      "get": {
        "summary": "Fetch the Sparkle update feed",
        "parameters": [
          {
            "name": "uuid",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Sparkle appcast XML",
            "content": {
              "application/rss+xml": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api/checkout": {
      "post": {
        "summary": "Start hosted checkout",
        "requestBody": {
          "required": false,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "tier": {
                    "type": "string",
                    "enum": [
                      "personal",
                      "supporter"
                    ]
                  },
                  "variant": {
                    "type": "string",
                    "enum": [
                      "a",
                      "b"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "303": {
            "description": "Redirect to hosted checkout",
            "headers": {
              "Location": {
                "schema": {
                  "type": "string",
                  "format": "uri"
                }
              }
            }
          },
          "403": {
            "description": "Cross-origin request rejected"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "LicenseStatus": {
        "type": "object",
        "required": [
          "status"
        ],
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "active",
              "revoked",
              "unknown"
            ]
          },
          "reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "updated_at": {
            "type": [
              "integer",
              "null"
            ]
          }
        }
      }
    }
  }
}
