Module to communicate to the Mobile Vikings API
Project description
aiomobilevikings
Asynchronous library to communicate with the Mobile Vikings API
Mobile Vikings API - Available Endpoints
1. Authenticate
- Description: Authenticates with the Mobile Vikings API to obtain an access token.
- Input:
username(string): Mobile Vikings account username.password(string): Mobile Vikings account password.
- Output:
refresh_token(string): Token for refreshing the access token.access_token(string): Token for accessing other endpoints.expires_in(int): Time in seconds until the access token expires.
2. Get Customer Info
- Description: Fetches customer details from the API.
- Input: None.
- Output:
id(string): Customer ID.name(string): Customer name.email(string): Email address.
3. Get Loyalty Points Balance
- Description: Retrieves the loyalty points balance of the customer.
- Input: None.
- Output:
points(int): Total loyalty points.valid_until(string, ISO 8601): Expiry date of points.
4. Get Subscriptions
- Description: Lists active subscriptions with additional details like modem settings or balance.
- Input: None.
- Output:
subscriptions(list of objects):id(string): Subscription ID.type(string): Type of subscription (e.g., "mobile", "fixed-internet").balance(object): Balance details including:used(float): Data/usage consumed.total(float): Total data/usage.period_percentage(float): Percentage of validity period elapsed.used_percentage(float): Percentage of usage consumed.
5. Get Invoices
- Description: Retrieves unpaid and pending invoices.
- Input: None.
- Output:
invoices(list of objects):id(string): Invoice ID.amount(float): Invoice amount.status(string): Invoice status (e.g., "pending_payment", "accepted").
6. Get All Data
- Description: Aggregates customer info, loyalty points, subscriptions, and unpaid invoices in one call.
- Input: None.
- Output:
customer_info(object): Customer details (see Get Customer Info).loyalty_points_balance(object): Loyalty points balance (see Get Loyalty Points Balance).subscriptions(list of objects): Subscriptions (see Get Subscriptions).unpaid_invoices(list of objects): Invoices (see Get Invoices).timestamp(string, ISO 8601): Time of data retrieval.
Mobile Vikings API Example Script
This example script demonstrates how to utilize the MobileVikingsClient class from the aiomobilevikings module to interact with the Mobile Vikings API. It showcases various functionalities available within the client class to retrieve different types of data from the API.
Usage
-
Installation: Ensure the
aiomobilevikingsmodule is installed. If not, install it usingpip install aiomobilevikings. -
Configuration: Replace the placeholder details within the script with actual values.
-
Execution: Run the script, and it will sequentially call these functions, displaying the retrieved data for each function.
Important Notes
- Replace placeholder values (user, password) with your actual Mobile Vikings account details.
- Make sure you have appropriate access rights and permissions for the Mobile Vikings API endpoints being accessed.
Feel free to modify the script as needed, adding error handling, logging, or additional functionalities based on your requirements and the Mobile Vikings API's capabilities.
"""
Example Script: Accessing Mobile Vikings API with aiomobilevikings
Requirements:
- aiomobilevikings library (installed via pip)
Usage:
Run the script and observe the output displaying various data from the Mobile Vikings API.
"""
from aiomobilevikings import MobileVikingsClient
import logging
import asyncio
import json
# Set the logging level to DEBUG for the root logger
logging.basicConfig(level=logging.ERROR)
# Create a logger for the aiomobilevikings module
_LOGGER = logging.getLogger("aiomobilevikings")
_LOGGER.setLevel(logging.DEBUG) # Set the logging level to DEBUG for this logger
async def main():
"""Run the main function."""
# Initialize the MobileVikingsClient with credentials
client = MobileVikingsClient(
username="xxxxxx@xxxxx.com", # Replace with actual username
password="xxxxxxxxxxxxxxxx", # Replace with actual password
)
try:
# Fetch customer information
data = await client.get_data()
print(json.dumps(data, indent=2))
except Exception as e:
print("An error occurred:", e)
finally:
# Close the client session
await client.close()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aiomobilevikings-0.3.0.tar.gz.
File metadata
- Download URL: aiomobilevikings-0.3.0.tar.gz
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f10386513cb78ae8d1718f0f0e108e23eb8d76bdc7f58d4c1cfd2554527845fb
|
|
| MD5 |
9cee41fe62ce09813d70b4098921abd8
|
|
| BLAKE2b-256 |
bafd7492807158255d02b7c06df7011daa95946f70c7ab60ceae69719acb6c17
|
File details
Details for the file aiomobilevikings-0.3.0-py3-none-any.whl.
File metadata
- Download URL: aiomobilevikings-0.3.0-py3-none-any.whl
- Upload date:
- Size: 9.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.10.15
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba3da4a6a27097f0aff8ba815620ea3b53e36384438aadcab5bf7b9cee8fb6b5
|
|
| MD5 |
43a5a26759b5fd7f8d3780c405ad4566
|
|
| BLAKE2b-256 |
29ec5ad79024c54d83cfffd81f21ca7108b71d7a8e7923bd6bda0bb2993fe6b4
|