openapi: 3.0.0
info:
  title: Staff and User API
  version: 1.0.0
  description: API for handling staff and user login, registration, and subscription plan creation.

paths:
  /staff/profile:
    get:
      summary: "get staff profile"
      tags:
        - Staff
      responses:
        "200":
          description: Success get profile
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: string
                      email:
                        type: string
                      name:
                        type: string
                      profile_picture:
                        type: string
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string

  /staff/login:
    post:
      summary: Login for staff
      tags:
        - Staff
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
                  format: email
                password:
                  type: string
              required:
                - email
                - password
      responses:
        "200":
          description: Successful login
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      token:
                        type: string
                        description: JWT token for staff authentication
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string

  /staff/register:
    post:
      summary: Register a new staff member
      tags:
        - Staff
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
                  format: email
                password:
                  type: string
                name:
                  type: string
                profile_picture:
                  type: string
              required:
                - email
                - password
                - name
      responses:
        "201":
          description: Staff member created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      token:
                        type: string
                        description: JWT token for staff authentication
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
        "409":
          description: Conflict (email already registered)
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string

  /user/profile:
    get:
      summary: "get staff profile"
      tags:
        - User
      responses:
        "200":
          description: Success get profile
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: string
                      email:
                        type: string
                      subscribe_plan_code:
                        type: string
                      subscribe_plan_name:
                        type: string
                      subscribe_status:
                        type: string
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string

  /user/login:
    post:
      summary: Login for user
      tags:
        - User
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
                  format: email
                password:
                  type: string
              required:
                - email
                - password
      responses:
        "200":
          description: Successful login
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      token:
                        type: string
                        description: JWT token for user authentication
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string

  /user/register:
    post:
      summary: Register a new user
      tags:
        - User
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                email:
                  type: string
                  format: email
                password:
                  type: string
                subscribe_plan_id:
                  type: string
                phone:
                  type: string
                  format: phone
              required:
                - email
                - password
      responses:
        "201":
          description: User created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      token:
                        type: string
                        description: JWT token for user authentication
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
        "409":
          description: Conflict (email already registered)
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string

  /subscribe-plan/create:
    post:
      summary: Create a new subscription plan
      tags:
        - Subscribe Plan
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                code:
                  type: string
              required:
                - code
                - name
      responses:
        "201":
          description: Subscription plan created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      message:
                        type: string
                        example: "Subscription plan created successfully."
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
        "409":
          description: Conflict (plan code already exists)
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string

  /subscribe-plan:
    get:
      summary: Get all subscription plans
      tags:
        - Subscribe Plan
      responses:
        "200":
          description: Successfully retrieved all subscription plans
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                        code:
                          type: string
                        name:
                          type: string
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string

  /tag:
    get:
      summary: Get all tags
      tags:
        - Tags
      responses:
        "200":
          description: Successfully retrieved all tags
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                        code:
                          type: string
                        name:
                          type: string
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string

  /tag/create:
    post:
      summary: Create a new tag
      tags:
        - Tags
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                code:
                  type: string
              required:
                - code
                - name
      responses:
        "201":
          description: Tag created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      message:
                        type: string
                        example: "tag created successfully."
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
        "409":
          description: Conflict (tag code already exists)
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string

  /category:
    get:
      summary: Get all categories
      tags:
        - Category
      responses:
        "200":
          description: Successfully retrieved all categories
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                        code:
                          type: string
                        name:
                          type: string
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string

  /category/create:
    post:
      summary: Create a new category
      tags:
        - Category
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                name:
                  type: string
                code:
                  type: string
              required:
                - code
                - name
      responses:
        "201":
          description: Category created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      message:
                        type: string
                        example: "category created successfully."
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
        "409":
          description: Conflict (category code already exists)
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string

  /news/create:
    post:
      summary: Create a new news article
      tags:
        - News
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                title:
                  type: string
                content:
                  type: string
                featured_image:
                  type: string
                  format: uri
                tags:
                  type: array
                  items:
                    type: string
                categories:
                  type: array
                  items:
                    type: string
                is_premium:
                  type: boolean
                live_at:
                  type: string
                  format: date-time
              required:
                - title
                - content
                - featured_image
                - tags
                - categories
                - is_premium
                - live_at
      responses:
        "201":
          description: News article created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      message:
                        type: string
                        example: "news created successfully."
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
        "409":
          description: Conflict (e.g., duplicate title or invalid tag/category)
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string

  /news:
    get:
      summary: Get all news articles
      tags:
        - News
      responses:
        "200":
          description: Successfully retrieved all news articles
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                        title:
                          type: string
                        content:
                          type: string
                        categories:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: string
                              name:
                                type: string
                              code:
                                type: string
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                        tags:
                          type: array
                          items:
                            type: object
                            properties:
                              id:
                                type: string
                              name:
                                type: string
                              code:
                                type: string
                              created_at:
                                type: string
                                format: date-time
                              updated_at:
                                type: string
                                format: date-time
                        is_premium:
                          type: boolean
                        slug:
                          type: string
                        featured_image:
                          type: string
                          format: uri
                        author_id:
                          type: string
                        live_at:
                          type: string
                          format: date-time
                        created_at:
                          type: string
                          format: date-time
                        updated_at:
                          type: string
                          format: date-time
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: object
                    properties:
                      code:
                        type: string
                      message:
                        type: string
