UNPKG

@sap_oss/wdio-qmate-service

Version:

[![REUSE status](https://api.reuse.software/badge/github.com/SAP/wdio-qmate-service)](https://api.reuse.software/info/github.com/SAP/wdio-qmate-service)[![Node.js CI](https://github.com/SAP/wdio-qmate-service/actions/workflows/node.js.yml/badge.svg)](http

227 lines (226 loc) 11.1 kB
interface IHeaders { [key: string]: string; } interface IParams { [key: string]: string; } /** * @class odata * @memberof service */ export declare class OData { readonly utilModule: any; readonly urlLib: any; readonly axios: any; Service: any; constructor(); /** * @function init * @memberOf service.odata * @description Initializes the OData Service. * XCSRF-Token will be automatically fetched and stored in the service instance. * Cookies will also automatically assembled and stored in the service instance. * @param {String} url - The base url of the service. * @param {String} username - The username to authenticate the service. * @param {String} password - The password of the username. * @param {Boolean} [loggingEnabled=false] - The boolean param to control whether user wants to see logs during build run. * @param {Object} [params={}] - JSON object with key-value pairs of parameter names and corresponding values. * By default we send { * "client": "715", * "documentation": ["heading", "quickinfo"], * "language": "EN" * } * These can be overridden by sending params as JSON object with additional params as shown in example. * @param {String} [authType] - authentication type, in case you want to override the default * SAML authentication. Set this to "basic", to use basic authentication for communication users for whom SAML login doesn't work. * Or "none" for no authentication. * @param {Object} [headers=undefined] - JSON object with key-value pairs of optional headers. * @returns {Object} The initialized service object. * @example const url = "<urlToSystem>/sap/opu/odata/sap/API_PURCHASEORDER_PROCESS_SRV/"; * const params = { * "saml2": "disabled", * "language": "de" * } * const srv = await service.odata.init(url, user, password, false, params); * @example const base64Credentials = Buffer.from(`${user}:${password}`).toString("base64"); * const authHeaders = { * "Authorization": `Basic ${base64Credentials}`, * "DwC-Tenant": tenant * }; * * const srv = await service.odata.init(url, user, password, true, params, "headers", authHeaders); */ init(url: string, username: string, password: string, loggingEnabled?: boolean, params?: {}, authType?: string, headers?: any): Promise<any>; /** * @function get * @memberOf service.odata * @description Sends a GET request to retrieve data from the specified OData entity set. * @param {Object} srv - An instance of the service. * @param {String} entitySet - The entity set from which data is to be retrieved. * @param {Object} keys - The required keys for the GET request. * @param {Boolean} [raw=false] - Specifies whether the response should include all header contents. * @param {Object} [headers] - Optional headers to be included in the request. * @param {Object} [queryParams] - JSON object of key value pairs of custom query parameters. * @returns {Promise} A Promise that resolves to the response data. * @example const url = "<baseUrl>/sap/opu/odata/sap/API_PURCHASEORDER_PROCESS_SRV/"; * const srv = await service.odata.init(url, user, password); * const keys = { * PurchaseOrder: "4100000000" * }; * const queryParams = { * "$top" : 5, * "$skip" : 10, * }; * const headers = { * 'X-Custom-Header': 'foobar' * } * const res = await service.odata.get(srv, "A_PurchaseOrder", keys, false, headers, queryParams); */ get(srv: any, entitySet: string, keys: any, raw?: boolean, headers?: IHeaders, queryParams?: any): Promise<any>; /** * @function getEntitySet * @memberOf service.odata * @description GET's the EntitySet collection. * @param {Object} srv - Instance of the service * @param {String} entitySet - The entitySet you want to GET from. * @param {String} [filterString] - The filters to be applied on get query * @param {String} [selectionFields] - comma separated list of fields to be selected * @param {Object} [queryParams] - JSON object of key value pairs of custom query parameters. * @returns {Promise} A Promise that resolves to the response data. * @example * const url = "<baseUrl>/sap/opu/odata/sap/API_PURCHASEORDER_PROCESS_SRV/"; * srv = await service.odata.init(url, user, password); * * let filterString = "Status eq '01'"; * let res = await service.odata.getEntitySet(srv, "A_PurchaseOrder", filterString); * * let select = "CentralPurchaseContract,PurchasingProcessingStatus" ; * let res = await service.odata.getEntitySet(srv, "A_PurchaseOrder", filterString, select); * * let queryParams = { * "$top" : 5, * "$skip" : 10, * }; * let res = await service.odata.getEntitySet(srv, "A_PurchaseOrder", filterString, select, queryParams); */ getEntitySet(srv: any, entitySet: string, filterString?: string, selectionFields?: string, queryParams?: any): Promise<any>; /** * @function post * @memberOf service.odata * @description Sends a POST request to retrieve data from the specified OData entity set for the given payload. * @param {Object} srv - Instance of the service * @param {String} entitySet - The entitySet you want to POST against. * @param {Object} payload - The payload of the POST request. * @param {Boolean} [raw=false] - Specifies whether the response should include all header contents. * @param {Object} [headers] - Optional headers to be included in the request. * @param {Object} [queryParams] - JSON object of key value pairs of custom query parameters. * @returns {Promise} A Promise that resolves to the response data. * @example * const payload = { * "PurchaseOrder": "4500007108", * "DraftUUID": "00000000-0000-0000-0000-000000000000", * "IsActiveEntity": "true" * }; * const res = await service.odata.post(srv, "A_PurchaseOrder", payload); */ post(srv: any, entitySet: string, payload: any, raw?: boolean, headers?: IHeaders, queryParams?: any): Promise<any>; /** * @function merge * @memberOf service.odata * @description @description Sends a MERGE request to merge data from the specified OData entity set for the given payload. * @param {Object} srv - Instance of the service * @param {String} entitySet - The entitySet you want to MERGE in. * @param {Object} payload - The payload of the MERGE request. * @param {Object} [headers] - Optional headers to be included in the request. * @returns {Promise} A Promise that resolves to the response data. * @example * const res = await service.odata.merge(srv, "A_PurchaseOrderScheduleLine", { * "PurchasingDocument": "4500007108", * "PurchasingDocumentItem": "10", * "ScheduleLine": "1", * "ScheduleLineDeliveryDate": new Date() * }; */ merge(srv: any, entitySet: string, payload: any, headers?: IHeaders): Promise<any>; /** * @function delete * @memberOf service.odata * @description Sends a DELETE request to the specified OData entity set. * @param {Object} srv - Instance of the service. * @param {String} entitySet - The entitySet you want to DELETE. * @param {Object} options - The options for the DELETE request. * @param {Object} [headers] - Optional headers to be included in the request. * @returns {Promise} A Promise that resolves to the response data. * @example * const options = { * "PurchaseOrder": "", * "DraftUUID": draftUUID, * "IsActiveEntity": false * }; * const res = await service.odata.delete(srv, "C_PurchaseOrderTP", options); */ delete(srv: any, entitySet: string, options: any, headers?: IHeaders): Promise<any>; /** * @function callFunctionImport * @memberOf service.odata * @description Sends a function import request to the OData service instance. * @param {Object} srv - Instance of the service. * @param {String} functionImportName - Name of Function Import. * @param {Object} options - Parameters for function import. * @returns {Promise} A Promise that resolves to the response data. * @example * const options = { * CentralRequestForQuotation : "7500000026", * Supplier : "100006" * }; * const res = await service.odata.callFunctionImport(srv, "Cancel", options); */ callFunctionImport(srv: any, functionImportName: string, options: any): Promise<any>; /** * @function isFeatureToggleActivated * @memberOf service.odata * @description Checks if a feature toggle is switched on or off. * @param {Object} srv - Instance of the service * @param {String} featureName - The name of the feature you want know the status of. * @returns {Promise} A Promise that resolves to a bool value. * @example const url = browser.params.systemUrl + "/sap/opu/odata/SAP/CA_FM_FEATURE_TOGGLE_STATUS_SRV/"; * const srv = await service.odata.init(url, user, password); * let isFeatureActive = await service.odata.isFeatureToggleActivated(srv, "MM_PUR_PO_BATCHES_IN_MANAGE_PO"); */ isFeatureToggleActivated(srv: any, featureName: string): Promise<boolean>; /** * @function getOutputManagementPdfStream * @memberOf service.odata * @description returns a stream of output management pdf file. * @param {Object} outputConf - Configuration for the output management pdf. * @param {String} url - system url * @param {String} username - username for login * @param {String} password - password for login * @example * const outputConf = * ApplObjectType: "REQUEST_FOR_QUOTATION", * ApplObjectId: "7000002653", * ItemId: "1" * }; * const pdfStream = await service.odata.getOutputManagementPdfStream(outputConf, url, user, password); */ getOutputManagementPdfStream(outputConf: any, url: string, username: string, password: string): Promise<any>; /** * @function readPdfFromDirectUrl * @memberOf service.odata * @description returns a stream of pdf file which is part of attachment. * @param {String} url - system url * @param {String} [username] - username for login * @param {String} [password] - password for login * @param {Boolean} [isSaml=false] - use SAML login if true * @example * const url = "https://domain.com/getPdfFile"; * const pdfStream = await service.odata.readPdfFromDirectUrl(url, "username", "Password"); */ readPdfFromDirectUrl(url: string, username: string, password: string, isSaml?: boolean): Promise<any>; _doRequest(url: string, username: string, password: string, isSaml: boolean): Promise<any>; _applyHeaders(entity: any, headers: IHeaders): any; _applyQueryParameters(entity: any, params: IParams): any; } declare const _default: OData; export default _default;