Skip to content

DRAFT: Started API verification implementation. - #83

Draft
BorekZnovustvoritel wants to merge 1 commit into
pumpkin-py:mainfrom
BorekZnovustvoritel:api_verify
Draft

DRAFT: Started API verification implementation.#83
BorekZnovustvoritel wants to merge 1 commit into
pumpkin-py:mainfrom
BorekZnovustvoritel:api_verify

Conversation

@BorekZnovustvoritel

Copy link
Copy Markdown
Contributor

This work is NOT FINISHED, a lot of components and a documentation is missing! DO NOT MERGE!

@BorekZnovustvoritel BorekZnovustvoritel left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Leaving my notes open, so I don't forget them in the future.

Comment thread verify/api_client.py
from .database import VerifyMember, DBAPI


class APIClient:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

TODO: Implement mechanism for handling API limits and HTTP exceptions for various reasons

Comment thread verify/module.py
return settings.is_valid


class APIVerify(Verify):

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

TODO: add tools for removing settings

Comment thread verify/module.py


async def setup(bot) -> None:
await bot.add_cog(Verify(bot))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

TODO: think about merging these classes

Comment thread verify/api_client.py
async with aiohttp.ClientSession(
headers={"Authorization": f"Bearer {self.settings.token}"}
) as session:
async with session.get(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

TODO: think about support for different methods than GET

Comment thread verify/api_client.py
print(member)
print(endpoint.role_endpoint.format(member.address))
print(endpoint.role_jmespath)
async with session.get(

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

TODO: Also suupport for different methods

Comment thread verify/api_client.py
print(
f"role data: {role_data} == mapping-api_data: {mapping.api_data}"
)
if role_data == mapping.api_data:

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

TODO: What if the field returned by jmespath search contains a list?

Comment thread verify/api_client.py
self.settings = settings

async def get_mail(self, idx: str) -> str:
async with aiohttp.ClientSession(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

For proper balancing I would suggest having global ClientSessions that you can use in every extension/module
That will make it more optimized when doing async with session.get(...)

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