openapi: 3.0.0
info:
  title: Activity Storecheck API
  description: API for managing activity storecheck records
  version: 1.0.0
  contact:
    name: Repzo
    url: https://repzo.com

servers:
  - url: https://sv.api.repzo.me
    description: Production server
  - url: https://staging.sv.api.repzo.me
    description: Staging server

tags:
  - name: Activity Storecheck
    description: Operations related to activity storecheck management

paths:
  /activity-storecheck:
    get:
      tags:
        - Activity Storecheck
      summary: Get all activity storecheck records
      description: Retrieve a list of all activity storecheck records with optional filtering and pagination
      parameters:
        - name: limit
          in: query
          description: Maximum number of records to return
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 50
        - name: offset
          in: query
          description: Number of records to skip for pagination
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
        - name: sort
          in: query
          description: Field to sort by
          required: false
          schema:
            type: string
        - name: order
          in: query
          description: Sort order (asc or desc)
          required: false
          schema:
            type: string
            enum: [asc, desc]
            default: desc
        - name: filter
          in: query
          description: Filter conditions in JSON format
          required: false
          schema:
            type: string
        - name: search
          in: query
          description: Search term for text fields
          required: false
          schema:
            type: string
      responses:
        "200":
          description: List of activity storecheck records retrieved successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/ActivityStorecheck"
                  total:
                    type: integer
                    description: Total number of records
        "400":
          description: Bad request
        "401":
          description: Unauthorized
        "500":
          description: Internal server error
    post:
      tags:
        - Activity Storecheck
      summary: Create a new activity storecheck record
      description: Create a new activity storecheck record with the provided data
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ActivityStorecheckInput"
      responses:
        "201":
          description: Activity storecheck record created successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    $ref: "#/components/schemas/ActivityStorecheck"
        "400":
          description: Bad request
        "401":
          description: Unauthorized
        "500":
          description: Internal server error

  /activity-storecheck/{id}:
    get:
      tags:
        - Activity Storecheck
      summary: Get activity storecheck record by ID
      description: Retrieve a specific activity storecheck record by its ID
      parameters:
        - name: id
          in: path
          required: true
          description: Activity storecheck record ID
          schema:
            type: string
      responses:
        "200":
          description: Activity storecheck record retrieved successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    $ref: "#/components/schemas/ActivityStorecheck"
        "404":
          description: Activity storecheck record not found
        "401":
          description: Unauthorized
        "500":
          description: Internal server error
    put:
      tags:
        - Activity Storecheck
      summary: Update activity storecheck record
      description: Update an existing activity storecheck record with new data
      parameters:
        - name: id
          in: path
          required: true
          description: Activity storecheck record ID
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ActivityStorecheckInput"
      responses:
        "200":
          description: Activity storecheck record updated successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  data:
                    $ref: "#/components/schemas/ActivityStorecheck"
        "400":
          description: Bad request
        "404":
          description: Activity storecheck record not found
        "401":
          description: Unauthorized
        "500":
          description: Internal server error
    delete:
      tags:
        - Activity Storecheck
      summary: Delete activity storecheck record
      description: Delete an existing activity storecheck record
      parameters:
        - name: id
          in: path
          required: true
          description: Activity storecheck record ID
          schema:
            type: string
      responses:
        "200":
          description: Activity storecheck record deleted successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  message:
                    type: string
                    example: Activity storecheck record deleted successfully
        "404":
          description: Activity storecheck record not found
        "401":
          description: Unauthorized
        "500":
          description: Internal server error

components:
  schemas:
    ActivityStorecheck:
      type: object
      properties:
        _id:
          type: string
          description: Unique identifier for the activity storecheck record
          example: "60f7b1b3e4b0e8b3f8b3f8b3"
        client:
          type: string
          description: Client identifier
          example: "60f7b1b3e4b0e8b3f8b3f8b4"
        rep:
          type: string
          description: Sales representative identifier
          example: "60f7b1b3e4b0e8b3f8b3f8b5"
        template:
          type: string
          description: Storecheck template identifier
          example: "60f7b1b3e4b0e8b3f8b3f8b6"
        date:
          type: string
          format: date-time
          description: Date and time of the storecheck activity
          example: "2023-01-15T10:30:00Z"
        location:
          type: object
          properties:
            latitude:
              type: number
              format: double
              description: Latitude coordinate
              example: 40.7128
            longitude:
              type: number
              format: double
              description: Longitude coordinate
              example: -74.0060
        responses:
          type: array
          items:
            type: object
            properties:
              questionId:
                type: string
                description: Question identifier
              answer:
                type: string
                description: Answer to the question
              photos:
                type: array
                items:
                  type: string
                  description: Photo URLs
        status:
          type: string
          enum: [draft, submitted, approved, rejected]
          default: draft
          description: Status of the storecheck activity
        notes:
          type: string
          description: Additional notes
        createdAt:
          type: string
          format: date-time
          description: Record creation timestamp
          example: "2023-01-15T08:00:00Z"
        updatedAt:
          type: string
          format: date-time
          description: Record last update timestamp
          example: "2023-01-15T10:30:00Z"
      required:
        - client
        - rep
        - template
        - date

    ActivityStorecheckInput:
      type: object
      properties:
        client:
          type: string
          description: Client identifier
          example: "60f7b1b3e4b0e8b3f8b3f8b4"
        rep:
          type: string
          description: Sales representative identifier
          example: "60f7b1b3e4b0e8b3f8b3f8b5"
        template:
          type: string
          description: Storecheck template identifier
          example: "60f7b1b3e4b0e8b3f8b3f8b6"
        date:
          type: string
          format: date-time
          description: Date and time of the storecheck activity
          example: "2023-01-15T10:30:00Z"
        location:
          type: object
          properties:
            latitude:
              type: number
              format: double
              description: Latitude coordinate
              example: 40.7128
            longitude:
              type: number
              format: double
              description: Longitude coordinate
              example: -74.0060
        responses:
          type: array
          items:
            type: object
            properties:
              questionId:
                type: string
                description: Question identifier
              answer:
                type: string
                description: Answer to the question
              photos:
                type: array
                items:
                  type: string
                  description: Photo URLs
        status:
          type: string
          enum: [draft, submitted, approved, rejected]
          default: draft
          description: Status of the storecheck activity
        notes:
          type: string
          description: Additional notes
      required:
        - client
        - rep
        - template
        - date

  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: api-key

security:
  - ApiKeyAuth: []
