openapi: 3.0.3

info:
  title: Data Collection Records
  description: "For retrieving and managing data collection records. A data collection record is a group of data fields acting as a single unit (record) of data. For information of how to construct requests utilising fieldsets, sorting, paging, filters, and '*includes*', please refer to the API Developer Portal. E&OE."
  version: "1.0"

externalDocs:
  description: API Developer Portal - Constructing API Requests
  url: https://docs.actionstep.com/api-requests/

paths:
  '/datacollectionrecords':
    get:
      description: Returns a collection of data collection records.
      tags:
        - Data Collection Records
      responses:
        '200':
          description: OK.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PagedDataCollectionRecords'

    post:
      description: Create a new data collection record.
      tags:
        - Data Collection Records
      requestBody:
        $ref: '#/components/requestBodies/CreateDataCollectionRecord'
      responses:
        '200':
          description: OK.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DataCollectionRecord'

  '/datacollectionrecords/{id}':
    get:
      description: Returns a single data collection record.
      tags:
        - Data Collection Records
      parameters:
        - name: id
          in: path
          description: Unique identifier for a data collection record.
          required: true
          schema:
            type: integer
            format: int32
          example: 380
      responses:
        '200':
          description: OK.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DataCollectionRecord'

    delete:
      description: Delete a data collection record.
      tags:
        - Data Collection Records
      parameters:
        - name: id
          in: path
          description: Unique identifier for a data collection record.
          required: true
          schema:
            type: integer
            format: int32
          example: 608
      responses:
        '204':
          description: Success, No Content.

components:
  schemas:
    PagedDataCollectionRecords:
      type: object
      properties:
        datacollectionrecords:
          type: array
          items:
            $ref: '#/components/schemas/DataCollectionRecord'
        meta:
          $ref: '#/components/schemas/PageMetaData'

    PageMetaData:
      type: object
      properties:
        paging:
          $ref: '#/components/schemas/PagingData'

    PagingData:
      type: object
      properties:
        datacollectionrecords:
          $ref: '#/components/schemas/DataCollectionRecordsPageData'

    DataCollectionRecordsPageData:
      type: object
      properties:
        recordCount:
          description: The total number of data collection records returned by the underlying query.
          type: integer
          example: 2487
        pageCount:
          description: The total number of pages generated by the underlying query.
          type: integer
          example: 50
        page:
          description: The page number for this page of data collection records.
          type: integer
          example: 2
        pageSize:
          description: Page size.
          type: integer
          example: 50
        prevPage:
          description: A URL to the previous page of data collection records.
          type: string
          example: https://ap-southeast-2.actionstep.com/api/rest/datacollectionrecords?page=1
        nextPage:
          description: A URL to the next page of data collection records.
          type: string
          example: https://ap-southeast-2.actionstep.com/api/rest/datacollectionrecords?page=3

    DataCollectionRecord:
      type: object
      properties:
        id:
          description: Unique identifier for the data collection record.
          example: 4910
          type: integer
          readOnly: true
        canWrite:
          description: Indicates if the data collection record can be written to.
          enum:
            - T
            - F
          example: F
          type: string
          readOnly: true
        canDelete:
          description: Indicates if the data collection record can be deleted.
          enum:
            - T
            - F
          example: F
          type: string
          readOnly: true
        links:
          $ref: '#/components/schemas/DataCollectionRecordLinks'

    DataCollectionRecordLinks:
      type: object
      properties:
        action:
          description: Unique identifier of the matter to which the data collection is associated.
          example: 822
          type: integer
        dataCollection:
          description: Unique identifier of the data collection to which the data collection record is associated.
          example: 50
          type: integer

    CreateDataCollectionRecord:
      type: object
      properties:
        canWrite:
          description: Indicates if the data collection record can be written to.
          enum:
            - T
            - F
          example: F
          type: string
        canDelete:
          description: Indicates if the data collection record can be deleted.
          enum:
            - T
            - F
          example: F
          type: string
        links:
          $ref: '#/components/schemas/CreateDataCollectionRecordLinks'

    CreateDataCollectionRecordLinks:
      type: object
      properties:
        action:
          description: Unique identifier of the matter to which the data collection is associated.
          example: 822
          type: integer
        dataCollection:
          description: Unique identifier of the data collection to which the data collection record is associated.
          example: 50
          type: integer

  requestBodies:
    CreateDataCollectionRecord:
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/CreateDataCollectionRecord'