{
    "$schema": "http:\/\/json-schema.org\/draft-06\/schema#",
    "$id": "https:\/\/estateagentfeeds.com\/docs\/createBranchRequestSchema.json",
    "title": "Create Branch",
    "description": "Estate Agent Feeds Branches API schema for creating branch accounts",
    "type": "object",
    "properties": {
        "branch": {
            "type": "object",
            "description": "The branch settings.",
            "properties": {
                "name": {
                    "description": "The name of the branch.",
                    "$ref": "#\/definitions\/name_str"
                },
                "location": {
                    "description": "The location of the branch.",
                    "$ref": "#\/definitions\/address_str"
                },
                "address": {
                    "description": "The full address of the branch location.",
                    "$ref": "#\/definitions\/address_str"
                },
                "primary_email": {
                    "description": "The enquiry email address for the branch.",
                    "$ref": "#\/definitions\/email_str"
                },
                "copy_email": {
                    "description": "The CC email address for the branch which is used to send some, but not all account notifications.",
                    "type": [
                        "string",
                        "null"
                    ],
                    "$ref": "#\/definitions\/email_str"
                },
                "support_email": {
                    "type": [
                        "string",
                        "null"
                    ],
                    "description": "The tech support email for the branch which is used to receive only error related notifications.",
                    "$ref": "#\/definitions\/email_str"
                },
                "company_address": {
                    "description": "The brand registered company address.",
                    "$ref": "#\/definitions\/address_str"
                },
                "company_phone": {
                    "description": "The brand company phone number.",
                    "$ref": "#\/definitions\/phone_str"
                },
                "company_website": {
                    "description": "The brand company website.",
                    "$ref": "#\/definitions\/web_url_str"
                },
                "contact": {
                    "description": "The branch contact settings.",
                    "type": "object",
                    "properties": {
                        "role": {
                            "description": "The branch contact role.",
                            "type": [
                                "string",
                                "null"
                            ],
                            "$ref": "#\/definitions\/str_long"
                        },
                        "first_name": {
                            "description": "The branch contact first name.",
                            "type": [
                                "string",
                                "null"
                            ],
                            "$ref": "#\/definitions\/str_long"
                        },
                        "last_name": {
                            "description": "The branch contact last name.",
                            "$ref": "#\/definitions\/str_long"
                        },
                        "email": {
                            "description": "The branch contact email address.",
                            "$ref": "#\/definitions\/email_str"
                        },
                        "phone": {
                            "description": "The branch contact phone number.",
                            "$ref": "#\/definitions\/phone_str"
                        }
                    },
                    "required": [
                        "first_name",
                        "last_name",
                        "email"
                    ],
                    "additionalProperties": false
                },
                "account_notifications": {
                    "description": "Whether the branch should send out account level notifications to the primary email address or not.",
                    "type": [
                        "boolean",
                        "null"
                    ],
                    "default": true
                },
                "error_notifications": {
                    "description": "Whether the branch should send out import\/export error notifications to the primary and support email or not.",
                    "type": [
                        "boolean",
                        "null"
                    ],
                    "default": true
                },
                "import": {
                    "description": "The branch import settings.",
                    "type": "object",
                    "properties": {
                        "feed_agency_id": {
                            "description": "If your import feed_url contains property records for multiple branches, include your unique agency ID for the branch which must match the agency_id you've used in the feed.",
                            "type": [
                                "string",
                                "null"
                            ],
                            "$ref": "#\/definitions\/str_long"
                        },
                        "feed_url": {
                            "description": "The absolute URL to a valid EAF v2 or v3 XML import feed",
                            "type": [
                                "string",
                                "null"
                            ],
                            "$ref": "#\/definitions\/web_url_str"
                        }
                    },
                    "additionalProperties": false
                },
                "export": {
                    "description": "The branch export settings",
                    "type": "object",
                    "properties": {
                        "rightmove_id": {
                            "description": "The Rightmove portal ID for the branch.",
                            "type": [
                                "integer",
                                "null"
                            ],
                            "$ref": "#\/definitions\/num_long"
                        },
                        "zoopla_id": {
                            "description": "The Zoopla portal ID for the branch.",
                            "type": [
                                "integer",
                                "null"
                            ],
                            "$ref": "#\/definitions\/num_long"
                        },
                        "onthemarket_id": {
                            "description": "The OnTheMarket portal ID for the branch.",
                            "type": [
                                "integer",
                                "null"
                            ],
                            "$ref": "#\/definitions\/num_long"
                        },
                        "sturents_id": {
                            "description": "The Sturents portal ID for the branch.",
                            "type": [
                                "integer",
                                "null"
                            ],
                            "$ref": "#\/definitions\/num_long"
                        },
                        "webhook_url": {
                            "description": "The URL where we should POST submission results.",
                            "type": [
                                "string",
                                "null"
                            ],
                            "$ref": "#\/definitions\/web_url_str"
                        },
                        "upload_method": {
                            "description": "The default portal upload method when property records are added to the account. Manual = properties must be manually submitted to portals, Automatic = the EAF system will automatically submit the properties when it detects changes on the record.",
                            "type": [
                                "string",
                                "null"
                            ],
                            "enum": [
                                "manual",
                                "automatic"
                            ],
                            "default": "manual"
                        },
                        "auto_delete": {
                            "description": "Whether our system should automatically unpublish properties from portal accounts when property records are no longer available in the EAF system such as it being deleted or removed from import feeds.",
                            "type": [
                                "boolean",
                                "null"
                            ],
                            "default": true
                        }
                    },
                    "additionalProperties": false
                }
            },
            "required": [
                "name",
                "location",
                "address",
                "primary_email",
                "company_address",
                "company_phone",
                "contact"
            ],
            "additionalProperties": false
        }
    },
    "required": [
        "branch"
    ],
    "additionalProperties": false,
    "definitions": {
        "email_str": {
            "type": "string",
            "pattern": "^[a-zA-Z0-9-._+]{1,}@[a-zA-Z0-9-_]{2,}\\.[a-zA-Z.]{2,25}$"
        },
        "phone_str": {
            "type": "string",
            "pattern": "^(\\+)?\\s?([0-9]{1})\\s?([0-9\\s]{8,25})$"
        },
        "web_url_str": {
            "type": "string",
            "pattern": "^(http|https)\\:\\\/\\\/"
        },
        "address_str": {
            "type": "string",
            "pattern": "^([a-zA-Z0-9]{1}\\s?(.*)?)$"
        },
        "name_str": {
            "type": "string",
            "pattern": "^([a-zA-Z0-9_\\-\\s]{1,40})$"
        },
        "str_short": {
            "type": "string",
            "minLength": 0,
            "maxLength": 20
        },
        "str_medium": {
            "type": "string",
            "minLength": 0,
            "maxLength": 60
        },
        "str_long": {
            "type": "string",
            "minLength": 0,
            "maxLength": 120
        },
        "str_xlong": {
            "type": "string",
            "minLength": 0,
            "maxLength": 200
        },
        "num_long": {
            "type": "integer",
            "minimum": 0,
            "maximum": 99999999999
        }
    }
}