https://github.com/grimpy/ispapi
Bundle of client to talk to ISP APIs
https://github.com/grimpy/ispapi
Last synced: 8 months ago
JSON representation
Bundle of client to talk to ISP APIs
- Host: GitHub
- URL: https://github.com/grimpy/ispapi
- Owner: grimpy
- License: mit
- Created: 2019-07-07T18:58:29.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-28T08:53:27.000Z (over 3 years ago)
- Last Synced: 2025-06-21T21:35:57.442Z (about 1 year ago)
- Language: Python
- Size: 24.4 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ispapi
Bundle of client to talk to ISP APIs
## List of implemtend providers
- TelecomEgypt
- Vodafone Egypt
- Lebara NL
## Add your provider
To add a new provider create a file inside providers module and add the corresponding import to `providers/__init__.py`. The provider implements a subclass of `Provider` class.
### Methods to be implemented in the provider
```py
class MyProvider(Provider):
def __init__(self, param1, param2='default value'):
super().__init__(param1, param2)
# do something with the paramters
def _login(self):
"""Do the login procedure and return session info"""
return NotImplemented
def login_from_session_data(self, session_data):
"""Do the login procedure from the cached session info"""
return NotImplemented
def _get_quota(self):
"""Get quota"""
raise NotImplementedError()
```
`_get_quota` is the only method that is required to be implemented. `_login` and `login_from_session_data` are optional.
`_login` tries to login, it optionally returns `session_data` to be stored and used later for login.
`login_from_session_data` will be tried first with the last stored `session_data` before trying to use `_login` again.
### Formatting for the provider
1. Class name will be used as the subcommand, so it is better to use something that will be unique, for example, adding the country name/code to the class name.
2. Arguments are converted to lower case and underscores are replaced to a dash and they are used as command line arguments. So it is better to use snake case in command line arguments.