openapi: 3.0.0
info:
  title: Multilingual Press Zone API
  description: API for managing multilingual content, translations, and workflows in WordPress.
  version: 1.0.0
servers:
  - url: https://example.com/wp-json/multilingual-press-zone/v1
    description: Production Server
  - url: http://localhost:8080/wp-json/multilingual-press-zone/v1
    description: Local Development Server

components:
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
    cookieAuth:
      type: apiKey
      in: cookie
      name: wordpress_logged_in_COOKIE

  schemas:
    Language:
      type: object
      properties:
        id:
          type: integer
          readOnly: true
        code:
          type: string
          example: 'en'
        locale:
          type: string
          example: 'en_US'
        name:
          type: string
          example: 'English'
        native_name:
          type: string
          example: 'English'
        direction:
          type: string
          enum: [ltr, rtl]
        flag_code:
          type: string
          example: 'US'
      required:
        - code
        - locale
        - name

    TranslationJob:
      type: object
      properties:
        id:
          type: integer
          readOnly: true
        status:
          type: string
          enum: [pending, processing, completed, failed]
        source_language:
          type: string
        target_language:
          type: string
        content_id:
          type: integer
        created_at:
          type: string
          format: date-time

paths:
  /languages:
    get:
      summary: List all languages
      tags: [Languages]
      responses:
        '200':
          description: A list of languages
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Language'
    post:
      summary: Add a new language
      tags: [Languages]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Language'
      responses:
        '201':
          description: Language created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Language'

  /languages/{id}:
    get:
      summary: Get a language by ID
      tags: [Languages]
      parameters:
        - in: path
          name: id
          schema:
            type: integer
          required: true
      responses:
        '200':
          description: Language details
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Language'
    put:
      summary: Update a language
      tags: [Languages]
      parameters:
        - in: path
          name: id
          schema:
            type: integer
          required: true
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Language'
      responses:
        '200':
          description: Language updated
    delete:
      summary: Delete a language
      tags: [Languages]
      parameters:
        - in: path
          name: id
          schema:
            type: integer
          required: true
      responses:
        '200':
          description: Language deleted

  /translation-jobs:
    post:
      summary: Queue a translation job
      tags: [Translation Jobs]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                contentId:
                  type: integer
                sourceLang:
                  type: string
                targetLang:
                  type: string
                contentType:
                  type: string
                  default: post
              required:
                - contentId
                - sourceLang
                - targetLang
      responses:
        '201':
          description: Job queued
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  data:
                    type: object
                    properties:
                      jobId:
                        type: integer

  /translation-jobs/bulk:
    post:
      summary: Queue bulk translation jobs
      tags: [Translation Jobs]
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                contentIds:
                  type: array
                  items:
                    type: integer
                targetLangs:
                  type: array
                  items:
                    type: string
                sourceLang:
                  type: string
      responses:
        '201':
          description: Bulk jobs queued

  /translation-jobs/{id}:
    get:
      summary: Get job status
      tags: [Translation Jobs]
      parameters:
        - in: path
          name: id
          schema:
            type: integer
          required: true
      responses:
        '200':
          description: Job status
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TranslationJob'
    delete:
      summary: Cancel job
      tags: [Translation Jobs]
      parameters:
        - in: path
          name: id
          schema:
            type: integer
          required: true
      responses:
        '200':
          description: Job cancelled

security:
  - basicAuth: []
  - cookieAuth: []
