Implement Integration Namespaces

REST Services

REST Integration Services are used to integrate an external API with the current project.

Note: The external API could be integrated by adding the specification as an API dependency or not.

Below is an example of the implementation of a REST service which is called GetExternalCustomer and belongs to the Integration Namespace cus.

// Make an HTTP request to an operation. The path and query parameters must have the same types
// and name as they are defined in the API dependency specification.
    const response = await this.apis.apiDependencyName.OperationId({pathParmamidentifier: “value1”});
    
    // Check whether the call was successful and, if it is, give the name of the customer as output
    if (response.status === 200) {
    // Initialize the output entity
    this.output = this.factory.entity.cus.RestServiceIdentifier_Output();
    // Initialize the output property
    this.output.property1 = response.body.property1;
Attention: Properties of type String with format Date must be initialized like this: strProperty = "2019-09-01". Additionally, properties of type String with format Date-Time must be initialized like this: strProperty = new Date("2019-09-01").toISOString(). Where the date structure is strictly "<year>-<month>-<day>".

Make External Requests using Request Utility

When creating external calls to APIs you can retrieve the API Binding option and if it contains a ca_cert property, you can use it to construct an SSLConfig object that can be used when making external API calls.

public async execute(): Promise<void> {          
    // get binding of petstore API
    const apiBinding = await this.apiBindings.getPetstore();
    
    // make the request using the custom ca_cert defined in the api binding
    await this.util.request.get('www.google.com', {param1: 'val'}, {header1: 'val'}, { ca_cert: bind.ca_cert});
}

Make API Facade Operations Calls

If your API Dependency's API Binding already contains ca_cert value, then this ca_cert value will be implicitly used to make external API facade operation calls.