Test the API with Postman

Aerosync Postman Collection

The provided instructions were designed to assist any team member/tester/stakeholder in following and executing a proper use of the Postman Collection. The Aerosync Postman Collection can be used to validate requests and responses from the Aerosync API suite.

Step 1 - Import Environment and Collection files

Copy and paste the following environment as shown in the following steps.

Step 1- Click Environments and then click the Import button

Step 2- Copy the JSON that is in this guide so you can add the environment, remember to copy it in the bar.

Staging Environment V1.0

{
	"id": "1756d231-8186-4d84-8ce6-7667fc4d7ee1",
	"name": "Aerosync API 2.0 Staging",
	"values": [
		{
			"key": "base_url",
			"value": "http://api.staging.aerosync.com/v2",
			"type": "default",
			"enabled": true
		},
		{
			"key": "apiKey",
			"value": "test1",
			"type": "default",
			"enabled": true
		},
		{
			"key": "apiSecret",
			"value": "test1",
			"type": "default",
			"enabled": true
		},
		{
			"key": "user_id",
			"value": "0225b027f36549e798041dbb52f1d93e",
			"type": "default",
			"enabled": true
		}
	],
	"_postman_variable_scope": "environment",
	"_postman_exported_at": "2024-02-28T15:41:49.901Z",
	"_postman_exported_using": "Postman/10.23.5"
}

Step 3- Click to accept the import.

Step 4- Validate that the environment was imported correctly.

APIs 2.0 Collection V.1.0

Next, you'll need to import the collection. Importing the collection is similar to importing the environment, except you'll be using the "Collections" tab.

{
	"info": {
		"_postman_id": "04c41eda-8e25-443c-9172-8debc1ebe998",
		"name": "Aerosync APIs 2.0",
		"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
		"_exporter_id": "27310382",
		"_collection_link": "https://aeropay.postman.co/workspace/Aerosync-APIs-2.0~46013fcc-da4a-412a-99d1-d4e49037f56a/collection/27310382-04c41eda-8e25-443c-9172-8debc1ebe998?action=share&source=collection_link&creator=27310382"
	},
	"item": [
		{
			"name": "Token",
			"item": [
				{
					"name": "/token_v2",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"//Response object\r",
									"var jsonData = pm.response.json();\r",
									"\r",
									"\r",
									"pm.test(\"Header & Response Time/Code Validations\", function()\r",
									"{\r",
									"pm.response.to.have.header(\"Content-Type\");\r",
									"pm.expect(pm.response.headers.get(\"Content-Type\")).to.eql(\"application/json\");\r",
									"pm.expect(pm.response.responseTime).to.be.below(10000);\r",
									"pm.response.to.have.status(200);\r",
									"\r",
									"});\r",
									"\r",
									"pm.test(\"Token not null or empty\", function()\r",
									"{\r",
									"pm.expect(jsonData.token).to.not.be.null\r",
									"pm.expect(jsonData.token).to.not.be.empty\r",
									"\r",
									"});\r",
									"//Set token collection variables for next apis bearer token (headers section)\r",
									"pm.collectionVariables.set(\"token\", jsonData.token);"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\r\n\t\"apiKey\":\"{{apiKey}}\",\r\n\t\"apiSecret\": \"{{apiSecret}}\"\r\n}"
						},
						"url": {
							"raw": "{{base_url}}/token",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"token"
							]
						}
					},
					"response": []
				},
				{
					"name": "/token_widget",
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\r\n    \"userId\": \"e474f4aca889461eu41a39abb71107t9\",\r\n    \"userPassword\": \"6e56a3c4e1u4414f853d10e11f989ccf\",\r\n    \"apiKey\": \"{{apiKey}}\",\r\n    \"apiSecret\": \"{{apiSecret}}\"\r\n    \r\n}"
						},
						"url": {
							"raw": "{{base_url}}/token_widget",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"token_widget"
							]
						}
					},
					"response": []
				}
			]
		},
		{
			"name": "Identity",
			"item": [
				{
					"name": "/accounts",
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Authorization",
								"value": "Bearer {{token}}"
							}
						],
						"url": {
							"raw": "{{base_url}}/accounts/{{user_id}}",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"accounts",
								"{{user_id}}"
							]
						}
					},
					"response": []
				},
				{
					"name": "/identity",
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Authorization",
								"value": "Bearer {{token}}"
							}
						],
						"url": {
							"raw": "{{base_url}}/accounts/{{user_id}}/identity",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"accounts",
								"{{user_id}}",
								"identity"
							]
						}
					},
					"response": []
				},
				{
					"name": "/identity_post",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"//Response object\r",
									"var jsonData = pm.response.json();\r",
									"job= jsonData.jobId;\r",
									"console.log(job);\r",
									"//Set job_id collection variables for next apis (job_status)\r",
									"pm.collectionVariables.set(\"job_id\", job);"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Authorization",
								"value": "Bearer {{token}}"
							}
						],
						"url": {
							"raw": "{{base_url}}/accounts/{{user_id}}/identity",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"accounts",
								"{{user_id}}",
								"identity"
							]
						}
					},
					"response": []
				}
			]
		},
		{
			"name": "Balance",
			"item": [
				{
					"name": "/balance",
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Authorization",
								"value": "Bearer {{token}}"
							}
						],
						"url": {
							"raw": "{{base_url}}/accounts/{{user_id}}/balance",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"accounts",
								"{{user_id}}",
								"balance"
							]
						}
					},
					"response": []
				},
				{
					"name": "/refresh",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"//Response object\r",
									"var jsonData = pm.response.json();\r",
									"job= jsonData.account.jobId;\r",
									"console.log(job);\r",
									"//Set job_id collection variables for next apis (job_status)\r",
									"pm.collectionVariables.set(\"job_id\", job);\r",
									""
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Authorization",
								"value": "Bearer {{token}}"
							}
						],
						"url": {
							"raw": "{{base_url}}/accounts/{{user_id}}/refresh",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"accounts",
								"{{user_id}}",
								"refresh"
							]
						}
					},
					"response": []
				},
				{
					"name": "/job-status",
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Authorization",
								"value": "Bearer {{token}}"
							}
						],
						"url": {
							"raw": "{{base_url}}/accounts/{{user_id}}/job/{{job_id}}",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"accounts",
								"{{user_id}}",
								"job",
								"{{job_id}}"
							]
						}
					},
					"response": []
				}
			]
		},
		{
			"name": "MFA",
			"item": [
				{
					"name": "/MFA",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"// Fixed TypeError by checking for existence of mfaAttributes\r",
									"var jsonData = pm.response.json();\r",
									"var guid = (jsonData.verifyPollAttributes.mfaAttributes && jsonData.verifyPollAttributes.mfaAttributes.length > 0) ? jsonData.verifyPollAttributes.mfaAttributes[0].guid : null;\r",
									"console.log(guid);\r",
									"\r",
									"// Set mfa_type collection variables for next APIs (resolve-mfa)\r",
									"pm.collectionVariables.set(\"mfa_type\", guid);"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Authorization",
								"value": "Bearer {{token}}"
							}
						],
						"url": {
							"raw": "{{base_url}}/accounts/{{user_id}}/mfa/{{job_id}}",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"accounts",
								"{{user_id}}",
								"mfa",
								"{{job_id}}"
							]
						}
					},
					"response": []
				},
				{
					"name": "/resolve-mfa",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									""
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Authorization",
								"value": "Bearer {{token}}"
							}
						],
						"body": {
							"mode": "raw",
							"raw": "{\r\n  \"mfaAttributes\": {\r\n    \"type\": \"{{mfa_type}}\",\r\n    \"answer\": \"correct\"\r\n  }\r\n}"
						},
						"url": {
							"raw": "{{base_url}}/accounts/{{user_id}}/mfa/{{job_id}}/resolve",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"accounts",
								"{{user_id}}",
								"mfa",
								"{{job_id}}",
								"resolve"
							]
						}
					},
					"response": []
				}
			]
		},
		{
			"name": "Transactions",
			"item": [
				{
					"name": "/transactions",
					"request": {
						"method": "GET",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Authorization",
								"value": "Bearer {{token}}"
							}
						],
						"url": {
							"raw": "{{base_url}}/accounts/{{user_id}}/transactions?start_date=2023-11-01&end_date=2023-12-13",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"accounts",
								"{{user_id}}",
								"transactions"
							],
							"query": [
								{
									"key": "start_date",
									"value": "2023-11-01"
								},
								{
									"key": "end_date",
									"value": "2023-12-13"
								}
							]
						}
					},
					"response": []
				},
				{
					"name": "/transaction_post",
					"event": [
						{
							"listen": "test",
							"script": {
								"exec": [
									"//Response object\r",
									"var jsonData = pm.response.json();\r",
									"job= jsonData.jobId;\r",
									"console.log(job);\r",
									"//Set job_id collection variables for next apis (job_status)\r",
									"pm.collectionVariables.set(\"job_id\", job);"
								],
								"type": "text/javascript"
							}
						}
					],
					"request": {
						"method": "POST",
						"header": [
							{
								"key": "Content-Type",
								"value": "application/json"
							},
							{
								"key": "Authorization",
								"value": "Bearer {{token}}"
							}
						],
						"url": {
							"raw": "{{base_url}}/accounts/{{user_id}}/transactions",
							"host": [
								"{{base_url}}"
							],
							"path": [
								"accounts",
								"{{user_id}}",
								"transactions"
							]
						}
					},
					"response": []
				}
			]
		}
	],
	"event": [
		{
			"listen": "prerequest",
			"script": {
				"type": "text/javascript",
				"exec": [
					""
				]
			}
		},
		{
			"listen": "test",
			"script": {
				"type": "text/javascript",
				"exec": [
					""
				]
			}
		}
	],
	"variable": [
		{
			"key": "token",
			"value": "",
			"type": "string"
		},
		{
			"key": "job_id",
			"value": "",
			"type": "string"
		},
		{
			"key": "mfa_type",
			"value": "",
			"type": "string"
		}
	]
}

Pre-Condition

To begin testing the Aeropay APIs, you'll need to generate a user_id variable. The user_id is a unique identifier for a bank connection that will be used to fetch data for that bank. This user_id is returned from the Aerosync widget after a user successfully links a bank.

If you're interested in diving into testing the Aerosync APIs before you've built a working bank connection widget, the following steps will walk you through how to retrieve a user_id value to begin testing.

Step 1:

Select the https://staging-online.aeropay.com/ and login with your account credentials.

Step 2: After successfully entering with your credentials, click on the "Add bank account" button to continue to the landing page. Check the policy agreement checkbox, and click on the continue button until you reach the bank list.

Step 3: Choose a bank to link a new account during this step right click on the page, select "Inspect" and click the "Network" tab.

Step 4: Do all the steps of a bank link process and validate the payload from the linkAccountFromAggregator, there you will find the user_id and user_password.

Note: Keep both the user_id and user_password in a notepad or bloc to user for future testing.

APIs TESTING STEPS

Step 1: Go to the environment variables and change the value of the user_id from the previous pre-conditions step.

Step 2: Select the environment staging (This is according to which environment the user_id was generated).

Step 3: Go to the collection Aerosync APIs 2.0 and select the /token_v2 and click on send.

Note: Is important to do this call first since the token will be used for the other APIs for authentication.

Step 4: Select any API from the collection and click on send and review the response.

END