Implement API Namespaces

Operations

In API namespaces only operations are needed to be implemented. The implementation of an operation is similar to the implementation of a service. An example of the structure of the operation is shown below:
// Get path parameter
const pathParameter =  this.request.path.pathParamName;

// Get query parameter
const queryParameter =  this.request.query.queryParamName;

// Get the request body 
const body = this.request.body;

// If body is of primitive type schema
const primitiveSchemaBody = body;

// If body is of complex type schema
const complexSchemaBody1 = body.property1;
const complexSchemaBody2 = body.property2;

// Call a service
// Initialize the input entity of a service
const input =  this.factory.entity.ServiceIdentifier_Input();
 
// Initialize the value of the input property
input.property1 = complexSchemaBody1; 

// Call service and pass as input the input entity created above
const serviceOutput = await this.services.order.ServiceIdentifier(input); 

// Set the response status to 200. The status can take only the values modelled in the Designer
this.response.status = 200;

// Set the response body 

// If the body is complex
// Initialize the response body type
this.response.body  = this.factory.schema.SchemaIdentifier();
// Initialize the response body properties
this.response.body.property1 = serviceOutput.output.property1;
this.response.body.property2 = serviceOutput.output.property2;
this.response.body.property3 = serviceOutput.output.property3;
this.response.body.property4 = serviceOutput.output.property4;
this.response.body. property5 = serviceOutput.output.property5;

// If the body is primitive
// Initialize the response body 
this.response.body = serviceOutput.output.property1;