openapi: 3.0.3

info:
  title: Contact (Document) Folders
  description: "Actionstep provide a feature to store and manage documents against individual contacts. Similarly to matter documents, contact documents can be stored in a folder hierarchy. This endpoint provides functionality for the management of contact folders. 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"

paths:
  '/contactfolders':
    get:
      description: Returns the collection of all contact folders.
      tags:
        - Contact Folders
      responses:
        '200':
          description: OK.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PagedContactFolders'

    post:
      description: Create a new contact folder.
      tags:
        - Contact Folders
      requestBody:
        $ref: '#/components/requestBodies/CreateContactFolder'
      responses:
        '200':
          description: OK.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContactFolder'

  '/contactfolders/{id}':
    get:
      description: Returns a single contact folder record.
      tags:
        - Contact Folders
      parameters:
        - name: id
          in: path
          description: Unique identifier for a single contact folder record.
          required: true
          schema:
            type: integer
            format: integer
          example: 7384
      responses:
        '200':
          description: OK.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContactFolder'

    put:
      description: Updates a single folder.
      tags:
        - Contact Folders
      parameters:
        - name: id
          in: path
          description: Unique identifier for a single contact folder record.
          required: true
          schema:
            type: integer
            format: integer
          example: 7384
      requestBody:
        $ref: '#/components/requestBodies/UpdateContactFolder'
      responses:
        '200':
          description: OK.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContactFolder'

    delete:
      description: Deletes a single contact folder record.
      tags:
        - Contact Folders
      parameters:
        - name: id
          in: path
          description: Unique identifier for a single contact folder record.
          required: true
          schema:
            type: integer
            format: integer
          example: 7384
      responses:
        '204':
          description: Success, No Content.

components:
  schemas:
    PagedContactFolders:
      type: object
      properties:
        contactfolders:
          type: array
          items:
            $ref: '#/components/schemas/ContactFolder'
        meta:
          $ref: '#/components/schemas/PageMetaData'

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

    PagingData:
      type: object
      properties:
        contactfolders:
          $ref: '#/components/schemas/ContactFoldersPageData'

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

    ContactFolder:
      type: object
      properties:
        id:
          description: Unique identifier for a single contact folder record. 
          type: integer
          format: integer
          example: 7384
          readOnly: true
        name:
          description: Name of the folder.
          type: string
          format: string
          example: Weekly Correspondence
        links:
          $ref: '#/components/schemas/ContactFolderLinks'

    ContactFolderLinks:
      type: object
      properties:
        parentFolder:
          description: Unique identifier for a parent folder. Null means root folder.
          example: 8263
          type: string
          readOnly: true
        participant:
          description: Unique identifier for the contact associated with the folder.
          example: 321845
          type: integer
          readOnly: true          

    CreateContactFolder:
      type: object
      required:
        - name
      properties:
        name:
          description: Name of the folder.
          type: string
          format: string
          example: Weekly Correspondence
        links:
          $ref: '#/components/schemas/CreateContactFolderLinks'

    CreateContactFolderLinks:
      type: object
      required:
        - participant
      properties:
        parentFolder:
          description: Unique identifier for a parent folder. Null means root folder.
          example: 8263
          type: string
          default: Null
        participant:
          description: Unique identifier for the contact associated with the folder.
          example: 321845
          type: integer

    UpdateContactFolder:
      type: object
      properties:
        name:
          description: Name of the folder.
          type: string
          format: string
          example: Weekly Correspondence
        links:
          $ref: '#/components/schemas/UpdateContactFolderLinks'

    UpdateContactFolderLinks:
      type: object
      required:
        - participant
      properties:
        parentFolder:
          description: Unique identifier for a parent folder. Null means root folder.
          example: 8263
          type: string
        participant:
          description: Unique identifier for the contact associated with the folder.
          example: 321845
          type: integer

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

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