Skip to content

Commit

Permalink
fixing errors
Browse files Browse the repository at this point in the history
  • Loading branch information
vwh committed Jun 15, 2024
1 parent e2a86e4 commit b8e8b2e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions rbrapi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from uuid import uuid4
from typing import Optional
from requests import Response
from json import loads

from .session import make_request
from .types import (
Expand Down Expand Up @@ -151,7 +151,7 @@ def send_friend_request(self, friend_code: str, timeout: int = None) -> bool:
if not self.token:
raise AuthenticationError("Token not found or user is unauthenticated")

data = ('"{\\"friend_code\\":\\"' + friend_code + '\\"}"',)
data = '"{\\"friend_code\\":\\"' + friend_code + '\\"}"'
make_request(
f"{BASE_URL}/rpc/winterpixel_query_user_id_for_friend_code",
headers={
Expand Down Expand Up @@ -198,10 +198,14 @@ def buy_crate(self, elite: bool = False, timeout: int = None) -> "LootBoxRespons
)

payload = response.get("payload")

if isinstance(payload, str):
payload = loads(payload)

if payload:
return LootBoxResponses.from_dict(payload)

raise LootBoxError(response.json().get("message", "Unable to buy crate"))
raise LootBoxError(response.get("message", "Unable to buy crate"))

@staticmethod
def signup(email: str, password: str, username: str, timeout=None) -> bool:
Expand Down
4 changes: 2 additions & 2 deletions rbrapi/types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import json
from json import loads

from typing import TypedDict, Dict, List

Expand Down Expand Up @@ -67,7 +67,7 @@ class AccountResponse(APIResponse):

def __init__(self, user: UserResponse, wallet: str, email: str, custom_id: str):
super().__init__(
user=user, wallet=json.loads(wallet), email=email, custom_id=custom_id
user=user, wallet=loads(wallet), email=email, custom_id=custom_id
)


Expand Down

0 comments on commit b8e8b2e

Please sign in to comment.