diff --git a/finicity.postman_collection.json b/finicity.postman_collection.json index 6d5ad6b..ea401fd 100644 --- a/finicity.postman_collection.json +++ b/finicity.postman_collection.json @@ -8774,6 +8774,11 @@ " pm.expect(pm.response.code).to.equals(201)\r", "})\r", "\r", + "if (pm.response.code !== 201) {\r", + " // Nothing to do\r", + " return\r", + "}\r", + "\r", "console.log(\"Request successful. Deleting created customer ...\")\r", "const options = {\r", " url: baseUrl + \"/aggregation/v1/customers/\" + pm.response.json().id, \r", @@ -8968,6 +8973,11 @@ " pm.expect([201, 401]).contain(pm.response.code)\r", "})\r", "\r", + "if (pm.response.code !== 201) {\r", + " // Nothing to do\r", + " return\r", + "}\r", + "\r", "console.log(\"Request successful. Deleting created customer ...\")\r", "const options = {\r", " url: baseUrl + \"/aggregation/v1/customers/\" + pm.response.json().id, \r", @@ -21020,8 +21030,8 @@ "const now = new Date()", "const expiryDate = appToken ? new Date(pm.globals.get(\"appTokenExpiry\")) : now", "if (appToken && expiryDate > now) {", - " // The token is still valid", - " return", + " // The token is still valid", + " return", "}", "", "// Create a new token", @@ -21035,13 +21045,13 @@ " \"Finicity-App-Key\": appKey", " },", " body: JSON.stringify({", - " \"partnerId\": partnerId,", - " \"partnerSecret\": partnerSecret", - " })", + " \"partnerId\": partnerId,", + " \"partnerSecret\": partnerSecret", + " })", "}", "pm.sendRequest(options, function (err, response) {", " if (response.code == 403) {", - " throw Error(\"HTTP 403. Check you are located in the United States.\")", + " throw Error(\"HTTP 403. Make sure you are located in the US, UK or Canada.\")", " }", " pm.expect(err).to.be.null", " pm.expect(response.code).to.equals(200)", @@ -21050,7 +21060,58 @@ " expiryDate.setMinutes(expiryDate.getMinutes() + 90)", " pm.globals.set(\"appToken\", tokenValue)", " pm.globals.set(\"appTokenExpiry\", expiryDate)", - "})" + "", + " // Create a consumer for report generation APIs", + " createConsumer()", + "})", + "", + "", + "function createConsumer() {", + " const baseUrl = pm.collectionVariables.get(\"baseUrl\")", + " const customerId = pm.environment.get(\"customerId\")", + " const appKey = pm.environment.get(\"appKey\")", + " const appToken = pm.globals.get(\"appToken\")", + "", + " const consumerExists = pm.globals.get(\"consumerExists\")", + " if (consumerExists) {", + " // A consumer was already created", + " return", + " }", + "", + " console.log(\"Creating consumer ... \")", + " const options = {", + " url: baseUrl + \"/decisioning/v1/customers/\" + customerId + \"/consumer\", ", + " method: 'POST',", + " header: {", + " \"Accept\": \"application/json\",", + " \"Content-type\": \"application/json\",", + " \"Finicity-App-Key\": appKey,", + " \"Finicity-App-Token\": appToken", + " },", + " body: JSON.stringify({", + " \"firstName\": \"Homer\",", + " \"lastName\": \"Loanseeke\",", + " \"address\": \"434 W Ascension Way\",", + " \"city\": \"Murray\",", + " \"state\": \"UT\",", + " \"zip\": \"84123\",", + " \"phone\": \"1-800-986-3343\",", + " \"ssn\": \"999601111\",", + " \"birthday\": {", + " \"year\": 1970,", + " \"month\": 7,", + " \"dayOfMonth\": 4", + " },", + " \"email\": \"finicity@test.com\",", + " \"suffix\": \"Mr\"", + " })", + " }", + " pm.sendRequest(options, function (err, response) {", + " pm.expect(err).to.be.null", + " pm.expect(response.code).to.be.oneOf([200, 201, 409])", + " pm.globals.set(\"consumerExists\", true)", + " })", + "}" ] } },