-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved pre-request and test scripts
- Loading branch information
1 parent
a4d6ac2
commit f4671b3
Showing
1 changed file
with
68 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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\": \"[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)", | ||
" })", | ||
"}" | ||
] | ||
} | ||
}, | ||
|