belvo.enums

 1from enum import Enum, unique
 2from typing import Optional
 3
 4
 5@unique
 6class AccessMode(Enum):
 7    SINGLE = "single"
 8    RECURRENT = "recurrent"
 9
10
11@unique
12class TaxReturnType(Enum):
13    YEARLY = "yearly"
14    MONTHLY = "monthly"
15
16
17@unique
18class TaxRetentionType(Enum):
19    INFLOW = "inflow"
20    OUTFLOW = "outflow"
21
22
23@unique
24class Environment(Enum):
25    SANDBOX = "https://sandbox.belvo.com"
26    DEVELOPMENT = "https://development.belvo.com"
27    PRODUCTION = "https://api.belvo.com"
28
29    @classmethod
30    def get_url(cls, environment: Optional[str]):
31        if not environment:
32            return None
33
34        try:
35            return cls[environment.upper()].value
36        except KeyError:
37            return environment
@unique
class AccessMode(enum.Enum):
6@unique
7class AccessMode(Enum):
8    SINGLE = "single"
9    RECURRENT = "recurrent"

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access:

    >>> Color.RED
    <Color.RED: 1>
    
  • value lookup:

    >>> Color(1)
    <Color.RED: 1>
    
  • name lookup:

    >>> Color['RED']
    <Color.RED: 1>
    

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details.

SINGLE = <AccessMode.SINGLE: 'single'>
RECURRENT = <AccessMode.RECURRENT: 'recurrent'>
Inherited Members
enum.Enum
name
value
@unique
class TaxReturnType(enum.Enum):
12@unique
13class TaxReturnType(Enum):
14    YEARLY = "yearly"
15    MONTHLY = "monthly"

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access:

    >>> Color.RED
    <Color.RED: 1>
    
  • value lookup:

    >>> Color(1)
    <Color.RED: 1>
    
  • name lookup:

    >>> Color['RED']
    <Color.RED: 1>
    

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details.

YEARLY = <TaxReturnType.YEARLY: 'yearly'>
MONTHLY = <TaxReturnType.MONTHLY: 'monthly'>
Inherited Members
enum.Enum
name
value
@unique
class TaxRetentionType(enum.Enum):
18@unique
19class TaxRetentionType(Enum):
20    INFLOW = "inflow"
21    OUTFLOW = "outflow"

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access:

    >>> Color.RED
    <Color.RED: 1>
    
  • value lookup:

    >>> Color(1)
    <Color.RED: 1>
    
  • name lookup:

    >>> Color['RED']
    <Color.RED: 1>
    

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details.

INFLOW = <TaxRetentionType.INFLOW: 'inflow'>
OUTFLOW = <TaxRetentionType.OUTFLOW: 'outflow'>
Inherited Members
enum.Enum
name
value
@unique
class Environment(enum.Enum):
24@unique
25class Environment(Enum):
26    SANDBOX = "https://sandbox.belvo.com"
27    DEVELOPMENT = "https://development.belvo.com"
28    PRODUCTION = "https://api.belvo.com"
29
30    @classmethod
31    def get_url(cls, environment: Optional[str]):
32        if not environment:
33            return None
34
35        try:
36            return cls[environment.upper()].value
37        except KeyError:
38            return environment

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access:

    >>> Color.RED
    <Color.RED: 1>
    
  • value lookup:

    >>> Color(1)
    <Color.RED: 1>
    
  • name lookup:

    >>> Color['RED']
    <Color.RED: 1>
    

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes -- see the documentation for details.

SANDBOX = <Environment.SANDBOX: 'https://sandbox.belvo.com'>
DEVELOPMENT = <Environment.DEVELOPMENT: 'https://development.belvo.com'>
PRODUCTION = <Environment.PRODUCTION: 'https://api.belvo.com'>
@classmethod
def get_url(cls, environment: Optional[str]):
30    @classmethod
31    def get_url(cls, environment: Optional[str]):
32        if not environment:
33            return None
34
35        try:
36            return cls[environment.upper()].value
37        except KeyError:
38            return environment
Inherited Members
enum.Enum
name
value