{
 "id": "karnema03MemberSync",
 "name": "کارنما ۳ — همگام‌سازی اعضا با ERP/CRM",
 "nodes": [
  {
   "parameters": {},
   "name": "اجرای دستی (آزمایش)",
   "type": "n8n-nodes-base.manualTrigger",
   "typeVersion": 1,
   "position": [
    0,
    0
   ]
  },
  {
   "parameters": {
    "rule": {
     "interval": [
      {
       "field": "days",
       "triggerAtHour": 2
      }
     ]
    }
   },
   "name": "هر شب ساعت ۲",
   "type": "n8n-nodes-base.scheduleTrigger",
   "typeVersion": 1.2,
   "position": [
    0,
    200
   ]
  },
  {
   "parameters": {
    "method": "GET",
    "url": "={{ $env.KARNEMA_BASE_URL }}/members",
    "authentication": "genericCredentialType",
    "genericAuthType": "httpHeaderAuth",
    "options": {
     "response": {
      "response": {
       "fullResponse": false,
       "neverError": false
      }
     }
    }
   },
   "name": "کارنما: اعضا",
   "type": "n8n-nodes-base.httpRequest",
   "typeVersion": 4.2,
   "position": [
    240,
    100
   ],
   "credentials": {
    "httpHeaderAuth": {
     "id": "karnemaApiKey",
     "name": "Karnema API Key"
    }
   }
  },
  {
   "parameters": {
    "mode": "manual",
    "assignments": {
     "assignments": [
      {
       "id": "کارمند در ERP-0",
       "name": "externalId",
       "value": "={{ $json.membershipId }}",
       "type": "string"
      },
      {
       "id": "کارمند در ERP-1",
       "name": "personnelCode",
       "value": "={{ $json.personnelCode }}",
       "type": "string"
      },
      {
       "id": "کارمند در ERP-2",
       "name": "fullName",
       "value": "={{ $json.firstName + ' ' + $json.lastName }}",
       "type": "string"
      },
      {
       "id": "کارمند در ERP-3",
       "name": "mobile",
       "value": "={{ $json.phone }}",
       "type": "string"
      },
      {
       "id": "کارمند در ERP-4",
       "name": "department",
       "value": "={{ $json.unitName }}",
       "type": "string"
      },
      {
       "id": "کارمند در ERP-5",
       "name": "jobTitle",
       "value": "={{ $json.positionName }}",
       "type": "string"
      }
     ]
    },
    "options": {}
   },
   "name": "کارمند در ERP",
   "type": "n8n-nodes-base.set",
   "typeVersion": 3.4,
   "position": [
    480,
    100
   ]
  },
  {
   "parameters": {},
   "name": "ارسال به ERP (جای اتصال شما)",
   "type": "n8n-nodes-base.noOp",
   "typeVersion": 1,
   "position": [
    720,
    100
   ]
  },
  {
   "parameters": {
    "content": "## همگام‌سازی اعضا\nهر شب فهرست اعضا (با کد پرسنلی، واحد و سمت) را از کارنما می‌گیرد و به قالب کارمند ERP/CRM درمی‌آورد.\nگرهٔ آخر را با گره ERP خود (HTTP، پایگاه داده، Odoo، HubSpot…) عوض کنید.",
    "height": 260,
    "width": 420
   },
   "name": "راهنما",
   "type": "n8n-nodes-base.stickyNote",
   "typeVersion": 1,
   "position": [
    -420,
    -260
   ]
  }
 ],
 "connections": {
  "اجرای دستی (آزمایش)": {
   "main": [
    [
     {
      "node": "کارنما: اعضا",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "هر شب ساعت ۲": {
   "main": [
    [
     {
      "node": "کارنما: اعضا",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "کارنما: اعضا": {
   "main": [
    [
     {
      "node": "کارمند در ERP",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "کارمند در ERP": {
   "main": [
    [
     {
      "node": "ارسال به ERP (جای اتصال شما)",
      "type": "main",
      "index": 0
     }
    ]
   ]
  }
 },
 "active": false,
 "settings": {
  "executionOrder": "v1"
 },
 "pinData": {},
 "tags": []
}