@atomist/automation-client
Version:
Atomist API for software low-level client
34 lines • 1.21 kB
JavaScript
;
/*
* Copyright © 2018 Atomist, Inc.
*
* See LICENSE file.
*/
Object.defineProperty(exports, "__esModule", { value: true });
const axios_1 = require("axios");
const stringify = require("json-stringify-safe");
const retry_1 = require("./util/retry");
/**
* Scheme and hostname (authority) of the Atomist webhook URL.
*/
function webhookBaseUrl() {
return process.env.ATOMIST_WEBHOOK_BASEURL || "https://webhook.atomist.com";
}
exports.webhookBaseUrl = webhookBaseUrl;
/**
* Post payload to the Atomist webhook URL. It will retry
* several times.
*
* @param webhook type of webhook
* @param payload object to post
* @param workspaceId Atomist team ID
* @param retryOptions change default retry options
* @return response of post operation
*/
function postAtomistWebhook(webhook, payload, workspaceId, retryOptions = retry_1.DefaultRetryOptions) {
const url = `${webhookBaseUrl()}/atomist/${webhook}/teams/${workspaceId}`;
const desc = `posting '${stringify(payload)}' to '${url}'`;
return retry_1.doWithRetry(() => axios_1.default.post(url, payload), desc, retryOptions);
}
exports.postAtomistWebhook = postAtomistWebhook;
//# sourceMappingURL=atomistWebhook.js.map