Closed tirannilakshe closed 7 years ago
Basically what you need to do is create the vouchers, then get the newly created vouchers and their details, format them on an html page and print. I can help with how to use the API client but not with the other elements; that comes down to basic HTML, CSS and PHP skills.
@tirannilakshe FYI, there was a bug in the create_vouchers()
function/method that is now fixed.
i have done voucher creating. but there is a little problem. that i can only create one time use vouchers only. how can i generate multi use vouchers
Are you able to create them in the controller? If so, how? I don't use them myself....
yes. when i create voucher in controller there is a option to select multi use
On Mon, Nov 7, 2016 at 10:49 PM, malle-pietje notifications@github.com wrote:
Are you able to create them in the controller? If so, how? I don't use them myself....
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/malle-pietje/UniFi-API-browser/issues/10#issuecomment-258900297, or mute the thread https://github.com/notifications/unsubscribe-auth/AMkb_BRkttyEqyAFd3Ozf6l0ShfwDAFuks5q7120gaJpZM4JrGXd .
Ah, I see. Let me see how to efficiently enable this in the API client.
there are some other things also how to delete vouchers, can i block and unblock guest by mac address
I've added the multi-use/single-use option to the create_voucher()
function below:
/**
* Create voucher(s)
* -----------------
* returns an array of vouchers codes (NOTE: without the "-" in the middle) by calling the stat_voucher method
* required parameter <minutes> = minutes the voucher is valid after activation
* optional parameter <number_of_vouchers_to_create> = number of vouchers to create, default value is 1
* optional parameter <quota> = single-use or multi-use vouchers, string value '0' is for multi-use, '1' is for single-use
* optional parameter <note> = note text to add to voucher when printing
* optional parameter <up> = upload speed limit in kbps
* optional parameter <down> = download speed limit in kbps
* optional parameter <MBytes> = data transfer limit in MB
*/
public function create_voucher($minutes, $number_of_vouchers_to_create = 1, $quota = '0', $note = NULL, $up = NULL, $down = NULL, $MBytes = NULL) {
if (!$this->is_loggedin) return FALSE;
$return = array();
$json = array('cmd' => 'create-voucher', 'expire' => $minutes, 'n' => $number_of_vouchers_to_create, 'quota' => $quota);
/**
* if we have received values for note/up/down/MBytes we append them to the payload array to be submitted
*/
if (isset($note)) $json['note'] = trim($note);
if (isset($up)) $json['up'] = $up;
if (isset($down)) $json['down'] = $down;
if (isset($MBytes)) $json['bytes'] = $MBytes;
$json = json_encode($json);
$content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/cmd/hotspot','json='.$json));
if ($content_decoded->meta->rc == 'ok') {
if (is_array($content_decoded->data)) {
$obj = $content_decoded->data[0];
foreach ($this->stat_voucher($obj->create_time) as $voucher) {
$return[]= $voucher->code;
}
}
}
return $return;
}
I would appreciate if you could test this in your environment and report back whether this works or not.
TIA
@tirannilakshe A function/method to delete vouchers can certainly be added, I will do that with the new release of the API client which will also include the improved create_voucher()
function after your confirmation that the above modification works.
For blocking/unblocking clients the block_sta()
and unblock_sta()
functions should do the trick. Have you already tried that?
yes it is ok now thank you
On Tue, Nov 8, 2016 at 6:04 PM, malle-pietje notifications@github.com wrote:
@tirannilakshe https://github.com/tirannilakshe A function/method to delete vouchers can certainly be added, I will do that with the new release of the API client which will also include the improved create_voucher() function after your confirmation that the above modification works.
For blocking/unblocking clients the block_sta() and unblock_sta() functions should do the trick. Have you already tried that?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/malle-pietje/UniFi-API-browser/issues/10#issuecomment-259125041, or mute the thread https://github.com/notifications/unsubscribe-auth/AMkb_CBH9y3qTg_qkHAkh2xiYQ9huaZYks5q8Gw9gaJpZM4JrGXd .
You're welcome. Thanks for the feedback; I'll update the class and add the voucher delete function shortly.
@tiransa I have pushed a new version of the API client class and the API browser tool. Could you please check whether the new revoke_voucher()
function/method does what you wanted to achieve with regard to voucher deletion?
revoke_voucher() ok now how about disconnect and extend in guest actions
On Wed, Nov 9, 2016 at 8:05 PM, malle-pietje notifications@github.com wrote:
@tiransa https://github.com/tiransa I have pushed a new version of the API client class and the API browser tool. Could you please check whether the new revoke_voucher() function/methods does what you wanted to achieve with regard to voucher deletion?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/malle-pietje/UniFi-API-browser/issues/10#issuecomment-259428590, or mute the thread https://github.com/notifications/unsubscribe-auth/AMkb_KAXRifgOpZdEe8Xsnl9mWAcrscnks5q8do9gaJpZM4JrGXd .
Thanks for the feedback. For disconnect/extend, see my comment from 2 days ago.
hello, can i create hotspot operator from this API Class
that has not yet been implemented, only the function to list the operators list_hotspotop()
can you do that soon please
On Mon, Nov 21, 2016 at 6:01 PM, malle-pietje notifications@github.com wrote:
that has not yet been implemented, only the function to list the operators list_hotspotop()
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/malle-pietje/UniFi-API-browser/issues/10#issuecomment-261924502, or mute the thread https://github.com/notifications/unsubscribe-auth/AMkb_HWScXzUSPbAFwUg1X_RdW4zkke4ks5rAY8PgaJpZM4JrGXd .
I'm quite busy at the moment so this will take at least a week or two
ok i will wait for that. thank you
On Mon, Nov 21, 2016 at 8:16 PM, malle-pietje notifications@github.com wrote:
I'm quite busy at the moment so this will take at least a week or two
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/malle-pietje/UniFi-API-browser/issues/10#issuecomment-261957277, or mute the thread https://github.com/notifications/unsubscribe-auth/AMkb_AkVsYrVUfzgD4wh3dEXFZRPKarFks5rAa7igaJpZM4JrGXd .
@tiransa This function should let you create hotspot operators. Could you please test and confirm back if it's working?
/**
* Create hotspot operator
* -----------------
* returns TRUE upon success
* required parameter <name> = name for the hotspot operator
* required parameter <x_password> = clear text password for the hotspot operator
* optional parameter <note> = note to attach to the hotspot operator
*/
public function create_hotspotop($name, $x_password, $note = NULL) {
if (!$this->is_loggedin) return FALSE;
$return = FALSE;
$json = array('name' => $name, 'x_password' => $x_password);
/**
* if we have received a value for note, we append it to the payload array to be submitted
*/
if (isset($note)) $json['note'] = trim($note);
$json = json_encode($json);
$content_decoded = json_decode($this->exec_curl($this->baseurl.'/api/s/'.$this->site.'/rest/hotspotop','json='.$json));
if (isset($content_decoded->meta->rc)) {
if ($content_decoded->meta->rc == 'ok') {
$return = TRUE;
}
}
return $return;
}
@tiransa If it works I will include it in the release I have ready for the API Browser and the API client class.
Added create_hotspotop()
function/method several commits ago.
need to create vouchers and print vouchers from api