Skip to content
This repository was archived by the owner on Jul 16, 2025. It is now read-only.

Commit d5ec2e1

Browse files
authored
Merge pull request #1 from TI-Sin-Problemas/develop
Complete API endpoints and catalogs
2 parents 34ebd82 + 9e83c65 commit d5ec2e1

5 files changed

Lines changed: 485 additions & 8 deletions

File tree

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ build-backend = "hatchling.build"
44

55
[project]
66
name = "facturapi-python"
7-
version = "0.0.2"
7+
version = "0.1.0"
88
authors = [{ name = "TI Sin Problemas", email = "pypi@tisinproblemas.com" }]
9-
description = "Unofficial Facturapi.io Python wrapper"
9+
description = "Unofficial Facturapi.io Python client"
1010
readme = "README.md"
1111
license = { file = "LICENSE" }
1212
requires-python = ">=3.7"

src/facturapi/catalogs.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
"""Catalogs API endpoint"""
2+
from .http import BaseClient
3+
4+
5+
class CatalogsClient(BaseClient):
6+
"""Catalogs API client"""
7+
8+
endpoint = "catalogs"
9+
10+
def search_products(self, search: str, page: int = None, limit: int = None) -> dict:
11+
"""Search in SAT's Products/Services catalog, which contains the key to include in the
12+
invoice
13+
14+
Args:
15+
search (str): Text to search on the description of the category.
16+
page (int, optional): Page of results to return, beginning from page 1.
17+
Defaults to None.
18+
limit (int, optional): Number from 1 to 100, represents the maximum quiantity of
19+
results to return. Defaults to None.
20+
21+
Returns:
22+
dict: List of products or services matching the query
23+
"""
24+
params = {"q": search}
25+
26+
if page:
27+
params.update({"page": page})
28+
if limit:
29+
params.update({"limit": limit})
30+
31+
url = self._get_request_url(["products"])
32+
return self._execute_request("GET", url, params).json()
33+
34+
def search_units_of_measurement(
35+
self, search: str, page: int = None, limit: int = None
36+
) -> dict:
37+
"""Search in SAT's Units of Measurement catalog
38+
39+
Args:
40+
search (str): Test to search in the description of the unit of measurement
41+
page (int, optional): Page of results to return, beginning from page 1.
42+
Defaults to None.
43+
limit (int, optional): Number from 1 to 100, represents the maximum quiantity of
44+
results to return. Defaults to None.
45+
46+
Returns:
47+
dict: List of units of measurement
48+
"""
49+
params = {"q": search}
50+
51+
if page:
52+
params.update({"page": page})
53+
if limit:
54+
params.update({"limit": limit})
55+
56+
url = self._get_request_url(["units"])
57+
return self._execute_request("GET", url, params).json()

0 commit comments

Comments
 (0)