belvo.resources.invoices

 1from typing import Dict, List, Union
 2
 3from belvo.resources.base import Resource
 4
 5
 6class Invoices(Resource):
 7    endpoint = "/api/invoices/"
 8
 9    def create(
10        self,
11        link: str,
12        date_from: str,
13        date_to: str,
14        type_: str,
15        *,
16        attach_xml: bool = False,
17        save_data: bool = True,
18        raise_exception: bool = False,
19        **kwargs: Dict,
20    ) -> Union[List[Dict], Dict]:
21        """Retrieve invoices for a link
22
23        You can ask for up to **one** year (365 days) of invoices per request. If you need invoices for more than one year, just make another request.
24
25        Example:
26        ```python
27        # Fetch invoices for a Link
28        invoices = client.Invoices.create(
29            "b91835f5-6f83-4d9b-a0ad-a5a249f18b7c",
30            "2019-07-01",
31            "2019-07-31",
32            "INFLOW"
33        )
34        ```
35
36        Args:
37            link (str): The fiscal `link.id` that you want to get information for (UUID).
38            date_from (str): Date from which you want to start receiving invoices for, in `YYYY-MM-DD` format. The value of `date_from` cannot be greater than `date_to`.
39            date_to (str, optional): Date that you want to stop receiving invoirces for, in `YYYY-MM-DD` format. The value of `date_to` cannot be greater than today's date (in other words, no future dates).
40            type_ (str): The direction of the invoice (from the perspective of the Link owner). Can be either `OUTFLOW` OR `INFLOW`.
41            attach_xml (bool, optional): When set to `True`, you will receive the XML invoice in the response. Defaults to False.
42             save_data (bool, optional): Indicates whether or not to persist the data in Belvo. Defaults to `True`.
43            raise_exception (bool, optional): Indicates whether to raise an exception or return the API error. Defaults to `False`.
44
45        Returns:
46            Union[List[Dict], Dict]: For more information on the response from the API, see our [Invoices API documentation](https://developers.belvo.com/reference/retrieveinvoices).
47        """
48
49        data = {
50            "link": link,
51            "date_from": date_from,
52            "date_to": date_to,
53            "type": type_,
54            "attach_xml": attach_xml,
55            "save_data": save_data,
56        }
57
58        return self.session.post(
59            self.endpoint, data=data, raise_exception=raise_exception, **kwargs
60        )
61
62    def resume(
63        self,
64        session: str,
65        token: str,
66        *,
67        link: str = None,
68        raise_exception: bool = False,
69        **kwargs: Dict,
70    ) -> Dict:
71        raise NotImplementedError()
class Invoices(belvo.resources.base.Resource):
 7class Invoices(Resource):
 8    endpoint = "/api/invoices/"
 9
10    def create(
11        self,
12        link: str,
13        date_from: str,
14        date_to: str,
15        type_: str,
16        *,
17        attach_xml: bool = False,
18        save_data: bool = True,
19        raise_exception: bool = False,
20        **kwargs: Dict,
21    ) -> Union[List[Dict], Dict]:
22        """Retrieve invoices for a link
23
24        You can ask for up to **one** year (365 days) of invoices per request. If you need invoices for more than one year, just make another request.
25
26        Example:
27        ```python
28        # Fetch invoices for a Link
29        invoices = client.Invoices.create(
30            "b91835f5-6f83-4d9b-a0ad-a5a249f18b7c",
31            "2019-07-01",
32            "2019-07-31",
33            "INFLOW"
34        )
35        ```
36
37        Args:
38            link (str): The fiscal `link.id` that you want to get information for (UUID).
39            date_from (str): Date from which you want to start receiving invoices for, in `YYYY-MM-DD` format. The value of `date_from` cannot be greater than `date_to`.
40            date_to (str, optional): Date that you want to stop receiving invoirces for, in `YYYY-MM-DD` format. The value of `date_to` cannot be greater than today's date (in other words, no future dates).
41            type_ (str): The direction of the invoice (from the perspective of the Link owner). Can be either `OUTFLOW` OR `INFLOW`.
42            attach_xml (bool, optional): When set to `True`, you will receive the XML invoice in the response. Defaults to False.
43             save_data (bool, optional): Indicates whether or not to persist the data in Belvo. Defaults to `True`.
44            raise_exception (bool, optional): Indicates whether to raise an exception or return the API error. Defaults to `False`.
45
46        Returns:
47            Union[List[Dict], Dict]: For more information on the response from the API, see our [Invoices API documentation](https://developers.belvo.com/reference/retrieveinvoices).
48        """
49
50        data = {
51            "link": link,
52            "date_from": date_from,
53            "date_to": date_to,
54            "type": type_,
55            "attach_xml": attach_xml,
56            "save_data": save_data,
57        }
58
59        return self.session.post(
60            self.endpoint, data=data, raise_exception=raise_exception, **kwargs
61        )
62
63    def resume(
64        self,
65        session: str,
66        token: str,
67        *,
68        link: str = None,
69        raise_exception: bool = False,
70        **kwargs: Dict,
71    ) -> Dict:
72        raise NotImplementedError()
endpoint = '/api/invoices/'
def create( self, link: str, date_from: str, date_to: str, type_: str, *, attach_xml: bool = False, save_data: bool = True, raise_exception: bool = False, **kwargs: Dict) -> Union[List[Dict], Dict]:
10    def create(
11        self,
12        link: str,
13        date_from: str,
14        date_to: str,
15        type_: str,
16        *,
17        attach_xml: bool = False,
18        save_data: bool = True,
19        raise_exception: bool = False,
20        **kwargs: Dict,
21    ) -> Union[List[Dict], Dict]:
22        """Retrieve invoices for a link
23
24        You can ask for up to **one** year (365 days) of invoices per request. If you need invoices for more than one year, just make another request.
25
26        Example:
27        ```python
28        # Fetch invoices for a Link
29        invoices = client.Invoices.create(
30            "b91835f5-6f83-4d9b-a0ad-a5a249f18b7c",
31            "2019-07-01",
32            "2019-07-31",
33            "INFLOW"
34        )
35        ```
36
37        Args:
38            link (str): The fiscal `link.id` that you want to get information for (UUID).
39            date_from (str): Date from which you want to start receiving invoices for, in `YYYY-MM-DD` format. The value of `date_from` cannot be greater than `date_to`.
40            date_to (str, optional): Date that you want to stop receiving invoirces for, in `YYYY-MM-DD` format. The value of `date_to` cannot be greater than today's date (in other words, no future dates).
41            type_ (str): The direction of the invoice (from the perspective of the Link owner). Can be either `OUTFLOW` OR `INFLOW`.
42            attach_xml (bool, optional): When set to `True`, you will receive the XML invoice in the response. Defaults to False.
43             save_data (bool, optional): Indicates whether or not to persist the data in Belvo. Defaults to `True`.
44            raise_exception (bool, optional): Indicates whether to raise an exception or return the API error. Defaults to `False`.
45
46        Returns:
47            Union[List[Dict], Dict]: For more information on the response from the API, see our [Invoices API documentation](https://developers.belvo.com/reference/retrieveinvoices).
48        """
49
50        data = {
51            "link": link,
52            "date_from": date_from,
53            "date_to": date_to,
54            "type": type_,
55            "attach_xml": attach_xml,
56            "save_data": save_data,
57        }
58
59        return self.session.post(
60            self.endpoint, data=data, raise_exception=raise_exception, **kwargs
61        )

Retrieve invoices for a link

You can ask for up to one year (365 days) of invoices per request. If you need invoices for more than one year, just make another request.

Example:

# Fetch invoices for a Link
invoices = client.Invoices.create(
    "b91835f5-6f83-4d9b-a0ad-a5a249f18b7c",
    "2019-07-01",
    "2019-07-31",
    "INFLOW"
)
Arguments:
  • link (str): The fiscal link.id that you want to get information for (UUID).
  • date_from (str): Date from which you want to start receiving invoices for, in YYYY-MM-DD format. The value of date_from cannot be greater than date_to.
  • date_to (str, optional): Date that you want to stop receiving invoirces for, in YYYY-MM-DD format. The value of date_to cannot be greater than today's date (in other words, no future dates).
  • type_ (str): The direction of the invoice (from the perspective of the Link owner). Can be either OUTFLOW OR INFLOW.
  • attach_xml (bool, optional): When set to True, you will receive the XML invoice in the response. Defaults to False. save_data (bool, optional): Indicates whether or not to persist the data in Belvo. Defaults to True.
  • raise_exception (bool, optional): Indicates whether to raise an exception or return the API error. Defaults to False.
Returns:

Union[List[Dict], Dict]: For more information on the response from the API, see our Invoices API documentation.

def resume( self, session: str, token: str, *, link: str = None, raise_exception: bool = False, **kwargs: Dict) -> Dict:
63    def resume(
64        self,
65        session: str,
66        token: str,
67        *,
68        link: str = None,
69        raise_exception: bool = False,
70        **kwargs: Dict,
71    ) -> Dict:
72        raise NotImplementedError()

Resume a resource sessions

Example:

# Login to Belvo API
client = Client("Secret Key ID", "Secret Key PASSWORD", "sandbox")

# Resume a link
link = client.Links.resume(
  session="session_id",
  token="token",
  link="link_id"
)

Arguments:
  • session (str): The session you want to resume (UUID).
  • token (str): The MFA token required to continue the session.
  • link (str, optional): The Link ID . Defaults to None.
  • raise_exception (bool, optional): Boolean indicating whether to return an API error or to raise an exception. Defaults to False.
Returns:

Union[List[Dict], Dict]: On success, returns the resource data requests.