{
  "info": {
    "_postman_id": "ac691401-9963-40f7-908a-71d3aef4ef1f",
    "name": "HR Open Assessment Supplier",
    "description": "Parent collection to be _forked_ for HR Open Assessment Suppliers.",
    "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
    "_exporter_id": "41698182",
    "_collection_link": "https://jobvite.postman.co/workspace/274995f4-3bf8-4d46-9852-5205d905483b/collection/41698182-ac691401-9963-40f7-908a-71d3aef4ef1f?action=share&source=collection_link&creator=41698182"
  },
  "item": [
    {
      "name": "Verify",
      "event": [
        {
          "listen": "test",
          "script": {
            "exec": [
              ""
            ],
            "type": "text/javascript"
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [],
        "url": {
          "raw": "{{jazzhr_base-uri}}{{jazzhr_verify-url}}",
          "host": [
            "{{jazzhr_base-uri}}{{jazzhr_verify-url}}"
          ]
        },
        "description": "JazzHR will call this endpoint to verify the bearer token included in the Authorization header is valid within the Assessment Partner’s system."
      },
      "response": []
    },
    {
      "name": "List Catalog",
      "event": [
        {
          "listen": "test",
          "script": {
            "exec": [
              "pm.test(\"response body is valid\", function () {",
              "    const packages = pm.response.json().packages;",
              "    ",
              "    pm.expect(packages).to.have.lengthOf.at.least(1);",
              "",
              "    for (let item of packages) {",
              "        pm.expect(item.name).to.be.a('string');",
              "        pm.expect(item.packageId.value).to.be.a('string');",
              "    }",
              "    ",
              "    pm.variables.set('testPackageId', packages[0].packageId.value);",
              "});",
              ""
            ],
            "type": "text/javascript"
          }
        }
      ],
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{jazzhr_base-uri}}{{jazzhr_list-catalog-url}}",
          "host": [
            "{{jazzhr_base-uri}}{{jazzhr_list-catalog-url}}"
          ]
        },
        "description": "JazzHR will call this endpoint to retrieve a list of packages available within the Partner’s assessment catalog."
      },
      "response": [
        {
          "name": "200 OK",
          "originalRequest": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{jazzhr_base-uri}}/catalog",
              "host": [
                "{{jazzhr_base-uri}}"
              ],
              "path": [
                "catalog"
              ]
            }
          },
          "status": "OK",
          "code": 200,
          "_postman_previewlanguage": "json",
          "header": [
            {
              "key": "Access-Control-Allow-Headers",
              "value": "Origin, X-Requested-With, Content-Type, Authorization, Accept"
            },
            {
              "key": "Access-Control-Allow-Methods",
              "value": "GET, POST, PUT, GET, DELETE, OPTIONS"
            },
            {
              "key": "Access-Control-Allow-Origin",
              "value": "*"
            },
            {
              "key": "Cache-Control",
              "value": "no-cache, private"
            },
            {
              "key": "Content-Type",
              "value": "application/json"
            },
            {
              "key": "Date",
              "value": "Thu, 02 May 2019 00:27:37 GMT"
            },
            {
              "key": "Server",
              "value": "Apache"
            },
            {
              "key": "Vary",
              "value": "Authorization"
            },
            {
              "key": "Content-Length",
              "value": "210"
            },
            {
              "key": "Connection",
              "value": "keep-alive"
            }
          ],
          "cookie": [],
          "body": "{\n    \"packages\": [\n        {\n            \"packageId\": {\n                \"value\": \"JB-L4LJHG2C9\"\n            },\n            \"name\": \"Business Analyst\"\n        },\n        {\n            \"packageId\": {\n                \"value\": \"JB-HD3RJCV15\"\n            },\n            \"name\": \"Developer customname\"\n        },\n        {\n            \"packageId\": {\n                \"value\": \"JB-71XXSH3UD\"\n            },\n            \"name\": \"Web Developer\"\n        }\n    ]\n}"
        }
      ]
    },
    {
      "name": "Order Package",
      "event": [
        {
          "listen": "prerequest",
          "script": {
            "exec": [
              "const uuid = require('uuid');",
              "",
              "if (!pm.variables.has('testPackageId')) {",
              "    pm.variables.set('testPackageId', '1');",
              "}",
              "",
              "pm.variables.set('testOrderId', uuid.v4()); // set explicit string over dynamic {{$guid}} to persist across requests",
              ""
            ],
            "type": "text/javascript",
            "packages": {}
          }
        },
        {
          "listen": "test",
          "script": {
            "exec": [
              "pm.test(\"response body is valid\", function () {",
              "    const accessUri = pm.response.json().assessmentAccessURL.uri;",
              "    ",
              "    pm.expect(accessUri).to.be.a('string');",
              "    pm.expect(accessUri).to.not.be.empty;",
              "});",
              ""
            ],
            "type": "text/javascript",
            "packages": {}
          }
        }
      ],
      "request": {
        "method": "POST",
        "header": [
          {
            "key": "Content-Type",
            "value": "application/json",
            "type": "text"
          }
        ],
        "body": {
          "mode": "raw",
          "raw": "{\n    \"packageId\": {\n        \"value\": \"{{jazzhr_testPackageId}}\"\n    },\n    \"orderId\": {\n        \"value\": \"{{jazzhr_testOrderId}}\"\n    },\n    \"sendAssessmentResultsToURL\": {\n        \"uri\": \"{{jazzhr_partner-event-api}}/assessment/v1/{{jazzhr_partner-id}}/event\"\n    },\n    \"subject\": {\n        \"name\": {\n            \"given\": \"Kenny\",\n            \"family\": \"JazzHR\",\n            \"formattedName\": \"Kenny JazzHR\"\n        },\n        \"communication\": {\n            \"email\": [\n                {\n                    \"address\": \"kenny.jazzhr@jazzhr.com\"\n                }\n            ]\n        }\n    }\n}"
        },
        "url": {
          "raw": "{{jazzhr_base-uri}}{{jazzhr_order-package-url}}",
          "host": [
            "{{jazzhr_base-uri}}{{jazzhr_order-package-url}}"
          ]
        },
        "description": "JazzHR will send order requests to this endpoint for a particular candidate.\n\nThe `orderId` property included in the request body should be persisted within the Assessment Partner system and is used to retrieve results. This property is a standard 36 character UUID.\n\nThe `sendAssessmentResultsToURL` property included in the request body denotes the endpoint at which to notify JazzHR of order results upon assessment completion.\n\nThe response of this endpoint should include a URL to access the assessment. JazzHR will include this URL in an email to the candidate."
      },
      "response": [
        {
          "name": "200 OK",
          "originalRequest": {
            "method": "POST",
            "header": [
              {
                "key": "Content-Type",
                "value": "application/json",
                "name": "Content-Type",
                "type": "text"
              }
            ],
            "body": {
              "mode": "raw",
              "raw": "{\n    \"packageId\": {\n        \"value\": \"JB-L4LJHG2C9\"\n    },\n    \"orderId\": {\n        \"value\": \"9d874152-98bc-49c6-99f5-0c815c193516\"\n    },\n    \"sendAssessmentResultsToURL\": {\n        \"uri\": \"https://partnereventapi.env-94.resumatorlabs.net/assessment/v1/criteria-corp/event\"\n    }\n}"
            },
            "url": {
              "raw": "{{jazzhr_base-uri}}/order",
              "host": [
                "{{jazzhr_base-uri}}"
              ],
              "path": [
                "order"
              ]
            }
          },
          "status": "OK",
          "code": 200,
          "_postman_previewlanguage": "json",
          "header": [],
          "cookie": [],
          "body": "{\n    \"assessmentAccessURL\": {\n        \"uri\": \"https://www.ondemandassessment.com\"\n    }\n}"
        }
      ]
    },
    {
      "name": "Retrieve Results",
      "event": [
        {
          "listen": "prerequest",
          "script": {
            "exec": [
              "if (!pm.variables.has('testOrderId')) {",
              "    pm.variables.set('testOrderId', '{{$guid}}');",
              "}",
              ""
            ],
            "type": "text/javascript",
            "packages": {}
          }
        },
        {
          "listen": "test",
          "script": {
            "exec": [
              "const moment = require('moment');",
              "",
              "let retryCount = Number(pm.variables.get('testResultRetryCount')) || 0;",
              "",
              "if (pm.response.code >= 200 && pm.response.code < 300) { // if successful response",
              "    pm.test(\"response body has one result\", function () {",
              "        pm.expect(_.get(pm.response.json(), 'results')).to.have.lengthOf(1);",
              "    });",
              "    ",
              "    pm.test(\"response body status is valid\", function () {",
              "        const status = _.get(pm.response.json(), 'results[0].assessmentStatus');",
              "        ",
              "        pm.expect(status).to.be.a('string');",
              "        pm.expect(status).to.be.oneOf(['OrderAcknowledged', 'OrderInProgress', 'OrderComplete']);",
              "    });",
              "    ",
              "    pm.test(\"response body numeric score is an integer\", function () {",
              "        const overallResultNumeric = _.get(pm.response.json(), 'results[0].overallResult.score.scoresNumeric[0].value');",
              "",
              "        if ('undefined' !== typeof overallResultNumeric) {",
              "            pm.expect(typeof overallResultNumeric).to.equal('number');",
              "            pm.expect(overallResultNumeric % 1).to.equal(0); // ensure numeric scores are integers",
              "        }",
              "    });",
              "    ",
              "    pm.test(\"response body passed indicator is a boolean\", function () {",
              "        const passedIndicator = _.get(pm.response.json(), 'results[0].overallResult.passedIndicator');",
              "",
              "        if ('undefined' !== typeof passedIndicator) {",
              "            pm.expect(typeof passedIndicator).to.equal('boolean');",
              "        }",
              "    });",
              "",
              "    pm.test(\"response body test date is a valid iso-8601 string\", function () {",
              "        const testInstance = _.get(pm.response.json(), 'results[0].testInstance');",
              "",
              "        if ('object' === typeof testInstance) {",
              "            pm.expect(typeof testInstance.testDate).to.equal('string');",
              "            pm.expect(moment(testInstance.testDate, moment.ISO_8601).isValid()).to.equal(true);",
              "            pm.expect(testInstance.testDate).to.have.length(24);",
              "        }",
              "    });",
              "} else if (retryCount++ < 5) { // otherwise, retry request",
              "    setTimeout(function() {}, 2000 * retryCount); // backoff",
              "    pm.variables.set('testResultRetryCount', retryCount);",
              "    postman.setNextRequest(pm.info.requestId);",
              "}",
              ""
            ],
            "type": "text/javascript",
            "packages": {}
          }
        }
      ],
      "request": {
        "method": "GET",
        "header": [],
        "url": {
          "raw": "{{jazzhr_base-uri}}{{jazzhr_retrieve-results-url}}?orderId={{jazzhr_testOrderId}}",
          "host": [
            "{{jazzhr_base-uri}}{{jazzhr_retrieve-results-url}}"
          ],
          "query": [
            {
              "key": "orderId",
              "value": "{{jazzhr_testOrderId}}",
              "description": "`orderId` included in the order package request body"
            }
          ]
        },
        "description": "JazzHR will call this endpoint to retrieve the results associated with the specified `orderId` query parameter."
      },
      "response": [
        {
          "name": "200 OK",
          "originalRequest": {
            "method": "GET",
            "header": [],
            "url": {
              "raw": "{{jazzhr_base-uri}}/report?orderId=9d874152-98bc-49c6-99f5-0c815c193516",
              "host": [
                "{{jazzhr_base-uri}}"
              ],
              "path": [
                "report"
              ],
              "query": [
                {
                  "key": "orderId",
                  "value": "9d874152-98bc-49c6-99f5-0c815c193516"
                }
              ]
            }
          },
          "status": "OK",
          "code": 200,
          "_postman_previewlanguage": "json",
          "header": [
            {
              "key": "Access-Control-Allow-Headers",
              "value": "Origin, X-Requested-With, Content-Type, Authorization, Accept"
            },
            {
              "key": "Access-Control-Allow-Methods",
              "value": "GET, POST, PUT, GET, DELETE, OPTIONS"
            },
            {
              "key": "Access-Control-Allow-Origin",
              "value": "*"
            },
            {
              "key": "Cache-Control",
              "value": "no-cache, private"
            },
            {
              "key": "Content-Type",
              "value": "application/json"
            },
            {
              "key": "Date",
              "value": "Wed, 01 May 2019 23:59:14 GMT"
            },
            {
              "key": "Server",
              "value": "Apache"
            },
            {
              "key": "Vary",
              "value": "Authorization"
            },
            {
              "key": "Content-Length",
              "value": "293"
            },
            {
              "key": "Connection",
              "value": "keep-alive"
            }
          ],
          "cookie": [],
          "body": "{\n    \"results\": {\n        \"assessmentStatus\": \"OrderComplete\",\n        \"overallResult\": {\n            \"passedIndicator\": false\n        },\n        \"testInstance\": {\n            \"testDate\": \"2019-04-25T12:55:42.000Z\"\n        }\n    },\n    \"assessmentResultsURL\": {\n        \"uri\": \"https://www.criteriacorp.com\"\n    }\n}"
        }
      ]
    }
  ],
  "auth": {
    "type": "bearer",
    "bearer": [
      {
        "key": "token",
        "value": "{{jazzhr_api-token}}",
        "type": "string"
      }
    ]
  },
  "event": [
    {
      "listen": "prerequest",
      "script": {
        "type": "text/javascript",
        "exec": [
          ""
        ]
      }
    },
    {
      "listen": "test",
      "script": {
        "type": "text/javascript",
        "exec": [
          "pm.test(\"status code is success\", function () {",
          "    pm.response.to.be.success;",
          "});",
          "",
          "if (pm.response.code < 200 || pm.response.code >= 300) {",
          "    postman.setNextRequest(null); // short-circuit collection run if any request fails",
          "}",
          ""
        ]
      }
    }
  ],
  "variable": [
    {
      "key": "jazzhr_api-token",
      "value": ""
    },
    {
      "key": "jazzhr_base-uri",
      "value": ""
    },
    {
      "key": "jazzhr_verify-url",
      "value": ""
    },
    {
      "key": "jazzhr_list-catalog-url",
      "value": ""
    },
    {
      "key": "jazzhr_order-package-url",
      "value": ""
    },
    {
      "key": "jazzhr_retrieve-results-url",
      "value": ""
    },
    {
      "key": "jazzhr_partner-id",
      "value": ""
    }
  ]
}
