planfix client

This commit is contained in:
Robert 2024-02-28 18:33:04 +07:00
parent 890494d86f
commit 20e8558ceb
No known key found for this signature in database
GPG Key ID: F631C7FD957D5F22
5 changed files with 101 additions and 1 deletions

View File

@ -3,6 +3,10 @@
DATABASE_URL=REQUIRED. Example: DATABASE_URL=mongodb://chain-service:password@127.0.0.1:27017
DATABASE_NAME=OPTOINAL. Default: chain-db
# Planfix Rest API
PLANFIX_HOSTNAME=REQUIRED. Example: crm.planfix.com
PLANFIX_TOKEN=REQUIRED
# Poetry (Gitlab Auth Token for PyPi)
POETRY_USERNAME=REQUIRED
POETRY_PASSWORD=REQUIRED

View File

@ -0,0 +1,16 @@
from planfix_client import PlanfixClient
from chain_service.settings import Settings
from fastapi import Depends
from typing import Annotated
def get_planfix_client() -> PlanfixClient:
settings = Settings()
return PlanfixClient(
planfix_hostname=settings.planfix_hostname, planfix_token=settings.planfix_token
)
PlanfixClientDependency = Annotated[PlanfixClient, Depends(get_planfix_client)]

View File

@ -5,4 +5,7 @@ from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
database_url: str
database_name: Optional[str] = "chain-db"
planfix_hostname: str
planfix_token: str
model_config = SettingsConfigDict(env_file=".env")

78
poetry.lock generated
View File

@ -31,6 +31,17 @@ doc = ["Sphinx (>=7)", "packaging", "sphinx-autodoc-typehints (>=1.2.0)", "sphin
test = ["anyio[trio]", "coverage[toml] (>=7)", "exceptiongroup (>=1.2.0)", "hypothesis (>=4.0)", "psutil (>=5.9)", "pytest (>=7.0)", "pytest-mock (>=3.6.1)", "trustme", "uvloop (>=0.17)"]
trio = ["trio (>=0.23)"]
[[package]]
name = "certifi"
version = "2024.2.2"
description = "Python package for providing Mozilla's CA Bundle."
optional = false
python-versions = ">=3.6"
files = [
{file = "certifi-2024.2.2-py3-none-any.whl", hash = "sha256:dc383c07b76109f368f6106eee2b593b04a011ea4d55f652c6ca24a754d1cdd1"},
{file = "certifi-2024.2.2.tar.gz", hash = "sha256:0569859f95fc761b18b45ef421b1290a0f65f147e92a1e5eb3e635f9a5e4e66f"},
]
[[package]]
name = "click"
version = "8.1.7"
@ -138,6 +149,51 @@ files = [
{file = "h11-0.14.0.tar.gz", hash = "sha256:8f19fbbe99e72420ff35c00b27a34cb9937e902a8b810e2c88300c6f0a3b699d"},
]
[[package]]
name = "httpcore"
version = "1.0.4"
description = "A minimal low-level HTTP client."
optional = false
python-versions = ">=3.8"
files = [
{file = "httpcore-1.0.4-py3-none-any.whl", hash = "sha256:ac418c1db41bade2ad53ae2f3834a3a0f5ae76b56cf5aa497d2d033384fc7d73"},
{file = "httpcore-1.0.4.tar.gz", hash = "sha256:cb2839ccfcba0d2d3c1131d3c3e26dfc327326fbe7a5dc0dbfe9f6c9151bb022"},
]
[package.dependencies]
certifi = "*"
h11 = ">=0.13,<0.15"
[package.extras]
asyncio = ["anyio (>=4.0,<5.0)"]
http2 = ["h2 (>=3,<5)"]
socks = ["socksio (==1.*)"]
trio = ["trio (>=0.22.0,<0.25.0)"]
[[package]]
name = "httpx"
version = "0.27.0"
description = "The next generation HTTP client."
optional = false
python-versions = ">=3.8"
files = [
{file = "httpx-0.27.0-py3-none-any.whl", hash = "sha256:71d5465162c13681bff01ad59b2cc68dd838ea1f10e51574bac27103f00c91a5"},
{file = "httpx-0.27.0.tar.gz", hash = "sha256:a0cb88a46f32dc874e04ee956e4c2764aba2aa228f650b06788ba6bda2962ab5"},
]
[package.dependencies]
anyio = "*"
certifi = "*"
httpcore = "==1.*"
idna = "*"
sniffio = "*"
[package.extras]
brotli = ["brotli", "brotlicffi"]
cli = ["click (==8.*)", "pygments (==2.*)", "rich (>=10,<14)"]
http2 = ["h2 (>=3,<5)"]
socks = ["socksio (==1.*)"]
[[package]]
name = "idna"
version = "3.6"
@ -202,6 +258,26 @@ srv = ["pymongo[srv] (>=4.5,<5)"]
test = ["aiohttp (<3.8.6)", "mockupdb", "motor[encryption]", "pytest (>=7)", "tornado (>=5)"]
zstd = ["pymongo[zstd] (>=4.5,<5)"]
[[package]]
name = "planfix-client"
version = "0.1.3"
description = ""
optional = false
python-versions = ">=3.12,<4.0"
files = [
{file = "planfix_client-0.1.3-py3-none-any.whl", hash = "sha256:e701adc263c89602dadfbb7a95624714b37302f8cab753a5d32de514a54d593f"},
{file = "planfix_client-0.1.3.tar.gz", hash = "sha256:e3e793ab5b0132e8035b7c75bcae91780a6a888dc20d0ef8b174b707f438acae"},
]
[package.dependencies]
httpx = ">=0.27.0,<0.28.0"
loguru = ">=0.7.2,<0.8.0"
[package.source]
type = "legacy"
url = "https://gitlab.com/api/v4/groups/82963914/-/packages/pypi/simple"
reference = "gitlab"
[[package]]
name = "pycodestyle"
version = "2.11.1"
@ -544,4 +620,4 @@ dev = ["black (>=19.3b0)", "pytest (>=4.6.2)"]
[metadata]
lock-version = "2.0"
python-versions = "^3.12"
content-hash = "28773ead745eb18500da153a3309d6fc967461497b9c5ceb18bcfaea1a8f1647"
content-hash = "5fa2301a3493a9a6a28c5b253c5af679e2c757478858fa58f6e382c804f13182"

View File

@ -24,6 +24,7 @@ uvicorn = "^0.27.1"
motor = "^3.3.2"
pydantic-settings = "^2.2.1"
loguru = "^0.7.2"
planfix-client = "^0.1.3"
[build-system]
requires = ["poetry-core"]