info:
  name: Get Request Identifier
  type: http
  seq: 3

http:
  method: GET
  url: "{{elixFormsApiUrl_Default}}/request/get-id?qrCode=123456"
  headers:
    - name: x-requested-with
      value: XMLHttpRequest
    - name: x-api-username
      value: "{{elixFormsApiUsername}}"
  params:
    - name: username
      value: "{{elixFormsApiUsername}}"
      type: query
      description: lo username con cui si è effettuato il login
      disabled: true
    - name: qrCode
      value: "123456"
      type: query
  body:
    type: form-urlencoded
  auth: inherit

runtime:
  scripts:
    - type: after-response
      code: |-
        function findBinaryColumns(obj) {
            let binaryColumns = [];

            if (Array.isArray(obj)) {
                obj.forEach(item => {
                    binaryColumns = binaryColumns.concat(findBinaryColumns(item));
                });
            } else if (typeof obj === "object" && obj !== null) {
                Object.keys(obj).forEach(key => {
                    if (key === "columns" && Array.isArray(obj[key])) {
                        obj[key].forEach(column => {
                            if (column.columnType === "BINARY") {
                                binaryColumns.push(column);
                            }
                        });
                    } else {
                        binaryColumns = binaryColumns.concat(findBinaryColumns(obj[key]));
                    }
                });
            }

            return binaryColumns;
        }

        // Carica il file JSON (sostituisci con il tuo oggetto JSON)
        const jsonData = res.getBody();

        // Esegui la ricerca
        const binaryColumns = findBinaryColumns(jsonData);

        // Stampa i risultati solo se ne abbiamo trovati (bisogna abilitare la visualizzazione dei Warning nella console Postman)
        if (binaryColumns.length > 0) {
            console.warn("Allegati trovati:", binaryColumns);
        }

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

examples:
  - name: Get Request Identifier - Invalid QRCode
    request:
      url: "{{elixFormsApiUrl_Default}}/request/get-id?username={{elixFormsApiUsername}}&qrCode=123456"
      method: GET
      params:
        - name: username
          value: "{{elixFormsApiUsername}}"
          type: query
          description: lo username con cui si è effettuato il login
        - name: qrCode
          value: "123456"
          type: query
      body:
        type: form-urlencoded
    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.2+json;charset=UTF-8
        - name: content-length
          value: "441"
        - 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": "WARNING",
                  "description": "Il qrCode fornito non è valido",
                  "complete": true,
                  "globalStatus": "WARNING",
                  "serviceInformationList": {
                      "serviceInformation": [
                          {
                              "ITSystemName": "EF-CORE",
                              "complete": true,
                              "serviceVersion": "1.2.0",
                              "statusDetailList": {
                                  "statusDetail": [
                                      {
                                          "code": "WARNING",
                                          "description": "Il qrCode fornito non è valido",
                                          "detailStatus": "WARNING"
                                      }
                                  ]
                              }
                          }
                      ]
                  },
                  "uuid": "52de6c90-8b75-4cab-ba37-4d81c567cb86",
                  "version": "3.9.2.17",
                  "size": 0
              }
          }
