Internet of Things

This guide's goal is to provide a tutorial on how you can make external objects integration with its related APIs. Here, we will use as an example a weighing-machine that sends data into LinkApi's platform, and then, redirects them to our point of purchase/sale Component, PDVend.

As a first step, we'll create our PDVend Component, in order to be able to consume its data. Their documentation provides information regarding the Base URL, as well as the API type.
In your Build menu, we'll choose Build Component in Packages, so we can start the initial settings:

Even though PDVend's API has a specific kind of authentication, we can leave these fields blank, because we'll define them on the Resources tab.

For the objective we have, we will use the get method to the Component's login resource, and we'll need to fill these credentials in the code page, so we can test it.

From what we can see in the Response view, we have the right answers being returned, but, in our example, we will only need company.id and the token code in order to create a sale object in the right way, thus, we have to manipulate data:

On the code tab, we specify what is our desired return, then we test it to make sure we have it.

After doing this, we have to specify another PDVend's resource, which is the endpoint responsible for creating the Sale object. In this API's case, the endpoint's name is companies/{company_uuid}/sales, using the post method. Just like the resource we configured in our previous step, we can insert the credentials to test and make sure the returned information is correct.

With those two resources created, we end the Component's creation part, so we save it and move on to the Project's creation.

    1. In the Build menu, select the Projects option, and choose New Project. On this step, you should choose which Components will be used, in our case, we will use only PDVend's one. Then, you have to name your project and end it by saving it.
  1. Now we have to set the needed automation for building this example, which is the creation of sale objects inside PDVend. On the automations menu, there is an editable example, which we can name createSaleOnPdvend, and that will serve as PDVend's data updating.

  2. For this case, we need to have an UniqueKey in order to know what information is being processed in LinkApi's platform. To build it, you can use linkapi.transaction.start from the snippets menu, in the upper right corner.

  3. We will need another snippet from the menu, which is the trace method. We can paste it and specify which data we need:

  1. Now, we have to consume PDVend's login snippet, that we set on a previous step. In your Component's menu, on the right side, you copy this resource's snippet and paste it.

  2. Specifying the expected data, we can use another trace.

  1. The last step regarding the project's building, we can use linkapi.transaction.success snippet. You can paste it after the previous and save the project using *commit project, then publishing it.

Just create the Job to run and you're ready.