Skip to content

Commit

Permalink
docs: unifi API wrapper docs
Browse files Browse the repository at this point in the history
  • Loading branch information
fronbasal committed Jun 21, 2019
1 parent 00fc1bc commit d725062
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ VoucherPI is a simple, hacky script that prints out a freshly generated voucher

The implementation is hacky and needs to be worked on. Error handling is non-existant. It can and will crash.

## API (Unifi)

You may use the Unifi API provided in this project for your own projects.
The documentation can be found in the file.

## Configuration

See `settings.py`.
Expand All @@ -23,3 +28,4 @@ Adjust neccesary parameters and copy to `/etc/systemd/user/voucherpi.service`. Y
## Maintainers

- Daniel Malik <[email protected]>

3 changes: 3 additions & 0 deletions unifi.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class UnifiAuthenticationException(Exception):


class Unifi:
"""Unifi voucher API wrapper"""

def __init__(self, username, password, base_url, site='default', ignore_ssl=True, authenticate=True):
"""
Expand Down Expand Up @@ -69,6 +70,7 @@ def generate_voucher(self, expire=60, usages=1, note='API generated voucher'):
return vouchers
return None

# Retrieve stats about a specific token
def token_stats(self, create_time):
"""
Retrieve token statistics
Expand All @@ -83,6 +85,7 @@ def token_stats(self, create_time):
vouchers.append(voucher)
return vouchers if vouchers else False

# List available vouchers
def list_vouchers(self):
"""
Retrieve all vouchers
Expand Down

0 comments on commit d725062

Please sign in to comment.