logicsrc/packages/schemas/schemas/logicsrc-openabtest-event.schema.json

460 lines
12 KiB
JSON

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://logicsrc.com/schemas/logicsrc-openabtest-event.schema.json",
"title": "OpenABTest authorized event (0.1 draft)",
"type": "object",
"additionalProperties": false,
"required": [
"openabtest",
"id",
"producerId",
"manifestId",
"manifestRevision",
"participantId",
"at",
"kind",
"payload"
],
"properties": {
"openabtest": {
"const": "0.1-draft"
},
"id": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"producerId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"manifestId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"manifestRevision": {
"type": "integer",
"minimum": 1,
"maximum": 9007199254740991
},
"participantId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"at": {
"type": "string",
"format": "date-time"
},
"kind": {
"enum": [
"eligibility",
"assignment",
"exposure",
"conversion",
"adjustment",
"reconciliation"
]
},
"payload": {
"type": "object"
}
},
"allOf": [
{
"if": {
"properties": {
"kind": {
"const": "eligibility"
}
}
},
"then": {
"properties": {
"payload": {
"type": "object",
"additionalProperties": false,
"required": [
"cohortId",
"eligible"
],
"properties": {
"cohortId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"eligible": {
"const": true
}
}
}
}
}
},
{
"if": {
"properties": {
"kind": {
"const": "assignment"
}
}
},
"then": {
"properties": {
"payload": {
"type": "object",
"additionalProperties": false,
"required": [
"assignmentId",
"variantId",
"cohortId"
],
"properties": {
"assignmentId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"variantId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"cohortId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
}
}
}
}
}
},
{
"if": {
"properties": {
"kind": {
"const": "exposure"
}
}
},
"then": {
"properties": {
"payload": {
"type": "object",
"additionalProperties": false,
"required": [
"assignmentId",
"variantId",
"offerId",
"surface"
],
"properties": {
"assignmentId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"variantId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"offerId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"surface": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
}
}
}
}
}
},
{
"if": {
"properties": {
"kind": {
"const": "conversion"
}
}
},
"then": {
"properties": {
"payload": {
"type": "object",
"additionalProperties": false,
"required": [
"assignmentId",
"variantId",
"conversionId",
"price"
],
"properties": {
"assignmentId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"variantId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"conversionId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"price": {
"type": "object",
"additionalProperties": false,
"required": [
"offerId",
"acceptedAt",
"currency",
"listUnitPriceMinor",
"chargedUnitPriceMinor",
"discountBps",
"quantityMilliUnits",
"rounding",
"totalMinor"
],
"properties": {
"offerId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"acceptedAt": {
"type": "string",
"format": "date-time"
},
"currency": {
"type": "string",
"pattern": "^[A-Z]{3}$"
},
"listUnitPriceMinor": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"chargedUnitPriceMinor": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"discountBps": {
"type": "integer",
"minimum": 0,
"maximum": 10000
},
"quantityMilliUnits": {
"type": "integer",
"minimum": 1,
"maximum": 9007199254740991
},
"rounding": {
"const": "half-up"
},
"totalMinor": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
}
}
}
}
}
}
}
},
{
"if": {
"properties": {
"kind": {
"const": "adjustment"
}
}
},
"then": {
"properties": {
"payload": {
"type": "object",
"additionalProperties": false,
"required": [
"assignmentId",
"variantId",
"conversionId",
"adjustmentId",
"currency",
"amountMinor",
"reason",
"proofRefs"
],
"properties": {
"assignmentId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"variantId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"conversionId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"adjustmentId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"currency": {
"type": "string",
"pattern": "^[A-Z]{3}$"
},
"amountMinor": {
"type": "integer",
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"reason": {
"enum": [
"refund",
"chargeback",
"correction"
]
},
"proofRefs": {
"type": "array",
"items": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"uniqueItems": true,
"maxItems": 100,
"minItems": 1
}
}
}
}
}
},
{
"if": {
"properties": {
"kind": {
"const": "reconciliation"
}
}
},
"then": {
"properties": {
"payload": {
"type": "object",
"additionalProperties": false,
"required": [
"assignmentId",
"variantId",
"conversionId",
"accountingRevision",
"currency",
"state",
"revenueMinor",
"refundsMinor",
"actualCostMinor",
"feesMinor",
"affiliateMinor",
"retainedProfitMinor",
"minimumRetainedProfitMinor",
"payoutStatus",
"proofRefs"
],
"properties": {
"assignmentId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"variantId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"conversionId": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"accountingRevision": {
"type": "integer",
"minimum": 1,
"maximum": 9007199254740991
},
"currency": {
"type": "string",
"pattern": "^[A-Z]{3}$"
},
"state": {
"enum": [
"pending",
"reconciled"
]
},
"revenueMinor": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"refundsMinor": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"actualCostMinor": {
"type": [
"integer",
"null"
],
"minimum": 0,
"maximum": 9007199254740991
},
"feesMinor": {
"type": [
"integer",
"null"
],
"minimum": 0,
"maximum": 9007199254740991
},
"affiliateMinor": {
"type": [
"integer",
"null"
],
"minimum": 0,
"maximum": 9007199254740991
},
"retainedProfitMinor": {
"type": [
"integer",
"null"
],
"minimum": -9007199254740991,
"maximum": 9007199254740991
},
"minimumRetainedProfitMinor": {
"type": "integer",
"minimum": 0,
"maximum": 9007199254740991
},
"payoutStatus": {
"enum": [
"withheld",
"eligible"
]
},
"proofRefs": {
"type": "array",
"items": {
"type": "string",
"pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$"
},
"uniqueItems": true,
"maxItems": 100
}
}
}
}
}
}
]
}