{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://futa.invalid/contracts/obligation-collection-event.v1.json",
  "title": "Replacement obligation collection event v1",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "id",
    "type",
    "schema_version",
    "occurred_at",
    "data"
  ],
  "properties": {
    "id": {
      "type": "string",
      "format": "uuid",
      "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
    },
    "type": {
      "type": "string",
      "enum": [
        "obligation.collected"
      ]
    },
    "schema_version": {
      "type": "integer",
      "enum": [
        1
      ]
    },
    "occurred_at": {
      "type": "string",
      "format": "date-time"
    },
    "data": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "obligation_id",
        "collected_payment_id",
        "predecessor_id",
        "approval_event_id",
        "attempt_ids",
        "merchant_id",
        "merchant_reference",
        "amount",
        "currency",
        "synthetic"
      ],
      "properties": {
        "obligation_id": {
          "type": "string",
          "format": "uuid",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
        },
        "collected_payment_id": {
          "type": "string",
          "format": "uuid",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
        },
        "predecessor_id": {
          "type": "string",
          "format": "uuid",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
        },
        "approval_event_id": {
          "type": "string",
          "format": "uuid",
          "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
        },
        "attempt_ids": {
          "type": "array",
          "minItems": 2,
          "maxItems": 65,
          "uniqueItems": true,
          "items": {
            "type": "string",
            "format": "uuid",
            "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
          }
        },
        "merchant_id": {
          "type": "string",
          "pattern": "^[a-z0-9][a-z0-9-]{2,63}$"
        },
        "merchant_reference": {
          "type": "string",
          "minLength": 1,
          "maxLength": 100
        },
        "amount": {
          "type": "integer",
          "minimum": 1,
          "maximum": 9000000000000
        },
        "currency": {
          "type": "string",
          "enum": [
            "CDF",
            "USD"
          ]
        },
        "synthetic": {
          "type": "boolean",
          "enum": [
            true
          ]
        }
      },
      "allOf": [
        {
          "if": {
            "properties": {
              "currency": {
                "const": "CDF"
              }
            }
          },
          "then": {
            "properties": {
              "amount": {
                "multipleOf": 100
              }
            }
          }
        }
      ]
    }
  }
}
