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
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.
Inherited Members
- enum.Enum
- name
- value
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.
Inherited Members
- enum.Enum
- name
- value
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.
Inherited Members
- enum.Enum
- name
- value
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.
Inherited Members
- enum.Enum
- name
- value