﻿{
  "$schema": "http://json-schema.org/draft-04/schema",
  "title": "JSON Schema for B2B Order Header Objects",

  "type": "object",
  "properties": {
    "B2BSupplierOrderID": { // Can be zero if B2BSalesOrderID or SuppliersOrderRef is supplied
      "type": "integer"
    },
    "B2BSalesOrderID": { //Can be zero if SuppliersOrderRef or B2BSupplierOrderID is supplied
      "type": "integer"
    },
    "OrderStatus": { //Company dependent. B2B will provide a list of allowable order status values and their meaning on request
      "type": "integer"
    },
    "SuppliersOrderRef": { //Can be null if SuppliersOrderRef or B2BSupplierOrderID is supplied
      "type": [
        "string",
        "null"
      ]
    },
    "ObjectType": { 
      "type": [
        "string",
        "null"
      ]
    },
    "ShopID": { //B2B unique shop identifier - may be 0 if ClientCode is supplied
      "type": "integer"
    },
    "CompanyID": { //B2B unique identifier for shop owner.
      "type": "integer"
    },
    "ClientCode": { // Unique Company based identifier for Shop - can be null if ShopID is supplied
      "type": [
        "string",
        "null"
      ]
    },
    "SupplierID": { //B2B Unique supplier ID
      "type": "integer"
    },
    "Signature": { //AES256 hash of SignedString + a Shared Secret Key 
      "type": [
        "string",
        "null"
      ]
    },
    "SignedString": { //Contcatinated string representations of selected fields.
      "type": [
        "string",
        "null"
      ]
    },
    "DateTimeStamp": { //Julian date timestamp of update time.  Can be 0 if LastUpdated supplied
      "type": "number"
    },
    "LastUpdated": { // DateTime of last update to data
      "type": "string",
      "format": "date-time"
    }
  },
  "required": [
    "B2BSupplierOrderID",
    "B2BSalesOrderID",
    "OrderStatus",
    "SuppliersOrderRef",
    "ObjectType",
    "ShopID",
    "CompanyID",
    "ClientCode",
    "SupplierID",
    "Signature",
    "SignedString",
    "DateTimeStamp",
    "LastUpdated"
  ]
}
