'use strict';

const Service = require('egg').Service;

class DingService extends Service {

  async push(message) {
    const webhook = 'https://oapi.dingtalk.com/robot/send?access_token=eb36b5a10ccd4da43e1bb93815fc44e3aab3ed6a68308dfad833792f1cf4b36e';
    const data = {
      msgtype: 'markdown',
      markdown: {
        title: '法催邮件异常',
        text: `### 法催邮件异常 \n${message || '未知错误'}`,
      },
    };
    return this.ctx.curl(webhook, {
      contentType: 'json',
      dataType: 'json',
      method: 'POST',
      data,
    });
  }

}

module.exports = DingService;
