Book a reservation given the session id, the room id as an integer, and the start and end time as datetimes.

def book_reservation(self, sessionid, roomid, start, end):
        """ Book a reservation given the session id, the room id as an integer, and the start and end time as datetimes. """
        duration = int((end - start).seconds / 60)
        format = "%Y-%m-%dT%H:%M:%S-{}".format(self.get_dst_gmt_timezone())
        booking_url = "{}/reserve/{}/{}/?d={}".format(BASE_URL, roomid, start.strftime(format), duration)
        resp = requests.get(booking_url, cookies={"sessionid": sessionid})

        if resp.status_code == 403:
            return {"success": False, "error": "Your account does not have permission to book Wharton GSRs!"}

        resp.raise_for_status()

        csrfheader = re.search(r"csrftoken=(.*?);", resp.headers["Set-Cookie"]).group(1)
        csrftoken = re.search(r"<input name=\"csrfmiddlewaretoken\" type=\"hidden\" value=\"(.*?)\"/>", resp.content.decode("utf8")).group(1)

        start_string = start.strftime("%I:%M %p")
        if start_string[0] == "0":
            start_string = start_string[1:]

        resp = requests.post(
            booking_url,
            cookies={"sessionid": sessionid, "csrftoken": csrfheader},
            headers={"Referer": booking_url},
            data={
                "csrfmiddlewaretoken": csrftoken,
                "room": roomid,
                "start_time": start_string,
                "end_time": end.strftime("%a %b %d %H:%M:%S %Y"),
                "date": start.strftime("%B %d, %Y")
            }
        )
        resp.raise_for_status()
        content = resp.content.decode("utf8")
        if "errorlist" in content:
            error_msg = re.search(r"class=\"errorlist\"><li>(.*?)</li>", content).group(1)
            return {"success": False, "error": error_msg}

        return {"success": True}