Last active
May 2, 2025 16:19
-
-
Save btg5679/d48b2e5af73781216a0076dce646c3f3 to your computer and use it in GitHub Desktop.
deals-v2-events.schema.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"$schema": "https://json-schema.org/draft/2020-12/schema", | |
"$id": "https://example.com/schemas/campaign-events.schema.json", | |
"title": "Campaign-Lifecycle Events", | |
"description": "Envelope and payload definitions for CampaignCreated | CampaignTerminated.", | |
"type": "object", | |
"oneOf": [ | |
{ "$ref": "#/$defs/CampaignCreatedEvent" }, | |
{ "$ref": "#/$defs/CampaignTerminatedEvent" } | |
], | |
"$defs": { | |
"EventEnvelope": { | |
"type": "object", | |
"required": ["event", "idempotencyKey", "attributes"], | |
"properties": { | |
"event": { "type": "string" }, | |
"idempotencyKey": { | |
"type": "string", | |
"pattern": "^deal-property#prop_[A-Za-z0-9]+-campaign#cmp_deal_[A-Za-z0-9]+$" | |
}, | |
"attributes": { "type": "object" } | |
}, | |
"additionalProperties": false | |
}, | |
"DiscountRate": { | |
"type": "object", | |
"required": ["type", "value"], | |
"properties": { | |
"type": { "type": "string", "enum": ["percent"] }, | |
"value": { "type": "number", "minimum": 0 } | |
}, | |
"additionalProperties": false | |
}, | |
"EligiblityRules": { | |
"type": "object", | |
"required": ["minNights", "bookingWindow", "nightOfArrival"], | |
"properties": { | |
"minNights": { | |
"type": "integer", | |
"minimum": 0, | |
"maximum": 100 | |
}, | |
"bookingWindow": { | |
"type": "object", | |
"oneOf": [ | |
{ | |
"required": ["minNightsBeforeCheckin"], | |
"properties": { | |
"minNightsBeforeCheckin": { | |
"type": "integer", | |
"minimum": 0 | |
} | |
}, | |
"additionalProperties": false | |
}, | |
{ | |
"required": ["maxNightsBeforeCheckin"], | |
"properties": { | |
"maxNightsBeforeCheckin": { | |
"type": "integer", | |
"minimum": 0 | |
} | |
}, | |
"additionalProperties": false | |
} | |
] | |
}, | |
"nightOfArrival": { | |
"type": "array", | |
"items": { | |
"type": "string", | |
"enum": ["mon", "tue", "wed", "thu", "fri", "sat", "sun"] | |
} | |
} | |
}, | |
"additionalProperties": false | |
}, | |
"CampaignCreatedPayload": { | |
"type": "object", | |
"required": [ | |
"campaignType", | |
"ref", | |
"propertyId", | |
"discountRate", | |
"eligibilityRules", | |
"discountedDates" | |
], | |
"properties": { | |
"campaignType": { "type": "string", "enum": ["DEAL"] }, | |
"ref": { "type": "string" }, | |
"propertyId": { "type": "string" }, | |
"discountRate": { "$ref": "#/$defs/DiscountRate" }, | |
"eligibilityRules": { "$ref": "#/$defs/EligibilityRules" }, | |
"discountedDates": { | |
"type": "array", | |
"items": { "type": "string", "format": "date" } | |
} | |
}, | |
"additionalProperties": false | |
}, | |
"CampaignTerminatedPayload": { | |
"type": "object", | |
"required": ["campaignType", "ref", "propertyId"], | |
"properties": { | |
"campaignType": { "type": "string", "enum": ["DEAL"] }, | |
"ref": { "type": "string" }, | |
"propertyId": { "type": "string" } | |
}, | |
"additionalProperties": false | |
}, | |
"CampaignCreatedEvent": { | |
"allOf": [ | |
{ "$ref": "#/$defs/EventEnvelope" }, | |
{ | |
"properties": { | |
"event": { "const": "CampaignCreated" }, | |
"attributes": { "$ref": "#/$defs/CampaignCreatedPayload" } | |
} | |
} | |
] | |
}, | |
"CampaignTerminatedEvent": { | |
"allOf": [ | |
{ "$ref": "#/$defs/EventEnvelope" }, | |
{ | |
"properties": { | |
"event": { "const": "CampaignTerminated" }, | |
"attributes": { "$ref": "#/$defs/CampaignTerminatedPayload" } | |
} | |
} | |
] | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment