Skip to content

Utility class

Create utility class

  • Click Add class(+) button, and give the path and utility class name to save the new utility.
  • Make sure the name of the utility class is unique and always start with a capital letter.

You will get a sample code below.

class Calculator {
    add(x: number, y: number) {
        return x + y;
    multi(x: number, y: number) {
        return x * y;
let temp = new Calculator();
export = temp;

Import utility classes

  • Import utility classes in code and use their function.
import * as T from 'types';
import * as calc from 'utils/Calculator'
async function main(g: T.IAMGlobal) {
    let sum = calc.add(3, 6);
    let mult = calc.multi(3, 6);
    return {sum, mult}
module.exports = main;

Interface in utility class

  • Create interfaces in utility classes. API Maker can use that interfaces in Custom API, Third Party API, and every place where we can import utility class.

Sample code for interfaces.

class Inf {
let temp = new Inf();
export interface IUserP {
    firstName: string;
    lastName: string;
    phone: number;

Import the above utility class in custom API and use its interfaces.

import * as T from 'types';
import * as inf from 'utils/Inf';
async function main(g: T.IAMGlobal) {
    const data: inf.IUserP = {
        firstName: "John",
        lastName: "Doe",
        phone: 123456789
    return data
module.exports = main;

Versions of utility classes

  • Users can create multiple versions of the utility class. Each version has a different code.
  • At a time only one version can be activated. The activated version's functions are used in imported utility classes.
  • Activate any utility version code at any time. Its functions use instantly.