Skip to content

Add a more fluent API wrapper #690

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

Closed
wants to merge 5 commits into from

Conversation

paulo-raca
Copy link
Contributor

@paulo-raca paulo-raca commented Oct 20, 2022

Instead of importing lots of different packages, the new "Api" object encapsulates everything neatly:

This builds on top of #688 and #689, and is currently being used in my Serpro API

The simplified usage looks like this:

    client = consulta_cpf.Api(
        "https://gateway.apiserpro.serpro.gov.br/consulta-cpf-df/v1",
        **credentials
    )

    print(
        "Consulta CPF", 
        client.cpf.get_cpf_ni(ni="45317828791"))

TODO:

  • Update the documentation

I'm working on a template where the client is provided by self.get_client() instead of by an explicit argument
…bals

This makes `endpoint_collections_by_tag` available in every template (Instead of only a few selected places).

`openapi` is not obviously useful, but is being used on my custom templates
@paulo-raca paulo-raca marked this pull request as draft October 20, 2022 07:03
@dbanty
Copy link
Collaborator

dbanty commented Nov 12, 2022

Moving toward an object-oriented style is a non-goal for this project, as is adding multiple ways to call the functions. There will eventually be a better way to manage clients, but API functions will be imported for the foreseeable future.

@dbanty dbanty closed this Nov 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants