EASYMOBILE PYTHON API
Overview
easymobile is a Python package that provides a simple interface for integrating with the EASYMOBILE API, allowing users to purchase airtime, data, cable subscriptions etc. This package is designed to streamline the process of interacting with the EasyMobile API and offers methods to handle various operations such as fetching available services, purchasing services, and checking transaction statuses.
Available Operations
- Account Operations
- Airtime Operations
- Data Operations
- Cable Operations
Installation
To install the EasyB2B package, clone this repository and install:
pip install easymobile
or if you wish to install from the git repo.
# Install from the main branch
pip install git+https://github.com/Ephraim-Akolo/EASYMOBILE.git
Usage
Initialization
To use the EASYMOBILE package, you need to initialize the classes with your API key. The API key can be provided during initialization or set in the environmental variable EASYMOBILE_API_KEY. Timeout for the requests to the easymobile API can be set on class initialization or by setting the EASYMOBILE_TIMEOUT environmental variable.
Account Operations
from easymobile import EasyBase
api_key = 'your_api_key'
client = EasyBase(api_key=api_key)
# Get Account Balance
response = client.get_wallet_balance("admin@email.com")
print(response)
Airtime Operations
from easymobile import EasyAirtime, get_easyb2b_reference
api_key = 'your_api_key'
client = EasyAirtime(api_key=api_key)
# Get Networks
networks = client.get_networks()
print(networks)
# Get Airtime Types
airtime_types = client.get_airtime_types(network=1)
print(airtime_types)
# Get Airtime Rates
airtime_rates = client.get_airtime_rates(network=1, airtimeType='VTU')
print(airtime_rates)
# Purchase Airtime
reference = get_easyb2b_reference() # Generate a unique reference code
response = client.purchase_airtime(reference=reference, network=1, airtimeType='SME', amount='10', phone='08168639124')
print(response)
# Get Transaction Status
status = client.get_transaction_status(ref=reference)
print(status)
Data Operations
from easymobile import EasyData, get_easyb2b_reference
api_key = 'your_api_key'
client = EasyData(api_key=api_key)
# Get Networks
networks = client.get_networks()
print(networks)
# Get Data Types
data_types = client.get_data_types(network=1)
print(data_types)
# Get Data Plans
data_plans = client.get_data_plans(network=1, dataType='SME')
print(data_plans)
# Purchase Data
reference = get_easyb2b_reference() # Generate a unique reference code
response = client.purchase_data(reference=reference, network=1, dataType='SME', planId='1', phone='08168639113')
print(response)
# Get Transaction Status
status = client.get_transaction_status(ref=reference)
print(status)
Cable Operations
from easymobile import EasyCable, get_easyb2b_reference
api_key = 'your_api_key'
client = EasyCable(api_key=api_key)
# Get Cables
cables = client.get_cables()
print(cables)
# Get Cable Packages
packages = client.get_cable_packages(cable_id=1)
print(packages)
# Validate Smartcard/IUC Number
validation = client.validate_smartcard_iuc_number(cable_id=1, smartcard_no='1234567890')
print(validation)
# Purchase Cable Subscription
reference = get_easyb2b_reference() # Generate a unique reference code
response = client.purchase_cable(reference=reference, cable_id='1', package_id='1', smartcard_no='1234567890')
print(response)
# Get Transaction Status
status = client.get_transaction_status(ref=reference)
print(status)
Single Client For All Operations
If you require a client object that is capable of accessing all services, you can instantiate the EasyMobile class and use easy_<service name> to access any service specific methods.
from easymobile import EasyMobile
api_key = 'your_api_key'
client = EasyMobile(api_key=api_key)
# Get Account Balance
response = client.get_wallet_balance("admin@email.com")
print(response)
# Get Networks (Airtime)
networks = client.easy_airtime.get_networks()
print(networks)
# Get Networks (Data)
networks = client.easy_data.get_networks()
print(networks)
# Get Cables
cables = client.easy_cable.get_cables()
print(cables)
Running Tests
To run the tests for the EASYMOBILE package, create and/or activate a Python virtual environment, ensure the current working directory is the root directory, and follow these steps:
# Install the test dependencies if not already done
pip install -r requirements-test.txt
# Discover and run tests
python -m unittest
Contributing
Contributions are welcome! Please fork the repository and create a pull request to dev branch with your changes.
License
This project is licensed under the MIT License. See the LICENSE file for details.
Metadata
Release files for easymobile 0.2.0.post0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| easymobile-0.2.0.post0.tar.gz | 14.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| easymobile-0.2.0.post0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 27.5 kB
Release files / easymobile-0.2.0.post0.tar.gz
| Download URL | easymobile-0.2.0.post0.tar.gz |
|---|---|
| Size | 14.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
509e7abf0a70b054f3b5f2ba426bbe35004b95f9e56530ce16dc29222e311275
|
|
BLAKE2b-256 checksum How to use checksums |
f8c91a1410ec848b3163c671e3cdc4e736e8e036d10a72e680db8ade47b6cbbe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.19
|
Release files / easymobile-0.2.0.post0-py3-none-any.whl
| Download URL | easymobile-0.2.0.post0-py3-none-any.whl |
|---|---|
| Size | 13.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e32dd777af2390848600dde74942826c7a9ba53113208bf284ea10e1c70136d2
|
|
BLAKE2b-256 checksum How to use checksums |
9cc28e1a781a17b425532d13bd3c4a3ba9909165be8a1aef4da714600482f558
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.9.19
|