Skip to content

Commit 2739e1e

Browse files
committed
Fixes to make the lib work
1 parent eb1888e commit 2739e1e

10 files changed

Lines changed: 34 additions & 19 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.pyc
2+
dist
3+
openpaygo.egg-info

README.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@ This open-source project was sponsored by:
2222
## Table of Contents
2323

2424
- [Installing the library](#installing-the-library)
25-
- [Getting Started - Generating Token](#getting-started---generating-token)
25+
- [Getting Started - Generating Tokens](#getting-started---generating-tokens)
26+
- [Getting Started - Decoding a Token](#getting-started---decoding-a-token)
2627

2728

2829
## Installing the library
2930

3031
You can install the library by running `pip install openpaygo` or adding `openpaygo` in your requirements.txt file and running `pip install -r requirements.txt`.
3132

32-
## Getting Started - Generating Token
33+
## Getting Started - Generating Tokens
3334

3435
You can use the `generate_token()` function to generate an OpenPAYGOToken Token. The function takes the following parameters, and they should match the configuration in the hardware of the device:
3536

@@ -48,7 +49,7 @@ The function returns the `updated_count` as a number as well as the `token` as a
4849
**Example 1 - Add 7 days:**
4950

5051
```
51-
from openpaygo.optoken import generate_token
52+
from openpaygo import generate_token
5253
from myexampleproject import device_getter
5354
5455
# We get a device with the parameters we need from our database, this will be specific to your project
@@ -68,7 +69,7 @@ device.save() # We save the new count that we set for the device
6869
**Example 2 - Disable PAYG (unlock forever):**
6970

7071
```
71-
from openpaygo.optoken import generate_token, TokenType
72+
from openpaygo import generate_token, TokenType
7273
7374
...
7475
@@ -109,7 +110,7 @@ The function will raise a `ValueError` if the key is in the wrong format, but wi
109110
**Example:**
110111

111112
```
112-
from openpaygo.optoken import decode_token
113+
from openpaygo import decode_token
113114
114115
# We assume the users enters a token and that the device state is saved in my_device_state
115116
...
@@ -138,8 +139,14 @@ elif token_type == TokenType.DISABLE_PAYG:
138139
my_device_state.unlocked_forever = True
139140
elif token_type == TokenType.COUNTER_SYNC:
140141
print('Counter Synced')
141-
if token_type == TokenType.ALREADY_USED:
142+
elif token_type == TokenType.ALREADY_USED:
142143
print('Token was already used')
143144
elif token_type == TokenType.INVALID:
144145
print('Token is invalid')
145-
```
146+
```
147+
148+
149+
## Changelog
150+
151+
### 2023-10-03 - v0.1.2
152+
- First working version published on PyPi

openpaygo/__init__.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from .encode_token import OpenPAYGOTokenEncoder
2+
from .decode_token import OpenPAYGOTokenDecoder
3+
from .shared import TokenType
4+
5+
6+
def generate_token(**kwargs):
7+
return OpenPAYGOTokenEncoder.generate_token(**kwargs)
8+
9+
10+
def decode_token(**kwargs):
11+
return OpenPAYGOTokenDecoder.decode_token(**kwargs)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from shared import OpenPAYGOTokenShared, TokenType
2-
from shared_extended import OpenPAYGOTokenSharedExtended
1+
from .shared import OpenPAYGOTokenShared, TokenType
2+
from .shared_extended import OpenPAYGOTokenSharedExtended
33

44

55
class OpenPAYGOTokenDecoder(object):
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from shared import OpenPAYGOTokenShared, TokenType
2-
from shared_extended import OpenPAYGOTokenSharedExtended
1+
from .shared import OpenPAYGOTokenShared, TokenType
2+
from .shared_extended import OpenPAYGOTokenSharedExtended
33

44

55
class OpenPAYGOTokenEncoder(object):
File renamed without changes.

optoken/__init__.py

Lines changed: 0 additions & 6 deletions
This file was deleted.

setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = openpaygo
3-
version = 0.1.0
3+
version = 0.1.2
44
url = https://github.com/openpaygo/openpaygo-python
55
description-file=README.md
66
license_files=LICENSE

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
setup(
55
name="openpaygo",
66
packages=find_packages(),
7-
version='0.1.0',
7+
version='0.1.2',
88
license='MIT',
99
author="Solaris Offgrid",
1010
url='https://github.com/openpaygo/openpaygo-python',

0 commit comments

Comments
 (0)