Skip to content

Commit

Permalink
Improved pre-request and test scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
jaaufauvre committed Dec 19, 2022
1 parent a4d6ac2 commit f4671b3
Showing 1 changed file with 68 additions and 7 deletions.
75 changes: 68 additions & 7 deletions finicity.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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)",
Expand All @@ -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\": \"[email protected]\",",
" \"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)",
" })",
"}"
]
}
},
Expand Down

0 comments on commit f4671b3

Please sign in to comment.