info:
  name: Check Richiedente IN Responsabili Scientifici
  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: "24218"
  body:
    type: json
    data: |-
      {
        "userDocument": "{{elixBase64EftlDocument}}", // see the pre-request script
        "userContext": {
          "lang": "IT",
          "crlf": "\r\n",
          "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="isRichiedenteInRS" type="string"][% isRichiedenteInRS = "Utente non ammesso alla compilazione perché non risulta fra i Responsabili Scientifici del contratto!"; %][/VAR]
        [VAR name="responsabiliScientifici" type="string"][TAG]GETVALUEBYTAG,CONTRATTO_RESPONSABILI,REQUEST,IUQOID[/TAG][/VAR]

        [VAR name="codiceFiscaleUtente" type="string"][TAG]GETVALUEBYTAG,RICHIEDENTE_CODFIS,REQUEST,IUQOID[/TAG][/VAR]
        [VAR name="codiceFiscaleUtenteDebug" type="string"][TAG]GETVALUEBYTAG,RICHIEDENTE_CODFIS,REQUEST,IUQOID[/TAG][/VAR]

        [% codiceFiscaleUtente = ", CF: " + codiceFiscaleUtente + ","; %]

        [IF]
            [CONDITION][CONTAINS varname="responsabiliScientifici"][VALUE_OF varname="codiceFiscaleUtente" /][/CONTAINS][/CONDITION]
            [THEN][% isRichiedenteInRS = ""; %][/THEN]
            [ELSE IF]
                [CONDITION][CONTAINS varname="codiciFiscaliAmmessi"][VALUE_OF varname="codiceFiscaleUtenteDebug" /][/CONTAINS][/CONDITION]
            [THEN][% isRichiedenteInRS = ""; %][/THEN]
            [/ELSE IF]
        [/IF]

        [%= responsabiliScientifici %]
        [%= crlf %]
        [%= codiceFiscaleUtente %]
        [%= crlf %]
        [%= isRichiedenteInRS %]
        [/EFTL]
        `);

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