openapi: 3.0.3
info:
  title: Productsup Platform API
  description: |
    Platform API - Account management and data read operations

    The Platform API provides endpoints for managing projects, sites, channels, and reading product data.

    For data uploads, please use the Stream API.

    For more information, visit our documentation at https://api-docs.productsup.io/#platform-api
  version: '2.0'
externalDocs:
  description: Productsup Platform API End User documentation
  url: https://api-docs.productsup.io/#platform-api
servers:
  - url: https://platform-api.productsup.io
    description: Production environment

security:
  - ApiKeyAuth: []

tags:
  - name: Projects
    description: Project management operations
  - name: Sites
    description: Site management operations
  - name: Site Tags
    description: Site tag management operations
  - name: Channels
    description: Channel operations
  - name: Import History
    description: Import history operations
  - name: Site Errors
    description: Site error operations
  - name: Product Data
    description: Product data read operations
  - name: Process
    description: Site processing operations
  - name: Site Stream Data Sources
    description: Stream data source management
  - name: Status
    description: Site status operations

paths:
  /platform/v2/projects:
    get:
      summary: List all projects
      tags:
        - Projects
      security:
        - ApiKeyAuth: []
      responses:
        '200':
          description: List of projects
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProjectsResponse'
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '500':
          $ref: '#/components/responses/InternalError'
    post:
      summary: Create a new project
      tags:
        - Projects
      security:
        - ApiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProjectCreate'
      responses:
        '201':
          description: Project created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProjectsResponse'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '500':
          $ref: '#/components/responses/InternalError'

  /platform/v2/projects/{projectId}:
    parameters:
      - $ref: '#/components/parameters/projectId'
    get:
      summary: Get project details
      tags:
        - Projects
      security:
        - ApiKeyAuth: []
      responses:
        '200':
          description: Project details
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProjectsResponse'
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalError'
    put:
      summary: Update a project
      tags:
        - Projects
      security:
        - ApiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProjectUpdate'
      responses:
        '200':
          description: Project updated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProjectsResponse'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalError'
    delete:
      summary: Delete a project
      tags:
        - Projects
      security:
        - ApiKeyAuth: []
      responses:
        '204':
          description: Project deleted successfully
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalError'

  /platform/v2/sites:
    get:
      summary: Get all sites by account
      tags:
        - Sites
      security:
        - ApiKeyAuth: []
      responses:
        '200':
          description: List of sites
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SitesResponse'
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '500':
          $ref: '#/components/responses/InternalError'
    post:
      summary: Create a new site
      tags:
        - Sites
      security:
        - ApiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SiteCreate'
      responses:
        '201':
          description: Site created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SitesResponse'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '500':
          $ref: '#/components/responses/InternalError'

  /platform/v2/sites/{tagName}:{tagValue}:
    parameters:
      - name: tagName
        in: path
        required: true
        schema:
          type: string
        description: Name of the tag for the site
      - name: tagValue
        in: path
        required: true
        schema:
          type: string
        description: Value of the tag for the site
    get:
      summary: Get a site by its tag
      tags:
        - Sites
      security:
        - ApiKeyAuth: []
      responses:
        '200':
          description: Site details
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SitesResponse'
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalError'

  /platform/v2/projects/{projectId}/sites:
    parameters:
      - $ref: '#/components/parameters/projectId'
    get:
      summary: Get all sites by project
      tags:
        - Sites
      security:
        - ApiKeyAuth: []
      responses:
        '200':
          description: List of sites in project
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SitesResponse'
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalError'
    post:
      summary: Create a new site
      tags:
        - Sites
      security:
        - ApiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SiteCreate'
      responses:
        '201':
          description: Site created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SitesResponse'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalError'

  /platform/v2/projects/{projectId}/sites/{siteId}:
    parameters:
      - $ref: '#/components/parameters/projectId'
      - $ref: '#/components/parameters/siteId'
    put:
      summary: Update a site
      tags:
        - Sites
      security:
        - ApiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SiteUpdate'
      responses:
        '200':
          description: Site updated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SitesResponse'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalError'

  /platform/v2/sites/{siteId}:
    parameters:
      - $ref: '#/components/parameters/siteId'
    get:
      summary: Get site details
      tags:
        - Sites
      security:
        - ApiKeyAuth: []
      responses:
        '200':
          description: Site details
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SitesResponse'
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalError'
    put:
      summary: Update a site
      tags:
        - Sites
      security:
        - ApiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SiteUpdate'
      responses:
        '200':
          description: Site updated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SitesResponse'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalError'
    delete:
      summary: Delete a site
      tags:
        - Sites
      security:
        - ApiKeyAuth: []
      responses:
        '204':
          description: Site deleted successfully
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalError'

  /platform/v2/sites/{siteId}/tags:
    parameters:
      - $ref: '#/components/parameters/siteId'
    get:
      summary: List tags for a site
      tags:
        - Site Tags
      security:
        - ApiKeyAuth: []
      responses:
        '200':
          description: List of site tags
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SiteTagsResponse'
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalError'
    post:
      summary: Create a tag for a site
      tags:
        - Site Tags
      security:
        - ApiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SiteTagCreate'
      responses:
        '201':
          description: Site tag created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SiteTagsResponse'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalError'

  /platform/v2/sites/{siteId}/tags/{tagId}:
    parameters:
      - $ref: '#/components/parameters/siteId'
      - $ref: '#/components/parameters/tagId'
    delete:
      summary: Delete a tag
      tags:
        - Site Tags
      security:
        - ApiKeyAuth: []
      responses:
        '204':
          description: Site tag deleted successfully
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalError'

  /platform/v2/sites/{siteId}/errors:
    parameters:
      - $ref: '#/components/parameters/siteId'
    get:
      summary: Get site errors
      tags:
        - Site Errors
      security:
        - ApiKeyAuth: []
      parameters:
        - name: pid
          in: query
          required: false
          schema:
            type: string
          description: "Process id, by default the latest process is shown"
        - $ref: '#/components/parameters/limit'
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
      responses:
        '200':
          description: Site errors
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorsResponse'
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalError'

  /platform/v2/sites/{siteId}/importhistory:
    parameters:
      - $ref: '#/components/parameters/siteId'
    get:
      summary: Get import history
      tags:
        - Import History
      security:
        - ApiKeyAuth: []
      responses:
        '200':
          description: Import history
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImportHistoryResponse'
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalError'

  /platform/v2/sites/{siteId}/channels:
    parameters:
      - $ref: '#/components/parameters/siteId'
    get:
      summary: Get all channels for a site
      tags:
        - Channels
      security:
        - ApiKeyAuth: []
      responses:
        '200':
          description: Channels
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChannelsResponse'
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalError'

  /platform/v2/sites/{siteId}/channels/{channelId}:
    parameters:
      - $ref: '#/components/parameters/siteId'
      - $ref: '#/components/parameters/channelId'
    get:
      summary: Get channel details
      tags:
        - Channels
      security:
        - ApiKeyAuth: []
      responses:
        '200':
          description: Channel details
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ChannelsResponse'
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalError'

  /platform/v2/sites/{siteId}/channels/{channelId}/history:
    parameters:
      - $ref: '#/components/parameters/siteId'
      - $ref: '#/components/parameters/channelId'
    get:
      summary: Get channel history
      tags:
        - Channels
      security:
        - ApiKeyAuth: []
      responses:
        '200':
          description: Channel history
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  Channels:
                    type: array
                    items:
                      allOf:
                        - $ref: '#/components/schemas/Channel'
                        - type: object
                          properties:
                            history:
                              type: array
                              items:
                                $ref: '#/components/schemas/ChannelHistory'
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalError'

  /product/v2/site/{siteId}/stage/{stageName}/{stageId}:
    parameters:
      - $ref: '#/components/parameters/siteId'
      - $ref: '#/components/parameters/stageName'
      - $ref: '#/components/parameters/stageId'
    get:
      summary: Read product data
      tags:
        - Product Data
      security:
        - ApiKeyAuth: []
      parameters:
        - $ref: '#/components/parameters/limit'
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
        - $ref: '#/components/parameters/fields'
        - $ref: '#/components/parameters/hidden'
        - $ref: '#/components/parameters/filter'
      responses:
        '200':
          description: Product data
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProductDataResponse'
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalError'

  /product/v2/site/{siteId}/stage/{stageName}/{stageId}/properties:
    parameters:
      - $ref: '#/components/parameters/siteId'
      - $ref: '#/components/parameters/stageName'
      - $ref: '#/components/parameters/stageId'
    get:
      summary: Get product data properties
      tags:
        - Product Data
      security:
        - ApiKeyAuth: []
      responses:
        '200':
          description: Product data properties
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  columns:
                    type: array
                    items:
                      type: string
                    example: ["id", "gtin", "price"]
                  products:
                    type: integer
                    example: 42
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalError'

  /platform/v2/process/{siteId}:
    parameters:
      - $ref: '#/components/parameters/siteId'
    post:
      summary: Trigger site processing
      tags:
        - Process
      security:
        - ApiKeyAuth: []
        - BearerAuth: []
      requestBody:
        required: false
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProcessRequest'
      responses:
        '200':
          description: Processing triggered
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProcessResponse'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalError'

  /platform/v2/sites/{siteId}/status/{pid}:
    parameters:
      - $ref: '#/components/parameters/siteId'
      - $ref: '#/components/parameters/pid'
    get:
      summary: Get site status
      tags:
        - Status
      security:
        - ApiKeyAuth: []
      responses:
        '200':
          description: Site status
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SiteStatus'
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalError'

  /platform/v2/sites/{siteId}/streams:
    parameters:
      - $ref: '#/components/parameters/siteId'
    get:
      summary: List stream data sources for a site
      tags:
        - Site Stream Data Sources
      security:
        - ApiKeyAuth: []
        - BearerAuth: []
      parameters:
        - $ref: '#/components/parameters/limit'
        - $ref: '#/components/parameters/cursor'
        - $ref: '#/components/parameters/previous'
      responses:
        '200':
          description: Stream data sources
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StreamDataSourcesResponse'
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalError'
    post:
      summary: Create a stream data source
      tags:
        - Site Stream Data Sources
      security:
        - ApiKeyAuth: []
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StreamDataSourceCreate'
      responses:
        '201':
          description: Stream data source created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StreamDataSourcesResponse'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalError'

  /platform/v2/sites/{siteId}/streams/{streamId}:
    parameters:
      - $ref: '#/components/parameters/siteId'
      - $ref: '#/components/parameters/streamId'
    get:
      summary: Get stream data source details
      tags:
        - Site Stream Data Sources
      security:
        - ApiKeyAuth: []
        - BearerAuth: []
      responses:
        '200':
          description: Stream data source details
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StreamDataSourcesResponse'
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalError'
    put:
      summary: Update stream data source
      tags:
        - Site Stream Data Sources
      security:
        - ApiKeyAuth: []
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/StreamDataSourceUpdate'
      responses:
        '200':
          description: Stream data source updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StreamDataSourcesResponse'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalError'
    delete:
      summary: Delete stream data source
      tags:
        - Site Stream Data Sources
      security:
        - ApiKeyAuth: []
        - BearerAuth: []
      responses:
        '204':
          description: Stream data source deleted
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                    example: true
                  message:
                    type: string
                    example: "Resource was deleted successfully!"
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalError'

  /platform/v2/sites/{siteId}/copy:
    parameters:
      - $ref: '#/components/parameters/siteId'
    post:
      summary: Copy a site
      tags:
        - Sites
      security:
        - ApiKeyAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SiteCopyRequest'
      responses:
        '201':
          description: Site copied successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SitesResponse'
        '400':
          $ref: '#/components/responses/BadRequestError'
        '401':
          $ref: '#/components/responses/AuthorizationError'
        '404':
          $ref: '#/components/responses/NotFoundError'
        '500':
          $ref: '#/components/responses/InternalError'

components:
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-Auth-Token
      description: |
        API Key authentication using X-Auth-Token header.
        
        The authentication token format is: `client_id:client_secret`
        
        **For Swagger UI**: Enter your token in the format `client_id:client_secret`.
        **For Postman**: The header name X-Auth-Token will be automatically set.
        
        Example: `1234:simsalabim`
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: |
        Bearer token authentication for unified endpoints (Process and Site Stream Data Sources).
        
        **For Swagger UI**: Enter your Personal Access Token without the "Bearer " prefix.
        **For Postman**: The Authorization header will be automatically set.
        
        Example: `your-personal-access-token-here`

  parameters:
    projectId:
      name: projectId
      in: path
      required: true
      schema:
        type: integer
        format: int64

    siteId:
      name: siteId
      in: path
      required: true
      schema:
        type: string

    channelId:
      name: channelId
      in: path
      required: true
      schema:
        type: string

    tagId:
      name: tagId
      in: path
      required: true
      schema:
        type: integer
        format: int64

    streamId:
      name: streamId
      in: path
      required: true
      schema:
        type: integer
        format: int64

    pid:
      name: pid
      in: path
      required: true
      schema:
        type: string

    stageName:
      name: stageName
      in: path
      required: true
      schema:
        type: string
        enum: [import, channel]

    stageId:
      name: stageId
      in: path
      required: true
      schema:
        type: string

    limit:
      name: limit
      in: query
      required: false
      schema:
        type: integer
        minimum: 1
        maximum: 1000
        default: 100

    cursor:
      name: cursor
      in: query
      required: false
      schema:
        type: integer
        minimum: 0
        default: 0

    previous:
      name: previous
      in: query
      required: false
      schema:
        type: integer
        minimum: 0
        default: 0

    hidden:
      name: hidden
      in: query
      required: false
      schema:
        type: integer
        enum: [0, 1]
        default: 0

    filter:
      name: filter
      in: query
      required: false
      schema:
        type: string
        description: "Condition to filter for, in SQL syntax"

    fields:
      name: fields
      in: query
      required: false
      schema:
        type: string

  responses:
    BadRequestError:
      description: Bad request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            success: false
            message: "Bad Request"

    AuthorizationError:
      description: Authorization error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            success: false
            message: "Unauthorized"

    NotFoundError:
      description: Resource not found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            success: false
            message: "The requested resource could not be found"

    InternalError:
      description: Internal server error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            success: false
            message: "Internal Server Error"

  schemas:
    Error:
      type: object
      properties:
        success:
          type: boolean
          example: false
        message:
          type: string
          example: "Unauthorized"

    ProjectsResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        Projects:
          type: array
          items:
            $ref: '#/components/schemas/Project'

    SitesResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        Sites:
          type: array
          items:
            $ref: '#/components/schemas/Site'

    SiteTagsResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        Tags:
          type: array
          items:
            $ref: '#/components/schemas/SiteTag'

    ChannelsResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        Channels:
          type: array
          items:
            $ref: '#/components/schemas/Channel'

    ErrorsResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        Errors:
          type: array
          items:
            $ref: '#/components/schemas/SiteError'

    ImportHistoryResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        Importhistory:
          type: array
          items:
            $ref: '#/components/schemas/ImportHistory'

    ProductDataResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        products:
          type: array
          items:
            $ref: '#/components/schemas/ProductData'

    StreamDataSourcesResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        Sources:
          type: array
          items:
            $ref: '#/components/schemas/StreamDataSource'
        meta:
          $ref: '#/components/schemas/CursorMeta'

    CursorMeta:
      type: object
      properties:
        cursor:
          type: object
          properties:
            current:
              type: integer
            prev:
              type: integer
            next:
              type: integer
            count:
              type: integer

    Project:
      type: object
      properties:
        id:
          type: string
          example: "1"
        name:
          type: string
          example: "default project"
        created_at:
          type: string
          format: date-time
          example: "2013-03-21 12:47:57"
        links:
          type: array
          items:
            type: object

    ProjectCreate:
      type: object
      required:
        - name
      properties:
        name:
          type: string
          example: "test project"

    ProjectUpdate:
      type: object
      properties:
        name:
          type: string
          example: "example project"

    Site:
      type: object
      properties:
        id:
          type: string
          example: "123"
        title:
          type: string
          example: "site 1"
        project_id:
          type: string
          example: "321"
        status:
          type: string
          enum: [active, paused_upload, disabled]
          example: "active"
        import_schedule:
          type: string
          example: "8 * * * *"
        id_column:
          type: string
          example: "id"
        processing_status:
          type: string
          enum: [Running, Done]
          example: "Done"
        created_at:
          type: string
          format: date-time
          example: "2015-01-01 11:22:33"
        links:
          type: array
          items:
            type: object

    SiteCreate:
      type: object
      required:
        - title
      properties:
        title:
          type: string
          example: "example site"
        reference:
          type: string
          example: "myReferenceKey:myReference1234"
        project_id:
          type: integer
          example: 321
        id_column:
          type: string
          example: "uniqueIdentifier"
        status:
          type: string
          enum: [active, paused_upload, disabled]
          example: "active"
        import_schedule:
          type: string
          example: "8 * * * *"

    SiteUpdate:
      type: object
      properties:
        id:
          type: integer
          example: 1
        project_id:
          type: integer
          example: 1
        title:
          type: string
          example: "My test site"
        id_column:
          type: string
          example: "uniqueIdentifier"
        status:
          type: string
          enum: [active, paused_upload, disabled]
        import_schedule:
          type: string
          example: "TZ=Europe/Berlin\\nH 2,6,19,22 * * 2,4,6"

    SiteCopyRequest:
      type: object
      required:
        - site_name
      properties:
        site_name:
          type: string
          example: "example copy site"
        project_id:
          type: string
          example: "2"
        copy_export:
          type: boolean
          default: false
          example: true
        copy_schedule_and_trigger:
          type: boolean
          default: false
          example: true
        copy_shared_setting:
          type: boolean
          default: false
          example: true

    SiteTag:
      type: object
      properties:
        id:
          type: integer
          format: int64
        key:
          type: string
        value:
          type: string
        readonly:
          type: integer
          enum: [0, 1]

    SiteTagCreate:
      type: object
      required:
        - site_id
        - key
        - value
      properties:
        site_id:
          type: string
        key:
          type: string
        value:
          type: string
        readonly:
          type: integer
          enum: [0, 1]
          default: 0

    Channel:
      type: object
      properties:
        id:
          type: string
          example: "321"
        site_id:
          type: string
          example: "123"
        channel_id:
          type: string
          example: "111"
        name:
          type: string
          example: "Criteo DE"
        export_name:
          type: string
          example: "Criteo"
        links:
          type: array
          items:
            type: object

    ChannelHistory:
      type: object
      properties:
        id:
          type: string
          example: "333"
        site_id:
          type: string
          example: "123"
        site_channel_id:
          type: string
          example: "444"
        export_time:
          type: string
          format: date-time
          example: "2015-09-30 10:18:56"
        export_start:
          type: string
          format: date-time
          example: "2015-09-30 10:18:54"
        product_count:
          type: string
          example: "18697"
        product_count_now:
          type: string
          example: "20904"
        product_count_previous:
          type: string
          example: "0"
        process_status:
          type: string
          example: "0"
        pid:
          type: string
          example: "560b96899e334"
        product_count_new:
          type: string
          example: "0"
        product_count_modified:
          type: string
          example: "0"
        product_count_deleted:
          type: string
          example: "0"
        product_count_unchanged:
          type: string
          example: "0"
        uploaded:
          type: string
          example: "0"

    ImportHistory:
      type: object
      properties:
        id:
          type: string
          example: "11111111"
        site_id:
          type: integer
          format: int64
          example: 1234
        import_time:
          type: string
          format: date-time
          example: "2015-01-01 11:22:33"
        product_count:
          type: string
          example: "18370"
        pid:
          type: string
          example: "47e6b828-3210-3568-8ec3-85ed3e2d944c"
        links:
          type: array
          items:
            type: object

    SiteError:
      type: object
      properties:
        id:
          type: string
          example: "1802017"
        pid:
          type: string
          example: "537cb0659a7dc"
        error:
          type: string
          example: "10012"
        data:
          type: string
          example: "{\"FTP Host\":\"sftp:\\/\\/example.org\",\"User\":\"sftpuser\"}"
        site_id:
          type: string
          example: "123"
        message:
          type: string
          example: "Connection failed"
        datetime:
          type: string
          format: date-time
          example: "2003-11-15 00:00:00"
        type:
          type: string
          enum: [Error, Warning, Info]
          example: "Error"
        classification:
          type: string
          enum: [low, medium, high]
          example: "medium"
        links:
          type: array
          items:
            type: object

    ProductData:
      type: object
      properties:
        id:
          type: string
          example: "123"
        gtin:
          type: string
          example: "42"
      additionalProperties:
        type: string

    ProcessRequest:
      type: object
      required:
        - action
      properties:
        action:
          type: string
          enum: [import, export, channel, export-all, all]
          example: "import"
        id:
          type: integer
          description: "Export or channel id, only required for action types export and channel"

    ProcessResponse:
      type: object
      properties:
        success:
          type: boolean
          example: true
        process_id:
          type: string
          example: "abc123def456"
        message:
          type: string
          description: "On failure this field will indicate why the request failed"

    SiteStatus:
      type: object
      properties:
        success:
          type: boolean
          example: true
        status:
          type: string
          enum: [queued, running, success, failed]
          example: "success"
        links:
          type: array
          items:
            type: object

    StreamDataSource:
      type: object
      properties:
        id:
          type: integer
          format: int64
          example: 1
        site_id:
          type: integer
          format: int64
          example: 1
        description:
          type: string
          example: "stream api"
        source:
          type: string
          example: ""
        import_type:
          type: integer
          enum: [1, 2]
          example: 1
        import_id:
          type: integer
          example: 331
        status:
          type: string
          enum: [active, paused]
          example: "active"
        settings:
          type: array
          items:
            type: string
          example: ["stream : 1"]

    StreamDataSourceCreate:
      type: object
      required:
        - import_type
        - description
        - stream_id
        - status
      properties:
        import_type:
          type: integer
          enum: [1, 2]
          example: 1
          description: "1 = Main Data Feed, 2 = Additional Data Feed"
        description:
          type: string
          example: "stream api"
        stream_id:
          type: integer
          example: 1
        status:
          type: string
          enum: [active, paused]
          example: "active"

    StreamDataSourceUpdate:
      type: object
      properties:
        import_type:
          type: integer
          enum: [1, 2]
          description: "1 = Main Data Feed, 2 = Additional Data Feed"
        description:
          type: string
        status:
          type: string
          enum: [active, paused]
