info:
  name: Gestione Istanze - Elenco carriere inserite
  type: http
  seq: 14

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: "33380"
  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: |-
        // Copy-pasta your EFTL document below inside the template literals (`)
        var eftlDocumentToBeProcessed = bru.setVar("elixBase64EftlDocument", btoa(String.raw`
        [EFTL][HEADER name="trimDocument" value="true" type="boolean" /]
        [% elencoCarriere = ""; item1 = 0; item2 = 1; %]

        [VAR name="carriereInserite" type="iterable" unique="true"][SPLIT regex="##"][TAG]GETVALUEBYTAG,CARRIERA_SELEZIONATA,REQUEST,IUQOID,CONCAT,##[/TAG][/SPLIT][/VAR]
        [FOR varname="carriera" iterable="carriereInserite"]
          [VAR name="carrieraIterable" type="iterable"][SPLIT regex=" - "][% carriera %][/SPLIT][/VAR]
          [VAR name="nomeCarriera" type="string"][VALUE_OF varname="carrieraIterable" index="item2" /][/VAR]
          [IF]
            [CONDITION][IS_EMPTY varname="elencoCarriere" /][/CONDITION]
            [THEN][% elencoCarriere = nomeCarriera; %][/THEN]
            [ELSE][% elencoCarriere = elencoCarriere + " ; " + nomeCarriera; %][/ELSE]
          [/IF]
        [/FOR]

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

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