info:
  name: TAG per riprotocollazione (integrazione)
  type: http
  seq: 3

http:
  method: POST
  url: "{{elixFormsApiUrl}}/eftl/process/v1"
  headers:
    - name: x-requested-with
      value: XMLHttpRequest
    - name: x-api-key
      value: "{{elixFormsWsAuthenticationToken}}"
    - name: x-ef-request-id
      value: "27399"
    - name: x-ef-request-id
      value: "27535"
      disabled: true
  body:
    type: json
    data: |-
      {
        "userDocument": "{{elixBase64EftlDocument}}", // see the pre-request script
        "userContext": {
          "lang": "IT",
          "crlf": "\r\n"
        }
      }
  auth: inherit

runtime:
  scripts:
    - type: before-request
      code: |-
        const { prepareEftlDocument } = require("./elixFormsJs.js")
        // Copy-pasta your EFTL document below inside the template literals (`)
        prepareEftlDocument(String.raw`
        [EFTL][HEADER name="trimDocument" value="true" type="boolean" /]
        [VAR name="firstItem" type="number"][% firstItem = 0; %][/VAR]
        [VAR name="secondItem" type="number"][% secondItem = 1; %][/VAR]

        [VAR name="folderSubject" type="string"][% folderSubject = "Richieste di Subappalti e Comunicazioni Subcontratti e Distacchi"; %][/VAR]
        [VAR name="subfolderSubject" type="string"][TAG]SCHEMAID,17,COL0013,IUQOID, , ,,yyyy[/TAG][/VAR]

        [VAR name="tipologiaRichiesta" type="string"][TAG]GETVALUEBYTAG,TIPOLOGIA_RICHIESTA,REQUEST,IUQOID[/TAG][/VAR]
        [VAR name="impresaAppaltatrice" type="string"][TAG]GETVALUEBYTAG,IMPRESA_APPALTATRICE,REQUEST,IUQOID[/TAG][/VAR]
        [VAR name="lavori" type="string"][TAG]GETVALUEBYTAG,RICHIESTA_OGGETTO_LAVORI,REQUEST,IUQOID[/TAG][/VAR]
        [VAR name="cig" type="string"][TAG]GETVALUEBYTAG,RICHIESTA_OGGETTO_CIG,REQUEST,IUQOID[/TAG][/VAR]
        [VAR name="cup" type="string"][TAG]GETVALUEBYTAG,RICHIESTA_OGGETTO_CUP,REQUEST,IUQOID[/TAG][/VAR]

        [VAR name="riapertureIter" type="iterable"][SPLIT regex="\|" emptyIfBlank="true"][TAG]SCHEMAID,198,COL0001,IUQOID,,|[/TAG][/SPLIT][/VAR]

        Date inoltro prima della riapertura: [TAG]SCHEMAID,198,COL0003,IUQOID,,|[/TAG]
        Date conferma prima della riapertura: [TAG]SCHEMAID,198,COL0004,IUQOID,,|[/TAG]
        Data ultimo inoltro: [TAG]SCHEMAID,17,COL0013,IUQOID, , [/TAG]

        [VAR name="dataCompletamento" type="string"][TAG]SCHEMAID,17,COL0013,IUQOID, , [/TAG][/VAR]
        [VAR name="confermePrecedenti" type="string"][TAG]SCHEMAID,198,COL0004,IUQOID,,|[/TAG][/VAR]

        [VAR name="integrazione"][% integrazione = ""; %][/VAR]
        [IF][CONDITION][% confermePrecedenti != "" %][/CONDITION][THEN][% integrazione = " (INTEGRAZIONE del " + dataCompletamento + ")"; %][/THEN][/IF]

        [VAR name="nomeDocumento" type="string"][% nomeDocumento = tipologiaRichiesta + " " + impresaAppaltatrice + " - Commessa: " + lavori + " (CIG: " + cig + " - CUP: " + cup + ")" + integrazione; %][/VAR]

        Nome documento: [%= nomeDocumento %]
        IF: [IF][CONDITION][ISEMPTY][TAG]SCHEMAID,198,COL0004,IUQOID,,|[/TAG][/ISEMPTY][/CONDITION][THEN][%= " (INTEGRAZIONE del " + dataCompletamento + ")" %][/THEN][/IF]

        Test: 

        [/EFTL]
        `);

settings:
  encodeUrl: true
  timeout: 0
  followRedirects: true
  maxRedirects: 5
  forwardAuthorizationHeader: true
