From 44f5d07ed7397c2441fdba6c02285643e19dffd8 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Thu, 5 Dec 2024 17:25:01 +0100 Subject: [PATCH] Adjusted yaml spec and fixed user interface for storing notification flags --- misc/BreCalApi.cs | 571 +++++++++++++++++++++-------- misc/BreCalApi.yaml | 25 +- src/server/BreCal/impl/login.py | 6 +- src/server/BreCal/impl/user.py | 2 +- src/server/BreCal/schemas/model.py | 31 +- 5 files changed, 454 insertions(+), 181 deletions(-) diff --git a/misc/BreCalApi.cs b/misc/BreCalApi.cs index ecefbc4..65bd1f9 100644 --- a/misc/BreCalApi.cs +++ b/misc/BreCalApi.cs @@ -1,8 +1,8 @@ //---------------------- // -// Generated REST API Client Code Generator v1.11.0.0 on 15.09.2024 15:38:00 -// Using the tool OpenAPI Generator v7.8.0 +// Generated REST API Client Code Generator v1.16.0.0 on 05.12.2024 17:03:25 +// Using the tool OpenAPI Generator v7.9.0 // //---------------------- @@ -1586,10 +1586,10 @@ namespace BreCalClient.misc.Api /// List of notifications (tbd) /// /// Thrown when fails to make API call - /// **Id of ship call**. *Example: 52*. Id given in ship call list + /// **Id of ship call**. *Example: 52*. Id given in ship call list (optional) /// Index associated with the operation. /// List<Notification> - List NotificationsGet(int shipcallId, int operationIndex = 0); + List NotificationsGet(int? shipcallId = default(int?), int operationIndex = 0); /// /// Gets a list of notifications pursuant to a specified participant and ship call /// @@ -1597,10 +1597,10 @@ namespace BreCalClient.misc.Api /// List of notifications (tbd) /// /// Thrown when fails to make API call - /// **Id of ship call**. *Example: 52*. Id given in ship call list + /// **Id of ship call**. *Example: 52*. Id given in ship call list (optional) /// Index associated with the operation. /// ApiResponse of List<Notification> - ApiResponse> NotificationsGetWithHttpInfo(int shipcallId, int operationIndex = 0); + ApiResponse> NotificationsGetWithHttpInfo(int? shipcallId = default(int?), int operationIndex = 0); /// /// gets one or all participants /// @@ -1706,11 +1706,11 @@ namespace BreCalClient.misc.Api /// List of notifications (tbd) /// /// Thrown when fails to make API call - /// **Id of ship call**. *Example: 52*. Id given in ship call list + /// **Id of ship call**. *Example: 52*. Id given in ship call list (optional) /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of List<Notification> - System.Threading.Tasks.Task> NotificationsGetAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task> NotificationsGetAsync(int? shipcallId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// Gets a list of notifications pursuant to a specified participant and ship call /// @@ -1718,11 +1718,11 @@ namespace BreCalClient.misc.Api /// List of notifications (tbd) /// /// Thrown when fails to make API call - /// **Id of ship call**. *Example: 52*. Id given in ship call list + /// **Id of ship call**. *Example: 52*. Id given in ship call list (optional) /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (List<Notification>) - System.Threading.Tasks.Task>> NotificationsGetWithHttpInfoAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); + System.Threading.Tasks.Task>> NotificationsGetWithHttpInfoAsync(int? shipcallId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)); /// /// gets one or all participants /// @@ -2198,10 +2198,10 @@ namespace BreCalClient.misc.Api /// Gets a list of notifications pursuant to a specified participant and ship call List of notifications (tbd) /// /// Thrown when fails to make API call - /// **Id of ship call**. *Example: 52*. Id given in ship call list + /// **Id of ship call**. *Example: 52*. Id given in ship call list (optional) /// Index associated with the operation. /// List<Notification> - public List NotificationsGet(int shipcallId, int operationIndex = 0) + public List NotificationsGet(int? shipcallId = default(int?), int operationIndex = 0) { BreCalClient.misc.Client.ApiResponse> localVarResponse = NotificationsGetWithHttpInfo(shipcallId); return localVarResponse.Data; @@ -2210,10 +2210,10 @@ namespace BreCalClient.misc.Api /// Gets a list of notifications pursuant to a specified participant and ship call List of notifications (tbd) /// /// Thrown when fails to make API call - /// **Id of ship call**. *Example: 52*. Id given in ship call list + /// **Id of ship call**. *Example: 52*. Id given in ship call list (optional) /// Index associated with the operation. /// ApiResponse of List<Notification> - public BreCalClient.misc.Client.ApiResponse> NotificationsGetWithHttpInfo(int shipcallId, int operationIndex = 0) + public BreCalClient.misc.Client.ApiResponse> NotificationsGetWithHttpInfo(int? shipcallId = default(int?), int operationIndex = 0) { BreCalClient.misc.Client.RequestOptions localVarRequestOptions = new BreCalClient.misc.Client.RequestOptions(); string[] _contentTypes = new string[] { @@ -2232,7 +2232,10 @@ namespace BreCalClient.misc.Api { localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); } - localVarRequestOptions.QueryParameters.Add(BreCalClient.misc.Client.ClientUtils.ParameterToMultiMap("", "shipcall_id", shipcallId)); + if (shipcallId != null) + { + localVarRequestOptions.QueryParameters.Add(BreCalClient.misc.Client.ClientUtils.ParameterToMultiMap("", "shipcall_id", shipcallId)); + } localVarRequestOptions.Operation = "StaticApi.NotificationsGet"; localVarRequestOptions.OperationIndex = operationIndex; // authentication (ApiKey) required @@ -2256,11 +2259,11 @@ namespace BreCalClient.misc.Api /// Gets a list of notifications pursuant to a specified participant and ship call List of notifications (tbd) /// /// Thrown when fails to make API call - /// **Id of ship call**. *Example: 52*. Id given in ship call list + /// **Id of ship call**. *Example: 52*. Id given in ship call list (optional) /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of List<Notification> - public async System.Threading.Tasks.Task> NotificationsGetAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> NotificationsGetAsync(int? shipcallId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { BreCalClient.misc.Client.ApiResponse> localVarResponse = await NotificationsGetWithHttpInfoAsync(shipcallId, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; @@ -2269,11 +2272,11 @@ namespace BreCalClient.misc.Api /// Gets a list of notifications pursuant to a specified participant and ship call List of notifications (tbd) /// /// Thrown when fails to make API call - /// **Id of ship call**. *Example: 52*. Id given in ship call list + /// **Id of ship call**. *Example: 52*. Id given in ship call list (optional) /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (List<Notification>) - public async System.Threading.Tasks.Task>> NotificationsGetWithHttpInfoAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task>> NotificationsGetWithHttpInfoAsync(int? shipcallId = default(int?), int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(global::System.Threading.CancellationToken)) { BreCalClient.misc.Client.RequestOptions localVarRequestOptions = new BreCalClient.misc.Client.RequestOptions(); string[] _contentTypes = new string[] { @@ -2292,7 +2295,10 @@ namespace BreCalClient.misc.Api { localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); } - localVarRequestOptions.QueryParameters.Add(BreCalClient.misc.Client.ClientUtils.ParameterToMultiMap("", "shipcall_id", shipcallId)); + if (shipcallId != null) + { + localVarRequestOptions.QueryParameters.Add(BreCalClient.misc.Client.ClientUtils.ParameterToMultiMap("", "shipcall_id", shipcallId)); + } localVarRequestOptions.Operation = "StaticApi.NotificationsGet"; localVarRequestOptions.OperationIndex = operationIndex; // authentication (ApiKey) required @@ -4750,6 +4756,12 @@ namespace BreCalClient.misc.Client // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 // For example: 2009-06-15T13:45:30.0000000 return dateTimeOffset.ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat); + if (obj is DateOnly dateOnly) + // Return a formatted date string - Can be customized with Configuration.DateTimeFormat + // Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o") + // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 + // For example: 2009-06-15 + return dateOnly.ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat); if (obj is bool boolean) return boolean ? "true" : "false"; if (obj is ICollection collection) { @@ -6339,62 +6351,80 @@ namespace BreCalClient.misc.Model /// /// Gets or Sets Id /// - /// 3 + /* + 3 + */ [DataMember(Name = "id", EmitDefaultValue = true)] public int Id { get; set; } /// /// Gets or Sets Name /// - /// Pier 1 + /* + Pier 1 + */ [DataMember(Name = "name", EmitDefaultValue = true)] public string Name { get; set; } /// /// Optional reference to a participant (terminal) /// /// Optional reference to a participant (terminal) - /// 5 + /* + 5 + */ [DataMember(Name = "owner_id", EmitDefaultValue = true)] public int? OwnerId { get; set; } /// /// Optional reference to a participant (port authority) /// /// Optional reference to a participant (port authority) - /// 6 + /* + 6 + */ [DataMember(Name = "authority_id", EmitDefaultValue = true)] public int? AuthorityId { get; set; } /// /// If true lock must be passed /// /// If true lock must be passed - /// true + /* + true + */ [DataMember(Name = "lock", EmitDefaultValue = true)] public bool? Lock { get; set; } /// /// Required reference to a port /// /// Required reference to a port - /// 1 + /* + 1 + */ [DataMember(Name = "port_id", EmitDefaultValue = true)] public int PortId { get; set; } /// /// Readonly field set by the database when berth was created /// /// Readonly field set by the database when berth was created - /// 2023-08-21T08:23:35Z + /* + 2023-08-21T08:23:35Z + */ [DataMember(Name = "created", EmitDefaultValue = true)] public DateTime Created { get; set; } /// /// Readonly field set by the database when berth was last modified /// /// Readonly field set by the database when berth was last modified - /// 2023-08-21T08:23:35Z + /* + 2023-08-21T08:23:35Z + */ [DataMember(Name = "modified", EmitDefaultValue = true)] public DateTime? Modified { get; set; } /// /// marks the berth as logically deleted /// /// marks the berth as logically deleted - /// false + /* + false + */ [DataMember(Name = "deleted", EmitDefaultValue = true)] public bool Deleted { get; set; } /// @@ -6487,13 +6517,17 @@ namespace BreCalClient.misc.Model /// /// Gets or Sets Username /// - /// alfred + /* + alfred + */ [DataMember(Name = "username", IsRequired = true, EmitDefaultValue = true)] public string Username { get; set; } /// /// Gets or Sets Password /// - /// 123456 + /* + 123456 + */ [DataMember(Name = "password", IsRequired = true, EmitDefaultValue = true)] public string Password { get; set; } /// @@ -6570,14 +6604,18 @@ namespace BreCalClient.misc.Model /// Input field that caused the error or general error message /// /// Input field that caused the error or general error message - /// eta + /* + eta + */ [DataMember(Name = "error_field", IsRequired = true, EmitDefaultValue = true)] public string ErrorField { get; set; } /// /// Detailed description if error_field was an input field /// /// Detailed description if error_field was an input field - /// eta must be in the future + /* + eta must be in the future + */ [DataMember(Name = "error_description", EmitDefaultValue = true)] public string ErrorDescription { get; set; } /// @@ -6704,31 +6742,41 @@ namespace BreCalClient.misc.Model /// /// Gets or Sets Id /// - /// 3 + /* + 3 + */ [DataMember(Name = "id", EmitDefaultValue = true)] public int Id { get; set; } /// /// Gets or Sets ParticipantId /// - /// 5 + /* + 5 + */ [DataMember(Name = "participant_id", EmitDefaultValue = true)] public int ParticipantId { get; set; } /// /// Gets or Sets ShipcallId /// - /// 42 + /* + 42 + */ [DataMember(Name = "shipcall_id", EmitDefaultValue = true)] public int ShipcallId { get; set; } /// /// Gets or Sets Timestamp /// - /// 2023-08-21T08:23:35Z + /* + 2023-08-21T08:23:35Z + */ [DataMember(Name = "timestamp", EmitDefaultValue = true)] public DateTime Timestamp { get; set; } /// /// Gets or Sets Eta /// - /// 2023-08-21T08:23:35Z + /* + 2023-08-21T08:23:35Z + */ [DataMember(Name = "eta", EmitDefaultValue = true)] public DateTime Eta { get; set; } /// @@ -6797,7 +6845,9 @@ namespace BreCalClient.misc.Model /// /// Gets or Sets VarId /// - /// 42 + /* + 42 + */ [DataMember(Name = "id", EmitDefaultValue = true)] public int VarId { get; set; } /// @@ -6876,55 +6926,73 @@ namespace BreCalClient.misc.Model /// /// Gets or Sets Id /// - /// 42 + /* + 42 + */ [DataMember(Name = "id", EmitDefaultValue = true)] public int Id { get; set; } /// /// Gets or Sets ParticipantId /// - /// 5 + /* + 5 + */ [DataMember(Name = "participant_id", EmitDefaultValue = true)] public int ParticipantId { get; set; } /// /// Gets or Sets FirstName /// - /// John + /* + John + */ [DataMember(Name = "first_name", EmitDefaultValue = true)] public string FirstName { get; set; } /// /// Gets or Sets LastName /// - /// Doe + /* + Doe + */ [DataMember(Name = "last_name", EmitDefaultValue = true)] public string LastName { get; set; } /// /// Gets or Sets UserName /// - /// johndoe + /* + johndoe + */ [DataMember(Name = "user_name", EmitDefaultValue = true)] public string UserName { get; set; } /// /// Gets or Sets UserPhone /// - /// 1234567890 + /* + 1234567890 + */ [DataMember(Name = "user_phone", EmitDefaultValue = true)] public string UserPhone { get; set; } /// /// Gets or Sets UserEmail /// - /// no@where.com + /* + no@where.com + */ [DataMember(Name = "user_email", EmitDefaultValue = true)] public string UserEmail { get; set; } /// /// Gets or Sets Exp /// - /// 1630000000 + /* + 1630000000 + */ [DataMember(Name = "exp", EmitDefaultValue = true)] public float Exp { get; set; } /// /// Gets or Sets Token /// - /// eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c + /* + eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c + */ [DataMember(Name = "token", EmitDefaultValue = true)] public string Token { get; set; } /// @@ -7010,33 +7078,43 @@ namespace BreCalClient.misc.Model /// /// Gets or Sets Id /// - /// 42 + /* + 42 + */ [DataMember(Name = "id", EmitDefaultValue = true)] public int Id { get; set; } /// /// Gets or Sets ShipcallId /// - /// 5 + /* + 5 + */ [DataMember(Name = "shipcall_id", EmitDefaultValue = true)] public int ShipcallId { get; set; } /// /// Gets or Sets Message /// - /// Entry XY violates rule Z + /* + Entry XY violates rule Z + */ [DataMember(Name = "message", EmitDefaultValue = true)] public string Message { get; set; } /// /// Readonly field set by the database when notification was created /// /// Readonly field set by the database when notification was created - /// 2023-08-21T08:23:35Z + /* + 2023-08-21T08:23:35Z + */ [DataMember(Name = "created", EmitDefaultValue = true)] public DateTime Created { get; set; } /// /// Readonly field set by the database when notification was last modified /// /// Readonly field set by the database when notification was last modified - /// 2023-08-21T08:23:35Z + /* + 2023-08-21T08:23:35Z + */ [DataMember(Name = "modified", EmitDefaultValue = true)] public DateTime? Modified { get; set; } /// @@ -7095,20 +7173,25 @@ namespace BreCalClient.misc.Model public enum NotificationType { /// - /// Enum Undefined for value: undefined + /// Enum Assignment for value: assignment /// - [EnumMember(Value = "undefined")] - Undefined = 1, + [EnumMember(Value = "assignment")] + Assignment = 1, /// - /// Enum Email for value: email + /// Enum Next24h for value: next24h /// - [EnumMember(Value = "email")] - Email = 2, + [EnumMember(Value = "next24h")] + Next24h = 2, /// - /// Enum Push for value: push + /// Enum TimeConflict for value: time_conflict /// - [EnumMember(Value = "push")] - Push = 3 + [EnumMember(Value = "time_conflict")] + TimeConflict = 3, + /// + /// Enum TimeConflictResolved for value: time_conflict_resolved + /// + [EnumMember(Value = "time_conflict_resolved")] + TimeConflictResolved = 4 } } @@ -7232,72 +7315,94 @@ namespace BreCalClient.misc.Model /// /// Gets or Sets Id /// - /// 42 + /* + 42 + */ [DataMember(Name = "id", EmitDefaultValue = true)] public int Id { get; set; } /// /// Gets or Sets Name /// - /// BSMD + /* + BSMD + */ [DataMember(Name = "name", EmitDefaultValue = true)] public string Name { get; set; } /// /// Gets or Sets Street /// - /// Hermann-Hollerith-Str. 7 + /* + Hermann-Hollerith-Str. 7 + */ [DataMember(Name = "street", EmitDefaultValue = true)] public string Street { get; set; } /// /// Gets or Sets PostalCode /// - /// 28359 + /* + 28359 + */ [DataMember(Name = "postal code", EmitDefaultValue = true)] public string PostalCode { get; set; } /// /// Gets or Sets City /// - /// Bremen + /* + Bremen + */ [DataMember(Name = "city", EmitDefaultValue = true)] public string City { get; set; } /// /// a logical combination (bitflag) of possible values. This cannot be encoded in a Enumeration type with discrete values in OpenAPI version < 3.1. /// /// a logical combination (bitflag) of possible values. This cannot be encoded in a Enumeration type with discrete values in OpenAPI version < 3.1. - /// 10 + /* + 10 + */ [DataMember(Name = "type", EmitDefaultValue = true)] public int Type { get; set; } /// /// Bit-encoded flag array for internal use /// /// Bit-encoded flag array for internal use - /// 0 + /* + 0 + */ [DataMember(Name = "flags", EmitDefaultValue = true)] public int? Flags { get; set; } /// /// Gets or Sets Ports /// - /// [1,2] + /* + [1,2] + */ [DataMember(Name = "ports", EmitDefaultValue = true)] public List Ports { get; set; } /// /// Readonly field set by the database when participant was created /// /// Readonly field set by the database when participant was created - /// 2023-08-21T08:23:35Z + /* + 2023-08-21T08:23:35Z + */ [DataMember(Name = "created", EmitDefaultValue = true)] public DateTime Created { get; set; } /// /// Readonly field set by the database when participant was last modified /// /// Readonly field set by the database when participant was last modified - /// 2023-08-21T08:23:35Z + /* + 2023-08-21T08:23:35Z + */ [DataMember(Name = "modified", EmitDefaultValue = true)] public DateTime? Modified { get; set; } /// /// marks the participant as logically deleted /// /// marks the participant as logically deleted - /// false + /* + false + */ [DataMember(Name = "deleted", EmitDefaultValue = true)] public bool Deleted { get; set; } /// @@ -7397,14 +7502,18 @@ namespace BreCalClient.misc.Model /// /// Gets or Sets ParticipantId /// - /// 5 + /* + 5 + */ [DataMember(Name = "participant_id", IsRequired = true, EmitDefaultValue = true)] public int ParticipantId { get; set; } /// /// Possible role values: 1: BSMD 2: TERMINAL, 4: PILOT, 8: AGENCY, 16: MOORING, 32: PORT_ADMINISTRATION, 64: TUG. A participant may appear multiple times with different roles. /// /// Possible role values: 1: BSMD 2: TERMINAL, 4: PILOT, 8: AGENCY, 16: MOORING, 32: PORT_ADMINISTRATION, 64: TUG. A participant may appear multiple times with different roles. - /// 4 + /* + 4 + */ [DataMember(Name = "type", IsRequired = true, EmitDefaultValue = true)] public int Type { get; set; } /// @@ -7478,40 +7587,52 @@ namespace BreCalClient.misc.Model /// /// Gets or Sets Id /// - /// 2 + /* + 2 + */ [DataMember(Name = "id", EmitDefaultValue = true)] public int Id { get; set; } /// /// Gets or Sets Name /// - /// Hamburg + /* + Hamburg + */ [DataMember(Name = "name", EmitDefaultValue = true)] public string Name { get; set; } /// /// Gets or Sets Locode /// - /// DEHAM + /* + DEHAM + */ [DataMember(Name = "locode", EmitDefaultValue = true)] public string Locode { get; set; } /// /// Readonly field set by the database when port was created /// /// Readonly field set by the database when port was created - /// 2023-08-21T08:23:35Z + /* + 2023-08-21T08:23:35Z + */ [DataMember(Name = "created", EmitDefaultValue = true)] public DateTime Created { get; set; } /// /// Readonly field set by the database when port was last modified /// /// Readonly field set by the database when port was last modified - /// 2023-08-21T08:23:35Z + /* + 2023-08-21T08:23:35Z + */ [DataMember(Name = "modified", EmitDefaultValue = true)] public DateTime? Modified { get; set; } /// /// marks the port as logically deleted /// /// marks the port as logically deleted - /// false + /* + false + */ [DataMember(Name = "deleted", EmitDefaultValue = true)] public bool Deleted { get; set; } /// @@ -7618,84 +7739,110 @@ namespace BreCalClient.misc.Model /// /// Gets or Sets Id /// - /// 8 + /* + 8 + */ [DataMember(Name = "id", EmitDefaultValue = true)] public int Id { get; set; } /// /// Gets or Sets Name /// - /// MS Bremen + /* + MS Bremen + */ [DataMember(Name = "name", EmitDefaultValue = true)] public string Name { get; set; } /// /// Gets or Sets Imo /// - /// 1234567 + /* + 1234567 + */ [DataMember(Name = "imo", EmitDefaultValue = true)] public int? Imo { get; set; } /// /// Gets or Sets Callsign /// - /// DBRE + /* + DBRE + */ [DataMember(Name = "callsign", EmitDefaultValue = true)] public string Callsign { get; set; } /// /// Optional reference to participant (tug role) /// /// Optional reference to participant (tug role) - /// 9 + /* + 9 + */ [DataMember(Name = "participant_id", EmitDefaultValue = true)] public int? ParticipantId { get; set; } /// /// Gets or Sets Length /// - /// 200 + /* + 200 + */ [DataMember(Name = "length", EmitDefaultValue = true)] public double? Length { get; set; } /// /// Gets or Sets Width /// - /// 30 + /* + 30 + */ [DataMember(Name = "width", EmitDefaultValue = true)] public double? Width { get; set; } /// /// Gets or Sets IsTug /// - /// false + /* + false + */ [DataMember(Name = "is_tug", EmitDefaultValue = true)] public bool IsTug { get; set; } /// /// Gets or Sets BollardPull /// - /// 100 + /* + 100 + */ [DataMember(Name = "bollard_pull", EmitDefaultValue = true)] public int? BollardPull { get; set; } /// /// BSMD internal use /// /// BSMD internal use - /// 1234567 + /* + 1234567 + */ [DataMember(Name = "eni", EmitDefaultValue = true)] public int? Eni { get; set; } /// /// Readonly field set by the database when ship was created /// /// Readonly field set by the database when ship was created - /// 2023-08-21T08:23:35Z + /* + 2023-08-21T08:23:35Z + */ [DataMember(Name = "created", EmitDefaultValue = true)] public DateTime Created { get; set; } /// /// Readonly field set by the database when ship was last modified /// /// Readonly field set by the database when ship was last modified - /// 2023-08-21T08:23:35Z + /* + 2023-08-21T08:23:35Z + */ [DataMember(Name = "modified", EmitDefaultValue = true)] public DateTime? Modified { get; set; } /// /// marks the ship as logically deleted /// /// marks the ship as logically deleted - /// false + /* + false + */ [DataMember(Name = "deleted", EmitDefaultValue = true)] public bool Deleted { get; set; } /// @@ -7851,145 +7998,193 @@ namespace BreCalClient.misc.Model /// /// Gets or Sets Id /// - /// 6 + /* + 6 + */ [DataMember(Name = "id", EmitDefaultValue = true)] public int Id { get; set; } /// /// Gets or Sets ShipId /// - /// 8 + /* + 8 + */ [DataMember(Name = "ship_id", IsRequired = true, EmitDefaultValue = true)] public int ShipId { get; set; } /// /// Gets or Sets PortId /// - /// 3 + /* + 3 + */ [DataMember(Name = "port_id", EmitDefaultValue = true)] public int PortId { get; set; } /// /// Gets or Sets Eta /// - /// 2023-08-21T08:23:35Z + /* + 2023-08-21T08:23:35Z + */ [DataMember(Name = "eta", EmitDefaultValue = true)] public DateTime? Eta { get; set; } /// /// Gets or Sets Voyage /// - /// Voyage 123 + /* + Voyage 123 + */ [DataMember(Name = "voyage", EmitDefaultValue = true)] public string Voyage { get; set; } /// /// Gets or Sets Etd /// - /// 2023-08-21T08:23:35Z + /* + 2023-08-21T08:23:35Z + */ [DataMember(Name = "etd", EmitDefaultValue = true)] public DateTime? Etd { get; set; } /// /// Gets or Sets ArrivalBerthId /// - /// 3 + /* + 3 + */ [DataMember(Name = "arrival_berth_id", EmitDefaultValue = true)] public int? ArrivalBerthId { get; set; } /// /// Gets or Sets DepartureBerthId /// - /// 4 + /* + 4 + */ [DataMember(Name = "departure_berth_id", EmitDefaultValue = true)] public int? DepartureBerthId { get; set; } /// /// Gets or Sets TugRequired /// - /// true + /* + true + */ [DataMember(Name = "tug_required", EmitDefaultValue = true)] public bool? TugRequired { get; set; } /// /// Gets or Sets PilotRequired /// - /// true + /* + true + */ [DataMember(Name = "pilot_required", EmitDefaultValue = true)] public bool? PilotRequired { get; set; } /// /// Gets or Sets Flags /// - /// 1 + /* + 1 + */ [DataMember(Name = "flags", EmitDefaultValue = true)] public int? Flags { get; set; } /// /// Gets or Sets PierSide /// - /// false + /* + false + */ [DataMember(Name = "pier_side", EmitDefaultValue = true)] public bool? PierSide { get; set; } /// /// Gets or Sets Bunkering /// - /// false + /* + false + */ [DataMember(Name = "bunkering", EmitDefaultValue = true)] public bool? Bunkering { get; set; } /// /// Gets or Sets ReplenishingTerminal /// - /// false + /* + false + */ [DataMember(Name = "replenishing_terminal", EmitDefaultValue = true)] public bool? ReplenishingTerminal { get; set; } /// /// Gets or Sets ReplenishingLock /// - /// false + /* + false + */ [DataMember(Name = "replenishing_lock", EmitDefaultValue = true)] public bool? ReplenishingLock { get; set; } /// /// Gets or Sets Draft /// - /// 10.5 + /* + 10.5 + */ [DataMember(Name = "draft", EmitDefaultValue = true)] public double? Draft { get; set; } /// /// Gets or Sets TidalWindowFrom /// - /// 2023-08-21T08:23:35Z + /* + 2023-08-21T08:23:35Z + */ [DataMember(Name = "tidal_window_from", EmitDefaultValue = true)] public DateTime? TidalWindowFrom { get; set; } /// /// Gets or Sets TidalWindowTo /// - /// 2023-08-21T08:23:35Z + /* + 2023-08-21T08:23:35Z + */ [DataMember(Name = "tidal_window_to", EmitDefaultValue = true)] public DateTime? TidalWindowTo { get; set; } /// /// Gets or Sets RainSensitiveCargo /// - /// false + /* + false + */ [DataMember(Name = "rain_sensitive_cargo", EmitDefaultValue = true)] public bool? RainSensitiveCargo { get; set; } /// /// Gets or Sets RecommendedTugs /// - /// 2 + /* + 2 + */ [DataMember(Name = "recommended_tugs", EmitDefaultValue = true)] public int? RecommendedTugs { get; set; } /// /// Gets or Sets Anchored /// - /// false + /* + false + */ [DataMember(Name = "anchored", EmitDefaultValue = true)] public bool? Anchored { get; set; } /// /// Gets or Sets MooredLock /// - /// false + /* + false + */ [DataMember(Name = "moored_lock", EmitDefaultValue = true)] public bool? MooredLock { get; set; } /// /// Gets or Sets Canceled /// - /// false + /* + false + */ [DataMember(Name = "canceled", EmitDefaultValue = true)] public bool? Canceled { get; set; } /// /// Gets or Sets EvaluationMessage /// - /// Time window too short + /* + Time window too short + */ [DataMember(Name = "evaluation_message", EmitDefaultValue = true)] public string EvaluationMessage { get; private set; } /// @@ -8008,27 +8203,35 @@ namespace BreCalClient.misc.Model /// Physical reference point for all times given in shipcall and depending times entries /// /// Physical reference point for all times given in shipcall and depending times entries - /// 1 + /* + 1 + */ [DataMember(Name = "time_ref_point", EmitDefaultValue = true)] public int? TimeRefPoint { get; set; } /// /// Gets or Sets Participants /// - /// [{"participant_id":5,"type":4},{"participant_id":6,"type":8}] + /* + [{"participant_id":5,"type":4},{"participant_id":6,"type":8}] + */ [DataMember(Name = "participants", EmitDefaultValue = true)] public List Participants { get; set; } /// /// Readonly field set by the database when shipcall was created /// /// Readonly field set by the database when shipcall was created - /// 2023-08-21T08:23:35Z + /* + 2023-08-21T08:23:35Z + */ [DataMember(Name = "created", EmitDefaultValue = true)] public DateTime Created { get; set; } /// /// Readonly field set by the database when shipcall was last modified /// /// Readonly field set by the database when shipcall was last modified - /// 2023-08-21T08:23:35Z + /* + 2023-08-21T08:23:35Z + */ [DataMember(Name = "modified", EmitDefaultValue = true)] public DateTime? Modified { get; set; } /// @@ -8222,167 +8425,215 @@ namespace BreCalClient.misc.Model /// /// Gets or Sets Id /// - /// 2 + /* + 2 + */ [DataMember(Name = "id", EmitDefaultValue = true)] public int Id { get; set; } /// /// Arrival time at berth /// /// Arrival time at berth - /// 2023-08-21T08:23:35Z + /* + 2023-08-21T08:23:35Z + */ [DataMember(Name = "eta_berth", EmitDefaultValue = true)] public DateTime? EtaBerth { get; set; } /// /// If true, the eta is fixed and cannot be changed /// /// If true, the eta is fixed and cannot be changed - /// true + /* + true + */ [DataMember(Name = "eta_berth_fixed", EmitDefaultValue = true)] public bool? EtaBerthFixed { get; set; } /// /// departure time from berth /// /// departure time from berth - /// 2023-08-21T08:23:35Z + /* + 2023-08-21T08:23:35Z + */ [DataMember(Name = "etd_berth", EmitDefaultValue = true)] public DateTime? EtdBerth { get; set; } /// /// If true, the etd is fixed and cannot be changed /// /// If true, the etd is fixed and cannot be changed - /// true + /* + true + */ [DataMember(Name = "etd_berth_fixed", EmitDefaultValue = true)] public bool? EtdBerthFixed { get; set; } /// /// arrival time at lock /// /// arrival time at lock - /// 2023-08-21T08:23:35Z + /* + 2023-08-21T08:23:35Z + */ [DataMember(Name = "lock_time", EmitDefaultValue = true)] public DateTime? LockTime { get; set; } /// /// If true, the lock time is fixed and cannot be changed /// /// If true, the lock time is fixed and cannot be changed - /// true + /* + true + */ [DataMember(Name = "lock_time_fixed", EmitDefaultValue = true)] public bool? LockTimeFixed { get; set; } /// /// Expected time of entry into the zone /// /// Expected time of entry into the zone - /// 2023-08-21T08:23:35Z + /* + 2023-08-21T08:23:35Z + */ [DataMember(Name = "zone_entry", EmitDefaultValue = true)] public DateTime? ZoneEntry { get; set; } /// /// If true, the zone entry time is fixed and cannot be changed /// /// If true, the zone entry time is fixed and cannot be changed - /// true + /* + true + */ [DataMember(Name = "zone_entry_fixed", EmitDefaultValue = true)] public bool? ZoneEntryFixed { get; set; } /// /// Start time for terminal operations /// /// Start time for terminal operations - /// 2023-08-21T08:23:35Z + /* + 2023-08-21T08:23:35Z + */ [DataMember(Name = "operations_start", EmitDefaultValue = true)] public DateTime? OperationsStart { get; set; } /// /// End time for terminal operations /// /// End time for terminal operations - /// 2023-08-21T08:23:35Z + /* + 2023-08-21T08:23:35Z + */ [DataMember(Name = "operations_end", EmitDefaultValue = true)] public DateTime? OperationsEnd { get; set; } /// /// Additional remarks /// /// Additional remarks - /// Please be aware of the strong current + /* + Please be aware of the strong current + */ [DataMember(Name = "remarks", EmitDefaultValue = true)] public string Remarks { get; set; } /// /// Reference to a shipcall id /// /// Reference to a shipcall id - /// 23 + /* + 23 + */ [DataMember(Name = "shipcall_id", IsRequired = true, EmitDefaultValue = true)] public int ShipcallId { get; set; } /// /// Reference to a participant id /// /// Reference to a participant id - /// 34 + /* + 34 + */ [DataMember(Name = "participant_id", IsRequired = true, EmitDefaultValue = true)] public int ParticipantId { get; set; } /// /// Reference to a berth id /// /// Reference to a berth id - /// 1 + /* + 1 + */ [DataMember(Name = "berth_id", EmitDefaultValue = true)] public int? BerthId { get; set; } /// /// Additional info text for berth /// /// Additional info text for berth - /// 200m length + /* + 200m length + */ [DataMember(Name = "berth_info", EmitDefaultValue = true)] public string BerthInfo { get; set; } /// /// true if ship is rotated, false otherwise /// /// true if ship is rotated, false otherwise - /// true + /* + true + */ [DataMember(Name = "pier_side", EmitDefaultValue = true)] public bool? PierSide { get; set; } /// /// Gets or Sets ParticipantType /// - /// 4 + /* + 4 + */ [DataMember(Name = "participant_type", EmitDefaultValue = true)] public int ParticipantType { get; set; } /// /// ata can be set by mooring if actual times are different from planned /// /// ata can be set by mooring if actual times are different from planned - /// 2023-08-21T08:23:35Z + /* + 2023-08-21T08:23:35Z + */ [DataMember(Name = "ata", EmitDefaultValue = true)] public DateTime? Ata { get; set; } /// /// atd can be set by mooring if actual times are different from planned /// /// atd can be set by mooring if actual times are different from planned - /// 2023-08-21T08:23:35Z + /* + 2023-08-21T08:23:35Z + */ [DataMember(Name = "atd", EmitDefaultValue = true)] public DateTime? Atd { get; set; } /// /// Optional end of the interval for the times eta entry /// /// Optional end of the interval for the times eta entry - /// 2023-08-21T08:23:35Z + /* + 2023-08-21T08:23:35Z + */ [DataMember(Name = "eta_interval_end", EmitDefaultValue = true)] public DateTime? EtaIntervalEnd { get; set; } /// /// Optional end of the interval for the times etd entry /// /// Optional end of the interval for the times etd entry - /// 2023-08-21T08:23:35Z + /* + 2023-08-21T08:23:35Z + */ [DataMember(Name = "etd_interval_end", EmitDefaultValue = true)] public DateTime? EtdIntervalEnd { get; set; } /// /// Readonly field set by the database when times record was created /// /// Readonly field set by the database when times record was created - /// 2023-08-21T08:23:35Z + /* + 2023-08-21T08:23:35Z + */ [DataMember(Name = "created", EmitDefaultValue = true)] public DateTime Created { get; set; } /// /// Readonly field set by the database when times record was last modified /// /// Readonly field set by the database when times record was last modified - /// 2023-08-21T08:23:35Z + /* + 2023-08-21T08:23:35Z + */ [DataMember(Name = "modified", EmitDefaultValue = true)] public DateTime? Modified { get; set; } /// @@ -8490,43 +8741,57 @@ namespace BreCalClient.misc.Model /// /// Gets or Sets Id /// - /// 42 + /* + 42 + */ [DataMember(Name = "id", EmitDefaultValue = true)] public int Id { get; set; } /// /// Gets or Sets OldPassword /// - /// oldpassword + /* + oldpassword + */ [DataMember(Name = "old_password", EmitDefaultValue = true)] public string OldPassword { get; set; } /// /// Gets or Sets NewPassword /// - /// newpassword + /* + newpassword + */ [DataMember(Name = "new_password", EmitDefaultValue = true)] public string NewPassword { get; set; } /// /// Gets or Sets FirstName /// - /// John + /* + John + */ [DataMember(Name = "first_name", EmitDefaultValue = true)] public string FirstName { get; set; } /// /// Gets or Sets LastName /// - /// Doe + /* + Doe + */ [DataMember(Name = "last_name", EmitDefaultValue = true)] public string LastName { get; set; } /// /// Gets or Sets UserPhone /// - /// 1234567890 + /* + 1234567890 + */ [DataMember(Name = "user_phone", EmitDefaultValue = true)] public string UserPhone { get; set; } /// /// Gets or Sets UserEmail /// - /// no@where.com + /* + no@where.com + */ [DataMember(Name = "user_email", EmitDefaultValue = true)] public string UserEmail { get; set; } /// diff --git a/misc/BreCalApi.yaml b/misc/BreCalApi.yaml index c792698..1a61e0b 100644 --- a/misc/BreCalApi.yaml +++ b/misc/BreCalApi.yaml @@ -657,7 +657,7 @@ paths: parameters: - name: shipcall_id in: query - required: true + required: false description: '**Id of ship call**. *Example: 52*. Id given in ship call list' schema: $ref: '#/components/schemas/shipcallId' @@ -1545,13 +1545,15 @@ components: id: type: integer example: 42 + nullable: false shipcall_id: type: integer example: 5 + nullable: false notification_type: - $ref: '#/components/schemas/NotificationType' + $ref: '#/components/schemas/NotificationType' message: - type: string + type: string example: Entry XY violates rule Z created: type: string @@ -1567,8 +1569,8 @@ components: example: id: 42 shipcall_id: 5 - notification_type: email - message: Entry XY violates rule Z + notification_type: next24h + message: Shipcall may be relevant to you in the next 24 hours created: '2023-08-21T08:23:35Z' modified: '2023-08-21T08:23:35Z' notification_list: @@ -1579,13 +1581,13 @@ components: example: - id: 42 shipcall_id: 5 - notification_type: email + notification_type: time_conflict message: Entry XY violates rule Z created: '2023-08-21T08:23:35Z' modified: '2023-08-21T08:23:35Z' - id: 43 shipcall_id: 7 - notification_type: email + notification_type: time_conflict message: Entry AB violates rule C created: '2023-08-21T08:23:35Z' modified: '2023-08-21T08:23:35Z' @@ -1804,10 +1806,11 @@ components: type: string description: Type of notification enum: - - undefined - - email - - push - example: email + - assignment + - next24h + - time_conflict + - time_conflict_resolved + example: time_conflict EvaluationType: description: Evaluation of the ship call readOnly: true diff --git a/src/server/BreCal/impl/login.py b/src/server/BreCal/impl/login.py index 949e04a..c65d630 100644 --- a/src/server/BreCal/impl/login.py +++ b/src/server/BreCal/impl/login.py @@ -31,7 +31,11 @@ def GetUser(options): "last_name": data[0].last_name, "user_name": data[0].user_name, "user_phone": data[0].user_phone, - "user_email": data[0].user_email + "user_email": data[0].user_email, + "notify_email": data[0].notify_email, + "notify_whatsapp": data[0].notify_whatsapp, + "notify_signal": data[0].notify_signal, + "notify_popup": data[0].notify_popup } token = jwt_handler.generate_jwt(payload=result, lifetime=120) # generate token valid 60 mins result["token"] = token # add token to user data diff --git a/src/server/BreCal/impl/user.py b/src/server/BreCal/impl/user.py index 92dc02d..6229bc8 100644 --- a/src/server/BreCal/impl/user.py +++ b/src/server/BreCal/impl/user.py @@ -35,7 +35,7 @@ def PutUser(schemaModel): # should this be refactored? # Also, what about the 'user_name'? # 'participant_id' would also not trigger an update in isolation - if "first_name" in schemaModel or "last_name" in schemaModel or "user_phone" in schemaModel or "user_email" in schemaModel: + if "first_name" in schemaModel or "last_name" in schemaModel or "user_phone" in schemaModel or "user_email" in schemaModel or "notify_email" in schemaModel or "notify_whatsapp" in schemaModel or "notify_signal" in schemaModel or "notify_popup" in schemaModel: # query = SQLQuery.get_user_put(schemaModel) query = "UPDATE user SET " isNotFirst = False diff --git a/src/server/BreCal/schemas/model.py b/src/server/BreCal/schemas/model.py index b8e80c4..280fa30 100644 --- a/src/server/BreCal/schemas/model.py +++ b/src/server/BreCal/schemas/model.py @@ -65,18 +65,16 @@ class EvaluationType(IntEnum): return cls.undefined class NotificationType(IntEnum): + """ - Any user has the attributes - 'notify_email' -> NotificationType.email - 'notify_popup' -> NotificationType.push - 'notify_whatsapp' -> undeclared - 'notify_signal' -> undeclared + This type is not the way the user is informed but the type of the notification, e.g. time conflict, time conflict resolved, etc. + It can be understood as an event type """ - undefined = 0 - email = 1 - push = 2 - # whatsapp = 3 - # signal = 4 + + assignment = 0 + next24h = 1 + time_conflict = 2 + time_conflict_resolved = 3 @classmethod def _missing_(cls, value): @@ -489,7 +487,10 @@ class UserSchema(Schema): user_email = fields.String(allow_none=True, required=False, validate=[validate.Length(max=64)]) old_password = fields.String(allow_none=True, required=False, validate=[validate.Length(max=128)]) new_password = fields.String(allow_none=True, required=False, validate=[validate.Length(min=6, max=128)]) - # #TODO: the user schema does not (yet) include the 'notify_' fields + notify_email = fields.Bool(allow_none=True, required=False) + notify_whatsapp = fields.Bool(allow_none=True, required=False) + notify_signal = fields.Bool(allow_none=True, required=False) + notify_popup = fields.Bool(allow_none=True, required=False) @validates("user_phone") def validate_user_phone(self, value): @@ -542,10 +543,10 @@ class User: user_phone: str password_hash: str api_key: str - notify_email: bool # #TODO_clarify: should we use an IntFlag for multi-assignment? - notify_whatsapp: bool # #TODO_clarify: should we use an IntFlag for multi-assignment? - notify_signal: bool # #TODO_clarify: should we use an IntFlag for multi-assignment? - notify_popup: bool # #TODO_clarify: should we use an IntFlag for multi-assignment? + notify_email: bool + notify_whatsapp: bool + notify_signal: bool + notify_popup: bool created: datetime modified: datetime