Files
lislgosms/docs/contracts/gateway-queue-messages.schema.json
T

179 lines
7.2 KiB
JSON

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://cmpp-platform.local/schemas/gateway-queue-messages.schema.json",
"title": "CMPP Gateway Queue Messages",
"oneOf": [
{ "$ref": "#/$defs/SubmitCommand" },
{ "$ref": "#/$defs/SubmitResult" },
{ "$ref": "#/$defs/ReceiptEvent" },
{ "$ref": "#/$defs/UplinkEvent" }
],
"$defs": {
"Envelope": {
"type": "object",
"required": ["schemaVersion", "messageType", "traceId", "messageId", "channelId", "createdAt"],
"properties": {
"schemaVersion": { "const": "v1" },
"messageType": {
"enum": ["SubmitCommand", "SubmitResult", "ReceiptEvent", "UplinkEvent"]
},
"traceId": { "type": "string", "minLength": 8 },
"messageId": { "type": "string", "minLength": 8 },
"channelId": { "type": "string", "minLength": 1 },
"createdAt": { "type": "string", "format": "date-time" }
}
},
"SubmitCommand": {
"allOf": [
{ "$ref": "#/$defs/Envelope" },
{
"type": "object",
"required": [
"messageType",
"tenantId",
"applicationId",
"submitId",
"phoneNumber",
"content",
"signature",
"templateId",
"billingUnits",
"queuePriority",
"route",
"cmpp",
"upstream",
"retry"
],
"properties": {
"messageType": { "const": "SubmitCommand" },
"tenantId": { "type": "string", "minLength": 1 },
"applicationId": { "type": "string", "minLength": 1 },
"taskId": { "type": "string" },
"submitId": { "type": "string", "minLength": 1 },
"phoneNumber": { "type": "string", "pattern": "^1[3-9][0-9]{9}$" },
"content": { "type": "string", "minLength": 1 },
"signature": { "type": "string", "minLength": 1 },
"templateId": { "type": "string", "minLength": 1 },
"billingUnits": { "type": "integer", "minimum": 1 },
"queuePriority": { "enum": ["normal", "priority"] },
"route": {
"type": "object",
"required": ["channelCode", "cmppAccountCode", "priority"],
"properties": {
"channelCode": { "type": "string", "minLength": 1 },
"cmppAccountCode": { "type": "string", "minLength": 1 },
"priority": { "type": "integer", "minimum": 0 },
"rateLimitPerSecond": { "type": "integer", "minimum": 1 }
}
},
"cmpp": {
"type": "object",
"required": ["serviceId", "srcId", "registeredDelivery", "msgFmt"],
"properties": {
"serviceId": { "type": "string", "minLength": 1 },
"srcId": { "type": "string", "minLength": 1 },
"registeredDelivery": { "type": "integer", "enum": [0, 1] },
"msgFmt": { "type": "integer", "enum": [8, 15] },
"feeUserType": { "type": "integer", "minimum": 0 },
"feeCode": { "type": "string" },
"feeType": { "type": "string" }
}
},
"upstream": {
"type": "object",
"required": ["gatewayHost", "gatewayPort", "account", "passwordCipher", "cmppVersion"],
"properties": {
"gatewayHost": { "type": "string", "minLength": 1 },
"gatewayPort": { "type": "integer", "minimum": 1, "maximum": 65535 },
"account": { "type": "string", "minLength": 1 },
"passwordCipher": { "type": "string", "minLength": 1 },
"cmppVersion": { "enum": ["2.0", "3.0"] },
"desiredConnections": { "type": "integer", "minimum": 1, "maximum": 32 },
"windowSize": { "type": "integer", "minimum": 1, "maximum": 1024 }
}
},
"retry": {
"type": "object",
"required": ["attempt", "maxAttempts"],
"properties": {
"attempt": { "type": "integer", "minimum": 0 },
"maxAttempts": { "type": "integer", "minimum": 1 }
}
}
}
}
]
},
"SubmitResult": {
"allOf": [
{ "$ref": "#/$defs/Envelope" },
{
"type": "object",
"required": ["messageType", "sequenceId", "gatewayMessageId", "submitStatus", "submittedAt"],
"properties": {
"messageType": { "const": "SubmitResult" },
"sequenceId": { "type": "integer", "minimum": 0 },
"gatewayMessageId": { "type": "string", "minLength": 1 },
"submitStatus": { "enum": ["accepted", "rejected", "timeout"] },
"errorCode": { "type": "string" },
"errorMessage": { "type": "string" },
"submittedAt": { "type": "string", "format": "date-time" },
"segments": {
"type": "array",
"items": {
"type": "object",
"required": ["segmentTotal", "segmentIndex", "sequenceId", "gatewayMessageId", "submitStatus", "submittedAt"],
"properties": {
"segmentTotal": { "type": "integer", "minimum": 1 },
"segmentIndex": { "type": "integer", "minimum": 1 },
"sequenceId": { "type": "integer", "minimum": 0 },
"gatewayMessageId": { "type": "string", "minLength": 1 },
"submitStatus": { "enum": ["accepted", "rejected", "timeout"] },
"errorCode": { "type": "string" },
"errorMessage": { "type": "string" },
"submittedAt": { "type": "string", "format": "date-time" }
}
}
}
}
}
]
},
"ReceiptEvent": {
"allOf": [
{ "$ref": "#/$defs/Envelope" },
{
"type": "object",
"required": ["messageType", "sequenceId", "gatewayMessageId", "receiptStatus", "rawStatus", "deliveredAt"],
"properties": {
"messageType": { "const": "ReceiptEvent" },
"sequenceId": { "type": "integer", "minimum": 0 },
"gatewayMessageId": { "type": "string", "minLength": 1 },
"receiptStatus": { "enum": ["delivered", "undelivered", "unknown"] },
"rawStatus": { "type": "string", "minLength": 1 },
"errorCode": { "type": "string" },
"deliveredAt": { "type": "string", "format": "date-time" }
}
}
]
},
"UplinkEvent": {
"allOf": [
{ "$ref": "#/$defs/Envelope" },
{
"type": "object",
"required": ["messageType", "sequenceId", "phoneNumber", "destId", "content", "receivedAt"],
"properties": {
"messageType": { "const": "UplinkEvent" },
"sequenceId": { "type": "integer", "minimum": 0 },
"phoneNumber": { "type": "string", "pattern": "^1[3-9][0-9]{9}$" },
"destId": { "type": "string", "minLength": 1 },
"content": { "type": "string", "minLength": 1 },
"receivedAt": { "type": "string", "format": "date-time" }
}
}
]
}
}
}