跳转到主要内容

Silvr客户端

项目描述

silvr-client

用于向经纪人发送新应用的Python客户端。

查看demo.py了解如何使用API。

安装

从PyPI安装

pip install silvr-client

从源安装

pip install -e .

演示

export BROKER_API_KEY="<api-key>"

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

API

列出现有应用

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()]

创建新应用

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())

上传新附件

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())

列出所有文档

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()]

变更日志

本文件描述了每个过去版本的更改。

0.1.1 (2023-11-13)

  • 添加Silvr模型数据类以帮助集成。
  • 在README中添加API文档

0.1.0 (2023-11-13)

  • 允许经纪人登录
  • 允许发送应用

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解更多关于 安装软件包 的信息。

源代码分发

silvr-client-0.1.1.tar.gz (7.8 kB 查看散列值)

上传于 源代码

构建分发

silvr_client-0.1.1-py3-none-any.whl (6.8 kB 查看散列值)

上传于 Python 3

支持者