Implement Integration Namespaces
REST Services
REST Integration services are used to integrate the external API with the current solution. The external API could be integrated by adding the specification as an API dependency or not.
An example of the implementation of a REST service which is called
GetExternalCustomer and belongs to the integration namespace cus
will
follow.
// Make a HTTP request to an operation. The path and query pathParmamidentifier must 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>".Use API Binding CA value to make external requests using request utility
When creating external calls to APIs you can retrieve the API binding option and if
it contains 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});
}
Use API Binding CA value when making 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.