diff --git a/uw_mazevo/api.py b/uw_mazevo/api.py new file mode 100644 index 0000000..8d7a26f --- /dev/null +++ b/uw_mazevo/api.py @@ -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 diff --git a/uw_mazevo/public_configuration.py b/uw_mazevo/public_configuration.py deleted file mode 100644 index 219765a..0000000 --- a/uw_mazevo/public_configuration.py +++ /dev/null @@ -1,30 +0,0 @@ -from uw_mazevo import get_resource, post_resource -from uw_mazevo.models import Room, Status - -PUBLICCONFIGURATION_API = "/api/PublicConfiguration/{}" - - -class PublicConfiguration(object): - def get_rooms(self, building_id=0): - """ - Gets a list of Rooms. building_id of 0 returns all rooms. - """ - url = PUBLICCONFIGURATION_API.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 = PUBLICCONFIGURATION_API.format("Statuses") - - statuses = [] - for data in get_resource(url): - statuses.append(Status.from_json(data)) - - return statuses diff --git a/uw_mazevo/public_event.py b/uw_mazevo/public_event.py deleted file mode 100644 index 5790f33..0000000 --- a/uw_mazevo/public_event.py +++ /dev/null @@ -1,21 +0,0 @@ -from uw_mazevo import post_resource -from uw_mazevo.models import Booking - -PUBLICEVENT_API = "/api/PublicEvent/{}" - - -class PublicEvent(object): - 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 = PUBLICEVENT_API.format("getevents") - body = kwargs - - events = [] - for data in post_resource(url, body): - events.append(Booking.from_json(data)) - return events diff --git a/uw_mazevo/tests/test_public_configuration.py b/uw_mazevo/tests/test_public_configuration.py index 7497c51..4a17985 100644 --- a/uw_mazevo/tests/test_public_configuration.py +++ b/uw_mazevo/tests/test_public_configuration.py @@ -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): diff --git a/uw_mazevo/tests/test_public_event.py b/uw_mazevo/tests/test_public_event.py index b422de6..07c6727 100644 --- a/uw_mazevo/tests/test_public_event.py +++ b/uw_mazevo/tests/test_public_event.py @@ -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):