{
 "name": "S08 - Mini-CRM על Supabase",
 "flow": [
  {
   "id": 1,
   "module": "gateway:CustomWebHook",
   "version": 1,
   "parameters": {
    "hook": null,
    "maxResults": 1
   },
   "mapper": {},
   "metadata": {
    "designer": {
     "x": 0,
     "y": 0,
     "name": "/deal (POST/GET)"
    }
   }
  },
  {
   "id": 7,
   "module": "builtin:BasicRouter",
   "version": 1,
   "parameters": {},
   "mapper": null,
   "metadata": {
    "designer": {
     "x": 300,
     "y": 0,
     "name": "לפי בקשה"
    }
   },
   "routes": [
    {
     "flow": [
      {
       "id": 2,
       "module": "supabase:createARow",
       "version": 1,
       "parameters": {
        "__IMTCONN__": null
       },
       "mapper": {
        "table": "deals",
        "fields": {
         "contact": "{{1.contact}}",
         "email": "{{lower(trim(1.email))}}",
         "company": "{{1.company}}",
         "value": "{{1.value}}"
        }
       },
       "metadata": {
        "designer": {
         "x": 600,
         "y": -150,
         "name": "INSERT עסקה"
        }
       },
       "filter": {
        "name": "POST",
        "conditions": [
         [
          {
           "a": "{{1.email}}",
           "o": "exist"
          },
          {
           "a": "{{1.contact}}",
           "o": "exist"
          }
         ]
        ]
       }
      },
      {
       "id": 3,
       "module": "gateway:WebhookRespond",
       "version": 1,
       "parameters": {},
       "mapper": {
        "status": "201",
        "body": "{\"ok\": true, \"id\": {{2.id}}}",
        "headers": [
         {
          "key": "Content-Type",
          "value": "application/json; charset=utf-8"
         }
        ]
       },
       "metadata": {
        "designer": {
         "x": 900,
         "y": -150,
         "name": "201"
        }
       }
      }
     ]
    },
    {
     "flow": [
      {
       "id": 4,
       "module": "supabase:searchRows",
       "version": 1,
       "parameters": {
        "__IMTCONN__": null
       },
       "mapper": {
        "table": "deals",
        "filter": "email=eq.{{lower(trim(1.email))}}",
        "limit": 20
       },
       "metadata": {
        "designer": {
         "x": 600,
         "y": 150,
         "name": "SELECT לפי מייל"
        }
       },
       "filter": {
        "name": "GET",
        "conditions": [
         [
          {
           "a": "{{1.email}}",
           "o": "exist"
          },
          {
           "a": "{{1.contact}}",
           "o": "notExist"
          }
         ]
        ]
       }
      },
      {
       "id": 5,
       "module": "builtin:BasicAggregator",
       "version": 1,
       "parameters": {
        "feeder": 4
       },
       "mapper": {},
       "metadata": {
        "designer": {
         "x": 900,
         "y": 150,
         "name": "Array aggregator"
        }
       }
      },
      {
       "id": 6,
       "module": "gateway:WebhookRespond",
       "version": 1,
       "parameters": {},
       "mapper": {
        "status": "200",
        "body": "{\"ok\": true, \"count\": {{length(5.array)}}}",
        "headers": [
         {
          "key": "Content-Type",
          "value": "application/json; charset=utf-8"
         }
        ]
       },
       "metadata": {
        "designer": {
         "x": 1200,
         "y": 150,
         "name": "200 / תוצאות"
        }
       }
      }
     ]
    }
   ]
  }
 ],
 "metadata": {
  "instant": true,
  "version": 1,
  "scenario": {
   "roundtrips": 1,
   "maxErrors": 3,
   "autoCommit": true,
   "autoCommitTriggerLast": true,
   "sequential": false,
   "slots": null,
   "confidential": false,
   "dataloss": false,
   "dlq": true,
   "freshVariables": false
  },
  "designer": {
   "orphans": []
  },
  "zone": "eu1.make.com"
 }
}