FortlevSolarClient
Client for interacting with the Fortlev Solar API. Provides methods for authentication and retrieving data related to surfaces, components, cities, and orders.
Attributes:
Name | Type | Description |
---|---|---|
base_url |
str
|
The base URL of the Fortlev Solar API. |
Methods:
Name | Description |
---|---|
register |
Register a new partner in the Fortlev Solar |
authenticate |
Authenticates the user and sets authorization headers. |
surfaces |
Retrieves a list of available surfaces. |
components |
Retrieves a list of available components. |
cities |
Retrieves a list of cities with specific details. |
orders |
Retrieves orders based on given parameters. |
financing |
Retrieves financing options based on the specified investment value. |
authenticate(username, pwd)
Authenticates the client with the provided username and password.
This method sends a request to [POST] /user/login
Parameters:
Name | Type | Description | Default |
---|---|---|---|
username |
str
|
The username for authentication. |
required |
pwd |
str
|
The password for authentication. |
required |
Returns:
Name | Type | Description |
---|---|---|
Auth |
Auth
|
The authentication details if successful. |
Raises:
Type | Description |
---|---|
RequestError
|
If the authentication fails. |
base_get_request(endpoint, Model, query_params={})
Sends a GET request to the specified endpoint with optional query parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
endpoint |
str
|
The endpoint to request data from. |
required |
Model |
type
|
The model class to parse the response data into. |
required |
query_params |
(dict, Optional)
|
Optional query parameters for the request. |
{}
|
Returns:
Type | Description |
---|---|
list[object]
|
list[Model]: A list of instances of the specified Model parsed from the response. |
Raises:
Type | Description |
---|---|
RequestError
|
If the request fails. |
cities(query_params={})
Retrieves a list of cities with specific details.
This method sends a request to [GET] /brazilian-city
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query_params |
(dict, Optional)
|
Optional query parameters for filtering the cities. |
{}
|
Returns:
Type | Description |
---|---|
list[City]
|
list[City]: A list of City instances. |
components(query_params={})
Retrieves a list of available components.
This method sends a request to [GET] /component/all
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query_params |
(dict, Optional)
|
Optional query parameters for filtering the components. |
{}
|
Returns:
Type | Description |
---|---|
list[Component]
|
list[Component]: A list of Component instances. |
financing(value, entry_value=0, grace=1)
Retrieves financing options based on the specified investment value.
This method sends a request to [POST] /financing/simplified
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value |
float
|
The total investment value. |
required |
entry_value |
float
|
The upfront entry value. Defaults to 0. |
0
|
grace |
Literal[1, 2, 3, 4, 5, 6]
|
The number of grace months before starting payments. Defaults to 1. |
1
|
Returns:
Type | Description |
---|---|
list[Financing]
|
list[Financing]: A list of Financing instances representing the available financing options. |
Raises:
Type | Description |
---|---|
RequestError
|
If the request fails or if the API returns an error response. |
Examples:
Authenticate and retrieve a list of financing:
orders(power=0, voltage='220', phase=1, surface=None, city=None)
Retrieves a list of orders based on the given parameters.
This method sends a request to [POST] /order
Parameters:
Name | Type | Description | Default |
---|---|---|---|
power |
(float, Optional)
|
The target power for the order. Defaults to 0. |
0
|
voltage |
(Literal['220', '380', '+'], Optional)
|
The voltage type. Defaults to "220". |
'220'
|
phase |
(Literal[1, 2, 3], Optional)
|
The phase (1, 2, or 3). Defaults to 1. |
1
|
surface |
(str, Optional)
|
The surface ID for the order. If None, no specific surface will be used. Defaults to None. |
None
|
city |
(str, Optional)
|
The city ID for the order. If None, the user's registered city will be used. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
list[Order]
|
list[Order]: A list of Order instances. |
Raises:
Type | Description |
---|---|
RequestError
|
If the client is not authenticated or the API request fails. |
Tip
You can generate a catalog of available kits by setting power=0
.
Examples:
Authenticate and retrieve a list of orders:
register(name, email, phone_number, cnpj, pwd)
Register a new partner in Fortlev Solar.
This method sends a request to [POST] /user/sign-up
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
The name of the user to be registered. |
required |
email |
str
|
The email address of the user. Must be a valid email format. |
required |
phone_number |
str
|
The user's phone number. Must contain 11 digits. |
required |
cnpj |
str
|
The CNPJ number of the user or company. Must follow CNPJ formatting rules. |
required |
pwd |
str
|
The password for the user's account. Must meet specified complexity requirements. |
required |
Returns:
Name | Type | Description |
---|---|---|
SignUpResponse |
RegisterResponse
|
An instance containing a message and the validation status of the email. |
Raises:
Type | Description |
---|---|
RequestError
|
If the registration request fails or if the server returns an error response. |
surfaces(query_params={})
Retrieves a list of available surfaces.
This method sends a request to [GET] /surface
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query_params |
(dict, Optional)
|
Optional query parameters for filtering the surfaces. |
{}
|
Returns:
Type | Description |
---|---|
list[Surface]
|
list[Surface]: A list of Surface instances. |