{
  "$schema": "http://json-schema.org/draft-06/schema#",
  "title": "Integration Configuration",
  "description": "The schema used to generate integration configuration in Contentful",
  "type": "object",
  "properties": {
    "webhooks": {
      "type": "array",
      "title": "Managed Webhooks",
      "description": "A list of webhooks managed by this integration",
      "items": {
        "$ref": "#/definitions/webhook"
      }
    },
    "linkInterceptors": {
      "type": "array",
      "title": "Managed Link Interceptors",
      "description": "A list of link interceptors managed by this integration",
      "items": {
        "$ref": "#/definitions/linkInterceptor"
      }
    },
    "formHandler": {
      "$ref": "#/definitions/formHandler"
    },
    "customFields": {
      "type": "array",
      "title": "Managed Custom Fields",
      "description": "A list of custom fields managed by this integration",
      "items": {
        "$ref": "#/definitions/customField"
      }
    },
    "userEvents": {
      "type": "array",
      "title": "Managed User Events",
      "description": "A list of user events managed by this integration",
      "items": {
        "$ref": "#/definitions/userEventMeta"
      }
    },
    "fulfilledRewardUnits": {
      "type": "array",
      "title": "Fulfilled Reward Units",
      "description": "A list of reward units fulfilled by this integration",
      "items": {
        "type": "string",
        "title": "Reward Unit"
      }
    }
  },
  "additionalProperties": false,
  "definitions": {
    "webhook": {
      "type": "object",
      "title": "Managed Webhook",
      "description": "Configuration for setting up a webhook",
      "properties": {
        "endpointUrl": {
          "type": "string",
          "title": "Endpoint Url",
          "format": "uri",
          "description": "The webhook destination"
        },
        "name": {
          "type": "string",
          "title": "Name",
          "description": "The name of the webhook (e.g. Stripe Integration Entry Point)"
        },
        "webhookTypes": {
          "type": "array",
          "title": "Webhook Types",
          "description": "Webhook types accepted by this webhook endpoint",
          "items": {
            "type": "string",
            "enum": [
              "coupon.created",
              "reward.created",
              "email.referral.started",
              "email.referred.reward.earned",
              "email.referral.paid",
              "user.created",
              "theme.publish.finished",
              "email.referral.rewardLimitReached",
              "export.created",
              "export.completed",
              "referral.started",
              "referral.converted",
              "referral.ended",
              "referral.automoderation.complete",
              "user.reward.balance.changed"
            ]
          }
        }
      },
      "additionalProperties": false,
      "required": [
        "endpointUrl",
        "name"
      ]
    },
    "linkInterceptor": {
      "type": "object",
      "title": "Managed Link Interceptor",
      "description": "Configuration for a link interceptor",
      "properties": {
        "endpointUrl": {
          "type": "string",
          "title": "Endpoint Url",
          "format": "uri",
          "description": "The link interceptor POST endpoint URL"
        },
        "name": {
          "type": "string",
          "title": "Name",
          "description": "The name of the link interceptor"
        },
        "order": {
          "type": "number",
          "title": "Order",
          "description": "The order of this link interceptor among other link interceptors"
        }
      },
      "additionalProperties": false,
      "required": [
        "endpointUrl",
        "name",
        "order"
      ]
    },
    "formHandler": {
      "type": "object",
      "title": "Managed Form Handler",
      "description": "Configuration for a form handler",
      "properties": {
        "endpointUrl": {
          "type": "string",
          "title": "Endpoint Url",
          "format": "uri",
          "description": "The form handler POST endpoint URL"
        },
        "name": {
          "type": "string",
          "title": "Name",
          "description": "The name of the form handler"
        }
      },
      "additionalProperties": false,
      "required": [
        "endpointUrl",
        "name"
      ]
    },
    "customField": {
      "type": "object",
      "title": "Managed Custom Field",
      "description": "Configuration for a custom field",
      "additionalProperties": false,
      "required": [
        "key"
      ],
      "properties": {
        "key": {
          "type": "string",
          "title": "Key",
          "description": "The custom field key"
        },
        "name": {
          "type": "string",
          "title": "Name",
          "description": "The human readable name of the custom field"
        },
        "schema": {
          "type": "object",
          "title": "Schema",
          "description": "The JSON Schema for the values of this custom field"
        }
      }
    },
    "userEventMeta": {
      "type": "object",
      "title": "Managed User Event Meta",
      "additionalProperties": false,
      "required": [
        "key"
      ],
      "properties": {
        "key": {
          "type": "string",
          "title": "Key",
          "description": "The user event key"
        },
        "name": {
          "type": "string",
          "title": "Name",
          "description": "The human readable name of the user event key"
        },
        "fieldsSchema": {
          "type": "object",
          "title": "Schema",
          "description": "The JSON Schema for the user event fields"
        }
      }
    }
  }
}