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