UNPKG

fsm-sdk

Version:

Node.JS sdk to interface with SAP Field Service Management APIs.

167 lines (166 loc) 8.01 kB
import { ClientConfig } from "../client-config.model"; import { DataCloudDTOModels, DataCloudDTOName } from "./dto-name.model"; import { HttpService } from "../http/http-service"; import { OAuthService } from "../oauth/oauth.service"; import { BatchAction } from "./batch/batch-action.model"; import { BatchResponseJson } from "./batch/batch-response"; import { DataApiResponse } from "./data/data-api.model"; /** * Data Service API (Data Cloud) - Legacy service for CRUD operations. */ export declare class DataServiceAPIService { private _config; private _http; private _auth; private _dataApi; private _queryAPi; private _batchApi; constructor(_config: Readonly<ClientConfig>, _http: Readonly<HttpService>, _auth: Readonly<OAuthService>); /** * Here, you can input and execute the CoreSQL query. * * @deprecated Use Service Management API for service calls and activities instead. * @param coreSQL valid CoreSQL * @param dtoNames DTOName[] * @returns Promise<{ data: DTO[] }> * @see https://help.sap.com/viewer/fsm_query_api/Cloud/en-US/query-api-intro.html */ query<T extends { [projection: string]: DataCloudDTOModels; }>(coreSQL: string, dtoNames: DataCloudDTOName[]): Promise<{ data: T[]; }>; /** * Retrieving Lists of Objects by Id * * @deprecated Use Service Management API for service calls and activities instead. * @param resourceName DTOName * @param resourceId uuid as string * @returns Promise<ClientResponse<DTO>> * @see https://help.sap.com/viewer/fsm_data_api/Cloud/en-US */ getById<T extends DataCloudDTOModels>(resourceName: DataCloudDTOName, resourceId: string): Promise<DataApiResponse<T>>; /** * Retrieving Lists of Objects by ExternalId * * @deprecated Use Service Management API for service calls and activities instead. * @param resourceName DTOName * @param externalId externalId as string * @returns Promise<ClientResponse<DTO>> * @note [useExternalIds=true] option will be used. Referenced resources will be objects containing id and externalId if present: `{ id: string, externalId?: string } | null` * @see https://help.sap.com/viewer/fsm_data_api/Cloud/en-US */ getByExternalId<T extends DataCloudDTOModels>(resourceName: DataCloudDTOName, externalId: string): Promise<DataApiResponse<T>>; /** * Deletes Existing Object by Id * * @deprecated Use Service Management API for service calls and activities instead. * @param resourceName DTOName * @param resource { id: string, lastChanged: number } * @returns Promise<undefined> * @see https://help.sap.com/viewer/fsm_data_api/Cloud/en-US */ deleteById<T extends Partial<DataCloudDTOModels> & { id: string; lastChanged: number; }>(resourceName: DataCloudDTOName, resource: T): Promise<undefined>; /** * Deletes Existing Object by ExternalId * * @deprecated Use Service Management API for service calls and activities instead. * @param resourceName DTOName * @param resource { externalId: string, lastChanged: number } * @returns Promise<undefined> * @see https://help.sap.com/viewer/fsm_data_api/Cloud/en-US */ deleteByExternalId<T extends Partial<DataCloudDTOModels> & { externalId: string; lastChanged: number; }>(resourceName: DataCloudDTOName, resource: T): Promise<undefined>; /** * Creating Objects by Id * * @deprecated Use Service Management API for service calls and activities instead. * @param resourceName DTOName * @param resource should contain in the body the ENTIRE updated resource * @returns Promise<ClientResponse<DTO>> * @see https://help.sap.com/viewer/fsm_data_api/Cloud/en-US */ post<T extends DataCloudDTOModels>(resourceName: DataCloudDTOName, resource: T): Promise<DataApiResponse<T>>; /** * Creating Objects by ExternalId * * @deprecated Use Service Management API for service calls and activities instead. * @param resourceName DTOName * @param resource should contain in the body the ENTIRE updated resource * @returns Promise<ClientResponse<DTO>> * @note [useExternalIds=true] option will be used. Referenced resources will be objects containing id and externalId if present: `{ id: string, externalId?: string } | null` * @see https://help.sap.com/viewer/fsm_data_api/Cloud/en-US */ postByExternalId<T extends DataCloudDTOModels>(resourceName: DataCloudDTOName, resource: T): Promise<DataApiResponse<T>>; /** * Updating Existing Objects by Id * * @deprecated Use Service Management API for service calls and activities instead. * @param resourceName resourceName * @param resource should contain in the body the ENTIRE updated resource * @returns Promise<ClientResponse<DTO>> * @see https://help.sap.com/viewer/fsm_data_api/Cloud/en-US */ put<T extends DataCloudDTOModels>(resourceName: DataCloudDTOName, resource: T): Promise<DataApiResponse<T>>; /** * Updating Existing Objects by ExternalId * * @deprecated Use Service Management API for service calls and activities instead. * @param resourceName resourceName * @param resource should contain in the resource the ENTIRE updated resource * @returns Promise<ClientResponse<DTO>> * @note [useExternalIds=true] option will be used. Referenced resources will be objects containing id and externalId if present: `{ id: string, externalId?: string } | null` * @see https://help.sap.com/viewer/fsm_data_api/Cloud/en-US */ putByExternalId<T extends DataCloudDTOModels & { externalId: string; }>(resourceName: DataCloudDTOName, resource: T): Promise<DataApiResponse<T>>; /** * Updating Existing Objects by Id * * @deprecated Use Service Management API for service calls and activities instead. * @param resourceName resourceName * @param resource should contain in the body the [id] & [FIELDS THAT YOU WANT TO UPDATE] * @returns Promise<ClientResponse<DTO>> * @see https://help.sap.com/viewer/fsm_data_api/Cloud/en-US */ patch<T extends DataCloudDTOModels>(resourceName: DataCloudDTOName, resource: T): Promise<DataApiResponse<T>>; /** * Updating Existing Objects by ExternalId * * @deprecated Use Service Management API for service calls and activities instead. * @param resourceName resourceName * @param resource should contain in the resource the [externalId] & [FIELDS THAT YOU WANT TO UPDATE] * @returns Promise<ClientResponse<DTO>> * @note [useExternalIds=true] option will be used. Referenced resources will be objects containing id and externalId if present: `{ id: string, externalId?: string } | null` * @see https://help.sap.com/viewer/fsm_data_api/Cloud/en-US */ patchByExternalId<T extends DataCloudDTOModels & { externalId: string; }>(resourceName: DataCloudDTOName, resource: T): Promise<DataApiResponse<T>>; /** * Batch request with transactional support * * @deprecated Use Service Management API for service calls and activities instead. * @param actions BatchAction | CreateAction | UpdateAction | DeleteAction * @returns Promise<BatchResponseJson<T>[]> * @example * ```typescript * const actions = [ * new CreateAction('ServiceCall', { ... }), * new UpdateAction('ServiceCall', { id, lastChanged ... }), * new DeleteAction('ServiceCall', { id, lastChanged ... }) * ]; * await client.dataServiceAPI.batch(actions) * ``` * @note Requests will be executed in order of the actions array. * @see https://help.sap.com/viewer/fsm_data_api/Cloud/en-US/batch-api-intro.html */ batch<T extends DataCloudDTOModels>(actions: BatchAction[]): Promise<BatchResponseJson<T>[]>; }