Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create vouchers #10

Closed
tirannilakshe opened this issue Aug 23, 2016 · 23 comments
Closed

Create vouchers #10

tirannilakshe opened this issue Aug 23, 2016 · 23 comments

Comments

@tirannilakshe
Copy link

need to create vouchers and print vouchers from api

@malle-pietje
Copy link
Collaborator

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.

@malle-pietje
Copy link
Collaborator

@tirannilakshe FYI, there was a bug in the create_vouchers() function/method that is now fixed.

@tiransa
Copy link

tiransa commented Nov 7, 2016

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

@malle-pietje
Copy link
Collaborator

Are you able to create them in the controller? If so, how? I don't use them myself....

@tiransa
Copy link

tiransa commented Nov 7, 2016

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
#10 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMkb_BRkttyEqyAFd3Ozf6l0ShfwDAFuks5q7120gaJpZM4JrGXd
.

@tiransa
Copy link

tiransa commented Nov 7, 2016

untitled

@malle-pietje
Copy link
Collaborator

Ah, I see. Let me see how to efficiently enable this in the API client.

@tiransa
Copy link

tiransa commented Nov 8, 2016

there are some other things also how to delete vouchers, can i block and unblock guest by mac address

@malle-pietje
Copy link
Collaborator

malle-pietje commented Nov 8, 2016

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

@malle-pietje
Copy link
Collaborator

@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?

@tiransa
Copy link

tiransa commented Nov 9, 2016

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
#10 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMkb_CBH9y3qTg_qkHAkh2xiYQ9huaZYks5q8Gw9gaJpZM4JrGXd
.

@malle-pietje
Copy link
Collaborator

You're welcome. Thanks for the feedback; I'll update the class and add the voucher delete function shortly.

@malle-pietje
Copy link
Collaborator

malle-pietje commented Nov 9, 2016

@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?

@tiransa
Copy link

tiransa commented Nov 10, 2016

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
#10 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMkb_KAXRifgOpZdEe8Xsnl9mWAcrscnks5q8do9gaJpZM4JrGXd
.

@malle-pietje
Copy link
Collaborator

Thanks for the feedback. For disconnect/extend, see my comment from 2 days ago.

@tiransa
Copy link

tiransa commented Nov 21, 2016

hello, can i create hotspot operator from this API Class

@malle-pietje
Copy link
Collaborator

that has not yet been implemented, only the function to list the operators list_hotspotop()

@tiransa
Copy link

tiransa commented Nov 21, 2016

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
#10 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMkb_HWScXzUSPbAFwUg1X_RdW4zkke4ks5rAY8PgaJpZM4JrGXd
.

@malle-pietje
Copy link
Collaborator

I'm quite busy at the moment so this will take at least a week or two

@tiransa
Copy link

tiransa commented Nov 21, 2016

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
#10 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AMkb_AkVsYrVUfzgD4wh3dEXFZRPKarFks5rAa7igaJpZM4JrGXd
.

@malle-pietje
Copy link
Collaborator

@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;
    }

@malle-pietje
Copy link
Collaborator

@tiransa If it works I will include it in the release I have ready for the API Browser and the API client class.

@malle-pietje
Copy link
Collaborator

Added create_hotspotop() function/method several commits ago.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants