{
  "description": "A contract import specification for abacus",
  "type": "object",
  "definitions": {
    "ContractTerm": {
      "type": "object",
      "properties": {
        "contract_term": {
          "type": "object",
          "properties": {
            "contract_term_name": {
              "type": ["string", "null"],
              "minLength": 1,
              "maxLength": 180
            },
            "attachments": {
              "type": ["array"],
              "minItems": 1,
              "items": {
                "type": ["integer", "string"]
              }
            },
            "attachments_relations": {
              "type": ["object", "null"],
              "properties": {}
            },
            "term_type": {
              "type": "string",
              "enum": ["label", "product", "track"]
            },
            "term_conditions": {
              "type": "array",
              "minItems": 1,
              "items": {
                "$ref": "#/definitions/ContractTermCondition"
              }
            }
          },
          "required": [
            "contract_term_name",
            "attachments",
            "attachments_relations",
            "term_type"
          ]
        }
      },
      "additionalProperties": false
    },
    "ContractTermCondition": {
      "type": "object",
      "properties": {
        "conditions": {
          "type": "object",
          "properties": {
            "countries": {
              "$ref": "#/definitions/Countries"
            },
            "stores": {
              "type": "array",
              "minItems": 0,
              "items": {
                "type": "string"
              }
            },
            "transaction_types": {
              "$ref": "#/definitions/TransactionType"
            }
          },
          "required": ["countries", "stores", "transaction_types"]
        },
        "contract_term_condition_name": {
          "type": ["string", "null"],
          "minLength": 1,
          "maxLength": 180
        },
        "term_rate": {
          "type": "number"
        },
        "commission": {
          "type": "number"
        },
        "priority": {
          "type": "integer",
          "minimum": 1
        }
      },
      "required": [
        "conditions",
        "contract_term_condition_name",
        "term_rate",
        "priority"
      ],
      "additionalProperties": false
    },
    "Reserve": {
      "type": ["object", "null"],
      "properties": {
        "reserve_conditions": {
          "type": ["object", "null"],
          "properties": {
            "transaction_types": {
              "$ref": "#/definitions/TransactionType"
            }
          },
          "required": ["transaction_types"],
          "additionalProperties": false
        },
        "reserve_installments_in_months": {
          "type": ["integer", "null"],
          "minimum": 1
        },
        "reserve_release_offset_in_months": {
          "type": ["integer", "null"],
          "minimum": 1
        },
        "reserve_rate": {
          "type": ["number", "null"],
          "minimum": 1
        },
        "reserve_release_schedule": {
          "type": ["array", "null"],
          "minItems": 0,
          "items": {
            "type": "number"
          }
        }
      },
      "required": [
        "reserve_conditions",
        "reserve_installments_in_months",
        "reserve_rate",
        "reserve_release_schedule"
      ],
      "additionalProperties": false
    },
    "TransactionType": {
      "type": "array",
      "minItems": 0,
      "items": {
        "type": "string",
        "enum": [
          "AC",
          "AEA",
          "AEV",
          "AL",
          "AO",
          "AP",
          "AS",
          "AV",
          "BR",
          "CA",
          "CAV",
          "CC",
          "CE",
          "CL",
          "CR",
          "CV",
          "CX",
          "DA",
          "DB",
          "DJ",
          "DR",
          "DT",
          "DV",
          "ED",
          "EH",
          "EQ",
          "ER",
          "FA",
          "FS",
          "FT",
          "LP",
          "LR",
          "MA",
          "MD",
          "ME",
          "MP",
          "MR",
          "MT",
          "MV",
          "NC",
          "NR",
          "NS",
          "NT",
          "OP",
          "OR",
          "PA",
          "PF",
          "PH",
          "PM",
          "PP",
          "PR",
          "PS",
          "PV",
          "PX",
          "RB",
          "RC",
          "RD",
          "RE",
          "RL",
          "RR",
          "RV",
          "RW",
          "S",
          "SA",
          "SB",
          "SC",
          "SE",
          "SF",
          "SL",
          "SP",
          "SR",
          "SV",
          "TA",
          "TD",
          "TH",
          "TL",
          "TR",
          "TV",
          "UA",
          "UN",
          "UP",
          "US",
          "UT",
          "UV",
          "VA",
          "VB",
          "VP",
          "VR",
          "VS",
          "VU",
          "WA",
          "WS",
          "YP"
        ]
      }
    },
    "Countries": {
      "type": "array",
      "minItems": 0,
      "items": {
        "type": "string",
        "enum": [
          "AFG",
          "ALA",
          "ALB",
          "DZA",
          "ASM",
          "AND",
          "AGO",
          "AIA",
          "ATA",
          "ATG",
          "ARG",
          "ARM",
          "ABW",
          "AUS",
          "AUT",
          "AZE",
          "BHS",
          "BHR",
          "BGD",
          "BRB",
          "BLR",
          "BEL",
          "BLZ",
          "BEN",
          "BMU",
          "BTN",
          "BOL",
          "BES",
          "BIH",
          "BWA",
          "BVT",
          "BRA",
          "IOT",
          "BRN",
          "BGR",
          "BFA",
          "BDI",
          "CPV",
          "KHM",
          "CMR",
          "CAN",
          "CYM",
          "CAF",
          "TCD",
          "CHL",
          "CHN",
          "CXR",
          "CCK",
          "COL",
          "COM",
          "COG",
          "COD",
          "COK",
          "CRI",
          "CIV",
          "HRV",
          "CUB",
          "CUW",
          "CYP",
          "CZE",
          "DNK",
          "DJI",
          "DMA",
          "DOM",
          "ECU",
          "EGY",
          "SLV",
          "GNQ",
          "ERI",
          "EST",
          "SWZ",
          "ETH",
          "FLK",
          "FRO",
          "FJI",
          "FIN",
          "FRA",
          "GUF",
          "PYF",
          "ATF",
          "GAB",
          "GMB",
          "GEO",
          "DEU",
          "GHA",
          "GIB",
          "GRC",
          "GRL",
          "GRD",
          "GLP",
          "GUM",
          "GTM",
          "GGY",
          "GIN",
          "GNB",
          "GUY",
          "HTI",
          "HMD",
          "VAT",
          "HND",
          "HKG",
          "HUN",
          "ISL",
          "IND",
          "IDN",
          "IRN",
          "IRQ",
          "IRL",
          "IMN",
          "ISR",
          "ITA",
          "JAM",
          "JPN",
          "JEY",
          "JOR",
          "KAZ",
          "KEN",
          "KIR",
          "PRK",
          "KOR",
          "KWT",
          "KGZ",
          "LAO",
          "LVA",
          "LBN",
          "LSO",
          "LBR",
          "LBY",
          "LIE",
          "LTU",
          "LUX",
          "MAC",
          "MDG",
          "MWI",
          "MYS",
          "MDV",
          "MLI",
          "MLT",
          "MHL",
          "MTQ",
          "MRT",
          "MUS",
          "MYT",
          "MEX",
          "FSM",
          "MDA",
          "MCO",
          "MNG",
          "MNE",
          "MSR",
          "MAR",
          "MOZ",
          "MMR",
          "NAM",
          "NRU",
          "NPL",
          "NLD",
          "NCL",
          "NZL",
          "NIC",
          "NER",
          "NGA",
          "NIU",
          "NFK",
          "MKD",
          "MNP",
          "NOR",
          "OMN",
          "PAK",
          "PLW",
          "PSE",
          "PAN",
          "PNG",
          "PRY",
          "PER",
          "PHL",
          "PCN",
          "POL",
          "PRT",
          "PRI",
          "QAT",
          "REU",
          "ROU",
          "RUS",
          "RWA",
          "BLM",
          "SHN",
          "KNA",
          "LCA",
          "MAF",
          "SPM",
          "VCT",
          "WSM",
          "SMR",
          "STP",
          "SAU",
          "SEN",
          "SRB",
          "SYC",
          "SLE",
          "SGP",
          "SXM",
          "SVK",
          "SVN",
          "SLB",
          "SOM",
          "ZAF",
          "SGS",
          "SSD",
          "ESP",
          "LKA",
          "SDN",
          "SUR",
          "SJM",
          "SWE",
          "CHE",
          "SYR",
          "TWN",
          "TJK",
          "TZA",
          "THA",
          "TLS",
          "TGO",
          "TKL",
          "TON",
          "TTO",
          "TUN",
          "TUR",
          "TKM",
          "TCA",
          "TUV",
          "UGA",
          "UKR",
          "ARE",
          "GBR",
          "USA",
          "UMI",
          "URY",
          "UZB",
          "VUT",
          "VEN",
          "VNM",
          "VGB",
          "VIR",
          "WLF",
          "ESH",
          "YEM",
          "ZMB",
          "ZWE"
        ]
      }
    }
  },
  "properties": {
    "account_id": {
      "type": "integer",
      "minimum": 1
    },
    "account_currency": {
      "type": "string",
      "enum": [
        "AUD",
        "CAD",
        "CHF",
        "DKK",
        "EUR",
        "GBP",
        "JPY",
        "NOK",
        "SEK",
        "USD"
      ]
    },
    "account_status": {
      "type": ["string", "null"],
      "enum": ["signed"]
    },
    "account_name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 180
    },
    "contract_id": {
      "type": "integer",
      "minimum": -1,
      "maximum": 499999
    },
    "contract_name": {
      "type": ["string", "null"],
      "minLength": 1,
      "maxLength": 180
    },
    "contract_terms": {
      "type": "array",
      "minItems": 1,
      "items": {
        "$ref": "#/definitions/ContractTerm"
      }
    },
    "term_start": {
      "type": ["string", "null"]
    },
    "term_end": {
      "type": ["string", "null"]
    },
    "payment_minimum": {
      "type": ["number", "null"]
    },
    "payment_schedule": {
      "type": ["string", "null"],
      "enum": [
        "30_days_after_month_end",
        "45_days_after_month_end",
        "60_days_after_month_end",
        "90_days_after_month_end",
        "30_days_after_quarter_end",
        "45_days_after_quarter_end",
        "60_days_after_quarter_end",
        "90_days_after_quarter_end",
        "30_days_after_half_year_end",
        "45_days_after_half_year_end",
        "60_days_after_half_year_end",
        "90_days_after_half_year_end"
      ]
    },
    "reserves": {
      "type": ["object", "null"],
      "$ref": "#/definitions/Reserve"
    }
  },
  "required": [
    "account_id",
    "account_currency",
    "account_status",
    "account_name",
    "contract_id",
    "contract_name",
    "contract_terms",
    "term_start",
    "term_end",
    "payment_minimum",
    "payment_schedule",
    "reserves"
  ],
  "additionalProperties": false
}
