UNPKG

ifpaytt

Version:

Trigger IFTTT actions with Bitcoin Lightning payments

16 lines (13 loc) 637 B
'use strict'; var _superagent = require('superagent'); var enc = encodeURIComponent, missing = function missing(_) { throw new Error('IFTTT_KEY is required'); }; module.exports = function () { var makerKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : missing(); var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; return function (event, value1, value2, value3) { return (0, _superagent.post)('https://maker.ifttt.com/trigger/' + enc(prefix + event) + '/with/key/' + enc(makerKey)).type('json').send({ value1: value1, value2: value2, value3: value3 }); }; };