info:
  name: Partecipanti - Riga dati completi ripartizione
  type: http
  seq: 18

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: "32873"
  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" /]
        [% item1 = 0; item2 = 1; %]

        [VAR name="partecipante" type="string"][TAG]GETVALUEBYTAG,PARTECIPANTE,REQUEST,IUQOID,UPDATED_LAST[/TAG][/VAR]
        [VAR name="importo" type="string"][TAG]GETVALUEBYTAG,IMPORTO_RIPARTIZIONE,REQUEST,IUQOID,UPDATED_LAST[/TAG][/VAR]


        [!-- Rimuoviamo l'indice della scelta da tendina "[X] " --]
        [VAR name="datiIterable" type="iterable"][SPLIT regex="] "][VALUE_OF varname="partecipante" /][/SPLIT][/VAR]
        [!-- Scorriamo l'iterable splittando man mano per i divisori nella scelta da tendina --]
        [VAR name="datiIterable" type="iterable"][SPLIT regex=" \(CF: "][VALUE_OF varname="datiIterable" index="item2" /][/SPLIT][/VAR]
        [VAR name="nominativo" type="string"][VALUE_OF varname="datiIterable" index="item1" /][/VAR]
        [VAR name="datiIterable" type="iterable"][SPLIT regex=", Qualifica: "][VALUE_OF varname="datiIterable" index="item2" /][/SPLIT][/VAR]
        [VAR name="codiceFiscale" type="string"][VALUE_OF varname="datiIterable" index="item1" /][/VAR]
        [VAR name="datiIterable" type="iterable"][SPLIT regex=", Struttura di afferenza: "][VALUE_OF varname="datiIterable" index="item2" /][/SPLIT][/VAR]
        [VAR name="qualifica" type="string"][VALUE_OF varname="datiIterable" index="item1" /][/VAR]
        [VAR name="datiIterable" type="iterable"][SPLIT regex="\)"][VALUE_OF varname="datiIterable" index="item2" /][/SPLIT][/VAR]
        [VAR name="struttura" type="string"][VALUE_OF varname="datiIterable" index="item1" /][/VAR]

        [%= nominativo + ";;" + codiceFiscale + ";;" + qualifica + ";;" + struttura + ";;" + importo %]
        [/EFTL]
        `);

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