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AM,QACjB,KAAQ,MAAM,QAAQ,KACtB,KAAQ,MAAM,QAAQ,OAG9B,QAAU,KAAK,KAAK,CAChB,IAAK,KAAK,SACV,QAAS,IAAI,OAAO,KAAK,UAAU,UACnC,QAAS,CACL,cAAiB,KAAK,UAE3B,SAAU,EAAK,GACd,QAAQ,IAAI,EAAK,EACrB,IAER,EAEA,OAAO,QAAU","file":"/npm/npm-sparkpost@1.0.0/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/npm-sparkpost@1.0.0/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","var _ = require('underscore');\nvar http = require('http-request');\n\nvar sparkpost = function (apiKey) {\n    this.apiKey = null;\n    this.endpoint = \"https://api.sparkpost.com/api/v1/transmissions\";\n    if (typeof apiKey !== 'undefined' && apiKey !== null) {\n        this.apiKey = apiKey\n    }\n};\n\nsparkpost.prototype.setApiKey = function (apiKey) {\n    if (typeof apiKey !== 'undefined' && apiKey !== null) {\n        this.apiKey = apiKey\n    } else {\n        throw new Error(\"API Key is required!\");\n    }\n};\n\nvar isset = function (val) {\n    return typeof val !== 'undefined' && val !== null;\n};\n\nsparkpost.prototype.send = function (options) {\n    if (!isset(this.apiKey)) throw new Error(\"No API Key set!\");\n    _opts = {\n        tracking: {\n            open: true,\n            click: true\n        }\n    };\n    _opts = _.defaults(_opts, options);\n    var fieldsValid = true;\n\n    if (!isset(_opts.from)) {\n        fieldsValid = false;\n        throw new Error(\"'From' object is required!\");\n    }\n    if (!isset(_opts.from.address)) {\n        fieldsValid = false;\n        throw new Error(\"'From Address' is required!\");\n    }\n    if (!isset(_opts.from.name)) {\n        fieldsValid = false;\n        throw new Error(\"'From Name' is required!\");\n    }\n    if (!isset(_opts.subject)) {\n        fieldsValid = false;\n        throw new Error(\"'Subject' is required!\");\n    }\n    if (!isset(_opts.content)) {\n        fieldsValid = false;\n        throw new Error(\"'Content' object is required!\");\n    }\n    if (!isset(_opts.content.text)) {\n        fieldsValid = false;\n        throw new Error(\"'Text' content is required!\");\n    }\n    if (!isset(_opts.content.html)) {\n        fieldsValid = false;\n        throw new Error(\"'HTML' content is required!\");\n    }\n\n    if (fieldsValid) {\n        reqBody = {\n            \"options\": {\"open_tracking\": _opts.tracking.open, \"click_tracking\": _opts.tracking.click},\n            \"recipients\": [{\"address\": {\"email\": _opts.from.address}}],\n            \"content\": {\n                \"from\": {\"name\": _opts.from.name, \"email\": _opts.from.address},\n                \"subject\": _opts.subject,\n                \"text\": _opts.content.text,\n                \"html\": _opts.content.html\n            }\n        };\n        request = http.post({\n            url: this.endpoint,\n            reqBody: new Buffer(JSON.stringify(reqBody)),\n            headers: {\n                \"Authorization\": this.apiKey\n            }\n        }, function (err, result) {\n            console.log(err, result);\n        });\n    }\n};\n\nmodule.exports = sparkpost;"]}