"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.gotify = void 0;

var _axios = _interopRequireDefault(require("axios"));

var _createNotificationPlatform = require("../createNotificationPlatform");

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

const gotify = (0, _createNotificationPlatform.createNotificationPlatform)({
  name: 'gotify',
  credentialNames: ['url', 'token', 'priority'],
  sendFunction: async args => {
    const {
      title,
      message,
      messageMarkdown,
      credentials,
      imagePath
    } = args;
    await _axios.default.post(new URL('/message', credentials.url).href, {
      extras: {
        'client::display': {
          contentType: messageMarkdown ? 'text/markdown' : 'text/plain'
        },
        'client::notification': {
          imageUrl: imagePath
        }
      },
      priority: Number(credentials.priority) || 5,
      message: messageMarkdown || message,
      title: title
    }, {
      headers: {
        'X-Gotify-Key': credentials.token
      }
    });
  }
});
exports.gotify = gotify;
//# sourceMappingURL=gotify.js.map