Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expõe todas as metainformações de uma consulta à API #48

Merged
merged 1 commit into from
Oct 10, 2023

Conversation

cuducos
Copy link
Collaborator

@cuducos cuducos commented Oct 9, 2023

Parte da #46

Para podermos fazer mais reequisições em paralelo, precisamos saber quantas páginas temos que requisitar. Esse PR facilita isso expondo outros dados do pageMeta além do hasNextPage.

@@ -29,6 +32,32 @@ class IncompatibleDataError(CrossfireError):
pass


@dataclass
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tive que rever seu artigo sobre dataclass.
Vc optou por essa abordagem para "facilitar" a criação dessa classe, correto? Assim vc pode declarar a classe sem definir cada método "mágico", e imagino que tenha feito isso por que a existência dessa classe está no método from_response.
O método from_response é um classmethod que, pelo que entendí "pertence" à classe. Dessa forma, é possível instanciar um objeto da classe Metadata diretamente ao usar o classmethod, ou seja, usando o Metadata.from_response(response) usa os itens que estão em response para instanciar a classe Metadata.
É isso ou entendi mal alguma coisa?

@@ -39,7 +68,7 @@ def wrapper(self, *args, **kwargs):
response = method(self, *args, **kwargs)
response.encoding = "utf8"
contents = response.json()
has_next_page = contents.get("pageMeta", {}).get("hasNextPage", False)
metadata = Metadata.from_response(contents)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Então aqui, o metadata é uma instancia de Metdata que teve seus parâmetros definidos diretamente pelo método from_response...

@FelipeSBarros FelipeSBarros merged commit 6e4aa67 into FelipeSBarros:master Oct 10, 2023
1 check passed
@cuducos cuducos deleted the meta-data branch October 23, 2023 13:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants