216 lines
4.5 KiB
Python
216 lines
4.5 KiB
Python
from dataclasses import field
|
|
from marshmallow import Schema, fields, INCLUDE, ValidationError
|
|
from marshmallow_dataclass import dataclass
|
|
from typing import List
|
|
|
|
import json
|
|
import datetime
|
|
|
|
def obj_dict(obj):
|
|
if isinstance(obj, datetime.datetime):
|
|
return obj.isoformat()
|
|
return obj.__dict__
|
|
|
|
@dataclass
|
|
class Berth(Schema):
|
|
id: int
|
|
name: str
|
|
participant_id: int
|
|
lock: bool
|
|
created: datetime
|
|
modified: datetime
|
|
deleted: bool
|
|
|
|
class Error(Schema):
|
|
message = fields.String(required=True,)
|
|
|
|
|
|
class GetVerifyInlineResp(Schema):
|
|
pass
|
|
|
|
@dataclass
|
|
class Notification(Schema):
|
|
|
|
id: int
|
|
times_id: int
|
|
acknowledged: bool
|
|
level: int
|
|
type: int
|
|
message: str
|
|
created: datetime
|
|
modified: datetime
|
|
|
|
@dataclass
|
|
class Participant(Schema):
|
|
id: int
|
|
name: str
|
|
street: str
|
|
postal_code: str
|
|
city: str
|
|
type: int
|
|
flags: int
|
|
created: datetime
|
|
modified: datetime
|
|
deleted: bool
|
|
|
|
class ParticipantList(Participant):
|
|
pass
|
|
|
|
|
|
class ShipcallSchema(Schema):
|
|
def __init__(self):
|
|
super().__init__(unknown=None)
|
|
pass
|
|
|
|
id = fields.Int()
|
|
ship_id = fields.Int()
|
|
type = fields.Int()
|
|
eta = fields.DateTime()
|
|
voyage = fields.Str()
|
|
etd = fields.DateTime()
|
|
arrival_berth_id = fields.Int()
|
|
departure_berth_id = fields.Int()
|
|
tug_required = fields.Bool()
|
|
pilot_required = fields.Bool()
|
|
flags = fields.Int()
|
|
pier_side = fields.Bool()
|
|
bunkering = fields.Bool()
|
|
replenishing_terminal = fields.Bool()
|
|
replenishing_lock = fields.Bool()
|
|
draft = fields.Float()
|
|
tidal_window_from = fields.DateTime()
|
|
tidal_window_to = fields.DateTime()
|
|
rain_sensitive_cargo = fields.Bool()
|
|
recommended_tugs = fields.Int()
|
|
anchored = fields.Bool()
|
|
moored_lock = fields.Bool()
|
|
canceled = fields.Bool()
|
|
participants = fields.List(fields.Int)
|
|
created = fields.DateTime()
|
|
modified = fields.DateTime()
|
|
|
|
@dataclass
|
|
class Shipcall:
|
|
|
|
id: int
|
|
ship_id: int
|
|
type: int
|
|
eta: datetime
|
|
voyage: str
|
|
etd: datetime
|
|
arrival_berth_id: int
|
|
departure_berth_id: int
|
|
tug_required: bool
|
|
pilot_required: bool
|
|
flags: int
|
|
pier_side: bool
|
|
bunkering: bool
|
|
replenishing_terminal: bool
|
|
replenishing_lock: bool
|
|
draft: float
|
|
tidal_window_from: datetime
|
|
tidal_window_to: datetime
|
|
rain_sensitive_cargo: bool
|
|
recommended_tugs: int
|
|
anchored: bool
|
|
moored_lock: bool
|
|
canceled: bool
|
|
created: datetime
|
|
modified: datetime
|
|
participants: List[int] = field(default_factory=list)
|
|
|
|
class ShipcallId(Schema):
|
|
pass
|
|
|
|
# this is the way!
|
|
|
|
class TimesSchema(Schema):
|
|
def __init__(self):
|
|
super().__init__(unknown=None)
|
|
pass
|
|
|
|
id = fields.Int(Required=False)
|
|
eta_berth = fields.DateTime(Required = False)
|
|
eta_berth_fixed = fields.Bool(Required = False)
|
|
etd_berth = fields.DateTime(Required = False)
|
|
etd_berth_fixed = fields.Bool(Required = False)
|
|
lock_time = fields.DateTime(Required = False)
|
|
lock_time_fixed = fields.Bool(Required = False)
|
|
zone_entry = fields.DateTime(Required = False)
|
|
zone_entry_fixed = fields.Bool(Required = False)
|
|
operations_start = fields.DateTime(Required = False)
|
|
operations_end = fields.DateTime(Required = False)
|
|
remarks = fields.String(Required = False)
|
|
participant_id = fields.Int(Required = True)
|
|
shipcall_id = fields.Int(Required = True)
|
|
created = fields.DateTime(Required = False)
|
|
modified = fields.DateTime(Required = False)
|
|
|
|
@dataclass
|
|
class Times:
|
|
|
|
id: int
|
|
eta_berth: datetime
|
|
eta_berth_fixed: bool
|
|
etd_berth: datetime
|
|
etd_berth_fixed: bool
|
|
lock_time: datetime
|
|
lock_time_fixed: bool
|
|
zone_entry: datetime
|
|
zone_entry_fixed: bool
|
|
operations_start: datetime
|
|
operations_end: datetime
|
|
remarks: str
|
|
participant_id: int
|
|
shipcall_id: int
|
|
created: datetime
|
|
modified: datetime
|
|
|
|
@dataclass
|
|
class User:
|
|
|
|
id: int
|
|
participant_id: int
|
|
first_name: str
|
|
last_name: str
|
|
user_name: str
|
|
user_email: str
|
|
user_phone: str
|
|
password_hash: str
|
|
api_key: str
|
|
|
|
@dataclass
|
|
class Ship(Schema):
|
|
id: int
|
|
name: str
|
|
imo: int
|
|
callsign: str
|
|
participant_id: int
|
|
length: float
|
|
width: float
|
|
is_tug: bool
|
|
bollard_pull: int
|
|
eni: str
|
|
created: datetime
|
|
modified: datetime
|
|
deleted: bool
|
|
|
|
class TimesId(Schema):
|
|
pass
|
|
|
|
|
|
class BerthList(Berth):
|
|
pass
|
|
|
|
|
|
class NotificationList(Notification):
|
|
pass
|
|
|
|
|
|
class Shipcalls(Shipcall):
|
|
pass
|
|
|
|
|
|
class TimesList(Times):
|
|
pass
|