silvr-client


Namesilvr-client JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/SilvrGroup/silvr-client/
SummarySilvr client
upload_time2023-11-13 18:21:51
maintainer
docs_urlNone
authorSilvr Group
requires_python
licenseApache License (2.0)
keywords web services
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # silvr-client

A Python client for brokers to send new applications.

See [demo.py](demo.py) to see how to use the API.


## Install

### From PyPI

```
pip install silvr-client
```

### From source

```
pip install -e .
```

## Demo

```
export BROKER_API_KEY="<api-key>"

CLIENT_EMAIL="john.doe@acme.com" \
COMPANY_REGISTRATION_NUMBER="123456789" \
python demo.py
```

## API

### List existing applications

```python
import os
import httpx
import json

from silvr_client import SilvrClient, TokenAuth
from silvr_client.models import Application, Document

API_URL = "https://demo.silvr.dev/api/"
BROKER_API_KEY = os.getenv("BROKER_API_KEY")

with SilvrClient(base_url=API_URL, auth=TokenAuth(BROKER_API_KEY)) as client:
    applications_response = client.applications()
    try:
        applications_response.raise_for_status()
    except httpx.HTTPStatusError:
        print(json.dumps(applications_response.json(), indent=2))

    applications = [Application.from_request(a) for a in applications_response.json()]
```

### Create new application

```python
import httpx
import json

from silvr_client import SilvrClient, TokenAuth, choices
from silvr_client.models import Application, Document

COMPANY_REGISTRATION_NUMBER = "123456789"
CLIENT_EMAIL = "john.doe@acme.com"


with SilvrClient(base_url=API_URL, auth=TokenAuth(BROKER_API_KEY)) as client:
    application = Application(
            first_name="John",
            last_name="Doe",
            email=CLIENT_EMAIL,
            phone_number="+33123456789",
            company_name="ACME SAS",
            company_registration_number=COMPANY_REGISTRATION_NUMBER,
            country=choices.Country.FR,
            expected_funding_amount_range=choices.ExpectedFundingAmountRange.BETWEEN_10K_AND_100K,
            declared_monthly_revenue_range=choices.DeclaredRevenueRange.BETWEEN_10K_AND_25K,
            declared_revenue_duration_range=choices.DeclaredRevenueDuration.ABOVE_12_MONTHS,
            additional_message="API demo",
    )
    application_response = application.save(client)
    try:
        application_response.raise_for_status()
    except httpx.HTTPStatusError:
        print(json.dumps(application_response.json(), indent=2))
    else:
        application = Application.from_request(application_response.json())
```


### Upload a new attachment


```python
import httpx
import json

from silvr_client import SilvrClient, TokenAuth, choices
from silvr_client.models import Application, Document


with SilvrClient(base_url=API_URL, auth=TokenAuth(BROKER_API_KEY)) as client:
    application = Application.from_request(applications_response.json())

    # From the application object

    document_response = application.upload_document(
        client,
        choices.UploadedFile("bank_statement.pdf", open("demo.pdf", "rb"), choices.ContentType.PDF),
        choices.DocumentCategory.BANK_STATEMENT
    )
    document_response.raise_for_status()
    Document.from_request(document_response.json())

    # Or from the client

    document_response = client.new_document(
        application_id=application.uuid,
        file=choices.UploadedFile("financial_statement.pdf", open("demo.pdf", "rb"), choices.ContentType.PDF),
        category=choices.DocumentCategory.FINANCIAL_STATEMENT,
    )
    document_response.raise_for_status()
    Document.from_request(document_response.json())
```


### List all documents


```python
import httpx
import json

from silvr_client import SilvrClient, TokenAuth, choices
from silvr_client.models import Application, Document


with SilvrClient(base_url=API_URL, auth=TokenAuth(BROKER_API_KEY)) as client:
    documents_response = client.documents(
        application_id=application.uuid,
    )
    documents_response.raise_for_status()
    documents = [Document.from_request(d) for d in documents_response.json()]
```


# CHANGELOG

This document describes changes between each  past release.

## 0.1.1 (2023-11-13)


- Add Silvr models dataclasses to help with the integration.
- Add API documentation in README

## 0.1.0 (2023-11-13)

- Allow broker login
- Allow sending applications

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/SilvrGroup/silvr-client/",
    "name": "silvr-client",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "web services",
    "author": "Silvr Group",
    "author_email": "contact@silvr.co",
    "download_url": "https://files.pythonhosted.org/packages/62/9b/902fc24dfde47335b65ecf9e474fcbf8fa62eaada5b7e00f3ae4ca44bac3/silvr-client-0.1.1.tar.gz",
    "platform": null,
    "description": "# silvr-client\n\nA Python client for brokers to send new applications.\n\nSee [demo.py](demo.py) to see how to use the API.\n\n\n## Install\n\n### From PyPI\n\n```\npip install silvr-client\n```\n\n### From source\n\n```\npip install -e .\n```\n\n## Demo\n\n```\nexport BROKER_API_KEY=\"<api-key>\"\n\nCLIENT_EMAIL=\"john.doe@acme.com\" \\\nCOMPANY_REGISTRATION_NUMBER=\"123456789\" \\\npython demo.py\n```\n\n## API\n\n### List existing applications\n\n```python\nimport os\nimport httpx\nimport json\n\nfrom silvr_client import SilvrClient, TokenAuth\nfrom silvr_client.models import Application, Document\n\nAPI_URL = \"https://demo.silvr.dev/api/\"\nBROKER_API_KEY = os.getenv(\"BROKER_API_KEY\")\n\nwith SilvrClient(base_url=API_URL, auth=TokenAuth(BROKER_API_KEY)) as client:\n    applications_response = client.applications()\n    try:\n        applications_response.raise_for_status()\n    except httpx.HTTPStatusError:\n        print(json.dumps(applications_response.json(), indent=2))\n\n    applications = [Application.from_request(a) for a in applications_response.json()]\n```\n\n### Create new application\n\n```python\nimport httpx\nimport json\n\nfrom silvr_client import SilvrClient, TokenAuth, choices\nfrom silvr_client.models import Application, Document\n\nCOMPANY_REGISTRATION_NUMBER = \"123456789\"\nCLIENT_EMAIL = \"john.doe@acme.com\"\n\n\nwith SilvrClient(base_url=API_URL, auth=TokenAuth(BROKER_API_KEY)) as client:\n    application = Application(\n            first_name=\"John\",\n            last_name=\"Doe\",\n            email=CLIENT_EMAIL,\n            phone_number=\"+33123456789\",\n            company_name=\"ACME SAS\",\n            company_registration_number=COMPANY_REGISTRATION_NUMBER,\n            country=choices.Country.FR,\n            expected_funding_amount_range=choices.ExpectedFundingAmountRange.BETWEEN_10K_AND_100K,\n            declared_monthly_revenue_range=choices.DeclaredRevenueRange.BETWEEN_10K_AND_25K,\n            declared_revenue_duration_range=choices.DeclaredRevenueDuration.ABOVE_12_MONTHS,\n            additional_message=\"API demo\",\n    )\n    application_response = application.save(client)\n    try:\n        application_response.raise_for_status()\n    except httpx.HTTPStatusError:\n        print(json.dumps(application_response.json(), indent=2))\n    else:\n        application = Application.from_request(application_response.json())\n```\n\n\n### Upload a new attachment\n\n\n```python\nimport httpx\nimport json\n\nfrom silvr_client import SilvrClient, TokenAuth, choices\nfrom silvr_client.models import Application, Document\n\n\nwith SilvrClient(base_url=API_URL, auth=TokenAuth(BROKER_API_KEY)) as client:\n    application = Application.from_request(applications_response.json())\n\n    # From the application object\n\n    document_response = application.upload_document(\n        client,\n        choices.UploadedFile(\"bank_statement.pdf\", open(\"demo.pdf\", \"rb\"), choices.ContentType.PDF),\n        choices.DocumentCategory.BANK_STATEMENT\n    )\n    document_response.raise_for_status()\n    Document.from_request(document_response.json())\n\n    # Or from the client\n\n    document_response = client.new_document(\n        application_id=application.uuid,\n        file=choices.UploadedFile(\"financial_statement.pdf\", open(\"demo.pdf\", \"rb\"), choices.ContentType.PDF),\n        category=choices.DocumentCategory.FINANCIAL_STATEMENT,\n    )\n    document_response.raise_for_status()\n    Document.from_request(document_response.json())\n```\n\n\n### List all documents\n\n\n```python\nimport httpx\nimport json\n\nfrom silvr_client import SilvrClient, TokenAuth, choices\nfrom silvr_client.models import Application, Document\n\n\nwith SilvrClient(base_url=API_URL, auth=TokenAuth(BROKER_API_KEY)) as client:\n    documents_response = client.documents(\n        application_id=application.uuid,\n    )\n    documents_response.raise_for_status()\n    documents = [Document.from_request(d) for d in documents_response.json()]\n```\n\n\n# CHANGELOG\n\nThis document describes changes between each  past release.\n\n## 0.1.1 (2023-11-13)\n\n\n- Add Silvr models dataclasses to help with the integration.\n- Add API documentation in README\n\n## 0.1.0 (2023-11-13)\n\n- Allow broker login\n- Allow sending applications\n",
    "bugtrack_url": null,
    "license": "Apache License (2.0)",
    "summary": "Silvr client",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://github.com/SilvrGroup/silvr-client/"
    },
    "split_keywords": [
        "web",
        "services"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f76c46c9e53c5100d63477d4b3a5291655805104b6142eea4627b86751843d53",
                "md5": "ec65aa123cd03f7b927d5fb9f2c7f70a",
                "sha256": "d1095b2c1ab96e130d178e54de31cc156dabc0fe230a950295aa69791a83c491"
            },
            "downloads": -1,
            "filename": "silvr_client-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ec65aa123cd03f7b927d5fb9f2c7f70a",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 6822,
            "upload_time": "2023-11-13T18:21:49",
            "upload_time_iso_8601": "2023-11-13T18:21:49.898722Z",
            "url": "https://files.pythonhosted.org/packages/f7/6c/46c9e53c5100d63477d4b3a5291655805104b6142eea4627b86751843d53/silvr_client-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "629b902fc24dfde47335b65ecf9e474fcbf8fa62eaada5b7e00f3ae4ca44bac3",
                "md5": "6ab14511fdb1d7986139e1a20f0493fb",
                "sha256": "1d629d454e602b743d89bcca74297249d955fe7401863291f6062d429de74151"
            },
            "downloads": -1,
            "filename": "silvr-client-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "6ab14511fdb1d7986139e1a20f0493fb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 7823,
            "upload_time": "2023-11-13T18:21:51",
            "upload_time_iso_8601": "2023-11-13T18:21:51.757229Z",
            "url": "https://files.pythonhosted.org/packages/62/9b/902fc24dfde47335b65ecf9e474fcbf8fa62eaada5b7e00f3ae4ca44bac3/silvr-client-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-13 18:21:51",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "SilvrGroup",
    "github_project": "silvr-client",
    "github_not_found": true,
    "lcname": "silvr-client"
}
        
Elapsed time: 0.13808s