mirror of
https://github.com/glenndehaan/unifi-voucher-site.git
synced 2026-04-05 08:54:17 -04:00
Implemented voucher types. Updated the README.md
This commit is contained in:
@@ -26,13 +26,14 @@ const controller = new unifi.Controller({host: config.unifi.ip, port: config.uni
|
||||
/**
|
||||
* Exports the UniFi voucher function
|
||||
*
|
||||
* @param type
|
||||
* @returns {Promise<unknown>}
|
||||
*/
|
||||
module.exports = () => {
|
||||
module.exports = (type) => {
|
||||
return new Promise((resolve) => {
|
||||
controller.login(config.unifi.username, config.unifi.password).then(() => {
|
||||
controller.getSitesStats().then(() => {
|
||||
controller.createVouchers(480).then((voucher_data) => {
|
||||
controller.createVouchers(type.expiration, 1, type.usage === 1 ? 1 : 0, null, typeof type.upload !== "undefined" ? type.upload : null, typeof type.download !== "undefined" ? type.download : null, typeof type.megabytes !== "undefined" ? type.megabytes : null).then((voucher_data) => {
|
||||
controller.getVouchers(voucher_data[0].create_time).then((voucher_data_complete) => {
|
||||
const voucher = `${[voucher_data_complete[0].code.slice(0, 5), '-', voucher_data_complete[0].code.slice(5)].join('')}`;
|
||||
resolve(voucher);
|
||||
|
||||
Reference in New Issue
Block a user