openapi: 3.0.3
info:
  title: Repzo API - Storecheck Template
  version: 1.0.0
  description: OpenAPI specification for Repzo Storecheck Template endpoints.
servers:
  - url: https://sv.api.repzo.me
paths:
  /storecheck-template:
    get:
      summary: Find storecheck templates
      operationId: findStorecheckTemplates
      parameters:
        - in: query
          name: params
          schema:
            type: object
            properties:
              _id:
                oneOf:
                  - type: array
                    items:
                      type: string
                  - type: string
              search:
                type: string
              name:
                type: string
              category:
                type: string
              disabled:
                type: boolean
              from_updatedAt:
                type: number
              from__id:
                type: string
              to__id:
                type: string
              sortBy:
                type: array
                items:
                  type: object
                  properties:
                    field:
                      type: string
                      enum: [_id, createdAt, updatedAt, name]
                    type:
                      type: string
                      enum: [asc, desc]
          description: Query parameters for filtering storecheck templates
      responses:
        "200":
          description: A list of storecheck templates
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StorecheckTemplateFindResult"
    post:
      summary: Create a storecheck template
      operationId: createStorecheckTemplate
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/StorecheckTemplateCreateBody"
      responses:
        "201":
          description: Storecheck template created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StorecheckTemplateCreateResult"
  /storecheck-template/{id}:
    get:
      summary: Get a storecheck template by ID
      operationId: getStorecheckTemplate
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Storecheck template details
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StorecheckTemplateGetResult"
    put:
      summary: Update a storecheck template
      operationId: updateStorecheckTemplate
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/StorecheckTemplateUpdateBody"
      responses:
        "200":
          description: Storecheck template updated
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StorecheckTemplateUpdateResult"
    delete:
      summary: Remove a storecheck template
      operationId: removeStorecheckTemplate
      parameters:
        - in: path
          name: id
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Storecheck template removed
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/StorecheckTemplateRemoveResult"
components:
  schemas:
    StorecheckTemplateFindResult:
      type: object
      description: Result of finding storecheck templates
      properties:
        data:
          type: array
          items:
            $ref: "#/components/schemas/StorecheckTemplateSchema"
        total_result:
          type: number
          description: Total number of storecheck templates
        current_count:
          type: number
          description: Count of storecheck templates in current page
        total_pages:
          type: number
          description: Total number of pages
        current_page:
          type: number
          description: Current page number
        per_page:
          type: number
          description: Number of storecheck templates per page
    StorecheckTemplateSchema:
      type: object
      description: Storecheck template schema
      properties:
        _id:
          type: string
          description: Unique identifier for the storecheck template
        name:
          type: string
          description: Name of the storecheck template
        description:
          type: string
          description: Description of the template
        category:
          type: string
          description: Category of the storecheck
        sections:
          type: array
          items:
            type: object
            properties:
              title:
                type: string
                description: Section title
              questions:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: string
                      description: Question ID
                    text:
                      type: string
                      description: Question text
                    type:
                      type: string
                      enum:
                        [
                          text,
                          number,
                          boolean,
                          multiple_choice,
                          photo,
                          signature,
                        ]
                      description: Question type
                    required:
                      type: boolean
                      description: Whether question is required
                    options:
                      type: array
                      items:
                        type: string
                      description: Options for multiple choice questions
                description: Questions in this section
          description: Template sections and questions
        targets:
          type: array
          items:
            type: string
          description: Target entities (clients, routes, etc.)
        frequency:
          type: string
          enum: [daily, weekly, monthly, quarterly, yearly, custom]
          description: Frequency of storecheck execution
        validFrom:
          type: string
          format: date-time
          description: Start date of template validity
        validTo:
          type: string
          format: date-time
          description: End date of template validity
        disabled:
          type: boolean
          description: Whether the template is disabled
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
        company_namespace:
          type: array
          items:
            type: string
          description: Company namespaces
        createdAt:
          type: string
          format: date-time
          description: Creation timestamp
        updatedAt:
          type: string
          format: date-time
          description: Last update timestamp
        __v:
          type: number
          description: Version number
    StorecheckTemplateCreateBody:
      type: object
      description: Body for creating a storecheck template
      required:
        - name
        - sections
      properties:
        name:
          type: string
          description: Name of the storecheck template
        description:
          type: string
          description: Description of the template
        category:
          type: string
          description: Category of the storecheck
        sections:
          type: array
          items:
            type: object
            properties:
              title:
                type: string
                description: Section title
              questions:
                type: array
                items:
                  type: object
                  properties:
                    text:
                      type: string
                      description: Question text
                    type:
                      type: string
                      enum:
                        [
                          text,
                          number,
                          boolean,
                          multiple_choice,
                          photo,
                          signature,
                        ]
                      description: Question type
                    required:
                      type: boolean
                      description: Whether question is required
                    options:
                      type: array
                      items:
                        type: string
                      description: Options for multiple choice questions
                description: Questions in this section
          description: Template sections and questions
        targets:
          type: array
          items:
            type: string
          description: Target entities (clients, routes, etc.)
        frequency:
          type: string
          enum: [daily, weekly, monthly, quarterly, yearly, custom]
          description: Frequency of storecheck execution
        validFrom:
          type: string
          format: date-time
          description: Start date of template validity
        validTo:
          type: string
          format: date-time
          description: End date of template validity
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
    StorecheckTemplateCreateResult:
      $ref: "#/components/schemas/StorecheckTemplateSchema"
      description: Result of creating a storecheck template
    StorecheckTemplateGetResult:
      $ref: "#/components/schemas/StorecheckTemplateSchema"
      description: Result of getting a storecheck template
    StorecheckTemplateUpdateBody:
      type: object
      description: Body for updating a storecheck template
      properties:
        name:
          type: string
          description: Name of the storecheck template
        description:
          type: string
          description: Description of the template
        category:
          type: string
          description: Category of the storecheck
        sections:
          type: array
          items:
            type: object
            properties:
              title:
                type: string
                description: Section title
              questions:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: string
                      description: Question ID
                    text:
                      type: string
                      description: Question text
                    type:
                      type: string
                      enum:
                        [
                          text,
                          number,
                          boolean,
                          multiple_choice,
                          photo,
                          signature,
                        ]
                      description: Question type
                    required:
                      type: boolean
                      description: Whether question is required
                    options:
                      type: array
                      items:
                        type: string
                      description: Options for multiple choice questions
                description: Questions in this section
          description: Template sections and questions
        targets:
          type: array
          items:
            type: string
          description: Target entities (clients, routes, etc.)
        frequency:
          type: string
          enum: [daily, weekly, monthly, quarterly, yearly, custom]
          description: Frequency of storecheck execution
        validFrom:
          type: string
          format: date-time
          description: Start date of template validity
        validTo:
          type: string
          format: date-time
          description: End date of template validity
        disabled:
          type: boolean
          description: Whether the template is disabled
        integration_meta:
          type: object
          additionalProperties: true
          description: Integration metadata
    StorecheckTemplateUpdateResult:
      $ref: "#/components/schemas/StorecheckTemplateSchema"
      description: Result of updating a storecheck template
    StorecheckTemplateRemoveResult:
      $ref: "#/components/schemas/StorecheckTemplateSchema"
      description: Result of removing a storecheck template
