citycom-mv-api


Namecitycom-mv-api JSON
Version 0.1.3 PyPI version JSON
download
home_pagehttps://github.com/Shenharo/py-citycom-mv-api
SummaryA Python wrapper for citycom-mv water meters api
upload_time2024-03-25 10:03:53
maintainerOmer Shenhar
docs_urlNone
authorshenharo
requires_python<4.0,>=3.11
licenseMIT
keywords python poetry api citcom citcom-mv israel water meter
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # citycom_mv_api

A python wrapper for citycom_mv api

## Module Usage

```python
import asyncio
import os

import aiohttp
from loguru import logger

from citycom_mv_api.citycom_mv_client import CityComMVClient
from citycom_mv_api.login import LoginError
from citycom_mv_api.models.exceptions import CitycomError

session = aiohttp.ClientSession(connector=aiohttp.TCPConnector(ssl=False), timeout=aiohttp.ClientTimeout(total=10))
try:
    # Example of usage
    client = CityComMVClient("XXXX@citycom-mv.com", "YYY", session)

    token_json_file = "token.json"
    if os.path.exists(token_json_file):
        await client.load_token_from_file(token_json_file)
    else:
        try:
            await client.login()
            await client.save_token_to_file(token_json_file)
        except LoginError as err:
            logger.error(f"Failed Login: (Code {err.code}): {err.error}")
            raise

    # refresh token example- currently not implemented, it just logins again
    token = client.get_token()
    await client.check_token()
    new_token = client.get_token()
    if token != new_token:
        print("Token refreshed")
        await client.save_token_to_file(token_json_file)

    print("access_token: " + token.access_token)

    customer = await client.get_customer()
    print(customer)

    reading = await client.get_last_meter_reading(customer.properties[0].meters[0].meter_id)
    print(reading)

except CitycomError as err:
    logger.error(f"Error: (Code {err.code}): {err.error}")
finally:
    await session.close()
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Shenharo/py-citycom-mv-api",
    "name": "citycom-mv-api",
    "maintainer": "Omer Shenhar",
    "docs_url": null,
    "requires_python": "<4.0,>=3.11",
    "maintainer_email": "shenharo@gmail.com",
    "keywords": "python, poetry, api, citcom, citcom-mv, israel, water, meter",
    "author": "shenharo",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/8c/cb/c7bf484af93e6f43ef61babcddd872758b34a365fac9d4a3c8911bea77d5/citycom_mv_api-0.1.3.tar.gz",
    "platform": null,
    "description": "# citycom_mv_api\n\nA python wrapper for citycom_mv api\n\n## Module Usage\n\n```python\nimport asyncio\nimport os\n\nimport aiohttp\nfrom loguru import logger\n\nfrom citycom_mv_api.citycom_mv_client import CityComMVClient\nfrom citycom_mv_api.login import LoginError\nfrom citycom_mv_api.models.exceptions import CitycomError\n\nsession = aiohttp.ClientSession(connector=aiohttp.TCPConnector(ssl=False), timeout=aiohttp.ClientTimeout(total=10))\ntry:\n    # Example of usage\n    client = CityComMVClient(\"XXXX@citycom-mv.com\", \"YYY\", session)\n\n    token_json_file = \"token.json\"\n    if os.path.exists(token_json_file):\n        await client.load_token_from_file(token_json_file)\n    else:\n        try:\n            await client.login()\n            await client.save_token_to_file(token_json_file)\n        except LoginError as err:\n            logger.error(f\"Failed Login: (Code {err.code}): {err.error}\")\n            raise\n\n    # refresh token example- currently not implemented, it just logins again\n    token = client.get_token()\n    await client.check_token()\n    new_token = client.get_token()\n    if token != new_token:\n        print(\"Token refreshed\")\n        await client.save_token_to_file(token_json_file)\n\n    print(\"access_token: \" + token.access_token)\n\n    customer = await client.get_customer()\n    print(customer)\n\n    reading = await client.get_last_meter_reading(customer.properties[0].meters[0].meter_id)\n    print(reading)\n\nexcept CitycomError as err:\n    logger.error(f\"Error: (Code {err.code}): {err.error}\")\nfinally:\n    await session.close()",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A Python wrapper for citycom-mv water meters api",
    "version": "0.1.3",
    "project_urls": {
        "Homepage": "https://github.com/Shenharo/py-citycom-mv-api",
        "Repository": "https://github.com/Shenharo/py-citycom-mv-api"
    },
    "split_keywords": [
        "python",
        " poetry",
        " api",
        " citcom",
        " citcom-mv",
        " israel",
        " water",
        " meter"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "cae4f3ae47706bf373e66fb4db406eb0cc0e1676d3e9c4dccd4625fa3c4be375",
                "md5": "0d830932782e2e136c959df532028f58",
                "sha256": "c7e66951a74448e8373e0a21ff31d67841fa5f30d7569bc23cc04b01e3b210de"
            },
            "downloads": -1,
            "filename": "citycom_mv_api-0.1.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "0d830932782e2e136c959df532028f58",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.11",
            "size": 18343,
            "upload_time": "2024-03-25T10:03:52",
            "upload_time_iso_8601": "2024-03-25T10:03:52.261409Z",
            "url": "https://files.pythonhosted.org/packages/ca/e4/f3ae47706bf373e66fb4db406eb0cc0e1676d3e9c4dccd4625fa3c4be375/citycom_mv_api-0.1.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8ccbc7bf484af93e6f43ef61babcddd872758b34a365fac9d4a3c8911bea77d5",
                "md5": "81aa121a8c378ec38a23809df2de7e89",
                "sha256": "8e74da7ba373ce6948841683c2db6142d32d99ff8c734d70dbbf7638ba45018b"
            },
            "downloads": -1,
            "filename": "citycom_mv_api-0.1.3.tar.gz",
            "has_sig": false,
            "md5_digest": "81aa121a8c378ec38a23809df2de7e89",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.11",
            "size": 11560,
            "upload_time": "2024-03-25T10:03:53",
            "upload_time_iso_8601": "2024-03-25T10:03:53.295540Z",
            "url": "https://files.pythonhosted.org/packages/8c/cb/c7bf484af93e6f43ef61babcddd872758b34a365fac9d4a3c8911bea77d5/citycom_mv_api-0.1.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-25 10:03:53",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Shenharo",
    "github_project": "py-citycom-mv-api",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "citycom-mv-api"
}
        
Elapsed time: 0.20222s