info:
  name: Create JSON
  type: http
  seq: 1

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: "22224"
  body:
    type: json
    data: |-
      {
        "userDocument": "{{elixBase64EftlDocument}}", // see the pre-request script
        "userContext": {
          "lang": "IT",
          "codiciFiscaliAmmessi": ";MMMPPL74T17E463A;;"
        }
      }
  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="json" type="string"][% json = ""; %][/VAR]

        [% json = "{ "; %]

        [VAR name="ripartizioniIterableWithSep" type="iterable"][SPLIT regex="#"][TAG]GETVALUEBYTAG,PARTECIPANTE,REQUEST,IUQOID,CONCAT,#[/TAG][/SPLIT][/VAR]

        [VAR name="arrayPartecipanti" type="string"][% arrayPartecipanti = "[ "; %][/VAR]
        [FOR]
          
        [/FOR]
        [% arrayPartecipanti = arrayPartecipanti + " ]"; %]

        [% json = json + " " + arrayPartecipanti " }"; %]

        [%= json %]
        [/EFTL]
        `);

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