Pular para conteúdo

2. USER

Module: user

User

Bases: MEBase

A factory for a User class.

This class provides methods to interact with user information in the MelhorEnvio API.

METHOD DESCRIPTION
me

Returns the current user information.

addresses

List of addresses of the current user account.

balance

Returns the balance of the current user.

insert_balance

Inserts a new balance for a given gateway.

me() -> dict

Returns the current user information .

Documentation.

Usage:

>>> sdk.user().me()

RETURNS DESCRIPTION
dict

A dictionary containing user information.

TYPE: dict

Source code in melhorenvio/resources/user.py
def me(self) -> dict:
    """Returns the current user information .

    [Documentation](https://docs.melhorenvio.com.br/reference/listar-informacoes-do-usuario).

    Usage:
    ```python
    >>> sdk.user().me()
    ```

    Returns:
        dict: A dictionary containing user information.
    """
    return self._get(uri="/api/v2/me")

addresses() -> dict

List of addresses of current user account .

This method retrieves a list of addresses associated with the current user account in the MelhorEnvio API.

Documentation.

Usage:

>>> sdk.user().addresses()

RETURNS DESCRIPTION
dict

A dictionary containing a list of user addresses.

TYPE: dict

Source code in melhorenvio/resources/user.py
def addresses(self) -> dict:
    """List of addresses of current user account .

    This method retrieves a list of addresses associated with the current user account in the MelhorEnvio API.

    [Documentation](https://docs.melhorenvio.com.br/reference/listar-enderecos-do-usuario).

    Usage:
    ```python
    >>> sdk.user().addresses()
    ```

    Returns:
        dict: A dictionary containing a list of user addresses.
    """
    return self._get(uri="/api/v2/me/addresses")

balance() -> dict

Returns the balance of the current user .

This method retrieves the balance of the current user's account in the MelhorEnvio API.

Documentation.

Usage:

>>> sdk.user().balance()

RETURNS DESCRIPTION
dict

A dictionary containing the user's balance information.

TYPE: dict

Source code in melhorenvio/resources/user.py
def balance(self) -> dict:
    """Returns the balance of the current user .

    This method retrieves the balance of the current user's account in the MelhorEnvio API.

    [Documentation](https://docs.melhorenvio.com.br/reference/saldo-do-usuario).

    Usage:
    ```python
    >>> sdk.user().balance()
    ```

    Returns:
        dict: A dictionary containing the user's balance information.
    """
    return self._get(uri="/api/v2/me/balance")

insert_balance(gateway: str, value: str) -> dict

Inserts a new balance for a given gateway .

This method allows you to insert a new balance for a specific gateway in the user's account in the MelhorEnvio API.

Documentation.

Usage:

>>> gateway = "example_gateway"
>>> value = "100.00"
>>> sdk.user().insert_balance(gateway=gateway, value=value)

PARAMETER DESCRIPTION
gateway

The gateway for which you want to insert the balance.

TYPE: str

value

The value of the balance to be inserted.

TYPE: str

RETURNS DESCRIPTION
dict

A dictionary containing information about the inserted balance.

TYPE: dict

Source code in melhorenvio/resources/user.py
    def insert_balance(self, gateway: str, value: str) -> dict:
        """Inserts a new balance for a given gateway .

        This method allows you to insert a new balance for a specific gateway in the user's account in the MelhorEnvio API.

        [Documentation](https://docs.melhorenvio.com.br/reference/inserir-saldo-na-carteira-do-usuario).

        Usage:
        ```python
        >>> gateway = "example_gateway"
        >>> value = "100.00"
        >>> sdk.user().insert_balance(gateway=gateway, value=value)
        ```

        Args:
            gateway (str): The gateway for which you want to insert the balance.
            value (str): The value of the balance to be inserted.

        Returns:
            dict: A dictionary containing information about the inserted balance.
		"""
        return self._post(
            uri="/api/v2/me/balance",
            data={
                "gateway": gateway,
                "redirect": self.config.redirect_uri,
                "value": value,
            },
        )