openapi: 3.0.0
info:
  title: 'iCollect API'
  description: "Read the docs at [https://sandbox.icollect.co.nz/api/docs](https://sandbox.icollect.co.nz/api/docs).\n This api follows Swagger OpenApi. You can find out more about Swagger at [http://swagger.io](http://swagger.io)"
  version: 1.0.0-beta
servers:
  -
    url: 'https://sandbox.icollect.co.nz/'
paths:
  '/api/v1/communications/{comms_id}':
    get:
      tags:
        - communications
      summary: 'Fetch Communication'
      description: 'Returns a signed url from which the file can be requested'
      operationId: dc2a489d7100ce4b996951267bcf848e
      parameters:
        -
          $ref: '#/components/parameters/comms_id'
      responses:
        '200':
          description: 'Returns a signed url from which the file can be requested'
        '422':
          description: 'Missing comms_id'
  '/api/v1/debtors/{debtor_id}':
    get:
      tags:
        - debtors
      summary: 'Fetch Debtor'
      description: 'Fetches information about a debtor'
      operationId: b066480d17386c4dfa6a64fe4e0fa265
      parameters:
        -
          $ref: '#/components/parameters/debtor_id'
      responses:
        '200':
          description: 'Debtor object'
        '422':
          description: 'Missing debtor id'
  /api/v1/debtors:
    post:
      tags:
        - debtors
      summary: 'Bulk upload of debtors'
      operationId: 53181e44feb35df1c4e2fbad51da80f7
      requestBody:
        description: 'Data packet for Test'
        required: true
        content:
          application/json:
            schema:
              properties:
                debtors:
                  type: array
                  items: { properties: { debt: { description: 'Dollar value', type: number, format: double, maximum: 10000000, minimum: 125, example: 1250.5 }, date: { type: string, format: date, example: '2020-01-01' }, reference: { description: 'Debt reference', type: string, maxLength: 45 }, type: { type: string, enum: [Individual, LTD, 'Sole Trader'], example: Individual }, organisation: { description: 'If not individual then required', type: string, maxLength: 100 }, name_given: { description: 'If individual then required', type: string, maxLength: 45 }, name_family: { type: string, maxLength: 45 }, email: { type: string, format: email, maxLength: 100, example: name@domain.com }, email_2: { type: string, format: email, maxLength: 100, example: name@domain.com }, phone: { description: 'NZ mobile numbers only - at least 9 numbers in length', type: string, maxLength: 45, pattern: '^[0-9+]+$', example: '+64210000000' }, phone_2: { description: 'Alternative phone', type: string, maxLength: 45, pattern: '^[0-9+]+$', example: '094440000' }, address_full: { description: 'Full address', type: string, maxLength: 255, example: '123 Place,Suburbia,Townberg,1023' }, address_1: { description: 'Street Address', type: string, maxLength: 100, example: '123 Place' }, address_2: { description: Suburb, type: string, maxLength: 100, example: Suburbia }, address_3: { description: City, type: string, maxLength: 100, example: Townberg }, postal_code: { description: Postcode, type: string, maxLength: 10, example: '123' } }, type: object }
              type: object
      responses:
        '200':
          description: 'JSON array of debtor_id(s)'
        '405':
          description: 'Invalid input'
  '/api/v1/documents/{document_id}':
    get:
      tags:
        - documents
      summary: 'Fetch Document'
      description: 'Returns a signed url from which the file can be requested'
      operationId: ceb64a08331f394ca6fa6aae1321c497
      parameters:
        -
          $ref: '#/components/parameters/document_id'
      responses:
        '200':
          description: 'Returns a signed url from which the file can be requested'
        '422':
          description: 'Missing document_id'
    delete:
      tags:
        - documents
      summary: 'Delete Document'
      description: 'Delete a document'
      operationId: b3f3437b9c2646e1ebe55564edba9801
      parameters:
        -
          $ref: '#/components/parameters/document_id'
      responses:
        '200':
          description: 'Returns a success message'
        '422':
          description: 'Missing document_id'
  /api/v1/documents:
    post:
      tags:
        - documents
      summary: 'Upload new document'
      description: 'Upload a new document'
      operationId: d06341f0d39af1c28b8bdd9cc199a888
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              required:
                - debtor_id
                - file_upload
              properties:
                debtor_id:
                  type: integer
                file_upload:
                  type: string
                  format: binary
              type: object
      responses:
        '200':
          description: 'Returns a document id and information'
        '422':
          description: 'Missing debtor_id or file stream'
  /api/v1/notes:
    post:
      tags:
        - notes
      summary: 'Upload new note'
      description: 'Create a new note'
      operationId: 95da956fa9c069e21605152332278118
      requestBody:
        required: true
        content:
          application/json:
            schema:
              required:
                - debtor_id
                - note_text
              properties:
                debtor_id:
                  type: integer
                  example: 21
                note_text:
                  type: string
                  maxLength: 5000
                  example: 'Please enter a note here'
              type: object
      responses:
        '200':
          description: 'Returns a note id and information'
        '422':
          description: 'Validation failure'
  /api/v1/payments:
    post:
      tags:
        - payments
      summary: 'Upload new payment'
      description: 'Create a new payment'
      operationId: d73c113d8b593895324a5facbb6d8c91
      requestBody:
        required: true
        content:
          application/json:
            schema:
              required:
                - debtor_id
                - payment_amount
                - payment_date
              properties:
                debtor_id:
                  type: integer
                  example: 21
                payment_amount:
                  description: 'dollar value'
                  type: number
                  format: double
                  maximum: 10000000
                  minimum: 0
                  example: 1250.5
                payment_date:
                  type: string
                  format: date
                  example: '2020-01-01'
              type: object
      responses:
        '200':
          description: 'Returns a payment id and information'
        '422':
          description: 'Validation failure'
components:
  parameters:
    comms_id:
      name: comms_id
      in: path
      description: 'Communication id'
      required: true
      schema:
        type: integer
    debtor_id:
      name: debtor_id
      in: path
      description: 'Debtor id'
      required: false
      allowEmptyValue: true
      schema:
        type: integer
    document_id:
      name: document_id
      in: path
      description: 'Document id'
      required: true
      schema:
        type: integer
    note_id:
      name: note_id
      in: path
      description: 'Note id'
      required: true
      schema:
        type: integer
    payment_id:
      name: payment_id
      in: path
      description: 'Payment id'
      required: true
      schema:
        type: integer
  securitySchemes:
    x_api_key:
      type: apiKey
      description: 'Api Key for authorization.'
      name: x-api-key
      in: header
security:
  -
    x_api_key: []
