smartbill-rest-sdk 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- smartbill_rest_sdk-1.0.0/.gitignore +289 -0
- smartbill_rest_sdk-1.0.0/.idea/.gitignore +10 -0
- smartbill_rest_sdk-1.0.0/.idea/inspectionProfiles/profiles_settings.xml +6 -0
- smartbill_rest_sdk-1.0.0/.idea/misc.xml +7 -0
- smartbill_rest_sdk-1.0.0/.idea/modules.xml +8 -0
- smartbill_rest_sdk-1.0.0/.idea/smartbill-sdk.iml +11 -0
- smartbill_rest_sdk-1.0.0/.idea/vcs.xml +6 -0
- smartbill_rest_sdk-1.0.0/AGENTS.md +99 -0
- smartbill_rest_sdk-1.0.0/CHANGELOG.md +58 -0
- smartbill_rest_sdk-1.0.0/LICENSE +7 -0
- smartbill_rest_sdk-1.0.0/PKG-INFO +135 -0
- smartbill_rest_sdk-1.0.0/README.md +119 -0
- smartbill_rest_sdk-1.0.0/docs/openapi.json +9741 -0
- smartbill_rest_sdk-1.0.0/examples/async_taxes_and_stocks.py +48 -0
- smartbill_rest_sdk-1.0.0/examples/create_estimate_sync.py +52 -0
- smartbill_rest_sdk-1.0.0/examples/create_invoice_sync.py +65 -0
- smartbill_rest_sdk-1.0.0/examples/create_payment_sync.py +42 -0
- smartbill_rest_sdk-1.0.0/examples/fiscal_receipt_async.py +73 -0
- smartbill_rest_sdk-1.0.0/examples/invoice_lifecycle_sync.py +50 -0
- smartbill_rest_sdk-1.0.0/examples/list_series_sync.py +33 -0
- smartbill_rest_sdk-1.0.0/examples/send_email_sync.py +43 -0
- smartbill_rest_sdk-1.0.0/pyproject.toml +30 -0
- smartbill_rest_sdk-1.0.0/skills/README.md +34 -0
- smartbill_rest_sdk-1.0.0/skills/smartbill-email/SKILL.md +118 -0
- smartbill_rest_sdk-1.0.0/skills/smartbill-invoices/SKILL.md +172 -0
- smartbill_rest_sdk-1.0.0/skills/smartbill-payments/SKILL.md +173 -0
- smartbill_rest_sdk-1.0.0/src/smartbill_sdk/__init__.py +86 -0
- smartbill_rest_sdk-1.0.0/src/smartbill_sdk/_transport.py +221 -0
- smartbill_rest_sdk-1.0.0/src/smartbill_sdk/async_client.py +95 -0
- smartbill_rest_sdk-1.0.0/src/smartbill_sdk/client.py +102 -0
- smartbill_rest_sdk-1.0.0/src/smartbill_sdk/exceptions.py +45 -0
- smartbill_rest_sdk-1.0.0/src/smartbill_sdk/models/__init__.py +61 -0
- smartbill_rest_sdk-1.0.0/src/smartbill_sdk/models/common.py +126 -0
- smartbill_rest_sdk-1.0.0/src/smartbill_sdk/models/config.py +42 -0
- smartbill_rest_sdk-1.0.0/src/smartbill_sdk/models/email.py +28 -0
- smartbill_rest_sdk-1.0.0/src/smartbill_sdk/models/estimates.py +38 -0
- smartbill_rest_sdk-1.0.0/src/smartbill_sdk/models/invoices.py +59 -0
- smartbill_rest_sdk-1.0.0/src/smartbill_sdk/models/payments.py +56 -0
- smartbill_rest_sdk-1.0.0/src/smartbill_sdk/models/responses.py +73 -0
- smartbill_rest_sdk-1.0.0/src/smartbill_sdk/models/stocks.py +40 -0
- smartbill_rest_sdk-1.0.0/src/smartbill_sdk/services/__init__.py +445 -0
- smartbill_rest_sdk-1.0.0/tests/conftest.py +38 -0
- smartbill_rest_sdk-1.0.0/tests/test_estimates.py +111 -0
- smartbill_rest_sdk-1.0.0/tests/test_invoices.py +181 -0
- smartbill_rest_sdk-1.0.0/tests/test_misc.py +157 -0
- smartbill_rest_sdk-1.0.0/tests/test_models.py +116 -0
- smartbill_rest_sdk-1.0.0/tests/test_payments.py +134 -0
- smartbill_rest_sdk-1.0.0/tests/test_transport.py +112 -0
- smartbill_rest_sdk-1.0.0/uv.lock +330 -0
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
# Created by https://www.toptal.com/developers/gitignore/api/python,jetbrains
|
|
2
|
+
# Edit at https://www.toptal.com/developers/gitignore?templates=python,jetbrains
|
|
3
|
+
|
|
4
|
+
### JetBrains ###
|
|
5
|
+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
|
6
|
+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
|
7
|
+
|
|
8
|
+
# User-specific stuff
|
|
9
|
+
.idea/**/workspace.xml
|
|
10
|
+
.idea/**/tasks.xml
|
|
11
|
+
.idea/**/usage.statistics.xml
|
|
12
|
+
.idea/**/dictionaries
|
|
13
|
+
.idea/**/shelf
|
|
14
|
+
|
|
15
|
+
# AWS User-specific
|
|
16
|
+
.idea/**/aws.xml
|
|
17
|
+
|
|
18
|
+
# Generated files
|
|
19
|
+
.idea/**/contentModel.xml
|
|
20
|
+
|
|
21
|
+
# Sensitive or high-churn files
|
|
22
|
+
.idea/**/dataSources/
|
|
23
|
+
.idea/**/dataSources.ids
|
|
24
|
+
.idea/**/dataSources.local.xml
|
|
25
|
+
.idea/**/sqlDataSources.xml
|
|
26
|
+
.idea/**/dynamic.xml
|
|
27
|
+
.idea/**/uiDesigner.xml
|
|
28
|
+
.idea/**/dbnavigator.xml
|
|
29
|
+
|
|
30
|
+
# Gradle
|
|
31
|
+
.idea/**/gradle.xml
|
|
32
|
+
.idea/**/libraries
|
|
33
|
+
|
|
34
|
+
# Gradle and Maven with auto-import
|
|
35
|
+
# When using Gradle or Maven with auto-import, you should exclude module files,
|
|
36
|
+
# since they will be recreated, and may cause churn. Uncomment if using
|
|
37
|
+
# auto-import.
|
|
38
|
+
# .idea/artifacts
|
|
39
|
+
# .idea/compiler.xml
|
|
40
|
+
# .idea/jarRepositories.xml
|
|
41
|
+
# .idea/modules.xml
|
|
42
|
+
# .idea/*.iml
|
|
43
|
+
# .idea/modules
|
|
44
|
+
# *.iml
|
|
45
|
+
# *.ipr
|
|
46
|
+
|
|
47
|
+
# CMake
|
|
48
|
+
cmake-build-*/
|
|
49
|
+
|
|
50
|
+
# Mongo Explorer plugin
|
|
51
|
+
.idea/**/mongoSettings.xml
|
|
52
|
+
|
|
53
|
+
# File-based project format
|
|
54
|
+
*.iws
|
|
55
|
+
|
|
56
|
+
# IntelliJ
|
|
57
|
+
out/
|
|
58
|
+
|
|
59
|
+
# mpeltonen/sbt-idea plugin
|
|
60
|
+
.idea_modules/
|
|
61
|
+
|
|
62
|
+
# JIRA plugin
|
|
63
|
+
atlassian-ide-plugin.xml
|
|
64
|
+
|
|
65
|
+
# Cursive Clojure plugin
|
|
66
|
+
.idea/replstate.xml
|
|
67
|
+
|
|
68
|
+
# SonarLint plugin
|
|
69
|
+
.idea/sonarlint/
|
|
70
|
+
|
|
71
|
+
# Crashlytics plugin (for Android Studio and IntelliJ)
|
|
72
|
+
com_crashlytics_export_strings.xml
|
|
73
|
+
crashlytics.properties
|
|
74
|
+
crashlytics-build.properties
|
|
75
|
+
fabric.properties
|
|
76
|
+
|
|
77
|
+
# Editor-based Rest Client
|
|
78
|
+
.idea/httpRequests
|
|
79
|
+
|
|
80
|
+
# Android studio 3.1+ serialized cache file
|
|
81
|
+
.idea/caches/build_file_checksums.ser
|
|
82
|
+
|
|
83
|
+
### JetBrains Patch ###
|
|
84
|
+
# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721
|
|
85
|
+
|
|
86
|
+
# *.iml
|
|
87
|
+
# modules.xml
|
|
88
|
+
# .idea/misc.xml
|
|
89
|
+
# *.ipr
|
|
90
|
+
|
|
91
|
+
# Sonarlint plugin
|
|
92
|
+
# https://plugins.jetbrains.com/plugin/7973-sonarlint
|
|
93
|
+
.idea/**/sonarlint/
|
|
94
|
+
|
|
95
|
+
# SonarQube Plugin
|
|
96
|
+
# https://plugins.jetbrains.com/plugin/7238-sonarqube-community-plugin
|
|
97
|
+
.idea/**/sonarIssues.xml
|
|
98
|
+
|
|
99
|
+
# Markdown Navigator plugin
|
|
100
|
+
# https://plugins.jetbrains.com/plugin/7896-markdown-navigator-enhanced
|
|
101
|
+
.idea/**/markdown-navigator.xml
|
|
102
|
+
.idea/**/markdown-navigator-enh.xml
|
|
103
|
+
.idea/**/markdown-navigator/
|
|
104
|
+
|
|
105
|
+
# Cache file creation bug
|
|
106
|
+
# See https://youtrack.jetbrains.com/issue/JBR-2257
|
|
107
|
+
.idea/$CACHE_FILE$
|
|
108
|
+
|
|
109
|
+
# CodeStream plugin
|
|
110
|
+
# https://plugins.jetbrains.com/plugin/12206-codestream
|
|
111
|
+
.idea/codestream.xml
|
|
112
|
+
|
|
113
|
+
# Azure Toolkit for IntelliJ plugin
|
|
114
|
+
# https://plugins.jetbrains.com/plugin/8053-azure-toolkit-for-intellij
|
|
115
|
+
.idea/**/azureSettings.xml
|
|
116
|
+
|
|
117
|
+
### Python ###
|
|
118
|
+
# Byte-compiled / optimized / DLL files
|
|
119
|
+
__pycache__/
|
|
120
|
+
*.py[cod]
|
|
121
|
+
*$py.class
|
|
122
|
+
|
|
123
|
+
# C extensions
|
|
124
|
+
*.so
|
|
125
|
+
|
|
126
|
+
# Distribution / packaging
|
|
127
|
+
.Python
|
|
128
|
+
build/
|
|
129
|
+
develop-eggs/
|
|
130
|
+
dist/
|
|
131
|
+
downloads/
|
|
132
|
+
eggs/
|
|
133
|
+
.eggs/
|
|
134
|
+
lib/
|
|
135
|
+
lib64/
|
|
136
|
+
parts/
|
|
137
|
+
sdist/
|
|
138
|
+
var/
|
|
139
|
+
wheels/
|
|
140
|
+
share/python-wheels/
|
|
141
|
+
*.egg-info/
|
|
142
|
+
.installed.cfg
|
|
143
|
+
*.egg
|
|
144
|
+
MANIFEST
|
|
145
|
+
|
|
146
|
+
# PyInstaller
|
|
147
|
+
# Usually these files are written by a python script from a template
|
|
148
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
149
|
+
*.manifest
|
|
150
|
+
*.spec
|
|
151
|
+
|
|
152
|
+
# Installer logs
|
|
153
|
+
pip-log.txt
|
|
154
|
+
pip-delete-this-directory.txt
|
|
155
|
+
|
|
156
|
+
# Unit test / coverage reports
|
|
157
|
+
htmlcov/
|
|
158
|
+
.tox/
|
|
159
|
+
.nox/
|
|
160
|
+
.coverage
|
|
161
|
+
.coverage.*
|
|
162
|
+
.cache
|
|
163
|
+
nosetests.xml
|
|
164
|
+
coverage.xml
|
|
165
|
+
*.cover
|
|
166
|
+
*.py,cover
|
|
167
|
+
.hypothesis/
|
|
168
|
+
.pytest_cache/
|
|
169
|
+
cover/
|
|
170
|
+
|
|
171
|
+
# Translations
|
|
172
|
+
*.mo
|
|
173
|
+
*.pot
|
|
174
|
+
|
|
175
|
+
# Django stuff:
|
|
176
|
+
*.log
|
|
177
|
+
local_settings.py
|
|
178
|
+
db.sqlite3
|
|
179
|
+
db.sqlite3-journal
|
|
180
|
+
|
|
181
|
+
# Flask stuff:
|
|
182
|
+
instance/
|
|
183
|
+
.webassets-cache
|
|
184
|
+
|
|
185
|
+
# Scrapy stuff:
|
|
186
|
+
.scrapy
|
|
187
|
+
|
|
188
|
+
# Sphinx documentation
|
|
189
|
+
docs/_build/
|
|
190
|
+
|
|
191
|
+
# PyBuilder
|
|
192
|
+
.pybuilder/
|
|
193
|
+
target/
|
|
194
|
+
|
|
195
|
+
# Jupyter Notebook
|
|
196
|
+
.ipynb_checkpoints
|
|
197
|
+
|
|
198
|
+
# IPython
|
|
199
|
+
profile_default/
|
|
200
|
+
ipython_config.py
|
|
201
|
+
|
|
202
|
+
# pyenv
|
|
203
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
204
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
205
|
+
# .python-version
|
|
206
|
+
|
|
207
|
+
# pipenv
|
|
208
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
209
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
210
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
211
|
+
# install all needed dependencies.
|
|
212
|
+
#Pipfile.lock
|
|
213
|
+
|
|
214
|
+
# poetry
|
|
215
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
216
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
217
|
+
# commonly ignored for libraries.
|
|
218
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
219
|
+
#poetry.lock
|
|
220
|
+
|
|
221
|
+
# pdm
|
|
222
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
223
|
+
#pdm.lock
|
|
224
|
+
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
|
|
225
|
+
# in version control.
|
|
226
|
+
# https://pdm.fming.dev/#use-with-ide
|
|
227
|
+
.pdm.toml
|
|
228
|
+
|
|
229
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
230
|
+
__pypackages__/
|
|
231
|
+
|
|
232
|
+
# Celery stuff
|
|
233
|
+
celerybeat-schedule
|
|
234
|
+
celerybeat.pid
|
|
235
|
+
|
|
236
|
+
# SageMath parsed files
|
|
237
|
+
*.sage.py
|
|
238
|
+
|
|
239
|
+
# Environments
|
|
240
|
+
.env
|
|
241
|
+
.venv
|
|
242
|
+
env/
|
|
243
|
+
venv/
|
|
244
|
+
ENV/
|
|
245
|
+
env.bak/
|
|
246
|
+
venv.bak/
|
|
247
|
+
|
|
248
|
+
# Spyder project settings
|
|
249
|
+
.spyderproject
|
|
250
|
+
.spyproject
|
|
251
|
+
|
|
252
|
+
# Rope project settings
|
|
253
|
+
.ropeproject
|
|
254
|
+
|
|
255
|
+
# mkdocs documentation
|
|
256
|
+
/site
|
|
257
|
+
|
|
258
|
+
# mypy
|
|
259
|
+
.mypy_cache/
|
|
260
|
+
.dmypy.json
|
|
261
|
+
dmypy.json
|
|
262
|
+
|
|
263
|
+
# Pyre type checker
|
|
264
|
+
.pyre/
|
|
265
|
+
|
|
266
|
+
# pytype static type analyzer
|
|
267
|
+
.pytype/
|
|
268
|
+
|
|
269
|
+
# Cython debug symbols
|
|
270
|
+
cython_debug/
|
|
271
|
+
|
|
272
|
+
# PyCharm
|
|
273
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
274
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
275
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
276
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
277
|
+
#.idea/
|
|
278
|
+
|
|
279
|
+
### Python Patch ###
|
|
280
|
+
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
|
|
281
|
+
poetry.toml
|
|
282
|
+
|
|
283
|
+
# ruff
|
|
284
|
+
.ruff_cache/
|
|
285
|
+
|
|
286
|
+
# LSP config files
|
|
287
|
+
pyrightconfig.json
|
|
288
|
+
|
|
289
|
+
# End of https://www.toptal.com/developers/gitignore/api/python,jetbrains
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="Black">
|
|
4
|
+
<option name="sdkName" value="uv (smartbill-sdk)" />
|
|
5
|
+
</component>
|
|
6
|
+
<component name="ProjectRootManager" version="2" project-jdk-name="uv (smartbill-sdk)" project-jdk-type="Python SDK" />
|
|
7
|
+
</project>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<project version="4">
|
|
3
|
+
<component name="ProjectModuleManager">
|
|
4
|
+
<modules>
|
|
5
|
+
<module fileurl="file://$PROJECT_DIR$/.idea/smartbill-sdk.iml" filepath="$PROJECT_DIR$/.idea/smartbill-sdk.iml" />
|
|
6
|
+
</modules>
|
|
7
|
+
</component>
|
|
8
|
+
</project>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<module type="PYTHON_MODULE" version="4">
|
|
3
|
+
<component name="NewModuleRootManager">
|
|
4
|
+
<content url="file://$MODULE_DIR$">
|
|
5
|
+
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
|
6
|
+
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
|
7
|
+
</content>
|
|
8
|
+
<orderEntry type="jdk" jdkName="uv (smartbill-sdk)" jdkType="Python SDK" />
|
|
9
|
+
<orderEntry type="sourceFolder" forTests="false" />
|
|
10
|
+
</component>
|
|
11
|
+
</module>
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# PROJECT KNOWLEDGE BASE
|
|
2
|
+
|
|
3
|
+
**Generated:** 2026-06-21
|
|
4
|
+
|
|
5
|
+
## OVERVIEW
|
|
6
|
+
Project: **smartbill-sdk**
|
|
7
|
+
Stack: Python ≥ 3.11, `httpx>=0.27`, `pydantic>=2.6`; build backend `hatchling`; dependency/
|
|
8
|
+
dev env managed with `uv`; tests with `pytest` + `pytest-asyncio` + `respx`.
|
|
9
|
+
|
|
10
|
+
A Python SDK for the [SmartBill Cloud REST API](https://www.facturionline.ro/api-program-facturare/)
|
|
11
|
+
offering both **synchronous** (`SmartBillClient`) and **asynchronous**
|
|
12
|
+
(`AsyncSmartBillClient`) interfaces, with typed pydantic v2 request/response
|
|
13
|
+
models covering every endpoint in the official `docs/openapi.json` spec.
|
|
14
|
+
|
|
15
|
+
## STRUCTURE
|
|
16
|
+
```
|
|
17
|
+
src/smartbill_sdk/ # the package (src-layout)
|
|
18
|
+
__init__.py # public API + __all__ re-exports
|
|
19
|
+
client.py # SmartBillClient (sync)
|
|
20
|
+
async_client.py # AsyncSmartBillClient (async)
|
|
21
|
+
_transport.py # shared request build / auth / envelope unwrap / errors / RateLimiter
|
|
22
|
+
exceptions.py # SmartBillError hierarchy
|
|
23
|
+
models/ # pydantic v2 models per resource (alias camelCase <-> snake_case)
|
|
24
|
+
services/ # per-resource endpoint logic, shared by sync + async clients
|
|
25
|
+
tests/ # pytest suite, mocked via respx (63 tests)
|
|
26
|
+
examples/ # standalone runnable example scripts
|
|
27
|
+
docs/openapi.json # official SmartBill OpenAPI spec (source of truth)
|
|
28
|
+
pyproject.toml # project + hatch build + pytest config
|
|
29
|
+
uv.lock # lockfile
|
|
30
|
+
```
|
|
31
|
+
* `src/smartbill_sdk/services/__init__.py`: All endpoint logic. Each service builds
|
|
32
|
+
`httpx.Request` objects and defines both sync (`create`, `delete`, ...) and async
|
|
33
|
+
(`acreate`, `adelete`, ...) methods that delegate to an injected `_Executor`
|
|
34
|
+
(`execute` / `aexecute`). Defined once, used by both clients.
|
|
35
|
+
* `src/smartbill_sdk/_transport.py`: Auth (HTTP Basic `username:token`), request
|
|
36
|
+
construction, SmartBill response-envelope unwrapping, error mapping, and the
|
|
37
|
+
optional client-side `RateLimiter` (SmartBill enforces 30 calls / 10s, then 403
|
|
38
|
+
for 10 minutes).
|
|
39
|
+
* `src/smartbill_sdk/models/`: snake_case attrs aliased to camelCase JSON; models
|
|
40
|
+
are permissive (`extra="allow"`) so new API fields don't break parsing.
|
|
41
|
+
|
|
42
|
+
## COMMANDS
|
|
43
|
+
| Action | Command |
|
|
44
|
+
|---------------------|----------------------------------|
|
|
45
|
+
| Install (dev) | `uv sync --extra dev` |
|
|
46
|
+
| Run tests | `uv run pytest` (or `uv run pytest -q`) |
|
|
47
|
+
| Run a single test | `uv run pytest tests/test_invoices.py` |
|
|
48
|
+
| Build wheel | `uv build` |
|
|
49
|
+
| Run an example | `uv run python examples/create_invoice_sync.py` |
|
|
50
|
+
|
|
51
|
+
Note: `pytest-asyncio` runs in `asyncio_mode = "auto"` (see `pyproject.toml`), so
|
|
52
|
+
async test functions need no `@pytest.mark.asyncio` decorator.
|
|
53
|
+
|
|
54
|
+
## CODING STANDARDS
|
|
55
|
+
* **Language**: Python 3.11+ (`from __future__ import annotations` is used throughout).
|
|
56
|
+
* **Style**: 4-space indent, double-quote strings, module-level docstrings, full
|
|
57
|
+
type hints, `Optional[...]` over `| None`. No formatter/linter is currently
|
|
58
|
+
configured (no ruff/black/mypy in `pyproject.toml`) — match the existing style.
|
|
59
|
+
* **Models**: pydantic v2, subclass the `ModelConfig` base in `models/common.py`
|
|
60
|
+
(`populate_by_name=True`, `extra="allow"`). Use `Field(..., alias="camelCase")`
|
|
61
|
+
and `AliasChoices` for snake_case ⇄ camelCase mapping. Serialize with
|
|
62
|
+
`model_dump(by_alias=True, exclude_none=True)`.
|
|
63
|
+
* **Services**: keep sync + async methods paired in the same service class; sync
|
|
64
|
+
method `foo` → async `afoo`. Build the `httpx.Request` once in a private
|
|
65
|
+
`_foo_request(...)` helper, then both `foo` and `afoo` reuse it.
|
|
66
|
+
* **Errors**: raise `SmartBillError` subclasses from `exceptions.py`; never bare
|
|
67
|
+
`Exception`. `handle_response()` in `_transport.py` is the single place that
|
|
68
|
+
maps HTTP status / envelopes to exceptions.
|
|
69
|
+
* **Responses**: the SmartBill API wraps payloads in envelopes (`sbcResponse`,
|
|
70
|
+
`Response`, `sbcTaxes`, `sbcSeries`, `sbcInvoicePaymentStatusResponse`,
|
|
71
|
+
`stocks`, `Fault`). `parse_envelope()` unwraps them — don't unwrap manually.
|
|
72
|
+
|
|
73
|
+
## WHERE TO LOOK
|
|
74
|
+
* **Source**: `src/smartbill_sdk/`
|
|
75
|
+
* **Tests**: `tests/` (mocked HTTP via `respx`; `tests/conftest.py` has shared
|
|
76
|
+
fixtures/helpers like `make_sync_client`, `make_async_client`, `envelope()`)
|
|
77
|
+
* **Docs**: `README.md`, `docs/openapi.json` (official spec), `examples/`
|
|
78
|
+
* **Public API surface**: `src/smartbill_sdk/__init__.py` (`__all__`)
|
|
79
|
+
|
|
80
|
+
## NOTES
|
|
81
|
+
* **Auth**: SmartBill uses HTTP Basic Auth with `username:token` where `username`
|
|
82
|
+
is the login e-mail and `token` comes from SmartBill Cloud → *Contul Meu →
|
|
83
|
+
Integrari → API*.
|
|
84
|
+
* **JSON only**: the SDK sends JSON (`format="json"`); XML is not supported.
|
|
85
|
+
* **Rate limit**: 30 calls / 10 seconds — exceeding it triggers a server-side 403
|
|
86
|
+
that blocks access for 10 minutes. Opt into a client-side preemptive limiter with
|
|
87
|
+
`SmartBillClient(..., enforce_rate_limit=True)`.
|
|
88
|
+
* **Dates**: all date fields are `YYYY-MM-DD` strings, matching the API.
|
|
89
|
+
* **Sync vs async**: `SmartBillClient` exposes sync service methods (`client.invoices.create`)
|
|
90
|
+
and `AsyncSmartBillClient` exposes async ones (`await client.invoices.acreate`).
|
|
91
|
+
Calling the wrong one raises a clear `SmartBillError`.
|
|
92
|
+
* **`taxes` / `series` alias**: on both clients, `client.taxes` and `client.series`
|
|
93
|
+
are the *same* `ConfigurationService` instance (taxes + series share one service).
|
|
94
|
+
* **Tests are mocked**: no network calls; `respx` intercepts `httpx`. The full suite
|
|
95
|
+
(63 tests) passes offline.
|
|
96
|
+
* **Disclaimer (from README)**: the SDK was AI-generated from `openapi.json` and
|
|
97
|
+
verified with 63 mocked tests — please have a human review before issuing real
|
|
98
|
+
invoices.
|
|
99
|
+
* No other context files (`.cursorrules`, `CLAUDE.md`, etc.) were found in the repo.
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is loosely based on [Keep a Changelog](https://keepachangelog.com/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
7
|
+
|
|
8
|
+
## [1.0.0] — 2026-06-21
|
|
9
|
+
|
|
10
|
+
First stable release of the Python SDK for the SmartBill Cloud REST API.
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- Synchronous `SmartBillClient` and asynchronous `AsyncSmartBillClient` with
|
|
14
|
+
HTTP Basic (`username:token`) authentication.
|
|
15
|
+
- Typed pydantic v2 request/response models for every endpoint in the official
|
|
16
|
+
`docs/openapi.json` spec, using snake_case attributes aliased to the
|
|
17
|
+
camelCase JSON field names.
|
|
18
|
+
- Per-resource services covering invoices, proformas (estimates), payments
|
|
19
|
+
(incl. `chitanta` and `bon fiscal`), e-mail, taxes, series and stocks.
|
|
20
|
+
- Exception hierarchy (`SmartBillError`, `SmartBillAuthError`,
|
|
21
|
+
`SmartBillRateLimitError`, `SmartBillAPIError`, `SmartBillTransportError`)
|
|
22
|
+
that surfaces the API `errorText`.
|
|
23
|
+
- SmartBill response-envelope unwrapping (`sbcResponse`, `Response`,
|
|
24
|
+
`sbcTaxes`, `sbcSeries`, `sbcInvoicePaymentStatusResponse`, `stocks`,
|
|
25
|
+
`Fault`) centralized in `_transport.parse_envelope`.
|
|
26
|
+
- Optional client-side `RateLimiter` (`enforce_rate_limit=True`) to preempt
|
|
27
|
+
the server's 403 (SmartBill blocks access for 10 minutes after >30 calls
|
|
28
|
+
in 10 seconds).
|
|
29
|
+
- Binary PDF retrieval for invoices, proformas and fiscal receipts.
|
|
30
|
+
- Draft (ciornă) support via `is_draft=True` on `Invoice`, `Estimate` and
|
|
31
|
+
`Payment`.
|
|
32
|
+
- Runnable example scripts under `examples/` and copy-pasteable pi agent
|
|
33
|
+
skills under `skills/` (`smartbill-invoices`, `smartbill-payments`,
|
|
34
|
+
`smartbill-email`).
|
|
35
|
+
- Test suite of 63 mocked tests using `respx` (no network calls).
|
|
36
|
+
|
|
37
|
+
### Fixed
|
|
38
|
+
- **Critical:** request bodies were incorrectly wrapped in XML-style
|
|
39
|
+
envelopes (`{"invoice": {...}}`, `{"estimate": {...}}`, `{"payment": {...}}`,
|
|
40
|
+
`{"sendDocumentRequest": {...}}`). The JSON endpoints reject these with
|
|
41
|
+
`400 Unrecognized property: <envelope>.` Envelope wrapping has been removed
|
|
42
|
+
from all POST request builders in `services/__init__.py`; the request body
|
|
43
|
+
is now the bare model. Verified against the live SmartBill API by emitting
|
|
44
|
+
a draft invoice.
|
|
45
|
+
- `InvoiceRef.series_name` now accepts both `seriesName` (requests) and
|
|
46
|
+
`series` (the `GET /estimate/invoices` response) via `AliasChoices`, while
|
|
47
|
+
still serializing as `seriesName`.
|
|
48
|
+
- `PaymentsService.create` / `acreate` now return `FiscalReceiptResponse`
|
|
49
|
+
(exposes the generated receipt `id`) instead of `BaseResponse`.
|
|
50
|
+
- README quick-start example used the non-existent `client.taxes.list(...)`;
|
|
51
|
+
corrected to `client.taxes.ataxes(...)`.
|
|
52
|
+
|
|
53
|
+
### Notes
|
|
54
|
+
- The SDK sends JSON only (`format="json"`); XML is not supported.
|
|
55
|
+
- Date fields use `YYYY-MM-DD` strings, matching the API.
|
|
56
|
+
- This SDK was AI-generated from the official `openapi.json` spec and
|
|
57
|
+
verified with a suite of mocked tests, then refined against live API
|
|
58
|
+
calls. Please have a human review before issuing real invoices.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright © 2026
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: smartbill-rest-sdk
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Python SDK (sync + async) for the SmartBill Cloud REST API.
|
|
5
|
+
Author: smartbill-sdk contributors
|
|
6
|
+
License: MIT
|
|
7
|
+
License-File: LICENSE
|
|
8
|
+
Requires-Python: >=3.11
|
|
9
|
+
Requires-Dist: httpx>=0.27
|
|
10
|
+
Requires-Dist: pydantic>=2.6
|
|
11
|
+
Provides-Extra: dev
|
|
12
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
13
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
14
|
+
Requires-Dist: respx>=0.21; extra == 'dev'
|
|
15
|
+
Description-Content-Type: text/markdown
|
|
16
|
+
|
|
17
|
+
# smartbill-sdk
|
|
18
|
+
|
|
19
|
+
A Python SDK for the [SmartBill Cloud REST API](https://www.facturionline.ro/api-program-facturare/),
|
|
20
|
+
offering both **synchronous** and **asynchronous** interfaces and typed
|
|
21
|
+
request/response models generated from the official `openapi.json` spec.
|
|
22
|
+
|
|
23
|
+
## Features
|
|
24
|
+
|
|
25
|
+
- Sync (`SmartBillClient`) and async (`AsyncSmartBillClient`) clients.
|
|
26
|
+
- Typed pydantic v2 models for invoices, proformas, payments, emails,
|
|
27
|
+
taxes, series and stocks.
|
|
28
|
+
- Covers every endpoint from the SmartBill OpenAPI definition.
|
|
29
|
+
- Helper exceptions with the API `errorText` surfaced.
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install smartbill-sdk
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
From source (development):
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
uv sync --extra dev
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Authentication
|
|
44
|
+
|
|
45
|
+
SmartBill uses HTTP Basic Auth with `username:token`:
|
|
46
|
+
|
|
47
|
+
- `username` — the e-mail you log in with in SmartBill Cloud.
|
|
48
|
+
- `token` — found in SmartBill Cloud > **Contul Meu** > **Integrari** > **API**.
|
|
49
|
+
|
|
50
|
+
```python
|
|
51
|
+
from smartbill_sdk import SmartBillClient
|
|
52
|
+
|
|
53
|
+
client = SmartBillClient(username="you@example.com", token="abc123...")
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Quick start (sync)
|
|
57
|
+
|
|
58
|
+
```python
|
|
59
|
+
from smartbill_sdk import SmartBillClient
|
|
60
|
+
from smartbill_sdk.models import Invoice, Client, Product
|
|
61
|
+
|
|
62
|
+
client = SmartBillClient(username="you@example.com", token="...")
|
|
63
|
+
|
|
64
|
+
invoice = Invoice(
|
|
65
|
+
company_vat_code="RO12345678",
|
|
66
|
+
client=Client(name="Intelligent IT", vat_code="RO12345678", city="Sibiu", country="Romania"),
|
|
67
|
+
series_name="FCT",
|
|
68
|
+
is_draft=False,
|
|
69
|
+
products=[
|
|
70
|
+
Product(name="Produs 1", measuring_unit_name="buc", currency="RON",
|
|
71
|
+
quantity=2, price=10, is_tax_included=True,
|
|
72
|
+
tax_name="Redusa", tax_percentage=9),
|
|
73
|
+
],
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
resp = client.invoices.create(invoice)
|
|
77
|
+
print(resp.series, resp.number)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Quick start (async)
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
import asyncio
|
|
84
|
+
from smartbill_sdk import AsyncSmartBillClient
|
|
85
|
+
|
|
86
|
+
async def main():
|
|
87
|
+
client = AsyncSmartBillClient(username="you@example.com", token="...")
|
|
88
|
+
taxes = await client.taxes.ataxes("RO12345678")
|
|
89
|
+
print(taxes)
|
|
90
|
+
await client.aclose()
|
|
91
|
+
|
|
92
|
+
asyncio.run(main())
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Endpoints covered
|
|
96
|
+
|
|
97
|
+
Invoices, Proformas, Payments (incl. chitanta & bon fiscal), E-mail,
|
|
98
|
+
Taxes, Series, Stocks. See `smartbill_sdk/services/` for the full list.
|
|
99
|
+
|
|
100
|
+
## Agent skills
|
|
101
|
+
|
|
102
|
+
This repo ships ready-to-import [pi](https://github.com/earendil-works/pi-coding-agent)
|
|
103
|
+
**skills** under [`skills/`](skills/) that teach coding agents how to use the
|
|
104
|
+
SDK. Each `SKILL.md` is a self-contained, copy-pasteable guide for one area of
|
|
105
|
+
the API:
|
|
106
|
+
|
|
107
|
+
| Skill | Covers |
|
|
108
|
+
|----------------------|-------------------------------------------------------------------------|
|
|
109
|
+
| `smartbill-invoices` | Invoices & proformas/estimates: create, storno, cancel, restore, PDF, payment status |
|
|
110
|
+
| `smartbill-payments` | Payments & fiscal receipts (`bon fiscal`): `POST /payment`, payment types, mixed cash/card, fiscal-printer text, delete |
|
|
111
|
+
| `smartbill-email` | Emailing a document (`POST /document/send`): base64 subject/body, invoice/proforma |
|
|
112
|
+
|
|
113
|
+
See [`skills/README.md`](skills/README.md) for how to import them into a pi
|
|
114
|
+
agent. The runnable scripts in [`examples/`](examples/) accompany these skills.
|
|
115
|
+
|
|
116
|
+
## Notes
|
|
117
|
+
|
|
118
|
+
- The SDK talks JSON by default (`format="json"`); XML is not yet supported.
|
|
119
|
+
- Rate limit: the SmartBill API allows 30 calls / 10 seconds. A client-side
|
|
120
|
+
limiter can be enabled with `enforce_rate_limit=True`.
|
|
121
|
+
- Date fields use `YYYY-MM-DD` strings, matching the API.
|
|
122
|
+
|
|
123
|
+
See [`CHANGELOG.md`](CHANGELOG.md) for release history.
|
|
124
|
+
|
|
125
|
+
## Disclaimer
|
|
126
|
+
|
|
127
|
+
This SDK was written by an AI agent (pi) which, to its credit.
|
|
128
|
+
The code was generated from the official
|
|
129
|
+
`openapi.json` spec, verified with a suite of 63 mocked tests, and refined
|
|
130
|
+
until everything passed.
|
|
131
|
+
|
|
132
|
+
That said, please have a human review it before issuing real invoices —
|
|
133
|
+
accountants work hard enough as it is, and the last thing they need is an
|
|
134
|
+
enthusiastic model quietly deciding that the 9% reduced rate applies to
|
|
135
|
+
shampoo.
|