{
  "name": "Prestamo",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "lab/prestamo",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        0,
        0
      ],
      "id": "da0267de-a303-48cb-aba0-e4ddf90df4c3",
      "name": "Webhook"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "56fcc3e0-1dbf-495c-9256-e45954028c3f",
              "name": "Fecha",
              "value": "={{$now.setZone('America/Guayaquil').toFormat(\"yyyy-LL-dd HH:mm\")}}",
              "type": "string"
            },
            {
              "id": "deda3169-c4a1-4413-9fe6-66b332ddc73e",
              "name": "Nombre",
              "value": "={{$json.nombre ?? $json.Nombre ?? $json.body?.nombre ?? $json.body?.Nombre}}",
              "type": "string"
            },
            {
              "id": "bace2852-ca23-483c-b8f6-579bb635e9e6",
              "name": "Semestre",
              "value": "={{$json.semestre ?? $json.Semestre ?? $json.body?.semestre ?? $json.body?.Semestre}}",
              "type": "string"
            },
            {
              "id": "ab55ede2-151b-4e70-9a61-912e2fc1b852",
              "name": "Equipo",
              "value": "={{$json.equipo ?? $json.Equipo ?? $json.body?.equipo ?? $json.body?.Equipo}}",
              "type": "string"
            },
            {
              "id": "210762b9-8d4e-4be1-b834-00a23ae26511",
              "name": "Prestado/ Devuelto",
              "value": "Prestado",
              "type": "string"
            },
            {
              "id": "a2333dbd-9b76-4001-9936-55df74631a65",
              "name": "ID",
              "value": "={{ \"LAB-\" + Date.now() }}",
              "type": "string"
            },
            {
              "id": "626eee79-433a-46b9-a920-363e1c9fda12",
              "name": "BannerID",
              "value": "={{$json.banner_id ?? $json.bannerId ?? $json.BannerID ?? $json.body?.banner_id ?? $json.body?.bannerId ?? $json.body?.BannerID}}",
              "type": "string"
            },
            {
              "id": "ae193bd3-f774-428b-b00d-3c7319f8638b",
              "name": "Extras",
              "value": "={{$json.extra_general ?? $json.Extra ?? $json.Extras ?? $json.body?.extra_general ?? $json.body?.Extra ?? $json.body?.Extras}}",
              "type": "string"
            }
          ]
        },
        "includeOtherFields": true,
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        192,
        16
      ],
      "id": "7d7a1b05-537f-42f0-90a8-150a4923a212",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "1qn03Xku9pT1_Uw-74fDAutxe1kbjcEJzyPnNlHIpOpE",
          "mode": "list",
          "cachedResultName": "Prestamos Lab",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1qn03Xku9pT1_Uw-74fDAutxe1kbjcEJzyPnNlHIpOpE/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Hoja 1",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1qn03Xku9pT1_Uw-74fDAutxe1kbjcEJzyPnNlHIpOpE/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Fecha": "={{$json.Fecha}}",
            "Nombre": "={{$json.Nombre}}",
            "Semestre": "={{$json.Semestre}}",
            "Equipo": "={{$json.Equipo}}",
            "Prestado/ Devuelto": "={{$json[\"Prestado/ Devuelto\"]}}",
            "ID": "={{ ($json.ID || \"\").toString().replace(/^=/, \"\") }}",
            "BannerID": "={{ ($json.BannerID || \"\").toString().replace(/^=/, \"\") }}",
            "Extras": "={{$json.extra_general}}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "BannerID",
              "displayName": "BannerID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "ID",
              "displayName": "ID",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Fecha",
              "displayName": "Fecha",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Nombre",
              "displayName": "Nombre",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Semestre",
              "displayName": "Semestre",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Equipo",
              "displayName": "Equipo",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Extras",
              "displayName": "Extras",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Prestado/ Devuelto",
              "displayName": "Prestado/ Devuelto",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        400,
        16
      ],
      "id": "91dfae7e-0ead-4ab2-b726-7d208e7386ce",
      "name": "Append row in sheet",
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={\n  \"ok\": true,\n  \"id\": \"{{($json.ID || '').toString().replace(/^=/,'')}}\",\n  \"banner_id\": \"{{($json.BannerID || '').toString().replace(/^=/,'')}}\",\n  \"msg\": \"Pr\u00e9stamo registrado correctamente\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.5,
      "position": [
        608,
        16
      ],
      "id": "1ecf3ff7-37dd-43ad-9fd1-dbfa927ff66e",
      "name": "Respond to Webhook"
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields": {
      "main": [
        [
          {
            "node": "Append row in sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append row in sheet": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "versionId": "f9463da1-9607-4bdc-8629-a11845487700",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "DxmqUAX9o6do0ey0",
  "tags": []
}