Skip to content

Commit

Permalink
move to single api file
Browse files Browse the repository at this point in the history
  • Loading branch information
btb committed Apr 19, 2024
1 parent f7746b8 commit 8b5d99d
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 53 deletions.
49 changes: 49 additions & 0 deletions uw_mazevo/api.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
from uw_mazevo import get_resource, post_resource
from uw_mazevo.models import Booking, Room, Status


class PublicConfiguration(object):
URL = "/api/PublicConfiguration/{}"

def get_rooms(self, building_id=0):
"""
Gets a list of Rooms. building_id of 0 returns all rooms.
"""
url = self.URL.format("Rooms")
body = {"buildingId": building_id}

rooms = []
for data in post_resource(url, body):
rooms.append(Room.from_json(data))
return rooms

def get_statuses(self):
"""
Gets a list of Statuses
"""
url = self.URL.format("Statuses")

statuses = []
for data in get_resource(url):
statuses.append(Status.from_json(data))

return statuses


class PublicEvent(object):
URL = "/api/PublicEvent/{}"

def get_events(self, **kwargs):
"""
Only pass in the "minDateChanged" parameter if you want results
for bookings that have been created or changed since the
"minDateChanged" date. Changed bookings are for critical booking
information only like date, time, status or room.
"""
url = self.URL.format("getevents")
body = kwargs

events = []
for data in post_resource(url, body):
events.append(Booking.from_json(data))
return events
30 changes: 0 additions & 30 deletions uw_mazevo/public_configuration.py

This file was deleted.

21 changes: 0 additions & 21 deletions uw_mazevo/public_event.py

This file was deleted.

2 changes: 1 addition & 1 deletion uw_mazevo/tests/test_public_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0

from unittest import TestCase
from uw_mazevo.public_configuration import PublicConfiguration
from uw_mazevo.api import PublicConfiguration


class TestPublicConfiguration(TestCase):
Expand Down
2 changes: 1 addition & 1 deletion uw_mazevo/tests/test_public_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0

from unittest import TestCase
from uw_mazevo.public_event import PublicEvent
from uw_mazevo.api import PublicEvent


class TestPublicEvent(TestCase):
Expand Down

0 comments on commit 8b5d99d

Please sign in to comment.