openapi: 3.0.0
info:
  title: YDM C-360 API
  description: API for YDMThailand Customer 360. Only core authentication and journey endpoints are documented here.
  version: 1.0.0
servers:
  - url: /
    description: Default server
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
paths:
  /user/register:
    post:
      summary: Register a new user
      description: Register a new user with email and password.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - email
                - password
              properties:
                email:
                  type: string
                  format: email
                  example: user@example.com
                password:
                  type: string
                  format: password
                  example: mySecurePassword123
      responses:
        '200':
          description: User registered successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: ok
                  message:
                    type: string
                    example: Success
                  access_token:
                    type: string
                  refresh_token:
                    type: string
                  user_id:
                    type: string
        '400':
          description: Bad request, missing required fields.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '405':
          description: Method not allowed.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /user/login:
    post:
      summary: User login
      description: Authenticate a user and return tokens.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - email
                - password
              properties:
                email:
                  type: string
                  format: email
                  example: user@example.com
                password:
                  type: string
                  format: password
                  example: mySecurePassword123
      responses:
        '200':
          description: User logged in successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: ok
                  message:
                    type: string
                    example: Success
                  access_token:
                    type: string
                  refresh_token:
                    type: string
                  user_id:
                    type: string
        '400':
          description: Bad request, missing required fields or user not registered.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Invalid credentials.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  message:
                    type: string
        '405':
          description: Method not allowed.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
  /user/refresh:
    post:
      summary: Refresh access token
      description: Refresh an expired access token using a valid refresh token.
      security:
        - bearerAuth: []
      parameters:
        - in: header
          name: Authorization
          schema:
            type: string
            example: Bearer <your_refresh_token>
          required: true
          description: Bearer token (refresh token) for authentication.
      responses:
        '200':
          description: Access token refreshed successfully.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: ok
                  access_token:
                    type: string
                  refresh_token:
                    type: string
        '401':
          description: Invalid or expired refresh token.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  message:
                    type: string
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  message:
                    type: string
  /query/journey/all-user:
    get:
      summary: Retrieve all user journey data
      description: Fetch user journey data based on property ID, date range, and pagination.
      security:
        - bearerAuth: []
      parameters:
        - in: query
          name: property_id
          schema:
            type: string
          required: true
          description: The ID of the property to filter data.
        - in: query
          name: date_start
          schema:
            type: string
            format: date
          required: true
          description: The start date for the data range (YYYY-MM-DD).
        - in: query
          name: date_end
          schema:
            type: string
            format: date
          required: true
          description: The end date for the data range (YYYY-MM-DD).
        - in: query
          name: page
          schema:
            type: integer
            default: 1
          required: true
          description: The page number for pagination.
        - in: query
          name: sort
          schema:
            type: string
            default: Last Update.desc
          required: false
          description: Field to sort by and order (e.g., "Last Update.desc").
      responses:
        '200':
          description: Successfully retrieved user journey data.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                    example: ok
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        User Status:
                          type: string
                        ID:
                          type: string
                        Facebook Engagement:
                          type: integer
                        Messenger Chat:
                          type: integer
                        LINE Chat:
                          type: integer
                        Facebook Ads:
                          type: integer
                        Last Update:
                          type: string
                          format: date-time
                  total_page:
                    type: integer
        '400':
          description: Bad request, missing required parameters.
          content:
            application/json:
              schema:
                type: object
                properties:
                  message:
                    type: string
        '401':
          description: Unauthorized (invalid or missing token).
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  message:
                    type: string
        '405':
          description: Method not allowed.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  message:
                    type: string
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                type: object
                properties:
                  status:
                    type: string
                  message:
                    type: string 