xcover-python


Namexcover-python JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://www.covergenius.com/xcover/
SummaryPython client for XCover API (XCore).
upload_time2023-06-10 14:41:13
maintainerArtem Kolesnikov
docs_urlNone
authorArtem Kolesnikov
requires_python>=3.8,<4.0
licenseMIT
keywords xcover api api-client insurance
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # &middot; xcover-python &middot;
[![Supported Versions](https://img.shields.io/pypi/pyversions/xcover-python.svg)](https://pypi.org/project/xcover-python)
[![codecov](https://codecov.io/gh/CoverGenius/xcover-python/branch/master/graph/badge.svg?token=KINNTVZV07)](https://codecov.io/gh/CoverGenius/xcover-python)

---

`xcover-python` is a Python API Client for [XCover](https://www.covergenius.com/xcover/).

---

## Installation

`xcover-python` is available on PyPI. To install the latest version run:

    pip install xcover-python

or

    poertry install xcover-python

## Features

- Authentication
- Simple configuration using env variables
- (WIP) High-level API to perform partner operations on quotes and bookings

## Configuration

### Config object

The library provides `XCoverConfig` dataclass that can be used as shown:

```python
from xcover import XCover, XCoverConfig

client = XCover(
    XCoverConfig( # minimal config, check autocomplete for more options
        base_url="https://api.xcover.com/xcover",
        partner_code="--PARTNER_CODE--",
        auth_api_key="--API_KEY--",
        auth_api_secret="--API_SECRET--",
    )
)

```

### Env variables

Alternatively, it is possible to use env variables.

The full list of configuration options:

* `XC_BASE_URL` (`XCoverConfig.base_url`): XCover base URL (e.g. `https://api.xcover.com/api/v2/`).
* `XC_PARTNER_CODE` (`XCoverConfig.partner_code`): Partner code (e.g. `LLODT`).
* `XC_HTTP_TIMEOUT` (`XCoverConfig.http_timeout`): HTTP timeout in seconds. Default value is `10`.
* `XC_AUTH_API_KEY` (`XCoverConfig.auth_api_key`): API key to use.
* `XC_AUTH_API_SECRET` (`XCoverConfig.auth_api_secret`): API secret to use.
* `XC_AUTH_ALGORITHM` (`XCoverConfig.auth_algorithm`): HMAC encoding algorithm to use. Default is `hmac-sha512`.
* `XC_AUTH_HEADERS` (`XCoverConfig.auth_headers`): Headers to sign. Default is `(request-target) date`.
* `XC_RETRY_TOTAL` (`XCoverConfig.retry_total`): Total number of retries. Default is `5`.
* `XC_RETRY_BACKOFF_FACTOR` (`XCoverConfig.retry_backoff_factor`): Backoff factor for retries timeout. Default is `2`.

## Usage example

### Using low-level `call` method

```python
import requests

from xcover.xcover import XCover

# Env variables are used
client = XCover()

# Prepare payload
payload = {
    "request": [
        {
            "policy_type": "event_ticket_protection",
            "policy_type_version": 1,
            "policy_start_date": "2021-12-01T17:59:00.831+00:00",
            "event_datetime": "2021-12-25T21:00:00+00:00",
            "event_name": "Ariana Grande",
            "event_location": "The O2",
            "number_of_tickets": 2,
            "tickets": [
                {"price": 100},
            ],
            "resale_ticket": False,
            "event_country": "GB",
        }
    ],
    "currency": "GBP",
    "customer_country": "GB",
    "customer_region": "London",
    "customer_language": "en",
}
# Calling XCover API
response: requests.Response = client.call(
    method="POST",
    url="partners/LLODT/quotes/",
    payload=payload,
)

quote = response.json()
print(quote)
```

### Retries

This client will automatically retry certain operations when it is considered safe to do this.
The retry number and intervals could be controlled via XC_RETRY_TOTAL and XC_RETRY_BACKOFF_FACTOR
environment variables ot the same config options.

Auto retry logic can be enabled/disabled per operation. However, further fine-tuning is possible
via extending XCover class if required.


            

Raw data

            {
    "_id": null,
    "home_page": "https://www.covergenius.com/xcover/",
    "name": "xcover-python",
    "maintainer": "Artem Kolesnikov",
    "docs_url": null,
    "requires_python": ">=3.8,<4.0",
    "maintainer_email": "artem@covergenius.com",
    "keywords": "xcover,api,api-client,insurance",
    "author": "Artem Kolesnikov",
    "author_email": "artem@covergenius.com",
    "download_url": "https://files.pythonhosted.org/packages/6d/b0/452387476f90506c7e33cba4d21b0f8bd28405ad45d0b0fc08a951cbcfae/xcover_python-0.1.1.tar.gz",
    "platform": null,
    "description": "# &middot; xcover-python &middot;\n[![Supported Versions](https://img.shields.io/pypi/pyversions/xcover-python.svg)](https://pypi.org/project/xcover-python)\n[![codecov](https://codecov.io/gh/CoverGenius/xcover-python/branch/master/graph/badge.svg?token=KINNTVZV07)](https://codecov.io/gh/CoverGenius/xcover-python)\n\n---\n\n`xcover-python` is a Python API Client for [XCover](https://www.covergenius.com/xcover/).\n\n---\n\n## Installation\n\n`xcover-python` is available on PyPI. To install the latest version run:\n\n    pip install xcover-python\n\nor\n\n    poertry install xcover-python\n\n## Features\n\n- Authentication\n- Simple configuration using env variables\n- (WIP) High-level API to perform partner operations on quotes and bookings\n\n## Configuration\n\n### Config object\n\nThe library provides `XCoverConfig` dataclass that can be used as shown:\n\n```python\nfrom xcover import XCover, XCoverConfig\n\nclient = XCover(\n    XCoverConfig( # minimal config, check autocomplete for more options\n        base_url=\"https://api.xcover.com/xcover\",\n        partner_code=\"--PARTNER_CODE--\",\n        auth_api_key=\"--API_KEY--\",\n        auth_api_secret=\"--API_SECRET--\",\n    )\n)\n\n```\n\n### Env variables\n\nAlternatively, it is possible to use env variables.\n\nThe full list of configuration options:\n\n* `XC_BASE_URL` (`XCoverConfig.base_url`): XCover base URL (e.g. `https://api.xcover.com/api/v2/`).\n* `XC_PARTNER_CODE` (`XCoverConfig.partner_code`): Partner code (e.g. `LLODT`).\n* `XC_HTTP_TIMEOUT` (`XCoverConfig.http_timeout`): HTTP timeout in seconds. Default value is `10`.\n* `XC_AUTH_API_KEY` (`XCoverConfig.auth_api_key`): API key to use.\n* `XC_AUTH_API_SECRET` (`XCoverConfig.auth_api_secret`): API secret to use.\n* `XC_AUTH_ALGORITHM` (`XCoverConfig.auth_algorithm`): HMAC encoding algorithm to use. Default is `hmac-sha512`.\n* `XC_AUTH_HEADERS` (`XCoverConfig.auth_headers`): Headers to sign. Default is `(request-target) date`.\n* `XC_RETRY_TOTAL` (`XCoverConfig.retry_total`): Total number of retries. Default is `5`.\n* `XC_RETRY_BACKOFF_FACTOR` (`XCoverConfig.retry_backoff_factor`): Backoff factor for retries timeout. Default is `2`.\n\n## Usage example\n\n### Using low-level `call` method\n\n```python\nimport requests\n\nfrom xcover.xcover import XCover\n\n# Env variables are used\nclient = XCover()\n\n# Prepare payload\npayload = {\n    \"request\": [\n        {\n            \"policy_type\": \"event_ticket_protection\",\n            \"policy_type_version\": 1,\n            \"policy_start_date\": \"2021-12-01T17:59:00.831+00:00\",\n            \"event_datetime\": \"2021-12-25T21:00:00+00:00\",\n            \"event_name\": \"Ariana Grande\",\n            \"event_location\": \"The O2\",\n            \"number_of_tickets\": 2,\n            \"tickets\": [\n                {\"price\": 100},\n            ],\n            \"resale_ticket\": False,\n            \"event_country\": \"GB\",\n        }\n    ],\n    \"currency\": \"GBP\",\n    \"customer_country\": \"GB\",\n    \"customer_region\": \"London\",\n    \"customer_language\": \"en\",\n}\n# Calling XCover API\nresponse: requests.Response = client.call(\n    method=\"POST\",\n    url=\"partners/LLODT/quotes/\",\n    payload=payload,\n)\n\nquote = response.json()\nprint(quote)\n```\n\n### Retries\n\nThis client will automatically retry certain operations when it is considered safe to do this.\nThe retry number and intervals could be controlled via XC_RETRY_TOTAL and XC_RETRY_BACKOFF_FACTOR\nenvironment variables ot the same config options.\n\nAuto retry logic can be enabled/disabled per operation. However, further fine-tuning is possible\nvia extending XCover class if required.\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python client for XCover API (XCore).",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://www.covergenius.com/xcover/",
        "Repository": "https://github.com/CoverGenius/xcover-python"
    },
    "split_keywords": [
        "xcover",
        "api",
        "api-client",
        "insurance"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4cc85785fdb8b16f41fa9dead94208db5f0fcfc63df9eaa2c0816bae4e99218e",
                "md5": "a36fe8b25a2a04a268671902eccc4f35",
                "sha256": "6292a5a9de74361d81254da842b62e07f2f69a8e86f6b53bb15a0b0e1ac3d48d"
            },
            "downloads": -1,
            "filename": "xcover_python-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a36fe8b25a2a04a268671902eccc4f35",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4.0",
            "size": 7275,
            "upload_time": "2023-06-10T14:41:12",
            "upload_time_iso_8601": "2023-06-10T14:41:12.354823Z",
            "url": "https://files.pythonhosted.org/packages/4c/c8/5785fdb8b16f41fa9dead94208db5f0fcfc63df9eaa2c0816bae4e99218e/xcover_python-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6db0452387476f90506c7e33cba4d21b0f8bd28405ad45d0b0fc08a951cbcfae",
                "md5": "82ec40f374a40c618afe598b3c128fd6",
                "sha256": "8e23b77808c93b11621bf0aa701976a4f903785a281ad24c238b4419482986c5"
            },
            "downloads": -1,
            "filename": "xcover_python-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "82ec40f374a40c618afe598b3c128fd6",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4.0",
            "size": 7134,
            "upload_time": "2023-06-10T14:41:13",
            "upload_time_iso_8601": "2023-06-10T14:41:13.858984Z",
            "url": "https://files.pythonhosted.org/packages/6d/b0/452387476f90506c7e33cba4d21b0f8bd28405ad45d0b0fc08a951cbcfae/xcover_python-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-10 14:41:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "CoverGenius",
    "github_project": "xcover-python",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "xcover-python"
}
        
Elapsed time: 0.07892s