info:
  name: Lookup requests
  type: http
  seq: 5

http:
  method: GET
  url: "{{elixFormsApiUrl_Default}}/request/lookup/by-status?requestStatus=PROCESSED&moduleTag=PROPOSTA_CCT_OPERATORE"
  headers:
    - name: x-requested-with
      value: XMLHttpRequest
    - name: x-api-username
      value: "{{elixFormsApiUsername}}"
  params:
    - name: requestStatus
      value: SUBMITTED
      type: query
      description: |-
        Valori possibili:
        - IN_PROGRESS
        - SUBMITTED
        - PROCESSED
        possibile selezionare valori multipli
      disabled: true
    - name: requestStatus
      value: PROCESSED
      type: query
    - name: moduleTag
      value: PROPOSTA_CCT_OPERATORE
      type: query
      description: Possibile specificare valori multipli
    - name: moduleTag
      value: PROPOSTA_CCT_DOCENTE
      type: query
      disabled: true
    - name: swfOptionKey
      value: "1"
      type: query
      disabled: true
    - name: swfOptionMode
      value: IN
      type: query
      disabled: true
  auth: inherit

runtime:
  scripts:
    - type: after-response
      code: |-
        bru.deleteVar("ef_request_cct_ids");
        // --------------------------------------------------------------------------------
        bru.deleteVar("elixFormsWebKitFormOutput");
        // --------------------------------------------------------------------------------

        // Carica il file JSON (sostituisci con il tuo oggetto JSON)
        const jsonData = res.getBody();
        const requests = jsonData.value.requests;
        const requestIds = [];
        for (const r of requests)
        {
          requestIds.push(r.requestId);
        }
        //console.log(requestIds);
        bru.setVar("elixFormsQueryRequestIds", requestIds);
        bru.setVar("elixFormsQueryRequestIndex", 0);
        bru.setVar("elixFormsQueryOutput", JSON.stringify(JSON.parse("[]")));

        // --------------------------------------------------------------------------------
        bru.setVar("elixFormsWebKitFormOutput", "");
        // --------------------------------------------------------------------------------

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

examples:
  - name: Lookup By Status (w SWF) - Success
    request:
      url: "{{elixFormsApiUrl_Default}}/request/lookup/by-status"
      method: POST
      headers:
        - name: x-requested-with
          value: XMLHttpRequest
      body:
        type: form-urlencoded
        data:
          - name: username
            value: "{{elixFormsApiUsername}}"
          - name: requestStatus
            value: PROCESSED
            description: |-
              Valori possibili:
              - IN_PROGRESS
              - SUBMITTED
              - PROCESSED

              possibile selezionare valori multipli
          - name: moduleTag
            value: PROPOSTA_CCT_OPERATORE
            disabled: true
          - name: moduleTag
            value: PROPOSTA_CCT_DOCENTE
            description: |-
              Per restringere il risultato alle sole richieste del/i modulo/i aventi tag specificato

              Possibile selezionare valori multipli
          - name: swfOptionKey
            value: "1"
          - name: swfOptionMode
            value: IN
    response:
      statusText: "200"
      headers:
        - name: cache-control
          value: no-cache, no-store, must-revalidate
        - name: pragma
          value: no-cache
        - name: proxy-connection
          value: Keep-Alive
        - name: x-content-security-policy
          value: default-src 'self'; connect-src 'self'; font-src 'none'; img-src 'self'; media-src 'self'; object-src 'self'; plugin-types application/pdf audio/x-wav; referrer no-referrer; reflected-xss block; script-src 'self'; style-src 'self'
        - name: content-type
          value: application/it.elixforms.api.v1+json;charset=UTF-8
        - name: content-length
          value: "787"
        - name: strict-transport-security
          value: max-age=63072000;includeSubDomains
        - name: content-security-policy
          value: "default-src https: data: 'unsafe-inline' 'unsafe-eval'"
        - name: x-frame-options
          value: SAMEORIGIN
        - name: x-xss-protection
          value: 1;mode=block
        - name: x-content-type-options
          value: nosniff
        - name: referrer-policy
          value: unsafe-url
      body:
        type: text
        data: |-
          {
              "value": {
                  "code": "OK",
                  "description": "OK",
                  "complete": true,
                  "globalStatus": "OK",
                  "serviceInformationList": {
                      "serviceInformation": [
                          {
                              "ITSystemName": "EF-CORE",
                              "complete": true,
                              "serviceVersion": "1.2.0",
                              "statusDetailList": {
                                  "statusDetail": [
                                      {
                                          "code": "OK",
                                          "description": "OK",
                                          "detailStatus": "OK"
                                      }
                                  ]
                              }
                          }
                      ]
                  },
                  "uuid": "88b0ea46-f1c2-4ed3-a5f2-1a43c6e1fd58",
                  "version": "3.10.0.23",
                  "requests": [
                      {
                          "moduleTag": "PROPOSTA_CCT_DOCENTE",
                          "requestId": 10699,
                          "step": "Inoltrata, senza stato di workflow semplice disponibile per il modulo"
                      },
                      {
                          "moduleTag": "PROPOSTA_CCT_DOCENTE",
                          "requestId": 10728,
                          "step": "Inoltrata, senza stato di workflow semplice disponibile per il modulo"
                      },
                      {
                          "moduleTag": "PROPOSTA_CCT_DOCENTE",
                          "requestId": 10868,
                          "step": "Inoltrata, senza stato di workflow semplice disponibile per il modulo"
                      }
                  ],
                  "requestsSize": 3
              }
          }
  - name: Lookup By Status - Error
    request:
      url: "{{elixFormsApiUrl_Default}}/request/lookup/by-status"
      method: POST
      body:
        type: form-urlencoded
        data:
          - name: username
            value: "{{elixFormsApiUsername}}"
          - name: requestStatus
            value: IN_PROGRESS
            description: |-
              Valori possibili:
              - IN_PROGRESS
              - SUBMITTED
              - PROCESSED

              possibile selezionare valori multipli
          - name: moduleTag
            value: PROPOSTA_CCT_OPERATORE
          - name: moduleTag
            value: PROPOSTA_CCT_DOCENTE
            description: |-
              Per restringere il risultato alle sole richieste del/i modulo/i aventi tag specificato

              Possibile selezionare valori multipli
            disabled: true
          - name: swfOptionKey
            value: "1"
    response:
      statusText: "200"
      headers:
        - name: cache-control
          value: no-cache, no-store, must-revalidate
        - name: pragma
          value: no-cache
        - name: proxy-connection
          value: Keep-Alive
        - name: x-content-security-policy
          value: default-src 'self'; connect-src 'self'; font-src 'none'; img-src 'self'; media-src 'self'; object-src 'self'; plugin-types application/pdf audio/x-wav; referrer no-referrer; reflected-xss block; script-src 'self'; style-src 'self'
        - name: content-type
          value: application/it.elixforms.api.v1+json;charset=UTF-8
        - name: content-length
          value: "925"
        - name: strict-transport-security
          value: max-age=63072000;includeSubDomains
        - name: content-security-policy
          value: "default-src https: data: 'unsafe-inline' 'unsafe-eval'"
        - name: x-frame-options
          value: SAMEORIGIN
        - name: x-xss-protection
          value: 1;mode=block
        - name: x-content-type-options
          value: nosniff
        - name: referrer-policy
          value: unsafe-url
      body:
        type: text
        data: |-
          {
              "value": {
                  "code": "ERROR",
                  "description": "Il modulo identificato dal tag \"PROPOSTA_CCT_OPERATORE\" NON contiene un workflow semplice (la scheda modulo 10 contiene un valore nullo o 0 nella colonna S_10_COL0051), ma è stato richiesto di filtrare i risultati per il valore INOLTRATA (uno stato di workflow semplice)",
                  "complete": true,
                  "globalStatus": "ERROR",
                  "serviceInformationList": {
                      "serviceInformation": [
                          {
                              "ITSystemName": "EF-CORE",
                              "complete": true,
                              "serviceVersion": "1.2.0",
                              "statusDetailList": {
                                  "statusDetail": [
                                      {
                                          "code": "ERROR",
                                          "description": "Il modulo identificato dal tag \"PROPOSTA_CCT_OPERATORE\" NON contiene un workflow semplice (la scheda modulo 10 contiene un valore nullo o 0 nella colonna S_10_COL0051), ma è stato richiesto di filtrare i risultati per il valore INOLTRATA (uno stato di workflow semplice)",
                                          "detailStatus": "ERROR"
                                      }
                                  ]
                              }
                          }
                      ]
                  },
                  "uuid": "ed18681c-a40e-458e-8f70-0b982a19ab0b",
                  "version": "3.9.2.17",
                  "requestsSize": 0
              }
          }
