DRAFT: Started API verification implementation. - #83
Conversation
BorekZnovustvoritel
left a comment
There was a problem hiding this comment.
Leaving my notes open, so I don't forget them in the future.
| from .database import VerifyMember, DBAPI | ||
|
|
||
|
|
||
| class APIClient: |
There was a problem hiding this comment.
TODO: Implement mechanism for handling API limits and HTTP exceptions for various reasons
| return settings.is_valid | ||
|
|
||
|
|
||
| class APIVerify(Verify): |
There was a problem hiding this comment.
TODO: add tools for removing settings
|
|
||
|
|
||
| async def setup(bot) -> None: | ||
| await bot.add_cog(Verify(bot)) |
There was a problem hiding this comment.
TODO: think about merging these classes
| async with aiohttp.ClientSession( | ||
| headers={"Authorization": f"Bearer {self.settings.token}"} | ||
| ) as session: | ||
| async with session.get( |
There was a problem hiding this comment.
TODO: think about support for different methods than GET
| print(member) | ||
| print(endpoint.role_endpoint.format(member.address)) | ||
| print(endpoint.role_jmespath) | ||
| async with session.get( |
There was a problem hiding this comment.
TODO: Also suupport for different methods
| print( | ||
| f"role data: {role_data} == mapping-api_data: {mapping.api_data}" | ||
| ) | ||
| if role_data == mapping.api_data: |
There was a problem hiding this comment.
TODO: What if the field returned by jmespath search contains a list?
| self.settings = settings | ||
|
|
||
| async def get_mail(self, idx: str) -> str: | ||
| async with aiohttp.ClientSession( |
There was a problem hiding this comment.
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(...)
This work is NOT FINISHED, a lot of components and a documentation is missing! DO NOT MERGE!