Skip to content

Phase 2 — Enrich Data

Time to complete: ~15 minutes

Overview: In this phase, you’ll extend the workflow created in Phase 1 and enrich its output with stock levels fetched from the Demo Inventory API. The result will be a workflow that combines product and inventory data into one output.

Completed Phase 2 Workflow A view of the completed Phase 2 workflow.

Steps

  1. In this step, you will use Martini Designer's built-in HTTP Client to consume the Get SKU operation of the Demo Inventory API and export it as a service. The process is the same as Step 3 from Phase 1. The same process is repeated here with the variables required for the Demo Inventory API. To consume the API in Martini's HTTP Client:

    • Open the HTTP Client by clicking the HTTP icon in the left-hand navigation bar.
    • Start a new request by clicking the + button in the HTTP Client toolbar.
    • Enter the following values in the HTTP request editor:
      • Method: GET
      • URL: https://demo-api.apiexplorer.io/api/lonti_demo_api_inventory/1.0/sku/product_code/{productCode} Enter URL of Get SKU by Product Code endpoint of Demo Inventory API
    • Under the Authentication tab enter the following values:
      • Authentication: OAuth 2.0
      • Access Token: <paste the token from Phase1, Step 1>
    • Under the Parameters tab enter the following values:
      • productCode: SKU001 (note that the value is case sentitive)
    • Click Send to execute the request.
    • Expected output:
      • Status: 200
      • Body: <a JSON object containing a SKU>

    The object below is a representative element of a SKU returned:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    {
    "result": "OK",
    "message": "OK",
    "warnings": [],
    "sku": {
       "sku_id": 1,
       "sku_name": "Chisel Wood 6mm",
       "product_code": "SKU001",
       "barcode": 12345678,
       "stock_in": 383,
       "stock_out": 192,
       "stock_on_hand": 191,
       "stock_reserved": 0,
       "stock_available": 191,
       "modified_date": "2025-09-08T00:00:04+0000",
       "created_date": "2025-09-08T00:00:04+0000"
       }
    }
    
  2. In this step, you will save the HTTP Client request from Step 1 as a reusable service. Services can be included as a step within a workflow or can be configured as a handler for an API operation. To save the HTTP Client request and export it as a service:

    • With the HTTP Client request tab still active, click Save in the main toolbar.
    • Enter any name for the request (or accept the default) and click Save.
    • The saved request will appear under the User Requests in the HTTP Client panel. Right-click it and select Export → Service.
    • Use the Browse button to select the Package my-first-project.
    • Name the service GetInventorySkuByProductCode, click Next, accept the defaults, then click Finish.
  3. In this step, you will create a new output model for the workflow that includes additional properties for the stock levels that will be returned by the Demo Inventory API. To create a new output model for the workflow:

    • Click on the Input/Output icon in the workflow editor toolbar for the MyFirstWorkflow workflow.
    • The mapper displays a single column for the Inputs to the Workflow and a single column for the Outputs from the Workflow. We will duplicate the existing skuArray data model and add properties to the new model. To do that right-click the skuArray model and select Copy then right-click anywhere thereunder and select Paste. The duplicated model will be called skuArray1, rename it by right-clicking it, selecting Rename, and entering skuArrayWithStockAvailable. Duplicate the data model skuArray and name the new model skuArrayWithStockAvailable
    • Add the following property to the new data model skuArrayWithStockAvailable by selecting it and clicking the + icon in the Output toolbar. Select the Type = Integer and name the property stockAvailable. Add a property to the model skuArrayWithStockAvailable of type Integer called stockAvailable
  4. In this step, you will start building out the rest of our workflow. As the output from the GetAllEcommerceSku service is an array we will add a Repeat node to the workflow to iterate over its output. To iterate over the results of a previous node:

    • Click the + icon in the toolbar of the workflow editor for the MyFirstWorkflow workflow.
    • Drag the Repeat node onto the workflow editor canvas and drop it next to the Invoke GetAllEcommerceSku node. Then click the x icon to close the modal.
    • If placed correctly, it should draw a line connecting the two nodes automatically. If not then simply connect the two nodes by dragging the output arrow of the Invoke GetAllEcommerceSku node to the input arrow of the Repeat node.
    • Click the expand icon on the Repeat node to set the Input and Output Arrays as follows: Input Array: skuArray Output Array: skuArrayWithStockAvailable Then click the x icon to close the modal. Configure the input and output arrays in the Repeat node
  5. In this step, you will map the output from the GetAllEcommerceSku service to the new data model skuArrayWithStockAvailable. To map the output from the previous Repeat node:

    • Click the + icon in the toolbar of the workflow editor.
    • Drag the Map node onto the workflow editor canvas and drop it next to the Repeat node. Then click the x icon to close the modal.
    • Connect the two nodes by dragging the output arrow labelled each of the Repeat node to the input arrow of the Map node.
    • Click the expand icon on the Map node to open the input/output mapper.
    • Drag the input skuArray to the output skuArrayWithStockAvailable. A line will be drawn on the connecting the two data models. All of the values from the input will now be mapped to the output with the corresponding property.
    • Click the x icon to close the mapper. Map skuArray to skuArrayWithStockAvailable
  6. In this step, you will include the GetInventorySkuByProductCode service that you created in Step 2 into your workflow. To include the service:

    • Locate the GetInventorySkuByProductCode service in your package my-first-project, drag it onto the workflow editor indicated by the tab labeled MyFirstWorkflow, and drop it next to the Map node.
    • If placed correctly, it should draw a line connecting the two nodes automatically. If not then simply connect the two nodes by dragging the output arrow of the Map node to the input arrow of the node labelled Invoke GetInventorySkuByProductCode.
  7. In this step, you will configure the inputs and outputs of the Invoke GetInventorySkuByProductCode service. To configure the inputs and outputs of the service:

    • Expand the skuArray model in the Input panel then drag its property productCode to the input product_code. This will take the value of the productCode returned by the GetAllEcommerceSku service and map it to the input variable product_code of the GetInventorySkuByProductCode service. Map productCode to product_code in the input of the GetInventorySkuByProductCode service
    • Expand the GetInventorySkuByProductCodeOutput data model and the sku object thereunder in Output panel.
    • Expand the skuArrayWithStockAvailable data model in the Output panel.
    • Drag the property stock_available to stockAvailable. This will take the value stock_available returned by the GetInventorySkuByProductCode service and map it to your enriched skuArrayWithStockAvailable data model. Map stock_available to stockAvailable in the output of the GetInventorySkuByProductCode service
  8. Run your workflow to verify its output. To run your workflow:

    • Click the Run button in the workflow editor toolbar. Accept the defaults and click Run.
    • Expected output in the Console:
      • Logs tab: <Output available, click the Output tab to view it>
      • Output tab: Expand the tree skuArrayWithStockAvailable[0][n]

    The object below is a representative element of the list/array of SKUs returned:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    {
      "skuId": 1,
      "name": "Chisel Wood 6mm",
      "productCode": "SKU001",
      "productVariant1": "Wood",
      "productVariant2": "6mm",
      "price": 13,
      "createdDate": "2025-08-12T02:30:21+0000",
      "modifiedDate": "2025-08-12T02:30:21+0000",
      "itemId": 1,
      "stockAvailable": 191
    }
    

What’s next: In Phase 3 you’ll learn how to store data in a database.