Making API calls in Order Hub

Use the helper services that the Order Hub libraries provide to communicate with OMS, Inventory Visibility (IV), and IBM® Sterling™ Intelligent Promising (SIP) tenants. These helper services simplify API communication by automatically handling authentication and other connection requirements when you call REST APIs that use JSON.

Invoking OMS APIs

OMS APIs can be called by using the Order Hub helper service BucCommOmsRestAPIService using the following function:
invokeOMSRESTApi(api, data, params): Observable<any>
Where:
api
The name of the API. For example, getOrderList, getItemList, and so forth.
data
The input JSON expected by the API.
params
Other parameters supported by Order Hub, such as caching parameters.
For example:
BucCommOmsRestAPIService.invokeOMSRESTApi('getItemPrice', payLoad, null);

As a reference, the following tutorial invokes OMS APIs: Tutorial: Customizing the Schedule order action.

Invoking OMS services

OMS services can be called by using the same Order Hub helper service BucCommOmsRestAPIService by using another function:
invokeOMSCustomService(api, data, params, customHeaders?: any): Observable<any>
Where:
api
The name of the API. For example, getOrderList, getItemList, and so on.
data
The input JSON expected by the API.
params
Other parameters supported by Order Hub, such as caching parameters.
customHeaders
Any extra custom headers that need to be added to the request header.
For example:
BucCommOmsRestAPIService.invokeOMSCustomService('RequestForReassignOrderRelease', orderReleaseInput, null, customHeaders);

Invoking IV and SIP APIs

To make REST calls to IV and SIP, you can check whether Order Hub already has helper services for the particular service. If not, you can create a new Angular service with a simple function to call the API.

For example:
public getNodeTypes(): Observable<any> {
        const resourceDomain = 'promising';
        const domain = BucCommBEHttpWrapperService.getPathPrefix(resourceDomain);
        const options = BucCommBEHttpWrapperService.getRequestOptions(resourceDomain);
        const tenantId = BucSvcAngularStaticAppInfoFacadeUtil.getPromisingTenantId();
        let path = '/{tenantId}/v1/nodeTypes';
        const queryParameters: any = {}
    
        path = path.replace('{tenantId}', tenantId);

        if (tenantId === undefined) {
            return throwError(new Error('Missing required  parameter: tenantId'));
        }
        const url = domain + path;
        const p: HttpParams = RestServicesHelper.getSupplyDemandParameters(queryParameters);
        const obsToReturn$ = this.http.get(url, resourceDomain, p, options);
        return obsToReturn$;
    }
Where there are two values to adjust from the preceding sample snippet:
  1. The Order Hub libraries can set up the proper domain and authentication headers for making http requests to the respective SIP micro services by using the resource domain.
    Accepted resource domain values are:
    cas
    Gets the tenant authentication headers for communicating with SIP carrier micro services.
    catalog
    Gets the tenant authentication headers for communicating with SIP catalog micro services.
    configuration
    Gets the tenant authentication headers for communicating with SIP configuration micro services.
    inventory
    Gets the tenant authentication headers for communicating with IV micro services.
    inventory_buc
    Gets the tenant authentication headers for communicating with IV micro services that are intended for specific Order Hub screens.
    promising
    Gets the tenant authentication headers for communicating with SIP promising micro services.
  2. Set the path to be the relative REST API path of the micro service that you are trying to invoke.

The rest of the function from the example can be left as-is.

As a reference, the following tutorial invokes IV and SIP APIs: Tutorial: Customizing the Inventory search results page.