diff --git a/schemas/fcmaterials_capi-README.md b/schemas/fcmaterials_capi-README.md new file mode 100644 index 0000000..357da91 --- /dev/null +++ b/schemas/fcmaterials_capi-README.md @@ -0,0 +1,38 @@ +# EDDN FCMaterials Schema + +## Introduction +This is the documentation for how to take data from an ED `FCMaterials.json` +file and properly structure it for sending to EDDN. + +Please consult [EDDN Schemas README](./README-EDDN-schemas.md) for general +documentation for a schema such as this. + +If you find any discrepancies between what this document says and what is +defined in the relevant Schema file, then you should, in the first instance, +assume that it is the Schema file that is correct. +**PLEASE open +[an issue on GitHub](https://github.com/EDCD/EDDN/issues/new/choose) +to report any such anomalies you find so that we can check and resolve the +discrepancy.** + +## Senders +The data source for this schema is the file `FCMaterials.json`. That it has +been freshly written is signalled by the ED Journal event `FCMaterials`. +**NB: This schema is not, currently, for sending CAPI `/market`-sourced data +about these materials.** + +So, monitor the Journal as normal, and when you see a `FCMaterials` event open +the `FCMaterials.json` file for reading, read it, and close it again. Use the +data you got from reading this file, not merely the Journal event. + +Your `message` should primarily be the contents of this file, with the addition +of any augmentations, as noted below. + +### Augmentations +#### horizons and odyssey flags +Please read [horizons and odyssey flags](../docs/Developers.md#horizons-and-odyssey-flags) +in the Developers' documentation. + +## Listeners +The advice above for [Senders](#senders), combined with the actual Schema file +*should* provide all the information you need to process these events. diff --git a/schemas/fcmaterials_capi-v1.0.json b/schemas/fcmaterials_capi-v1.0.json new file mode 100644 index 0000000..49edb06 --- /dev/null +++ b/schemas/fcmaterials_capi-v1.0.json @@ -0,0 +1,144 @@ +{ + "$schema" : "http://json-schema.org/draft-04/schema#", + "id" : "https://eddn.edcd.io/schemas/fcmaterials_capi/1", + "type" : "object", + "additionalProperties" : false, + "required": [ "$schemaRef", "header", "message" ], + "properties": { + "$schemaRef": { + "type" : "string" + }, + "header": { + "type" : "object", + "additionalProperties" : true, + "required" : [ "uploaderID", "softwareName", "softwareVersion" ], + "properties" : { + "uploaderID": { + "type" : "string" + }, + "softwareName": { + "type" : "string" + }, + "softwareVersion": { + "type" : "string" + }, + "gatewayTimestamp": { + "type" : "string", + "format" : "date-time", + "description" : "Timestamp upon receipt at the gateway. If present, this property will be overwritten by the gateway; submitters are not intended to populate this property." + } + } + }, + "message": { + "type" : "object", + "description" : "Contains all properties from the listed events in the client's journal minus the Localised strings and the properties marked below as 'disallowed'", + "additionalProperties" : false, + "required" : [ "timestamp", "event", "MarketID", "CarrierID", "Items" ], + "properties" : { + "timestamp": { + "type" : "string", + "format" : "date-time" + }, + "event" : { + "enum" : [ "FCMaterials" ] + }, + "horizons": { + "type" : "boolean", + "description" : "Boolean value copied from the Journal LoadGame event, when it is present there." + }, + "odyssey": { + "type" : "boolean", + "description" : "Boolean value copied from the Journal LoadGame event, when it is present there." + }, + + "MarketID": { + "type" : "integer" + }, + + "CarrierID": { + "type" : "string", + "minLength" : 1 + }, + + "Items": { + "properties": { + "purchases": { + "type": "array", + "items": { + "type": "object", + "required": [ "name", "price", "outstanding", "total" ], + "additionalProperties": false, + "properties": { + "name": { + "type": "string", + "minLength": 1 + }, + "locName": { + "$ref": "#/definitions/disallowed" + }, + "outstanding": { + "type": "integer" + }, + "price": { + "type": "integer" + }, + "total": { + "type": "integer" + } + } + } + }, + "sales": { + "anyOf": [ + { + "type": "array", + "$comment": "If there are no items then sales is an empty array", + "minItems": 0, + "maxItems": 0 + }, + { + "type": "object", + "$comment": "If there ARE items then sales is an object, *NOT* an array", + "patternProperties": { + "^[0-9]+$": { + "type" : "object", + "required" : [ "id", "name", "price", "stock" ], + "additionalProperties": false, + "properties": { + "id" : { + "type" : "integer" + }, + "name" : { + "type" : "string", + "minLength": 1 + }, + "locName" : { + "$ref": "#/definitions/disallowed" + }, + "price" : { + "type": "integer" + }, + "stock": { + "type": "integer" + } + } + } + } + } + ] + } + } + } + } + } + }, + "definitions": { + "disallowed": { + "not" : { + "type": [ + "array", "boolean", "integer", "number", "null", "object", "string" + ] + } + } + } +}