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

124 lines (123 loc) 4.78 kB
import { AxiosRequestConfig, AxiosResponse } from "axios"; /** * @class rest * @memberof service */ export declare class Rest { private axios; private _getError; /** * @function init * @memberOf service.rest * @description Returns an axios instance for custom axios handling. * @param {Object} [customConfig= {}] - Custom config for axios. If not specified axios defaults will be taken. * @returns {Object} The axios instance. * @example const customConfig = { baseURL: 'https://some-domain.com/api/', timeout: 1000, headers: { 'X-Custom-Header': 'foobar' } * const axios = service.rest.init(customConfig); */ init(customConfig?: AxiosRequestConfig<any> | undefined): import("axios").AxiosInstance; /** * @function get * @memberOf service.rest * @description makes a GET request. * @param {String} uri - The uri to the data source you want to GET. * @param {Object} [config] - The config options for the request. * @returns {Object} The response of the GET request. * @example const uri = https://api.predic8.de/shop/products/"; * let res = await service.rest.get(uri); * common.assertion.expectEqual(res.data.title, "qmate-service"); */ get(uri: string, config?: AxiosRequestConfig<any>): Promise<AxiosResponse<any, any>>; /** * @function post * @memberOf service.rest * @description makes a POST request. * @param {String} uri - The uri to the data source you want to POST against. * @param {Object} payload - The data you want to POST against your entity set. * @param {Object} [config] - The config options for the request. * @returns {Object} The response of the POST request. * @example const payload = { id: 99, title: "qmate-service", author: "marvin" }; const config = { headers: { "X-CSRF-TOKEN": "<CSRF TOKEN>", "Cookie": "<COOKIE>", "Content-Type": "application/json" } }; let res = await service.rest.post(`${browser.config.baseUrl}/posts/99`, payload, config); */ post(uri: string, payload: any, config?: AxiosRequestConfig<any>): Promise<AxiosResponse<any, any>>; /** * @function delete * @memberOf service.rest * @description makes a DELETE request. * @param {String} uri - The uri to the data source you want to DELETE. * @param {Object} [config] - The config options for the request. * @returns {Object} The response of the DELETE request. * @example * const config = { auth: { "username": "<username>", "password": "<password>" } }; let res = await service.rest.delete(`${browser.config.baseUrl}/posts/99`, config); */ delete(uri: string, config?: AxiosRequestConfig<any>): Promise<AxiosResponse<any, any>>; /** * @function patch * @memberOf service.rest * @description makes a PATCH request. * @param {String} uri - The uri to the data source you want to PATCH. * @param {Object} payload - The data to be used for updating the entity. * @param {Object} [config] - The config options for the request. * @returns {Object} The response of the PATCH request. * @example * const config = { auth: { "username": "<username>", "password": "<password>" } }; const payload = { "title": "patched-qmate-service", "author": "qmate-tester" }, let res = await service.rest.patch(`${browser.config.baseUrl}/posts/99`, payload, config); */ patch(uri: string, payload: any, config?: AxiosRequestConfig<any>): Promise<AxiosResponse<any, any>>; /** * @function put * @memberOf service.rest * @description makes a PUT request. * @param {String} uri - The uri to the data source you want to PUT. * @param {Object} payload - The data to be used for updating the entity. * @param {Object} [config] - The config options for the request. * @returns {Object} The response of the PUT request. * @example * const config = { auth: { "username": "<username>", "password": "<password>" } } const payload = { "id": 99, "title": "put-qmate-service", "author": "qmate-tester" }, let res = await service.rest.put(`${browser.config.baseUrl}/posts/99`, payload, config); */ put(uri: string, payload: any, config?: AxiosRequestConfig<any> | undefined): Promise<AxiosResponse<any, any>>; } declare const _default: Rest; export default _default;