Making API calls in Order Hub
Use the different helper services provided by the Order Hub libraries to communicate with the OMS environment, the IV and SIP tenants. By using these helpers, you will not need to deal with authentication and other communication aspects that you would otherwise have to by using the basic HttpClient Angular interface. Order Hub is designed to call REST APIs using the JSON notation.
Invoking OMS APIs
BucCommOmsRestAPIService
using the following
function:invokeOMSRESTApi(api, data, params): Observable<any>
- api
- The name of the API. For example,
getOrderList
,getItemList
, etc. - data
- The input JSON expected by the API.
- params
- Other parameters supported by Order Hub, such as caching parameters.
BucCommOmsRestAPIService.invokeOMSRESTApi('getItemPrice', payLoad, null);
As a reference, the following tutorial invokes OMS APIs: Tutorial: Customizing the Schedule order action.
Invoking OMS services
BucCommOmsRestAPIService
by using another
function:invokeOMSCustomService(api, data, params, customHeaders?: any): Observable<any>
- api
- The name of the API. For example,
getOrderList
,getItemList
, etc. - 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.
BucCommOmsRestAPIService.invokeOMSCustomService('RequestForReassignOrderRelease', orderReleaseInput, null, customHeaders);
Invoking IV and SIP APIs
To make REST calls to IV and SIP, you can check if 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.
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$;
}
- 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.
- 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.