Восстановить шаблон уведомления по умолчанию

Восстанавливает заданный шаблон уведомления в его исходное состояние.

Запрос

HTTP Запрос

POST /node/api/notification-templates/send

Параметры пути

Параметр Тип Описание

subjectTemplate

String

Шаблон темы письма.

contentTemplate

String

Шаблон тела письма.

templateVars

String

Переменные для шаблона в формате объекта JSON. Формат указан в примере тела запроса ниже.

sendParams

String

Параметры отправки письма. Подробную информацию можно найти в доументации Nodemailer.

entityId

String

ID сущности, из которой берутся значения переменных для шаблона.

entityType

String

Тип сущности. 1 для объекта, 2 для связи.

Тело запроса

Тело запроса содержит настройки и содержание email-сообщения.

{
  "entityId": "67f7e77a2b10d179db91dfa6",
  "subjectTemplate": "Subject {{entityName}}",
  "contentTemplate": "<h1>{{foo}}</h1><ul>{{#bar.a}}{{#x}} <li>{{x}}</li>{{/x}}{{/bar.a}}</ul>",
  "templateVars": {
    "foo": "This is foo var!",
    "bar": {
      "a": [{
          "x": 1
        },
        {
          "x": 22
        },
        {
          "x2": 20
        }
      ]
    }
  },
  "sendParams": {
    "to": "user@example.com"
  }
}

Ответ

Тело ответа пустое.

Пример

Запрос

  • Bash

  • JavaScript

  • NodeJS

  • Python

login=<...>
password=<...>
saymon_hostname=<...>
url=https://$saymon_hostname/node/api/notification-templates/send

curl -X POST $url -u $login:$password \
    -H "Content-Type: application/json" \
    -d @- <<EOF
{
  "entityId": "67f7e77a2b10d179db91dfa6",
  "subjectTemplate": "Subject {{entityName}}",
  "contentTemplate": "<h1>{{foo}}</h1><ul>{{#bar.a}}{{#x}} <li>{{x}}</li>{{/x}}{{/bar.a}}</ul>",
  "templateVars": {
    "foo": "This is foo var!",
    "bar": {
      "a": [{
          "x": 1
        },
        {
          "x": 22
        },
        {
          "x2": 20
        }
      ]
    }
  },
  "sendParams": {
    "to": "user@example.com"
  }
}
EOF
let login = <...>
let password = <...>
let saymonHostname = <...>
let path = "/node/api/notification-templates/send";
let auth = "Basic " + btoa(login + ":" + password);

let headers = new Headers();
headers.append("Content-Type", "application/json");
headers.append("Authorization", auth);

let data = JSON.stringify({
  "entityId": "67f7e77a2b10d179db91dfa6",
  "subjectTemplate": "Subject {{entityName}}",
  "contentTemplate": "<h1>{{foo}}</h1><ul>{{#bar.a}}{{#x}} <li>{{x}}</li>{{/x}}{{/bar.a}}</ul>",
  "templateVars": {
    "foo": "This is foo var!",
    "bar": {
      "a": [{
          "x": 1
        },
        {
          "x": 22
        },
        {
          "x2": 20
        }
      ]
    }
  },
  "sendParams": {
    "to": "user@example.com"
  }
});

let requestOptions = {
    method: "POST",
    headers: headers,
    body: data
};

fetch(saymonHostname + path, requestOptions)
    .then(response => response.text())
    .then(result => console.log(result))
    .catch(error => console.log("error", error));
const http = require("http");

let login = <...>
let password = <...>
let saymonHostname = <...>
let path = "/node/api/notification-templates/send";
let auth = "Basic " + Buffer.from(login + ":" + password).toString("base64");

let options = {
    "method": "POST",
    "hostname": saymonHostname,
    "headers": {
        "Authorization": auth,
        "Content-Type": "application/json"
    },
    "path": path
};

let req = http.request(options, function (res) {
    let chunks = [];

    res.on("data", function (chunk) {
        chunks.push(chunk);
    });

    res.on("end", function (chunk) {
        let body = Buffer.concat(chunks);
        console.log(body.toString());
    });

    res.on("error", function (error) {
        console.error(error);
    });
});

let data = JSON.stringify({
  "entityId": "67f7e77a2b10d179db91dfa6",
  "subjectTemplate": "Subject {{entityName}}",
  "contentTemplate": "<h1>{{foo}}</h1><ul>{{#bar.a}}{{#x}} <li>{{x}}</li>{{/x}}{{/bar.a}}</ul>",
  "templateVars": {
    "foo": "This is foo var!",
    "bar": {
      "a": [{
          "x": 1
        },
        {
          "x": 22
        },
        {
          "x2": 20
        }
      ]
    }
  },
  "sendParams": {
    "to": "user@example.com"
  }
});

req.write(data);
req.end();
import requests

login = <...>
password = <...>
saymon_hostname = <...>
url = "https://" + saymon_hostname + "/node/api/notification-templates/send"
body = {
  "entityId": "67f7e77a2b10d179db91dfa6",
  "subjectTemplate": "Subject {{entityName}}",
  "contentTemplate": "<h1>{{foo}}</h1><ul>{{#bar.a}}{{#x}} <li>{{x}}</li>{{/x}}{{/bar.a}}</ul>",
  "templateVars": {
    "foo": "This is foo var!",
    "bar": {
      "a": [{
          "x": 1
        },
        {
          "x": 22
        },
        {
          "x2": 20
        }
      ]
    }
  },
  "sendParams": {
    "to": "user@example.com"
  }
}

response = requests.request("POST", url, json=body, auth=(login, password))
print(response.text)