{
    "$schema": "http://json-schema.org/draft-07/schema#",
    "type": "object",
    "properties": {
        "order": {
            "type": "object",
            "properties": {
                "source": {
                    "type": "string"
                },
                "user": {
                    "type": ["null","string"]
                },
                "app_id": {
                    "type": ["null", "string"]
                },
                "id": {
                    "type": ["string", "number"]
                },
                "number": {
                    "type": ["string", "number"]
                },
                "status": {
                    "type": ["string", "object"]
                },
                "created": {
                    "type": "string",
                    "format": "date-time"
                },
                "paid": {
                    "type": ["null", "string"],
                    "format": "date-time"
                },
                "completed": {
                    "type": ["null", "string"],
                    "format": "date-time"
                },
                "valid": {
                    "type": ["null", "string"],
                    "format": "date-time"
                },
                "currency": {
                    "type": ["null", "string"],
                    "maxLength": 3
                },
                "observation": {
                    "type": ["null", "string"]
                }
            },
            "required": [
                "source",
                "user",
                "app_id",
                "id",
                "number",
                "status",
                "created",
                "paid",
                "completed",
                "valid",
                "currency",
                "observation"
            ]
        },
        "totals": {
            "type": "object",
            "properties": {
                "taxes_included": {
                    "type": ["boolean"]
                },
                "order_amount": {
                    "type": [ "number"],
                    "minimum": 0
                },
                "order_tax": {
                    "type": ["number"],
                    "minimum": 0
                },
                "discount_amount": {
                    "type": ["number"],
                    "minimum": 0
                },
                "discount_tax": {
                    "type": ["number"],
                    "minimum": 0
                },
                "shipping_amount": {
                    "type": ["number"],
                    "minimum": 0
                },
                "shipping_tax": {
                    "type": ["number"],
                    "minimum": 0
                }
            },
            "required": [
                "taxes_included",
                "order_amount",
                "order_tax",
                "discount_amount",
                "discount_tax",
                "shipping_amount",
                "shipping_tax"
            ]
        },
        "provider": {
            "type": "object",
            "properties": {
                "id": {
                    "type": ["null", "string", "number"]
                },
                "vat_number": {
                    "type": ["null", "string", "number"]
                },
                "full_name": {
                    "type": ["null", "string"]
                }
            },
            "required": [
                "id",
                "vat_number",
                "full_name"
            ]
        },
        "customer": {
            "type": "object",
            "properties": {
                "id": {
                    "type": ["null", "string", "number"]
                },
                "full_name": {
                    "type": ["null", "string"]
                },
                "first_name": {
                    "type": ["null", "string"]
                },
                "last_name": {
                    "type": ["null", "string"]
                }
            },
            "required": [
                "id",
                "full_name",
                "first_name",
                "last_name"
            ]
        },
        "billing_address": {
            "type": "object",
            "properties": {
                "id": {
                    "type": ["null", "string", "number"]
                },
                "company": {
                    "type": ["null", "string"]
                },
                "document_type": {
                    "type": ["null", "number", "string"]
                },
                "vat_number": {
                    "type": ["null", "number", "string"]
                },
                "business_activity": {
                    "type": ["null", "string"]
                },
                "full_name": {
                    "type": ["null", "string"]
                },
                "first_name": {
                    "type": ["null", "string"]
                },
                "last_name": {
                    "type": ["null", "string"]
                },
                "email": {
                    "type": ["null", "string"],
                    "pattern": "^$|^[^@\\s]+@[^@\\s]+\\.[^@\\s]+$"
                },
                "telephone": {
                    "type": ["null", "string", "number"]
                },
                "address1": {
                    "type": ["null", "string"]
                },
                "address2": {
                    "type": ["null", "string"]
                },
                "city": {
                    "type": ["null", "string"]
                },
                "state": {
                    "type": ["null", "string"]
                },
                "country_code": {
                    "type": ["null", "string"],
                    "minLength": 2,
                    "maxLength": 2,
                    "pattern": "^[a-z]{2}$"
                },
                "zip": {
                    "type": ["null", "string", "number"]
                }
            },
            "required": [
                "id",
                "company",
                "document_type",
                "vat_number",
                "business_activity",
                "full_name",
                "first_name",
                "last_name",
                "email",
                "telephone",
                "address1",
                "address2",
                "city",
                "state",
                "country_code",
                "zip"
            ]
        },
        "shipping_address": {
            "type": "object",
            "properties": {
                "company": {
                    "type": ["null", "string"]
                },
                "full_name": {
                    "type": ["null", "string"]
                },
                "first_name": {
                    "type": ["null", "string"]
                },
                "last_name": {
                    "type": ["null", "string"]
                },
                "address1": {
                    "type": ["null", "string"]
                },
                "address2": {
                    "type": ["null", "string"]
                },
                "city": {
                    "type": ["null", "string"]
                },
                "country_code": {
                    "type": ["null", "string"],
                    "minLength": 2,
                    "maxLength": 2,
                    "pattern": "^[a-z]{2}$"
                },
                "telephone": {
                    "type": ["null", "string"]
                },
                "zip": {
                    "type": ["null", "string"]
                }
            },
            "required": [
                "company",
                "full_name",
                "first_name",
                "last_name",
                "address1",
                "address2",
                "city",
                "country_code",
                "telephone",
                "zip"
            ]
        },
        "details": {
            "type": "array",
            "minItems": 1,
            "items": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": ["null", "string", "number"]
                    },
                    "tax": {
                        "type": ["number"],
                        "minimum": 0
                    },
                    "code": {
                        "type": ["null", "string", "number"]
                    },
                    "name": {
                        "type": ["string"]
                    },
                    "price": {
                        "type": "number",
                        "minimum": 0
                    },
                    "taxable": {
                        "type": ["boolean"]
                    },
                    "quantity": {
                        "type": "number",
                        "minimum": 1
                    },
                    "description": {
                        "type": ["null", "string"]
                    },
                    "discount_amount": {
                        "type": ["number"],
                        "minimum": 0
                    },
                    "discount_percentage": {
                        "type": ["number"],
                        "minimum": 0.0,
                        "maximum": 100.0
                    }
                },
                "required": [
                    "id",
                    "tax",
                    "code",
                    "name",
                    "price",
                    "taxable",
                    "quantity",
                    "description",
                    "discount_amount",
                    "discount_percentage"
                ]
            }
        },
        "taxes": {
            "type": "array",
            "minItems": 0,
            "items": {
                "type": "object",
                "properties": {
                    "name": {
                        "type": ["null", "string"]
                    },
                    "rate": {
                        "type": "number",
                        "minimum": 0
                    },
                    "amount": {
                        "type": "number",
                        "minimum": 0
                    },
                    "type": {
                        "type": ["null", "string"]
                    },
                    "code": {
                        "type": ["null", "string"]
                    }
                },
                "required": [
                    "name",
                    "rate",
                    "amount",
                    "type",
                    "code"
                ]
            }
        },
        "shippings": {
            "type": "array",
            "minItems": 0,
            "items": {
                "type": "object",
                "properties": {
                "name": {
                        "type": ["null", "string"]
                    },
                    "description": {
                        "type": ["null", "string"]
                    },
                    "amount": {
                        "type": ["number"],
                        "minimum": 0
                    },
                    "discount_amount": {
                        "type": ["number"],
                        "minimum": 0
                    },
                    "taxable": {
                        "type": ["boolean"]
                    },
                    "tax": {
                        "type": ["number"],
                        "minimum": 0
                    }
                },
                "required": [
                    "name",
                    "description",
                    "amount",
                    "discount_amount",
                    "taxable",
                    "tax"
                ]
            }
        },
        "discounts": {
            "type": "array",
            "minItems": 0,
            "items": {
                "type": "object",
                "properties": {
                    "name": {
                        "type": ["null", "string"]
                    },
                    "description": {
                        "type": ["null", "string"]
                    },
                    "percentage": {
                        "type": [ "number"],
                        "minimum": 0.0,
                        "maximum": 100.0
                    },
                    "amount": {
                        "type": ["number"],
                        "minimum": 0
                    },
                    "taxable": {
                        "type": ["boolean"]
                    },
                    "tax": {
                        "type": ["number"],
                        "minimum": 0
                    }
                },
                "required": [
                    "name",
                    "description",
                    "percentage",
                    "amount",
                    "taxable",
                    "tax"
                ]
            }
        },
        "payments": {
            "type": "array",
            "minItems": 0,
            "items": {
                "type": "object",
                "properties": {
                    "currency": {
                        "type": ["null", "string"],
                        "minLength": 3,
                        "maxLength": 3,
                        "pattern": "^[a-z]{3}$"
                    },
                    "code": {
                        "type": ["null", "string"]
                    },
                    "amount": {
                        "type": ["number"],
                        "minimum": 0
                    },
                    "description": {
                        "type": ["null", "string"]
                    },
                    "paid": {
                        "type": ["null", "string"],
                        "format": "date-time"
                    },
                    "taxable": {
                        "type": ["boolean"]
                    }
                },
                "required": [
                    "currency",
                    "code",
                    "amount",
                    "description",
                    "paid",
                    "taxable"
                ]
            }
        }
    },
    "required": ["order", "totals", "billing_address", "details"]
}