fsm-sdk
Version:
Node.JS sdk to interface with SAP Field Service Management APIs.
213 lines • 9.78 kB
JavaScript
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DataServiceAPIService = void 0;
const batch_api_service_1 = require("./batch/batch-api.service");
const data_api_service_1 = require("./data/data-api.service");
const query_api_service_1 = require("./query/query-api.service");
/**
* Data Service API (Data Cloud) - Legacy service for CRUD operations.
*/
class DataServiceAPIService {
constructor(_config, _http, _auth) {
this._config = _config;
this._http = _http;
this._auth = _auth;
this._dataApi = new data_api_service_1.DataApiService(this._config, _http, this._auth);
this._queryAPi = new query_api_service_1.QueryApiService(this._config, _http, this._auth);
this._batchApi = new batch_api_service_1.BatchAPIService(this._config, _http, this._auth);
}
/**
* 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(coreSQL, dtoNames) {
return __awaiter(this, void 0, void 0, function* () {
return this._queryAPi.query(coreSQL, dtoNames);
});
}
/**
* 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(resourceName, resourceId) {
return __awaiter(this, void 0, void 0, function* () {
return this._dataApi.getById(resourceName, { resourceId });
});
}
/**
* 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(resourceName, externalId) {
return __awaiter(this, void 0, void 0, function* () {
return this._dataApi.getById(resourceName, { externalId }, { useExternalIds: true });
});
}
/**
* 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(resourceName, resource) {
return __awaiter(this, void 0, void 0, function* () {
const { id, lastChanged } = resource;
return this._dataApi.deleteById(resourceName, { resourceId: id }, lastChanged);
});
}
/**
* 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(resourceName, resource) {
return __awaiter(this, void 0, void 0, function* () {
const { externalId, lastChanged } = resource;
return this._dataApi.deleteById(resourceName, { externalId }, lastChanged);
});
}
/**
* 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(resourceName, resource) {
return __awaiter(this, void 0, void 0, function* () {
return this._dataApi.post(resourceName, resource);
});
}
/**
* 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(resourceName, resource) {
return __awaiter(this, void 0, void 0, function* () {
return this._dataApi.post(resourceName, resource, { useExternalIds: true });
});
}
/**
* 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(resourceName, resource) {
return __awaiter(this, void 0, void 0, function* () {
return this._dataApi.put(resourceName, { resourceId: resource.id }, resource);
});
}
/**
* 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(resourceName, resource) {
return __awaiter(this, void 0, void 0, function* () {
return this._dataApi.put(resourceName, { externalId: resource.externalId }, resource, { useExternalIds: true });
});
}
/**
* 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(resourceName, resource) {
return __awaiter(this, void 0, void 0, function* () {
return this._dataApi.patch(resourceName, { resourceId: resource.id }, resource);
});
}
/**
* 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(resourceName, resource) {
return __awaiter(this, void 0, void 0, function* () {
return this._dataApi.patch(resourceName, { externalId: resource.externalId }, resource, { useExternalIds: true });
});
}
/**
* 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(actions) {
return __awaiter(this, void 0, void 0, function* () {
return this._batchApi.batch(actions);
});
}
}
exports.DataServiceAPIService = DataServiceAPIService;
//# sourceMappingURL=data-service.service.js.map