UNPKG

wdio-ms-teams-service

Version:

A WebdriverIO plugin to report to Microsoft Teams channel webhooks

35 lines (34 loc) 1.09 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const axios_1 = __importDefault(require("axios")); const errors_1 = require("./errors"); class IncomingWebhook { constructor(url, timeout) { this._url = url; this._timeout = timeout || 10000; if (!this._url) { throw new errors_1.MsTeamsServiceError("no webhook URL provided"); } this._axios = axios_1.default.create({ baseURL: this._url, timeout: 10000, headers: { "Content-Type": "application/json", }, }); } async send(message) { let response; try { response = await this._axios.post(this._url, message); return { message: response.data }; } catch (error) { throw new errors_1.MsTeamsServiceError(error.message); } } } exports.default = IncomingWebhook;