11.2. Creating Test Companies

In this Postman collection we start from scratch. So we need some sample companies to work with - this we will do in this section. We will create registration app tokens and use them to connect new companies to our third party system. In production new company would register itself using same app token, so we could manage it with APIs.

Open up CargoX Integration Examples and click on Creat Company 1 request. Everything is already set-up, so click on the Send button. In the body response there will JSON object containing registration_url link. Open this link in your web browser to continue with manual steps.

Tip

We don't describe specific calls and responses here - it's easy to see them right in Postman. On every request call you can see what call is being made, what headers, body and parameters we send and what response we fetch. Also check Tests tab - there we check the response and parse some data from it.

../_images/create_company_1.png

Tip

You can always change the data (like email etc) to your needs. Simply go to collection variables and change it.

When we open web app, we continue to simulate new company registration and some manual steps.. We click on Creat Company button. There are two more steps, just fill in the missing data, set up your password for this company and verify your email.

../_images/create_company_2.png

After verifying your/user email we continue to grant permissions page where user grants us access to his CargoX account.

../_images/create_company_3.png

Continue generating Blockchain key = Your personal digital signature. You can create a new blockchain key (most new users) or link an existing blockchain key (only if you already have one, or if you use a hardware wallet device). So in this example we create new blockchain key, store it on our computer and activate it. There are few steps, at the end you should get activate blockchain key screen.

../_images/create_company_4.png ../_images/create_company_5.png

After completing this step we are finished with setting up first company. Repeat all steps for second company, since we need two companies for our collection examples.

Important

We will use blockchain key on later examples, so please store it to secure location.

11.2.1. Getting and parsing company and user data

Next we make few GET calls to get our new companies and users, parse retrieved responses and store data into collection variables. All the request are set up in example collection, we will just go trough the process to examine what is happening. First, we got to Company and contact creation->Company list and click on Send button. We get a 200 OK Response and we can see some JSON response.

../_images/get_company_data_1.png

We can also check the Tests tab. There we make some basic checks that response is really ok. But we also parse response JSON and store some data we will need in proceeding calls

../_images/get_company_data_2.png

Next we do similar with next two calls - Company and contact creation->Company1 Users and Company and contact creation->Company1 User1 Data. Postman will get some more data parse it and store it into collection variables..

../_images/get_company_data_3.png

Tip

If you ever get a 403 response saying {"detail": "Authentication credentials were not provided."} It means that our access token has expired and we have to get a new one.

11.2.2. Create and confirm contact between test companies

../_images/contacs_1.png

We can see results of creating and confirming contact on a web app.

../_images/contacs_2.png