Skip to main content

Silvr client

Project description

silvr-client

A Python client for brokers to send new applications.

See 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

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

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

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

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

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

silvr-client-0.1.1.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

silvr_client-0.1.1-py3-none-any.whl (6.8 kB view details)

Uploaded Python 3

File details

Details for the file silvr-client-0.1.1.tar.gz.

File metadata

  • Download URL: silvr-client-0.1.1.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for silvr-client-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1d629d454e602b743d89bcca74297249d955fe7401863291f6062d429de74151
MD5 6ab14511fdb1d7986139e1a20f0493fb
BLAKE2b-256 629b902fc24dfde47335b65ecf9e474fcbf8fa62eaada5b7e00f3ae4ca44bac3

See more details on using hashes here.

File details

Details for the file silvr_client-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: silvr_client-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for silvr_client-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d1095b2c1ab96e130d178e54de31cc156dabc0fe230a950295aa69791a83c491
MD5 ec65aa123cd03f7b927d5fb9f2c7f70a
BLAKE2b-256 f76c46c9e53c5100d63477d4b3a5291655805104b6142eea4627b86751843d53

See more details on using hashes here.

Supported by

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