paths:
  /admin/email-templates:
    get:
      summary: Get all email templates
      description: Retrieve a list of all email templates available in the system for SuperAdmins to manage.
      tags: [Admin - Settings]
      security:
        - bearerAuth: []
      responses:
        '200':
          description: List of email templates
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          format: uuid
                        slug:
                          type: string
                          example: "merchant_welcome"
                        name:
                          type: string
                          example: "Merchant Welcome"
                        subject:
                          type: string
                          example: "Welcome to Airpero, {{businessName}}! 🎉"
                        availableVariables:
                          type: string
                          example: "{{businessName}}, {{email}}, {{publicKey}}, {{accountNumber}}"
                        updatedAt:
                          type: string
                          format: date-time

  /admin/email-templates/{slug}:
    get:
      summary: Get email template by slug
      description: Retrieve the full HTML content and details of a specific email template.
      tags: [Admin - Settings]
      security:
        - bearerAuth: []
      parameters:
        - in: path
          name: slug
          required: true
          schema:
            type: string
            example: "merchant_welcome"
      responses:
        '200':
          description: Email template details
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: object
                    properties:
                      id:
                        type: string
                        format: uuid
                      slug:
                        type: string
                      name:
                        type: string
                      subject:
                        type: string
                      bodyHtml:
                        type: string
                        description: The raw HTML template with variables
                      availableVariables:
                        type: string
        '404':
          description: Template not found

    patch:
      summary: Update email template
      description: Update the subject or HTML body of an email template. The `bodyHtml` will be injected into the standard Airpero branded wrapper.
      tags: [Admin - Settings]
      security:
        - bearerAuth: []
      parameters:
        - in: path
          name: slug
          required: true
          schema:
            type: string
            example: "merchant_welcome"
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                subject:
                  type: string
                  example: "Welcome aboard, {{businessName}}!"
                bodyHtml:
                  type: string
                  example: "<p>Hello {{businessName}}, welcome to Airpero!</p>"
      responses:
        '200':
          description: Email template updated successfully
        '404':
          description: Template not found
