{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "#/components/schemas/PushOperation",
  "title": "Push operation",
  "type": "object",
  "x-internal": true,
  "properties": {
    "changes": {
      "type": "array",
      "nullable": true,
      "description": "Contains a single entry that communicates which record has changed and the manner in which it changed. ",
      "items": {
        "$ref": "#/components/schemas/PushOperation/definitions/pushOperationChange"
      }
    },
    "dataType": {
      "$ref": "#/components/schemas/DataType",
      "description": "The type of data being pushed, eg invoices, customers."
    },
    "companyId": {
      "$ref": "#/components/parameters/companyId/schema"
    },
    "pushOperationKey": {
      "type": "string",
      "format": "uuid",
      "description": "A unique identifier generated by Codat to represent this single push operation. This identifier can be used to track the status of the push, and should be persisted."
    },
    "dataConnectionKey": {
      "$ref": "#/components/parameters/connectionId/schema"
    },
    "requestedOnUtc": {
      "$ref": "#/components/schemas/DateTime",
      "description": "The datetime when the push was requested."
    },
    "completedOnUtc": {
      "$ref": "#/components/schemas/DateTime",
      "description": "The datetime when the push was completed, null if Pending."
    },
    "timeoutInMinutes": {
      "type": "integer",
      "format": "int32",
      "nullable": true,
      "description": "Number of minutes the push operation must complete within before it times out."
    },
    "timeoutInSeconds": {
      "type": "integer",
      "format": "int32",
      "nullable": true,
      "deprecated": true,
      "description": "Number of seconds the push operation must complete within before it times out."
    },
    "status": {
      "$ref": "#/components/schemas/PushOperation/definitions/pushOperationStatus"
    },
    "errorMessage": {
      "type": "string",
      "nullable": true,
      "description": "A message about the error."
    },
    "validation": {
      "$ref": "#/components/schemas/PushOperation/definitions/validation"
    },
    "statusCode": {
      "type": "integer",
      "description": "Push status code."
    }
  },
  "required": [
    "companyId",
    "pushOperationKey",
    "dataConnectionKey",
    "requestedOnUtc",
    "status",
    "statusCode"
  ],
  "definitions": {
    "validation": {
      "type": "object",
      "title": "Validation",
      "description": "A human-readable object describing validation decisions Codat has made when pushing data into the platform. If a push has failed because of validation errors, they will be detailed here.",
      "properties": {
        "errors": {
          "type": "array",
          "nullable": true,
          "items": {
            "$ref": "#/components/schemas/PushOperation/definitions/validationItem"
          }
        },
        "warnings": {
          "type": "array",
          "nullable": true,
          "items": {
            "$ref": "#/components/schemas/PushOperation/definitions/validationItem"
          }
        }
      }
    },
    "validationItem": {
      "title": "Validation item",
      "type": "object",
      "properties": {
        "itemId": {
          "type": "string",
          "nullable": true,
          "description": "Unique identifier for a validation item."
        },
        "message": {
          "type": "string",
          "nullable": true,
          "description": "A message outlining validation item's issue."
        },
        "validatorName": {
          "type": "string",
          "nullable": true,
          "description": "Name of validator."
        }
      },
      "additionalProperties": false
    },
    "pushChangeType": {
      "title": "Push change type",
      "description": "Type of change being applied to record in third party platform.",
      "type": "string",
      "enum": [
        "Unknown",
        "Created",
        "Modified",
        "Deleted",
        "AttachmentUploaded"
      ]
    },
    "pushOperationRef": {
      "title": "Push operation reference",
      "x-internal": true,
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "Unique identifier for a push operation."
        },
        "dataType": {
          "$ref": "#/components/schemas/DataType",
          "nullable": true
        }
      },
      "additionalProperties": false
    },
    "pushOperationStatus": {
      "title": "Push operation status",
      "type": "string",
      "enum": [
        "Pending",
        "Failed",
        "Success",
        "TimedOut"
      ],
      "description": "The current status of the push operation."
    },
    "pushOperationChange": {
      "type": "object",
      "properties": {
        "type": {
          "$ref": "#/components/schemas/PushOperation/definitions/pushChangeType"
        },
        "recordRef": {
          "$ref": "#/components/schemas/PushOperation/definitions/pushOperationRef"
        },
        "attachmentId": {
          "type": "string",
          "description": "Unique identifier for the attachment created otherwise null.",
          "nullable": true
        }
      }
    }
  }
}