// This file is auto-generated, don't edit it
// 依赖的模块可通过下载工程中的模块依赖文件或右上角的获取 SDK 依赖信息查看
import Dm20151123, * as $Dm20151123 from '@alicloud/dm20151123';
import OpenApi, * as $OpenApi from '@alicloud/openapi-client';
import Console from '@alicloud/tea-console';
import Util, * as $Util from '@alicloud/tea-util';
import * as $tea from '@alicloud/tea-typescript';


export default class Client {

  /**
   * 使用AK&SK初始化账号Client
   * @param accessKeyId
   * @param accessKeySecret
   * @return Client
   * @throws Exception
   */
  static createClient(accessKeyId: string, accessKeySecret: string): Dm20151123 {
    let config = new $OpenApi.Config({
      // 必填，您的 AccessKey ID
      accessKeyId: accessKeyId,
      // 必填，您的 AccessKey Secret
      accessKeySecret: accessKeySecret,
    });
    // 访问的域名
    config.endpoint = `dm.aliyuncs.com`;
    return new Dm20151123(config);
  }

  /**
  * 使用STS鉴权方式初始化账号Client，推荐此方式。
  * @param accessKeyId
  * @param accessKeySecret
  * @param securityToken
  * @return Client
  * @throws Exception
  */
  static createClientWithSTS(accessKeyId: string, accessKeySecret: string, securityToken: string): Dm20151123 {
    let config = new $OpenApi.Config({
      // 必填，您的 AccessKey ID
      accessKeyId: accessKeyId,
      // 必填，您的 AccessKey Secret
      accessKeySecret: accessKeySecret,
      // 必填，您的 Security Token
      securityToken: securityToken,
      // 必填，表明使用 STS 方式
      type: "sts",
    });
    // 访问的域名
    config.endpoint = `dm.aliyuncs.com`;
    return new Dm20151123(config);
  }

  static async main(type:String,content:String): Promise<void> {
    // 工程代码泄露可能会导致AccessKey泄露，并威胁账号下所有资源的安全性。以下代码示例仅供参考，建议使用更安全的 STS 方式，更多鉴权访问方式请参见：https://help.aliyun.com/document_detail/378664.html
    let client = Client.createClient("LTAI5tEzKa1MzVZ1QAQPayJX", "77mXtGCkWYPWLyCBc0fyOQMLYjn7Dj");
    let singleSendMailRequest = new $Dm20151123.SingleSendMailRequest({
      accountName: "sxxzs@email.zilber.cn",
      addressType: 1,
      replyToAddress: false,
      toAddress: "529315546@qq.com",
      // toAddress: "liujunhong@zilber.cn",
      subject: type,
      textBody: content,
    });
    let runtime = new $Util.RuntimeOptions({ });
    let resp = await client.singleSendMailWithOptions(singleSendMailRequest, runtime);
    Console.log(Util.toJSONString(resp));
  }

}

// Client.main(process.argv.slice(2));