{"version":3,"sources":["jsdelivr-header.js","/npm/bitpay-invoice-generator@0.1.2/index.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,IAAI,WAAa,QAAQ,cACrB,QAAU,QAAQ,YAEtB,SAAS,uBAAuB,GAC9B,IAAK,EAAQ,OAAU,MAAM,IAAI,MAAM,uBACvC,KAAK,OAAS,EAAQ,OACtB,KAAK,gBAAkB,EAAQ,eACjC,CAEA,uBAAuB,UAAY,CACjC,cAAe,SAAS,GACtB,IAAI,EAAQ,KACZ,OAAO,IAAI,SAAQ,SAAS,EAAS,GACnC,IAAI,EAAO,CAAC,EACR,EAAe,OAAQ,EAAO,EAAe,MACjD,IAAI,EAAU,CACZ,MAAO,EAAe,OACtB,SAAU,MACV,gBAAiB,EAAM,gBACvB,mBAAmB,EACnB,QAAS,KAAK,UAAU,IAE1B,WACG,KAAK,kCACL,KAAK,EAAM,OAAQ,IACnB,KAAK,GACL,KAAI,SAAS,EAAO,GACnB,OAAI,EACM,EAAO,GAEkB,MAA/B,EAAgB,WACX,EAAO,IAAI,MAAM,sBAExB,EAAQ,EAAgB,KAE5B,GACJ,GACF,GAGF,OAAO,QAAU","file":"/npm/bitpay-invoice-generator@0.1.2/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/bitpay-invoice-generator@0.1.2/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 httpClient = require('superagent');\nvar Promise = require('bluebird');\n\nfunction BitpayInvoiceGenerator(options) {\n  if (!options.apiKey) { throw new Error('InvalidBitpayApiKey') }\n  this.apiKey = options.apiKey\n  this.notificationURL = options.notificationURL\n}\n\nBitpayInvoiceGenerator.prototype = {\n  getNewInvoice: function(invoiceOptions) {\n    var _this = this;\n    return new Promise(function(resolve, reject) {\n      var data = {};\n      if (invoiceOptions.data) { data = invoiceOptions.data }\n      var invoice = {\n        price: invoiceOptions.amount,\n        currency: 'BTC',\n        notificationURL: _this.notificationURL,\n        fullNotifications: true,\n        posData: JSON.stringify(data)\n      };\n      httpClient\n        .post('https://bitpay.com/api/invoice')\n        .auth(_this.apiKey, '')\n        .send(invoice)\n        .end(function(error, invoiceResponse) {\n          if (error) {\n            return  reject(error);\n          }\n          if (invoiceResponse.statusCode === 401) {\n            return reject(new Error('Unauthorized'))\n          } else {\n            resolve(invoiceResponse.body); \n          }\n        });\n    });\n  }\n}\n\nmodule.exports = BitpayInvoiceGenerator;\n\n"]}