From 2a0d96018480527f79abe37ef45687a057094bf2 Mon Sep 17 00:00:00 2001 From: miguelpadin Date: Mon, 27 Dec 2021 20:55:13 +0100 Subject: [PATCH] [REF] pms-api-rest: refactor services --- pms_api_rest/controllers/pms_rest.py | 9 +-------- pms_api_rest/services/calendar_service.py | 6 ++++-- pms_api_rest/services/folio_services.py | 2 +- pms_api_rest/services/login_service.py | 3 ++- pms_api_rest/services/partner_services.py | 3 ++- pms_api_rest/services/property_services.py | 8 +++++++- pms_api_rest/services/reservation_services.py | 6 +++++- pms_api_rest/services/room_services.py | 4 +++- pms_api_rest/services/room_type_services.py | 4 +++- 9 files changed, 28 insertions(+), 17 deletions(-) diff --git a/pms_api_rest/controllers/pms_rest.py b/pms_api_rest/controllers/pms_rest.py index d3389b247..3bfda003f 100644 --- a/pms_api_rest/controllers/pms_rest.py +++ b/pms_api_rest/controllers/pms_rest.py @@ -3,13 +3,6 @@ from odoo.addons.base_rest.controllers import main class BaseRestPrivateApiController(main.RestController): _root_path = "/api/" - _collection_name = "pms.private.services" - _default_auth = "jwt_api_pms" - _default_cors = "*" - - -class BaseRestPublicApiController(main.RestController): - _root_path = "/auth/" - _collection_name = "pms.public.services" + _collection_name = "pms.services" _default_auth = "public" _default_cors = "*" diff --git a/pms_api_rest/services/calendar_service.py b/pms_api_rest/services/calendar_service.py index a420d767c..ce0c02cf3 100644 --- a/pms_api_rest/services/calendar_service.py +++ b/pms_api_rest/services/calendar_service.py @@ -9,7 +9,7 @@ class PmsCalendarService(Component): _inherit = "base.rest.service" _name = "pms.private.services" _usage = "calendar" - _collection = "pms.private.services" + _collection = "pms.services" @restapi.method( [ @@ -22,7 +22,8 @@ class PmsCalendarService(Component): ], input_param=Datamodel("pms.calendar.search.param"), output_param=Datamodel("pms.calendar.info", is_list=True), - auth="public", + auth="jwt_api_pms", + ) def get_calendar(self, calendar_search_param): domain = list() @@ -62,6 +63,7 @@ class PmsCalendarService(Component): ) ], input_param=Datamodel("pms.calendar.swap.info", is_list=False), + auth="jwt_api_pms", ) def swap_reservation_slices(self, swap_info): room_id_a = swap_info.roomIdA diff --git a/pms_api_rest/services/folio_services.py b/pms_api_rest/services/folio_services.py index a985335cf..22d360edd 100644 --- a/pms_api_rest/services/folio_services.py +++ b/pms_api_rest/services/folio_services.py @@ -9,7 +9,7 @@ class PmsFolioService(Component): _inherit = "base.rest.service" _name = "pms.folio.service" _usage = "folios" - _collection = "pms.private.services" + _collection = "pms.services" @restapi.method( [ diff --git a/pms_api_rest/services/login_service.py b/pms_api_rest/services/login_service.py index 67fad6570..bc1a98d0f 100644 --- a/pms_api_rest/services/login_service.py +++ b/pms_api_rest/services/login_service.py @@ -14,7 +14,7 @@ class PmsPartnerService(Component): _inherit = "base.rest.service" _name = "pms.auth.service" _usage = "login" - _collection = "pms.public.services" + _collection = "pms.services" @restapi.method( [ @@ -27,6 +27,7 @@ class PmsPartnerService(Component): ], input_param=Datamodel("pms.api.rest.user.input", is_list=False), output_param=Datamodel("pms.api.rest.user.output", is_list=False), + auth="public", ) def login(self, user): diff --git a/pms_api_rest/services/partner_services.py b/pms_api_rest/services/partner_services.py index 1940da10b..ec48cd19e 100644 --- a/pms_api_rest/services/partner_services.py +++ b/pms_api_rest/services/partner_services.py @@ -7,7 +7,7 @@ class PmsPartnerService(Component): _inherit = "base.rest.service" _name = "pms.partner.service" _usage = "partners" - _collection = "pms.private.services" + _collection = "pms.services" @restapi.method( [ @@ -19,6 +19,7 @@ class PmsPartnerService(Component): ) ], output_param=Datamodel("pms.partner.info", is_list=True), + auth="jwt_api_pms", ) def get_partners(self): domain = [] diff --git a/pms_api_rest/services/property_services.py b/pms_api_rest/services/property_services.py index 3ad41d29f..60b270940 100644 --- a/pms_api_rest/services/property_services.py +++ b/pms_api_rest/services/property_services.py @@ -7,7 +7,7 @@ class PmsPropertyComponent(Component): _inherit = "base.rest.service" _name = "pms.property.service" _usage = "properties" - _collection = "pms.private.services" + _collection = "pms.services" @restapi.method( [ @@ -20,6 +20,8 @@ class PmsPropertyComponent(Component): ], input_param=Datamodel("pms.property.search.param"), output_param=Datamodel("pms.property.info", is_list=True), + auth="jwt_api_pms", + ) def get_properties(self, property_search_param): domain = [] @@ -55,6 +57,8 @@ class PmsPropertyComponent(Component): ) ], output_param=Datamodel("pms.property.info"), + auth="jwt_api_pms", + ) def get_property(self, property_id): pms_property = ( @@ -83,6 +87,8 @@ class PmsPropertyComponent(Component): ) ], output_param=Datamodel("pms.account.journal.info", is_list=True), + auth="jwt_api_pms", + ) def get_method_payments_property(self, property_id): diff --git a/pms_api_rest/services/reservation_services.py b/pms_api_rest/services/reservation_services.py index db1b3c112..c97821c22 100644 --- a/pms_api_rest/services/reservation_services.py +++ b/pms_api_rest/services/reservation_services.py @@ -9,7 +9,7 @@ class PmsRoomService(Component): _inherit = "base.rest.service" _name = "pms.reservation.service" _usage = "reservations" - _collection = "pms.private.services" + _collection = "pms.services" @restapi.method( [ @@ -21,6 +21,8 @@ class PmsRoomService(Component): ) ], output_param=Datamodel("pms.reservation.info", is_list=True), + auth="jwt_api_pms", + ) def get_reservations(self): domain = [] @@ -54,6 +56,8 @@ class PmsRoomService(Component): ) ], input_param=Datamodel("pms.calendar.changes", is_list=False), + auth="jwt_api_pms", + ) def move_reservation_line(self, reservation_id, reservation_lines_changes): diff --git a/pms_api_rest/services/room_services.py b/pms_api_rest/services/room_services.py index ca981708e..62ca6fd4b 100644 --- a/pms_api_rest/services/room_services.py +++ b/pms_api_rest/services/room_services.py @@ -7,7 +7,7 @@ class PmsRoomService(Component): _inherit = "base.rest.service" _name = "pms.room.service" _usage = "rooms" - _collection = "pms.private.services" + _collection = "pms.services" @restapi.method( [ @@ -20,6 +20,8 @@ class PmsRoomService(Component): ], input_param=Datamodel("pms.room.search.param"), output_param=Datamodel("pms.room.info", is_list=True), + auth="jwt_api_pms", + ) def get_rooms(self, room_search_param): domain = [] diff --git a/pms_api_rest/services/room_type_services.py b/pms_api_rest/services/room_type_services.py index e6ef7dc23..668250440 100644 --- a/pms_api_rest/services/room_type_services.py +++ b/pms_api_rest/services/room_type_services.py @@ -7,7 +7,7 @@ class PmsRoomTypeService(Component): _inherit = "base.rest.service" _name = "pms.room.type.service" _usage = "room-types" - _collection = "pms.private.services" + _collection = "pms.services" @restapi.method( [ @@ -20,6 +20,8 @@ class PmsRoomTypeService(Component): ], input_param=Datamodel("pms.room.search.param"), output_param=Datamodel("pms.room.info", is_list=True), + auth="jwt_api_pms", + ) def get_room_types(self, room_type_search_param): domain = []