diff --git a/code_generator/client_gen.py b/code_generator/client_gen.py index 2c8322d..8f5f454 100644 --- a/code_generator/client_gen.py +++ b/code_generator/client_gen.py @@ -15,7 +15,7 @@ class OpenAPIClientGenerator: from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data - +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -202,8 +202,31 @@ def generate_pydantic_model( model_code += "\n" model_code += "\n" - model_code += f""" - def request(self): + model_code += f''' + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.{method_name}( self.model_dump(exclude={{"_api_client"}}, exclude_unset=True) @@ -211,7 +234,7 @@ def request(self): return response else: raise ValueError("Client not initialized. Use the 'connect' method.") -""" +''' return model_code.strip() diff --git a/moloni/api/bankaccounts_client.py b/moloni/api/bankaccounts_client.py index 265808e..0c744d4 100644 --- a/moloni/api/bankaccounts_client.py +++ b/moloni/api/bankaccounts_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -23,7 +24,30 @@ class BankaccountsCountModifiedSinceModel(ApiRequestModel): company_id: Union[str, int] lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -37,7 +61,30 @@ class BankaccountsDeleteModel(ApiRequestModel): company_id: Union[str, int] bank_account_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.delete( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -50,7 +97,30 @@ def request(self): class BankaccountsGetAllModel(ApiRequestModel): company_id: Union[str, int] - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -66,7 +136,30 @@ class BankaccountsInsertModel(ApiRequestModel): order: Optional[str] = None value: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.insert( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -83,7 +176,30 @@ class BankaccountsUpdateModel(ApiRequestModel): order: Optional[str] = None value: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.update( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/billsoflading_client.py b/moloni/api/billsoflading_client.py index 6ff03ec..44c5689 100644 --- a/moloni/api/billsoflading_client.py +++ b/moloni/api/billsoflading_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -53,7 +54,30 @@ class BillsofladingCountModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -67,7 +91,30 @@ class BillsofladingDeleteModel(ApiRequestModel): company_id: Union[str, int] document_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.delete( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -88,7 +135,30 @@ class BillsofladingGetAllModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -108,7 +178,30 @@ class BillsofladingGetOneModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_one( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -141,7 +234,30 @@ class BillsofladingInsertModel(ApiRequestModel): vehicle_id: Optional[Union[str, int]] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.insert( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -156,7 +272,30 @@ class BillsofladingSetTransportCodeModel(ApiRequestModel): document_id: Optional[Union[str, int]] = None transport_code: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.set_transport_code( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -190,7 +329,30 @@ class BillsofladingUpdateModel(ApiRequestModel): vehicle_id: Optional[Union[str, int]] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.update( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/companies_client.py b/moloni/api/companies_client.py index 533ba21..a9e946c 100644 --- a/moloni/api/companies_client.py +++ b/moloni/api/companies_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -39,7 +40,30 @@ class Warehouses(BaseModel): class CompaniesGetOneModel(ApiRequestModel): company_id: Union[str, int] - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_one( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -98,7 +122,30 @@ class CompaniesUpdateModel(ApiRequestModel): website: Optional[str] = None zip_code: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.update( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/countries_client.py b/moloni/api/countries_client.py index 754556f..b8caae2 100644 --- a/moloni/api/countries_client.py +++ b/moloni/api/countries_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -22,7 +23,30 @@ def __exit__(self, exc_type, exc_value, traceback): class CountriesCountModifiedSinceModel(ApiRequestModel): lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -35,7 +59,30 @@ def request(self): class CountriesGetModifiedSinceModel(ApiRequestModel): lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/creditnotes_client.py b/moloni/api/creditnotes_client.py index 5e6a226..b4d23c0 100644 --- a/moloni/api/creditnotes_client.py +++ b/moloni/api/creditnotes_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -57,7 +58,30 @@ class CreditnotesCountModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -71,7 +95,30 @@ class CreditnotesDeleteModel(ApiRequestModel): company_id: Union[str, int] document_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.delete( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -96,7 +143,30 @@ class CreditnotesGetAllModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -120,7 +190,30 @@ class CreditnotesGetOneModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_one( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -146,7 +239,30 @@ class CreditnotesInsertModel(ApiRequestModel): status: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.insert( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -173,7 +289,30 @@ class CreditnotesUpdateModel(ApiRequestModel): status: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.update( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/currencies_client.py b/moloni/api/currencies_client.py index 54e421d..04b5f79 100644 --- a/moloni/api/currencies_client.py +++ b/moloni/api/currencies_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -22,7 +23,30 @@ def __exit__(self, exc_type, exc_value, traceback): class CurrenciesCountModifiedSinceModel(ApiRequestModel): lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -35,7 +59,30 @@ def request(self): class CurrenciesGetModifiedSinceModel(ApiRequestModel): lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/customeralternateaddresses_client.py b/moloni/api/customeralternateaddresses_client.py index 3d4f03d..30394c7 100644 --- a/moloni/api/customeralternateaddresses_client.py +++ b/moloni/api/customeralternateaddresses_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -23,7 +24,30 @@ class CustomeralternateaddressesCountModifiedSinceModel(ApiRequestModel): company_id: Union[str, int] lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -38,7 +62,30 @@ class CustomeralternateaddressesDeleteModel(ApiRequestModel): address_id: Optional[Union[str, int]] = None customer_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.delete( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -52,7 +99,30 @@ class CustomeralternateaddressesGetAllModel(ApiRequestModel): company_id: Union[str, int] customer_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -68,7 +138,30 @@ class CustomeralternateaddressesGetModifiedSinceModel(ApiRequestModel): offset: Optional[Union[str, int]] = 0 qty: Optional[Union[str, int]] = 25 - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -92,7 +185,30 @@ class CustomeralternateaddressesInsertModel(ApiRequestModel): phone: Optional[str] = None zip_code: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.insert( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -117,7 +233,30 @@ class CustomeralternateaddressesUpdateModel(ApiRequestModel): phone: Optional[str] = None zip_code: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.update( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/customerreturnnotes_client.py b/moloni/api/customerreturnnotes_client.py index 3670a3d..dc12b17 100644 --- a/moloni/api/customerreturnnotes_client.py +++ b/moloni/api/customerreturnnotes_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -53,7 +54,30 @@ class CustomerreturnnotesCountModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -67,7 +91,30 @@ class CustomerreturnnotesDeleteModel(ApiRequestModel): company_id: Union[str, int] document_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.delete( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -88,7 +135,30 @@ class CustomerreturnnotesGetAllModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -108,7 +178,30 @@ class CustomerreturnnotesGetOneModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_one( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -142,7 +235,30 @@ class CustomerreturnnotesInsertModel(ApiRequestModel): vehicle_id: Optional[Union[str, int]] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.insert( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -157,7 +273,30 @@ class CustomerreturnnotesSetTransportCodeModel(ApiRequestModel): document_id: Optional[Union[str, int]] = None transport_code: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.set_transport_code( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -192,7 +331,30 @@ class CustomerreturnnotesUpdateModel(ApiRequestModel): vehicle_id: Optional[Union[str, int]] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.update( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/customers_client.py b/moloni/api/customers_client.py index e96c438..ad848df 100644 --- a/moloni/api/customers_client.py +++ b/moloni/api/customers_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -22,7 +23,30 @@ def __exit__(self, exc_type, exc_value, traceback): class CustomersCountModel(ApiRequestModel): company_id: Union[str, int] - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -36,7 +60,30 @@ class CustomersCountByNameModel(ApiRequestModel): company_id: Union[str, int] name: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_by_name( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -50,7 +97,30 @@ class CustomersCountByNumberModel(ApiRequestModel): company_id: Union[str, int] number: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_by_number( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -64,7 +134,30 @@ class CustomersCountBySearchModel(ApiRequestModel): company_id: Union[str, int] search: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_by_search( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -78,7 +171,30 @@ class CustomersCountByVatModel(ApiRequestModel): company_id: Union[str, int] vat: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_by_vat( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -92,7 +208,30 @@ class CustomersCountModifiedSinceModel(ApiRequestModel): company_id: Union[str, int] lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -106,7 +245,30 @@ class CustomersDeleteModel(ApiRequestModel): company_id: Union[str, int] customer_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.delete( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -121,7 +283,30 @@ class CustomersGetAllModel(ApiRequestModel): offset: Optional[Union[str, int]] = 0 qty: Optional[Union[str, int]] = 25 - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -137,7 +322,30 @@ class CustomersGetByNameModel(ApiRequestModel): offset: Optional[Union[str, int]] = 0 qty: Optional[Union[str, int]] = 25 - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_by_name( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -153,7 +361,30 @@ class CustomersGetByNumberModel(ApiRequestModel): offset: Optional[Union[str, int]] = 0 qty: Optional[Union[str, int]] = 25 - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_by_number( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -169,7 +400,30 @@ class CustomersGetBySearchModel(ApiRequestModel): qty: Optional[Union[str, int]] = 25 search: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_by_search( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -185,7 +439,30 @@ class CustomersGetByVatModel(ApiRequestModel): qty: Optional[Union[str, int]] = 25 vat: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_by_vat( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -198,7 +475,30 @@ def request(self): class CustomersGetLastNumberModel(ApiRequestModel): company_id: Union[str, int] - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_last_number( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -214,7 +514,30 @@ class CustomersGetModifiedSinceModel(ApiRequestModel): offset: Optional[Union[str, int]] = 0 qty: Optional[Union[str, int]] = 25 - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -228,7 +551,30 @@ class CustomersGetOneModel(ApiRequestModel): company_id: Union[str, int] customer_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_one( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -266,7 +612,30 @@ class CustomersInsertModel(ApiRequestModel): website: Optional[str] = None zip_code: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.insert( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -305,7 +674,30 @@ class CustomersUpdateModel(ApiRequestModel): website: Optional[str] = None zip_code: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.update( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/debitnotes_client.py b/moloni/api/debitnotes_client.py index 2be3cec..7b8df02 100644 --- a/moloni/api/debitnotes_client.py +++ b/moloni/api/debitnotes_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -57,7 +58,30 @@ class DebitnotesCountModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -71,7 +95,30 @@ class DebitnotesDeleteModel(ApiRequestModel): company_id: Union[str, int] document_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.delete( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -96,7 +143,30 @@ class DebitnotesGetAllModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -120,7 +190,30 @@ class DebitnotesGetOneModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_one( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -143,7 +236,30 @@ class DebitnotesInsertModel(ApiRequestModel): status: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.insert( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -167,7 +283,30 @@ class DebitnotesUpdateModel(ApiRequestModel): status: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.update( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/deductions_client.py b/moloni/api/deductions_client.py index 64b112a..ebededa 100644 --- a/moloni/api/deductions_client.py +++ b/moloni/api/deductions_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -23,7 +24,30 @@ class DeductionsCountModifiedSinceModel(ApiRequestModel): company_id: Union[str, int] lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -37,7 +61,30 @@ class DeductionsDeleteModel(ApiRequestModel): company_id: Union[str, int] deduction_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.delete( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -50,7 +97,30 @@ def request(self): class DeductionsGetAllModel(ApiRequestModel): company_id: Union[str, int] - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -64,7 +134,30 @@ class DeductionsGetModifiedSinceModel(ApiRequestModel): company_id: Union[str, int] lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -79,7 +172,30 @@ class DeductionsInsertModel(ApiRequestModel): name: Optional[str] = None value: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.insert( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -95,7 +211,30 @@ class DeductionsUpdateModel(ApiRequestModel): name: Optional[str] = None value: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.update( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/deliverymethods_client.py b/moloni/api/deliverymethods_client.py index 7e184b3..aa1ecb7 100644 --- a/moloni/api/deliverymethods_client.py +++ b/moloni/api/deliverymethods_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -23,7 +24,30 @@ class DeliverymethodsCountModifiedSinceModel(ApiRequestModel): company_id: Union[str, int] lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -37,7 +61,30 @@ class DeliverymethodsDeleteModel(ApiRequestModel): company_id: Union[str, int] delivery_method_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.delete( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -50,7 +97,30 @@ def request(self): class DeliverymethodsGetAllModel(ApiRequestModel): company_id: Union[str, int] - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -64,7 +134,30 @@ class DeliverymethodsGetModifiedSinceModel(ApiRequestModel): company_id: Union[str, int] lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -78,7 +171,30 @@ class DeliverymethodsInsertModel(ApiRequestModel): company_id: Union[str, int] name: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.insert( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -93,7 +209,30 @@ class DeliverymethodsUpdateModel(ApiRequestModel): delivery_method_id: Optional[Union[str, int]] = None name: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.update( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/deliverynotes_client.py b/moloni/api/deliverynotes_client.py index db113e9..8cd69cc 100644 --- a/moloni/api/deliverynotes_client.py +++ b/moloni/api/deliverynotes_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -54,7 +55,30 @@ class DeliverynotesCountModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -68,7 +92,30 @@ class DeliverynotesDeleteModel(ApiRequestModel): company_id: Union[str, int] document_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.delete( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -90,7 +137,30 @@ class DeliverynotesGetAllModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -111,7 +181,30 @@ class DeliverynotesGetOneModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_one( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -146,7 +239,30 @@ class DeliverynotesInsertModel(ApiRequestModel): vehicle_id: Optional[Union[str, int]] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.insert( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -161,7 +277,30 @@ class DeliverynotesSetTransportCodeModel(ApiRequestModel): document_id: Optional[Union[str, int]] = None transport_code: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.set_transport_code( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -197,7 +336,30 @@ class DeliverynotesUpdateModel(ApiRequestModel): vehicle_id: Optional[Union[str, int]] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.update( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/documentmodels_client.py b/moloni/api/documentmodels_client.py index 87e2246..8853711 100644 --- a/moloni/api/documentmodels_client.py +++ b/moloni/api/documentmodels_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -22,7 +23,30 @@ def __exit__(self, exc_type, exc_value, traceback): class DocumentmodelsCountModifiedSinceModel(ApiRequestModel): lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -35,7 +59,30 @@ def request(self): class DocumentmodelsGetModifiedSinceModel(ApiRequestModel): lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/documents_client.py b/moloni/api/documents_client.py index 83f0cd1..7797419 100644 --- a/moloni/api/documents_client.py +++ b/moloni/api/documents_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -57,7 +58,30 @@ class DocumentsCountModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -82,7 +106,30 @@ class DocumentsGetAllModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -95,7 +142,30 @@ def request(self): class DocumentsGetAllDocumentTypesModel(ApiRequestModel): language_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all_document_types( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -119,7 +189,30 @@ class DocumentsGetOneModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_one( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -133,7 +226,30 @@ class DocumentsGetPdfLinkModel(ApiRequestModel): company_id: Union[str, int] document_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_pdf_link( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/documentsets_client.py b/moloni/api/documentsets_client.py index 9f77fc1..7d6c013 100644 --- a/moloni/api/documentsets_client.py +++ b/moloni/api/documentsets_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -23,7 +24,30 @@ class DocumentsetsCountModifiedSinceModel(ApiRequestModel): company_id: Union[str, int] lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -37,7 +61,30 @@ class DocumentsetsDeleteModel(ApiRequestModel): company_id: Union[str, int] document_set_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.delete( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -50,7 +97,30 @@ def request(self): class DocumentsetsGetAllModel(ApiRequestModel): company_id: Union[str, int] - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -64,7 +134,30 @@ class DocumentsetsGetModifiedSinceModel(ApiRequestModel): company_id: Union[str, int] lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -81,7 +174,30 @@ class DocumentsetsInsertModel(ApiRequestModel): name: Optional[str] = None template_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.insert( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -99,7 +215,30 @@ class DocumentsetsUpdateModel(ApiRequestModel): name: Optional[str] = None template_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.update( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/estimates_client.py b/moloni/api/estimates_client.py index 5d25cd7..8d0cc79 100644 --- a/moloni/api/estimates_client.py +++ b/moloni/api/estimates_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -55,7 +56,30 @@ class EstimatesCountModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -69,7 +93,30 @@ class EstimatesDeleteModel(ApiRequestModel): company_id: Union[str, int] document_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.delete( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -92,7 +139,30 @@ class EstimatesGetAllModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -114,7 +184,30 @@ class EstimatesGetOneModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_one( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -151,7 +244,30 @@ class EstimatesInsertModel(ApiRequestModel): vehicle_id: Optional[Union[str, int]] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.insert( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -189,7 +305,30 @@ class EstimatesUpdateModel(ApiRequestModel): vehicle_id: Optional[Union[str, int]] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.update( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/fiscalzones_client.py b/moloni/api/fiscalzones_client.py index 1607de8..8d7697b 100644 --- a/moloni/api/fiscalzones_client.py +++ b/moloni/api/fiscalzones_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -22,7 +23,30 @@ def __exit__(self, exc_type, exc_value, traceback): class FiscalzonesCountModifiedSinceModel(ApiRequestModel): lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -35,7 +59,30 @@ def request(self): class FiscalzonesGetAllModel(ApiRequestModel): country_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -48,7 +95,30 @@ def request(self): class FiscalzonesGetModifiedSinceModel(ApiRequestModel): lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/identificationtemplates_client.py b/moloni/api/identificationtemplates_client.py index 984d69e..6a4f3c1 100644 --- a/moloni/api/identificationtemplates_client.py +++ b/moloni/api/identificationtemplates_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -23,7 +24,30 @@ class IdentificationtemplatesCountModifiedSinceModel(ApiRequestModel): company_id: Union[str, int] lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -37,7 +61,30 @@ class IdentificationtemplatesDeleteModel(ApiRequestModel): company_id: Union[str, int] template_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.delete( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -50,7 +97,30 @@ def request(self): class IdentificationtemplatesGetAllModel(ApiRequestModel): company_id: Union[str, int] - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -64,7 +134,30 @@ class IdentificationtemplatesGetModifiedSinceModel(ApiRequestModel): company_id: Union[str, int] lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -91,7 +184,30 @@ class IdentificationtemplatesInsertModel(ApiRequestModel): website: Optional[str] = None zip_code: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.insert( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -119,7 +235,30 @@ class IdentificationtemplatesUpdateModel(ApiRequestModel): website: Optional[str] = None zip_code: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.update( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/invoicereceipts_client.py b/moloni/api/invoicereceipts_client.py index 27c3c24..959a907 100644 --- a/moloni/api/invoicereceipts_client.py +++ b/moloni/api/invoicereceipts_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -57,7 +58,30 @@ class InvoicereceiptsCountModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -71,7 +95,30 @@ class InvoicereceiptsDeleteModel(ApiRequestModel): company_id: Union[str, int] document_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.delete( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -96,7 +143,30 @@ class InvoicereceiptsGetAllModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -120,7 +190,30 @@ class InvoicereceiptsGetOneModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_one( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -161,7 +254,30 @@ class InvoicereceiptsInsertModel(ApiRequestModel): vehicle_id: Optional[Union[str, int]] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.insert( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -203,7 +319,30 @@ class InvoicereceiptsUpdateModel(ApiRequestModel): vehicle_id: Optional[Union[str, int]] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.update( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/invoices_client.py b/moloni/api/invoices_client.py index 6c4a2cf..ca0cbc6 100644 --- a/moloni/api/invoices_client.py +++ b/moloni/api/invoices_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -57,7 +58,30 @@ class InvoicesCountModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -71,7 +95,30 @@ class InvoicesDeleteModel(ApiRequestModel): company_id: Union[str, int] document_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.delete( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -96,7 +143,30 @@ class InvoicesGetAllModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -120,7 +190,30 @@ class InvoicesGetOneModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_one( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -161,7 +254,30 @@ class InvoicesInsertModel(ApiRequestModel): vehicle_id: Optional[Union[str, int]] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.insert( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -203,7 +319,30 @@ class InvoicesUpdateModel(ApiRequestModel): vehicle_id: Optional[Union[str, int]] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.update( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/languages_client.py b/moloni/api/languages_client.py index 0df1548..61a8e78 100644 --- a/moloni/api/languages_client.py +++ b/moloni/api/languages_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -22,7 +23,30 @@ def __exit__(self, exc_type, exc_value, traceback): class LanguagesCountModifiedSinceModel(ApiRequestModel): lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -35,7 +59,30 @@ def request(self): class LanguagesGetModifiedSinceModel(ApiRequestModel): lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/maturitydates_client.py b/moloni/api/maturitydates_client.py index 09c80ca..347e83d 100644 --- a/moloni/api/maturitydates_client.py +++ b/moloni/api/maturitydates_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -23,7 +24,30 @@ class MaturitydatesCountModifiedSinceModel(ApiRequestModel): company_id: Union[str, int] lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -37,7 +61,30 @@ class MaturitydatesDeleteModel(ApiRequestModel): company_id: Union[str, int] maturity_date_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.delete( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -50,7 +97,30 @@ def request(self): class MaturitydatesGetAllModel(ApiRequestModel): company_id: Union[str, int] - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -64,7 +134,30 @@ class MaturitydatesGetModifiedSinceModel(ApiRequestModel): company_id: Union[str, int] lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -80,7 +173,30 @@ class MaturitydatesInsertModel(ApiRequestModel): days: Optional[str] = None name: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.insert( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -97,7 +213,30 @@ class MaturitydatesUpdateModel(ApiRequestModel): maturity_date_id: Optional[Union[str, int]] = None name: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.update( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/measurementunits_client.py b/moloni/api/measurementunits_client.py index 93ae540..c5b98f9 100644 --- a/moloni/api/measurementunits_client.py +++ b/moloni/api/measurementunits_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -23,7 +24,30 @@ class MeasurementunitsCountModifiedSinceModel(ApiRequestModel): company_id: Union[str, int] lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -37,7 +61,30 @@ class MeasurementunitsDeleteModel(ApiRequestModel): company_id: Union[str, int] unit_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.delete( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -50,7 +97,30 @@ def request(self): class MeasurementunitsGetAllModel(ApiRequestModel): company_id: Union[str, int] - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -64,7 +134,30 @@ class MeasurementunitsGetModifiedSinceModel(ApiRequestModel): company_id: Union[str, int] lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -79,7 +172,30 @@ class MeasurementunitsInsertModel(ApiRequestModel): name: Optional[str] = None short_name: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.insert( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -95,7 +211,30 @@ class MeasurementunitsUpdateModel(ApiRequestModel): short_name: Optional[str] = None unit_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.update( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/ownassetsmovementguides_client.py b/moloni/api/ownassetsmovementguides_client.py index f2b25cd..bf0172d 100644 --- a/moloni/api/ownassetsmovementguides_client.py +++ b/moloni/api/ownassetsmovementguides_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -53,7 +54,30 @@ class OwnassetsmovementguidesCountModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -67,7 +91,30 @@ class OwnassetsmovementguidesDeleteModel(ApiRequestModel): company_id: Union[str, int] document_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.delete( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -88,7 +135,30 @@ class OwnassetsmovementguidesGetAllModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -108,7 +178,30 @@ class OwnassetsmovementguidesGetOneModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_one( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -139,7 +232,30 @@ class OwnassetsmovementguidesInsertModel(ApiRequestModel): vehicle_id: Optional[Union[str, int]] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.insert( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -154,7 +270,30 @@ class OwnassetsmovementguidesSetTransportCodeModel(ApiRequestModel): document_id: Optional[Union[str, int]] = None transport_code: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.set_transport_code( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -186,7 +325,30 @@ class OwnassetsmovementguidesUpdateModel(ApiRequestModel): vehicle_id: Optional[Union[str, int]] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.update( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/paymentmethods_client.py b/moloni/api/paymentmethods_client.py index 34c5203..6fb1d1c 100644 --- a/moloni/api/paymentmethods_client.py +++ b/moloni/api/paymentmethods_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -23,7 +24,30 @@ class PaymentmethodsCountModifiedSinceModel(ApiRequestModel): company_id: Union[str, int] lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -37,7 +61,30 @@ class PaymentmethodsDeleteModel(ApiRequestModel): company_id: Union[str, int] payment_method_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.delete( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -50,7 +97,30 @@ def request(self): class PaymentmethodsGetAllModel(ApiRequestModel): company_id: Union[str, int] - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -64,7 +134,30 @@ class PaymentmethodsGetModifiedSinceModel(ApiRequestModel): company_id: Union[str, int] lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -78,7 +171,30 @@ class PaymentmethodsInsertModel(ApiRequestModel): company_id: Union[str, int] name: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.insert( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -93,7 +209,30 @@ class PaymentmethodsUpdateModel(ApiRequestModel): name: Optional[str] = None payment_method_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.update( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/productcategories_client.py b/moloni/api/productcategories_client.py index 5327e68..fdf9902 100644 --- a/moloni/api/productcategories_client.py +++ b/moloni/api/productcategories_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -40,7 +41,30 @@ class ProductcategoriesDeleteModel(ApiRequestModel): company_id: Union[str, int] category_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.delete( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -54,7 +78,30 @@ class ProductcategoriesGetAllModel(ApiRequestModel): company_id: Union[str, int] parent_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -68,7 +115,30 @@ class ProductcategoriesGetModifiedSinceModel(ApiRequestModel): company_id: Union[str, int] lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -85,7 +155,30 @@ class ProductcategoriesInsertModel(ApiRequestModel): parent_id: Optional[Union[str, int]] = None pos_enabled: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.insert( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -103,7 +196,30 @@ class ProductcategoriesUpdateModel(ApiRequestModel): parent_id: Optional[Union[str, int]] = None pos_enabled: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.update( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/products_client.py b/moloni/api/products_client.py index 17f1f94..cf01839 100644 --- a/moloni/api/products_client.py +++ b/moloni/api/products_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -40,7 +41,30 @@ class ProductsCountModel(ApiRequestModel): company_id: Union[str, int] category_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -54,7 +78,30 @@ class ProductsCountByEanModel(ApiRequestModel): company_id: Union[str, int] ean: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_by_ean( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -68,7 +115,30 @@ class ProductsCountByNameModel(ApiRequestModel): company_id: Union[str, int] name: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_by_name( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -82,7 +152,30 @@ class ProductsCountByReferenceModel(ApiRequestModel): company_id: Union[str, int] reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_by_reference( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -96,7 +189,30 @@ class ProductsCountBySearchModel(ApiRequestModel): company_id: Union[str, int] search: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_by_search( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -110,7 +226,30 @@ class ProductsCountModifiedSinceModel(ApiRequestModel): company_id: Union[str, int] lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -124,7 +263,30 @@ class ProductsDeleteModel(ApiRequestModel): company_id: Union[str, int] product_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.delete( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -140,7 +302,30 @@ class ProductsGetAllModel(ApiRequestModel): offset: Optional[Union[str, int]] = 0 qty: Optional[Union[str, int]] = 25 - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -156,7 +341,30 @@ class ProductsGetByEanModel(ApiRequestModel): offset: Optional[Union[str, int]] = 0 qty: Optional[Union[str, int]] = 25 - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_by_ean( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -172,7 +380,30 @@ class ProductsGetByNameModel(ApiRequestModel): offset: Optional[Union[str, int]] = 0 qty: Optional[Union[str, int]] = 25 - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_by_name( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -188,7 +419,30 @@ class ProductsGetByReferenceModel(ApiRequestModel): qty: Optional[Union[str, int]] = 25 reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_by_reference( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -204,7 +458,30 @@ class ProductsGetBySearchModel(ApiRequestModel): qty: Optional[Union[str, int]] = 25 search: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_by_search( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -220,7 +497,30 @@ class ProductsGetModifiedSinceModel(ApiRequestModel): offset: Optional[Union[str, int]] = 0 qty: Optional[Union[str, int]] = 25 - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -234,7 +534,30 @@ class ProductsGetOneModel(ApiRequestModel): company_id: Union[str, int] product_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_one( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -264,7 +587,30 @@ class ProductsInsertModel(ApiRequestModel): warehouse_id: Optional[Union[str, int]] = None warehouses: Optional[List[Warehouses]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.insert( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -294,7 +640,30 @@ class ProductsUpdateModel(ApiRequestModel): unit_id: Optional[Union[str, int]] = None warehouse_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.update( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/receipts_client.py b/moloni/api/receipts_client.py index 422abc1..caaec38 100644 --- a/moloni/api/receipts_client.py +++ b/moloni/api/receipts_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -57,7 +58,30 @@ class ReceiptsCountModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -71,7 +95,30 @@ class ReceiptsDeleteModel(ApiRequestModel): company_id: Union[str, int] document_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.delete( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -96,7 +143,30 @@ class ReceiptsGetAllModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -120,7 +190,30 @@ class ReceiptsGetOneModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_one( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -142,7 +235,30 @@ class ReceiptsInsertModel(ApiRequestModel): related_documents_notes: Optional[str] = None status: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.insert( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -165,7 +281,30 @@ class ReceiptsUpdateModel(ApiRequestModel): related_documents_notes: Optional[str] = None status: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.update( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/salesmen_client.py b/moloni/api/salesmen_client.py index d274228..c395569 100644 --- a/moloni/api/salesmen_client.py +++ b/moloni/api/salesmen_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -23,7 +24,30 @@ class SalesmenCountModifiedSinceModel(ApiRequestModel): company_id: Union[str, int] lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -37,7 +61,30 @@ class SalesmenDeleteModel(ApiRequestModel): company_id: Union[str, int] salesman_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.delete( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -50,7 +97,30 @@ def request(self): class SalesmenGetAllModel(ApiRequestModel): company_id: Union[str, int] - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -64,7 +134,30 @@ class SalesmenGetModifiedSinceModel(ApiRequestModel): company_id: Union[str, int] lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -78,7 +171,30 @@ class SalesmenGetOneModel(ApiRequestModel): company_id: Union[str, int] salesman_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_one( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -106,7 +222,30 @@ class SalesmenInsertModel(ApiRequestModel): website: Optional[str] = None zip_code: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.insert( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -135,7 +274,30 @@ class SalesmenUpdateModel(ApiRequestModel): website: Optional[str] = None zip_code: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.update( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/simplifiedinvoices_client.py b/moloni/api/simplifiedinvoices_client.py index 9c24fb4..413fac5 100644 --- a/moloni/api/simplifiedinvoices_client.py +++ b/moloni/api/simplifiedinvoices_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -57,7 +58,30 @@ class SimplifiedinvoicesCountModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -71,7 +95,30 @@ class SimplifiedinvoicesDeleteModel(ApiRequestModel): company_id: Union[str, int] document_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.delete( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -96,7 +143,30 @@ class SimplifiedinvoicesGetAllModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -120,7 +190,30 @@ class SimplifiedinvoicesGetOneModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_one( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -161,7 +254,30 @@ class SimplifiedinvoicesInsertModel(ApiRequestModel): vehicle_id: Optional[Union[str, int]] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.insert( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -203,7 +319,30 @@ class SimplifiedinvoicesUpdateModel(ApiRequestModel): vehicle_id: Optional[Union[str, int]] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.update( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/subscription_client.py b/moloni/api/subscription_client.py index 46f958e..2c0f9c6 100644 --- a/moloni/api/subscription_client.py +++ b/moloni/api/subscription_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -39,7 +40,30 @@ class Warehouses(BaseModel): class SubscriptionGetOneModel(ApiRequestModel): company_id: Union[str, int] - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_one( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/suppliers_client.py b/moloni/api/suppliers_client.py index 5170d3e..c892c6d 100644 --- a/moloni/api/suppliers_client.py +++ b/moloni/api/suppliers_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -22,7 +23,30 @@ def __exit__(self, exc_type, exc_value, traceback): class SuppliersCountModel(ApiRequestModel): company_id: Union[str, int] - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -36,7 +60,30 @@ class SuppliersCountByNameModel(ApiRequestModel): company_id: Union[str, int] name: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_by_name( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -50,7 +97,30 @@ class SuppliersCountByNumberModel(ApiRequestModel): company_id: Union[str, int] number: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_by_number( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -64,7 +134,30 @@ class SuppliersCountBySearchModel(ApiRequestModel): company_id: Union[str, int] search: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_by_search( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -78,7 +171,30 @@ class SuppliersCountByVatModel(ApiRequestModel): company_id: Union[str, int] vat: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_by_vat( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -92,7 +208,30 @@ class SuppliersCountModifiedSinceModel(ApiRequestModel): company_id: Union[str, int] lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -106,7 +245,30 @@ class SuppliersDeleteModel(ApiRequestModel): company_id: Union[str, int] supplier_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.delete( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -121,7 +283,30 @@ class SuppliersGetAllModel(ApiRequestModel): offset: Optional[Union[str, int]] = 0 qty: Optional[Union[str, int]] = 25 - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -137,7 +322,30 @@ class SuppliersGetByNameModel(ApiRequestModel): offset: Optional[Union[str, int]] = 0 qty: Optional[Union[str, int]] = 25 - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_by_name( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -153,7 +361,30 @@ class SuppliersGetByNumberModel(ApiRequestModel): offset: Optional[Union[str, int]] = 0 qty: Optional[Union[str, int]] = 25 - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_by_number( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -169,7 +400,30 @@ class SuppliersGetBySearchModel(ApiRequestModel): qty: Optional[Union[str, int]] = 25 search: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_by_search( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -185,7 +439,30 @@ class SuppliersGetByVatModel(ApiRequestModel): qty: Optional[Union[str, int]] = 25 vat: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_by_vat( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -201,7 +478,30 @@ class SuppliersGetModifiedSinceModel(ApiRequestModel): offset: Optional[Union[str, int]] = 0 qty: Optional[Union[str, int]] = 25 - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -215,7 +515,30 @@ class SuppliersGetOneModel(ApiRequestModel): company_id: Union[str, int] supplier_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_one( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -251,7 +574,30 @@ class SuppliersInsertModel(ApiRequestModel): website: Optional[str] = None zip_code: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.insert( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -288,7 +634,30 @@ class SuppliersUpdateModel(ApiRequestModel): website: Optional[str] = None zip_code: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.update( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/taxes_client.py b/moloni/api/taxes_client.py index 1cdbf60..7cfba7e 100644 --- a/moloni/api/taxes_client.py +++ b/moloni/api/taxes_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -23,7 +24,30 @@ class TaxesCountModifiedSinceModel(ApiRequestModel): company_id: Union[str, int] lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -37,7 +61,30 @@ class TaxesDeleteModel(ApiRequestModel): company_id: Union[str, int] tax_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.delete( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -50,7 +97,30 @@ def request(self): class TaxesGetAllModel(ApiRequestModel): company_id: Union[str, int] - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -64,7 +134,30 @@ class TaxesGetModifiedSinceModel(ApiRequestModel): company_id: Union[str, int] lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -86,7 +179,30 @@ class TaxesInsertModel(ApiRequestModel): value: Optional[str] = None vat_type: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.insert( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -109,7 +225,30 @@ class TaxesUpdateModel(ApiRequestModel): value: Optional[str] = None vat_type: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.update( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/taxexemptions_client.py b/moloni/api/taxexemptions_client.py index 1ad03a3..d7637d6 100644 --- a/moloni/api/taxexemptions_client.py +++ b/moloni/api/taxexemptions_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -22,7 +23,30 @@ def __exit__(self, exc_type, exc_value, traceback): class TaxexemptionsCountModifiedSinceModel(ApiRequestModel): lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -35,7 +59,30 @@ def request(self): class TaxexemptionsGetModifiedSinceModel(ApiRequestModel): lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/users_client.py b/moloni/api/users_client.py index be8daab..5e919bb 100644 --- a/moloni/api/users_client.py +++ b/moloni/api/users_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -39,7 +40,30 @@ class Warehouses(BaseModel): class UsersGetAllModel(ApiRequestModel): company_id: Union[str, int] - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/vehicles_client.py b/moloni/api/vehicles_client.py index 261a636..e7a856f 100644 --- a/moloni/api/vehicles_client.py +++ b/moloni/api/vehicles_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -23,7 +24,30 @@ class VehiclesCountModifiedSinceModel(ApiRequestModel): company_id: Union[str, int] lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -37,7 +61,30 @@ class VehiclesDeleteModel(ApiRequestModel): company_id: Union[str, int] vehicle_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.delete( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -50,7 +97,30 @@ def request(self): class VehiclesGetAllModel(ApiRequestModel): company_id: Union[str, int] - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -64,7 +134,30 @@ class VehiclesGetModifiedSinceModel(ApiRequestModel): company_id: Union[str, int] lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -79,7 +172,30 @@ class VehiclesInsertModel(ApiRequestModel): description: Optional[str] = None number_plate: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.insert( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -95,7 +211,30 @@ class VehiclesUpdateModel(ApiRequestModel): number_plate: Optional[str] = None vehicle_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.update( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/warehouses_client.py b/moloni/api/warehouses_client.py index 85aed97..8688476 100644 --- a/moloni/api/warehouses_client.py +++ b/moloni/api/warehouses_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -40,7 +41,30 @@ class WarehousesCountModifiedSinceModel(ApiRequestModel): company_id: Union[str, int] lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -54,7 +78,30 @@ class WarehousesDeleteModel(ApiRequestModel): company_id: Union[str, int] warehouse_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.delete( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -67,7 +114,30 @@ def request(self): class WarehousesGetAllModel(ApiRequestModel): company_id: Union[str, int] - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -81,7 +151,30 @@ class WarehousesGetModifiedSinceModel(ApiRequestModel): company_id: Union[str, int] lastmodified: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_modified_since( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -105,7 +198,30 @@ class WarehousesInsertModel(ApiRequestModel): title: Optional[str] = None zip_code: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.insert( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -130,7 +246,30 @@ class WarehousesUpdateModel(ApiRequestModel): warehouse_id: Optional[Union[str, int]] = None zip_code: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.update( self.model_dump(exclude={"_api_client"}, exclude_unset=True) diff --git a/moloni/api/waybills_client.py b/moloni/api/waybills_client.py index 6a415d1..5b1adfd 100644 --- a/moloni/api/waybills_client.py +++ b/moloni/api/waybills_client.py @@ -3,6 +3,7 @@ from moloni.base.client import MoloniBaseClient from moloni.base.helpers import endpoint, fill_query_params, validate_data +from moloni.base import ApiResponse class ApiRequestModel(BaseModel): @@ -53,7 +54,30 @@ class WaybillsCountModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.count( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -67,7 +91,30 @@ class WaybillsDeleteModel(ApiRequestModel): company_id: Union[str, int] document_id: Optional[Union[str, int]] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.delete( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -88,7 +135,30 @@ class WaybillsGetAllModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_all( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -108,7 +178,30 @@ class WaybillsGetOneModel(ApiRequestModel): year: Optional[str] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.get_one( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -142,7 +235,30 @@ class WaybillsInsertModel(ApiRequestModel): vehicle_id: Optional[Union[str, int]] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.insert( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -157,7 +273,30 @@ class WaybillsSetTransportCodeModel(ApiRequestModel): document_id: Optional[Union[str, int]] = None transport_code: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.set_transport_code( self.model_dump(exclude={"_api_client"}, exclude_unset=True) @@ -192,7 +331,30 @@ class WaybillsUpdateModel(ApiRequestModel): vehicle_id: Optional[Union[str, int]] = None your_reference: Optional[str] = None - def request(self): + def request(self) -> ApiResponse: + """ + request(self) -> ApiResponse + + Make an API request using the initialized client. + + This method checks if the `_api_client` attribute is set (i.e., if the client has been initialized via the `connect` method). + If the client is initialized, it will make an API request using the provided method name and the model's data, + excluding the `_api_client` attribute itself from the request payload. If the client is not initialized, it will raise a `ValueError`. + + Returns: + The response from the API. + + Raises: + ValueError: If the client is not initialized via the `connect` method. + + Example: + # Assuming you have a model instance `request_model` and an API client `api_client` + with request_model.connect(auth_config=auth_config) as api: + response = api.request() + + # The above example assumes that the `connect` method has been used to initialize the client. + # The request method then sends the model's data to the API and returns the API's response. + """ if hasattr(self, "_api_client"): response = self._api_client.update( self.model_dump(exclude={"_api_client"}, exclude_unset=True)