info:
  name: Campi conferma - Codice struttura assegnazione
  type: http
  seq: 2

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",
          "struttureCensite": "106014;;106227;;106208;;106027;;106178;;106177;;106006;;106017;;106016;;106012;;300221;;106013;;106015;;106007;;106011;;106156;;106151;;106154;;106155;;106152;;106157;;106153;;106150;;106148;;106277;;106272",
          "codiceStrutturaDefault": "CENTRO_DEFAULT"
        }
      }
  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" /]
        [% codiceStruttura = codiceStrutturaDefault; %]

        [VAR name="codiceStrutturaContratto" type="string"][TAG]GETVALUEBYTAG,STRUTTURA_PRINCIPALE_CODICE_INIZIALE,REQUEST,ID_OBJECT[/TAG][/VAR]

        [IF]
          [CONDITION][CONTAINS varname="struttureCensite" value="codiceStrutturaContratto" /][/CONDITION]
          [THEN][% codiceStruttura = codiceStrutturaContratto; %][/THEN]
        [/IF]

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

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