Skip to content

Instantly share code, notes, and snippets.

@TrentBrown
Last active December 17, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TrentBrown/5623662 to your computer and use it in GitHub Desktop.
Save TrentBrown/5623662 to your computer and use it in GitHub Desktop.
Sidecar Schema

Metadata JSON Schema Version 2

The following is defined using JSON Schema.

Examples can be validated against schemas here.

{
    "$schema": "http://json-schema.org/draft-04/schema#",

    "title": "Metadata Schema Version 2",
    "type": "object",
    "additionalProperties": false,
    "required": [ "version", "isCurrent", "partnerAccountId", "document" ],
    "properties":
    {
        "version":
        {
            "description": "Version of the metadata schema",
            "type": "string",
            "enum": ["2.0"]
        },
        "isCurrent":
        {
            "description": "When true, this is the current document. When false, it is 'historical'",
            "type": "boolean"
        },
        "partnerAccountId":
        {
            "description": "The externally-defined user id provided in the account creation request",
            "type": "string"
        },
        "document":
        {
            "title": "Document",
            "anyOf":
            [
                {
                    "description": "Bill - Any document with a payment request",
                    "type": "object",
                    "additionalProperties": false,
                    "required": [ "documentType", "date", "institution", "filename", "account", "accounts", "sourceId" ],
                    "properties":
                    {
                        "documentType":
                        {
                            "type": "string",
                            "enum": ["bill"]
                        },
                        "date":
                        {
                            "type": "string"
                        },
                        "sourceId":
                        {
                            "description": "ID of source/institution/brand",
                            "type": "string"
                        },
                        "institution":
                        {
                            "type": "string"
                        },
                        "filename":
                        {
                            "type": "string"
                        },
                        "account":
                        {
                            "type": "string"
                        },
                        "accounts":
                        {
                            "title": "Accounts",
                            "type": "array",
                            "items": 
                            {
                                "title": "Account",
                                "type": "object",
                                "additionalProperties": false,
                                "required": [ "name", "amountDue", "dateDue" ],
                                "properties":
                                {
                                    "name":
                                    {
                                        "type": "string"
                                    },
                                    "amountDue":
                                    {
                                        "type": "string"
                                    },
                                    "dateDue":
                                    {
                                        "type": "string"
                                    },
                                    "balance":
                                    {
                                        "type": "string"
                                    },
                                    "totalAmountDue":
                                    {
                                        "type": "string"
                                    },
                                    "lastPaymentAmount":
                                    {
                                        "type": "string"
                                    }
                                }
                            }
                        }                        
                    }
                },
                {
                    "description": "Statement - Any document with account summary information within",
                    "type": "object",
                    "additionalProperties": false,
                    "required": [ "documentType", "date", "institution", "filename", "account", "accounts", "sourceId" ],
                    "properties":
                    {
                        "documentType":
                        {
                            "type": "string",
                            "enum": ["statement"]
                        },
                        "date":
                        {
                            "type": "string"
                        },
                        "sourceId":
                        {
                            "description": "ID of source/institution/brand",
                            "type": "string"
                        },
                        "institution":
                        {
                            "type": "string"
                        },
                        "filename":
                        {
                            "type": "string"
                        },
                        "account":
                        {
                            "type": "string"
                        },
                        "accounts":
                        {
                            "title": "Accounts",
                            "type": "array",
                            "items": 
                            {
                                "title": "Account",
                                "type": "object",
                                "additionalProperties": false,
                                "required": [ "name" ],
                                "properties":
                                {
                                    "name":
                                    {
                                        "type": "string"
                                    },
                                    "accountBalance":
                                    {
                                        "type": "string"
                                    },
                                    "statementStartDate":
                                    {
                                        "type": "string"
                                    },
                                    "statementEndDate":
                                    {
                                        "type": "string"
                                    }
                                }
                            }
                        }                        
                    }
                },
                {
                    "description": "Notice - Any document that is informational and does not require repeated delivery",
                    "type": "object",
                    "additionalProperties": false,
                    "required": [ "documentType", "date", "institution", "filename", "account", "accounts", "sourceId" ],
                    "properties":
                    {
                        "documentType":
                        {
                            "type": "string",
                            "enum": ["notice"]
                        },
                        "date":
                        {
                            "type": "string"
                        },
                        "sourceId":
                        {
                            "description": "ID of source/institution/brand",
                            "type": "string"
                        },
                        "institution":
                        {
                            "type": "string"
                        },
                        "filename":
                        {
                            "type": "string"
                        },
                        "account":
                        {
                            "type": "string"
                        },
                        "accounts":
                        {
                            "title": "Accounts",
                            "type": "array",
                            "items": 
                            {
                                "title": "Account",
                                "type": "object",
                                "additionalProperties": false,
                                "required": [ "name" ],
                                "properties":
                                {
                                    "name":
                                    {
                                        "type": "string"
                                    }
                                }
                            }
                        }                        
                    }
                }
            ]
        }
    }
}

Metadata Examples

{
  "version" : "2.0",
  "isCurrent": true,
  "partnerAccountId" : "user123",
  "document" :
  {
    "documentType" : "bill",
    "date" : "05-01-2012",
    "institution" : "Fake Bank",
    "sourceId" : "123",
    "filename" : "Bank-Bill-05-01-2012-1469.pdf",
    "account" : "UBS-7g4ax33",
    "accounts" :
    [
      {
        "name" : "UBS-7g4ax33",
        "dateDue" : "08-08-2013",
        "amountDue" : "186.76"
      }
    ]
  }
}
{
  "version" : "2.0",
  "isCurrent": true,
  "partnerAccountId" : "user123",
  "document" :
  {
    "documentType" : "statement",
    "date" : "05-01-2012",
    "institution" : "Fake Bank",
    "sourceId" : "123",
    "filename" : "Bank-Bill-05-01-2012-1469.pdf",
    "account" : "UBS-7g4ax33",
    "accounts" :
    [
      {
        "name" : "UBS-7g4ax33"
      }
    ]
  }
}
{
  "version" : "2.0",
  "isCurrent": true,
  "partnerAccountId" : "user123",
  "document" :
  {
    "documentType" : "notice",
    "date" : "05-01-2012",
    "institution" : "Fake Bank",
    "sourceId" : "123",
    "filename" : "Bank-Bill-05-01-2012-1469.pdf",
    "account" : "UBS-7g4ax33",
    "accounts" :
    [
      {
        "name" : "UBS-7g4ax33"
      }
    ]
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment