import json import logging import pydapper from ..schemas import model from .. import local_db def GetShipcalls(options): """ No parameters, gets all entries """ # TODO: validate token try: commands = pydapper.using(local_db.connection_pool) data = commands.query("SELECT id, ship_id, type, eta, voyage, etd, arrival_berth_id, departure_berth_id, tug_required, pilot_required, " + "flags, pier_side, bunkering, replenishing, draft, tidal_window_from, tidal_window_to, rain_sensitive_cargo, recommended_tugs, " + "created, modified FROM shipcall WHERE eta IS NULL OR eta >= DATE(NOW() - INTERVAL 2 DAY) " + "ORDER BY eta", model=model.Shipcall) except Exception as ex: logging.error(ex) print(ex) return json.dumps("call failed"), 500 return json.dumps(data, default=model.obj_dict), 200 def PostShipcalls(body): """ :param body: The parsed body of the request """ # Implement your business logic here # All the parameters are present in the options argument return 400 def PutShipcalls(body): """ :param body: The parsed body of the request """ # Implement your business logic here # All the parameters are present in the options argument return 400