{
  "nodes": [
    {
      "parameters": {},
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "register-user"
      },
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "and": [
            {
              "value1": "={{$json.name}}",
              "operation": "notEmpty"
            },
            {
              "value1": "={{$json.email}}",
              "operation": "notEmpty"
            },
            {
              "value1": "={{$json.password}}",
              "operation": "notEmpty"
            },
            {
              "value1": "={{$json.companyId}}",
              "operation": "notEmpty"
            }
          ]
        }
      },
      "name": "If",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        700,
        300
      ]
    },
    {
      "parameters": {
        "operation": "query",
        "query": "SELECT registerUser($1::varchar, $2::varchar, $3::varchar, $4::int) AS message",
        "values": [
          "={{$json.name}}",
          "={{$json.email}}",
          "={{$json.password}}",
          "={{$json.companyId}}"
        ]
      },
      "name": "Postgres",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 1,
      "position": [
        950,
        300
      ]
    },
    {
      "parameters": {
        "values": {
          "success": true,
          "message": "={{$node[\"Postgres\"].json[\"message\"]}}"
        },
        "options": {}
      },
      "name": "Set Success",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        1200,
        300
      ]
    },
    {
      "parameters": {
        "values": {
          "success": false,
          "message": "={{$node[\"If\"].json[\"error\"].message}}"
        },
        "options": {}
      },
      "name": "Set Error",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        1200,
        500
      ]
    },
    {
      "parameters": {
        "options": {}
      },
      "name": "Response",
      "type": "n8n-nodes-base.response",
      "typeVersion": 1,
      "position": [
        1200,
        300
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Postgres",
            "type": "main",
            "index": 0
          }
        ]
      ],
      "false": [
        [
          {
            "node": "Set Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Postgres": {
      "main": [
        [
          {
            "node": "Set Success",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Success": {
      "main": [
        [
          {
            "node": "Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Error": {
      "main": [
        [
          {
            "node": "Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}