@sap/subaccount-destination-service-provider
Version:
Provide service consumption of SAP subaccount services
77 lines • 3.77 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.SubaccountDestinationProviderSystemBusiness = void 0;
const service_provider_apis_1 = require("@sap/service-provider-apis");
const messages_1 = require("../../i18n/messages");
const retrieverUtils_1 = require("../utils/retrieverUtils");
class SubaccountDestinationProviderSystemBusiness {
constructor(name, url, dataType, proxyType, authType, product, description, abapBusinessRetrieverRepository) {
this.logger = service_provider_apis_1.DefaultLogger;
this.name = name;
this.url = url;
this.dataType = dataType;
this.proxyType = proxyType;
this.authenticationType = authType;
this.product = product;
this.description = description;
this.repository = abapBusinessRetrieverRepository;
}
getBOs(options) {
return __awaiter(this, void 0, void 0, function* () {
try {
this.validateDataType();
return yield this.repository.abapRetrieverBo.retrieveBusinessItems(this.name, options === null || options === void 0 ? void 0 : options.credentials);
}
catch (e) {
(0, retrieverUtils_1.handleProviderError)(e, messages_1.messages.ERROR_FAILED_TO_GET_BOS, this.logger);
}
});
}
getCDS(options) {
return __awaiter(this, void 0, void 0, function* () {
try {
this.validateDataType();
return yield this.repository.abapRetrieverCds.retrieveBusinessItems(this.name, options === null || options === void 0 ? void 0 : options.credentials);
}
catch (e) {
(0, retrieverUtils_1.handleProviderError)(e, messages_1.messages.ERROR_FAILED_TO_GET_CDS, this.logger);
}
});
}
getSpecBo(businessItemId) {
return __awaiter(this, void 0, void 0, function* () {
try {
return yield this.repository.abapRetrieverBo.retrieveSpecBusinessItem(businessItemId);
}
catch (e) {
(0, retrieverUtils_1.handleProviderError)(e, messages_1.messages.ERROR_FAILED_TO_GET_BO_SPEC(businessItemId), this.logger);
}
});
}
getSpecCds(businessItemId) {
return __awaiter(this, void 0, void 0, function* () {
try {
return yield this.repository.abapRetrieverCds.retrieveSpecBusinessItem(businessItemId);
}
catch (e) {
(0, retrieverUtils_1.handleProviderError)(e, messages_1.messages.ERROR_FAILED_TO_GET_CDS_SPEC(businessItemId), this.logger);
}
});
}
validateDataType() {
if (this.dataType !== service_provider_apis_1.DataType.CATALOG) {
throw new Error(messages_1.messages.ERROR_UNSUPPORTED_BUSINESS_ITEMS_PROVIDER());
}
}
}
exports.SubaccountDestinationProviderSystemBusiness = SubaccountDestinationProviderSystemBusiness;
//# sourceMappingURL=subaccountDestinationProviderSystemBusiness.js.map