Ejemplo n.º 1
0
 def get_available_rooms(cls):
     url = f"{constants.SERVER_DOMAIN}/rooms"
     headers = {'x-access-token': cls.player_token}
     response = requests.get(url, headers=headers)
     rooms_as_dict = response.json()
     rooms_as_obj = [
         Room.dict_to_obj(room_as_dict)
         for room_as_dict in rooms_as_dict.values()
     ]
     return rooms_as_obj
Ejemplo n.º 2
0
 def display_room_details_by_room_name(cls):
     room_name = input("Please insert the name of the room: ")
     print("")
     url = f"{constants.SERVER_DOMAIN}/rooms/{room_name}"
     headers = {'x-access-token': cls.player_token}
     response = requests.get(url, headers=headers)
     room_as_dict = response.json()
     if not room_as_dict:
         print(f"{RoomsAPIErrors.ROOM_NAME_DOESNT_EXIST.value}\n")
     else:
         room_as_obj = Room.dict_to_obj(room_as_dict)
         print(room_as_obj)
     cls.display_main_menu()