openapi: 3.0.3

info:
  title: Data Collections
  description: "For retrieving and managing data collections. Data collections are values that can be attached to a Matter. Each Data Collection contains one or more Data Fields. 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:
  '/datacollections':
    get:
      description: Returns a collection of data collections.
      tags:
        - Data Collections
      responses:
        '200':
          description: OK.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PagedDataCollections'

    post:
      description: Create a new data collection.
      tags:
        - Data Collections
      requestBody:
        $ref: '#/components/requestBodies/CreateDataCollection'
      responses:
        '200':
          description: OK.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DataCollection'

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

    put:
      description: Update a data collection.
      tags:
        - Data Collections
      parameters:
        - name: id
          in: path
          description: Unique identifier for a data collection.
          required: true
          schema:
            type: integer
            format: int32
          example: 608
      requestBody:
        $ref: '#/components/requestBodies/UpdateDataCollection'
      responses:
        '200':
          description: OK.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DataCollection'

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

components:
  schemas:
    PagedDataCollections:
      type: object
      properties:
        datacollections:
          type: array
          items:
            $ref: '#/components/schemas/DataCollection'
        meta:
          $ref: '#/components/schemas/PageMetaData'

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

    PagingData:
      type: object
      properties:
        datacollections:
          $ref: '#/components/schemas/DataCollectionsPageData'

    DataCollectionsPageData:
      type: object
      properties:
        recordCount:
          description: The total number of data collections 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 collections.
          type: integer
          example: 2
        pageSize:
          description: Page size.
          type: integer
          example: 50
        prevPage:
          description: A URL to the previous page of data collections.
          type: string
          example: https://ap-southeast-2.actionstep.com/api/rest/datacollections?page=1
        nextPage:
          description: A URL to the next page of data collections.
          type: string
          example: https://ap-southeast-2.actionstep.com/api/rest/datacollections?page=3

    DataCollection:
      type: object
      properties:
        id:
          description: Unique identifier for the data collection.
          example: 2347
          type: integer
          readOnly: true
        name:
          description: Name for the data collection.
          example: AMLData
          type: string
        description:
          description: Description for the data collection.
          example: AML status and progress values.
          type: string
        multipleRecords:
          description: Indicates if the data collection supports multiple records of values.
          enum:
            - T
            - F
          example: F
          type: string
        order:
          description: The display order compared to other data collections.
          example: 5
          type: integer
        label:
          description: The display label for the data collection.
          example: AML Certification
          type: string
        alwaysShowDescriptions:
          description: Indicates if the data collection description should always be displayed.
          enum:
            - T
            - F
          example: F
          type: string
        links:
          $ref: '#/components/schemas/DataCollectionLinks'

    DataCollectionLinks:
      type: object
      properties:
        actionType:
          description: Unique identifier of the matter type to which the data collection is associated.
          example: 822
          type: integer

    CreateDataCollection:
      type: object
      required:
        - name
        - description
      properties:
        name:
          description: Name for the data collection.
          example: AMLData
          type: string
        description:
          description: Description for the data collection.
          example: AML status and progress values.
          type: string
        multipleRecords:
          description: Indicates if the data collection supports multiple records of values.
          enum:
            - T
            - F
          example: F
          type: string
        order:
          description: The display order compared to other data collections.
          example: 5
          type: integer
        label:
          description: The display label for the data collection.
          example: AML Certification
          type: string
        alwaysShowDescriptions:
          description: Indicates if the data collection description should always be displayed.
          enum:
            - T
            - F
          example: F
          type: string
        links:
          $ref: '#/components/schemas/CreateDataCollectionLinks'

    CreateDataCollectionLinks:
      type: object
      required:
        - actionType
      properties:
        actionType:
          description: Unique identifier of the matter type to which the data collection is associated.
          example: 822
          type: integer

    UpdateDataCollection:
      type: object
      properties:
        name:
          description: Name for the data collection.
          example: AMLData
          type: string
        description:
          description: Description for the data collection.
          example: AML status and progress values.
          type: string
        multipleRecords:
          description: Indicates if the data collection supports multiple records of values.
          enum:
            - T
            - F
          example: F
          type: string
        order:
          description: The display order compared to other data collections.
          example: 5
          type: integer
        label:
          description: The display label for the data collection.
          example: AML Certification
          type: string
        alwaysShowDescriptions:
          description: Indicates if the data collection description should always be displayed.
          enum:
            - T
            - F
          example: F
          type: string
        links:
          $ref: '#/components/schemas/UpdateDataCollectionLinks'

    UpdateDataCollectionLinks:
      type: object
      properties:
        actionType:
          description: Unique identifier of the matter type to which the data collection is associated.
          example: 822
          type: integer

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

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