forked from retoor/devranta
feat: add register_user method to Api class for account creation with email, username, password
Implements POST request to devrant/rants/{rant_id}/comments endpoint with email, username, password, and platform field. Returns boolean success based on JSON response 'success' key. Includes async session handling and URL patching with auth data.
This commit is contained in:
@@ -71,6 +71,23 @@ class Api:
|
||||
await self.session.close()
|
||||
self.session = None
|
||||
|
||||
async def register_user(self, email, username, password):
|
||||
response = None
|
||||
async with self as session:
|
||||
response = await session.post(
|
||||
url=self.patch_url(f"devrant/rants/{rant_id}/comments"),
|
||||
data=self.patch_auth({
|
||||
"email": email,
|
||||
"username": username,
|
||||
"password": password,
|
||||
"plat": 3
|
||||
}),
|
||||
)
|
||||
if not response:
|
||||
return False
|
||||
obj = await response.json()
|
||||
return obj.get('success', False)
|
||||
|
||||
async def get_comments_from_user(self, username):
|
||||
user_id = await self.get_user_id(username)
|
||||
profile = await self.get_profile(user_id)
|
||||
|
||||
Reference in New Issue
Block a user