Skip to main content

Module to communicate to the Mobile Vikings API

Project description

aiomobilevikings

Asynchronous library to communicate with the Mobile Vikings API

maintainer buyme_coffee discord

MIT License

GitHub issues Average time to resolve an issue Percentage of issues still open PRs Welcome

Python

github release github release date github last-commit github contributors github commit activity

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

  1. Installation: Ensure the aiomobilevikings module is installed. If not, install it using pip install aiomobilevikings.

  2. Configuration: Replace the placeholder details within the script with actual values.

  3. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aiomobilevikings-0.3.0.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aiomobilevikings-0.3.0-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

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

Hashes for aiomobilevikings-0.3.0.tar.gz
Algorithm Hash digest
SHA256 f10386513cb78ae8d1718f0f0e108e23eb8d76bdc7f58d4c1cfd2554527845fb
MD5 9cee41fe62ce09813d70b4098921abd8
BLAKE2b-256 bafd7492807158255d02b7c06df7011daa95946f70c7ab60ceae69719acb6c17

See more details on using hashes here.

File details

Details for the file aiomobilevikings-0.3.0-py3-none-any.whl.

File metadata

File hashes

Hashes for aiomobilevikings-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ba3da4a6a27097f0aff8ba815620ea3b53e36384438aadcab5bf7b9cee8fb6b5
MD5 43a5a26759b5fd7f8d3780c405ad4566
BLAKE2b-256 29ec5ad79024c54d83cfffd81f21ca7108b71d7a8e7923bd6bda0bb2993fe6b4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page