From c1d8b2e855c5eed1dfed0a525d84e44077a62dc9 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Wed, 27 Dec 2023 08:33:49 +0100 Subject: [PATCH] fixed notification endpoint to return real data for a shipcall --- misc/BreCalApi.cs | 534 ++++++++++++++++++++---- misc/BreCalApi.yaml | 17 +- src/server/BreCal/api/notifications.py | 6 +- src/server/BreCal/impl/notifications.py | 29 +- src/server/BreCal/schemas/model.py | 6 +- 5 files changed, 475 insertions(+), 117 deletions(-) diff --git a/misc/BreCalApi.cs b/misc/BreCalApi.cs index 7d96edc..6fdeb2e 100644 --- a/misc/BreCalApi.cs +++ b/misc/BreCalApi.cs @@ -1,7 +1,7 @@ //---------------------- // -// Generated REST API Client Code Generator v1.9.1.0 on 19.12.2023 07:58:27 +// Generated REST API Client Code Generator v1.9.1.0 on 27.12.2023 08:25:38 // Using the tool OpenAPI Generator v7.1.0 // //---------------------- @@ -736,17 +736,36 @@ namespace BreCalClient.misc.Api /// ApiResponse of List<Berth> ApiResponse> BerthsGetWithHttpInfo(int operationIndex = 0); /// - /// Gets a list of notifications pursuant to a specified participant and ship call + /// History data /// /// - /// List of notifications (tbd) + /// This endpoint returns a list of changes made to the specific shipcall /// /// Thrown when fails to make API call - /// **Id of participant**. *Example: 2*. Id returned through loading of participant - /// **Id of ship call**. *Example: 52*. Id given in ship call list /// Index associated with the operation. - /// Notification - Notification NotificationsGet(int participantId, int shipcallId, int operationIndex = 0); + /// List<History> + List HistoryGet(int operationIndex = 0); + /// + /// History data + /// + /// + /// This endpoint returns a list of changes made to the specific shipcall + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// ApiResponse of List<History> + ApiResponse> HistoryGetWithHttpInfo(int operationIndex = 0); + /// + /// 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 + /// Index associated with the operation. + /// Notification + Notification NotificationsGet(int shipcallId, int operationIndex = 0); /// /// Gets a list of notifications pursuant to a specified participant and ship call /// @@ -754,11 +773,10 @@ namespace BreCalClient.misc.Api /// List of notifications (tbd) /// /// Thrown when fails to make API call - /// **Id of participant**. *Example: 2*. Id returned through loading of participant /// **Id of ship call**. *Example: 52*. Id given in ship call list /// Index associated with the operation. /// ApiResponse of Notification - ApiResponse NotificationsGetWithHttpInfo(int participantId, int shipcallId, int operationIndex = 0); + ApiResponse NotificationsGetWithHttpInfo(int shipcallId, int operationIndex = 0); /// /// gets one or all participants /// @@ -832,18 +850,39 @@ namespace BreCalClient.misc.Api /// Task of ApiResponse (List<Berth>) System.Threading.Tasks.Task>> BerthsGetWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// - /// Gets a list of notifications pursuant to a specified participant and ship call + /// History data /// /// - /// List of notifications (tbd) + /// This endpoint returns a list of changes made to the specific shipcall /// /// Thrown when fails to make API call - /// **Id of participant**. *Example: 2*. Id returned through loading of participant - /// **Id of ship call**. *Example: 52*. Id given in ship call list /// Index associated with the operation. /// Cancellation Token to cancel the request. - /// Task of Notification - System.Threading.Tasks.Task NotificationsGetAsync(int participantId, int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// Task of List<History> + System.Threading.Tasks.Task> HistoryGetAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// + /// History data + /// + /// + /// This endpoint returns a list of changes made to the specific shipcall + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (List<History>) + System.Threading.Tasks.Task>> HistoryGetWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + /// + /// 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 + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of Notification + System.Threading.Tasks.Task NotificationsGetAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// Gets a list of notifications pursuant to a specified participant and ship call /// @@ -851,12 +890,11 @@ namespace BreCalClient.misc.Api /// List of notifications (tbd) /// /// Thrown when fails to make API call - /// **Id of participant**. *Example: 2*. Id returned through loading of participant /// **Id of ship call**. *Example: 52*. Id given in ship call list /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Notification) - System.Threading.Tasks.Task> NotificationsGetWithHttpInfoAsync(int participantId, int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task> NotificationsGetWithHttpInfoAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); /// /// gets one or all participants /// @@ -1121,27 +1159,137 @@ namespace BreCalClient.misc.Api return localVarResponse; } /// - /// Gets a list of notifications pursuant to a specified participant and ship call List of notifications (tbd) + /// History data This endpoint returns a list of changes made to the specific shipcall /// /// Thrown when fails to make API call - /// **Id of participant**. *Example: 2*. Id returned through loading of participant - /// **Id of ship call**. *Example: 52*. Id given in ship call list /// Index associated with the operation. - /// Notification - public Notification NotificationsGet(int participantId, int shipcallId, int operationIndex = 0) + /// List<History> + public List HistoryGet(int operationIndex = 0) { - BreCalClient.misc.Client.ApiResponse localVarResponse = NotificationsGetWithHttpInfo(participantId, shipcallId); + BreCalClient.misc.Client.ApiResponse> localVarResponse = HistoryGetWithHttpInfo(); return localVarResponse.Data; } /// - /// Gets a list of notifications pursuant to a specified participant and ship call List of notifications (tbd) + /// History data This endpoint returns a list of changes made to the specific shipcall /// /// Thrown when fails to make API call - /// **Id of participant**. *Example: 2*. Id returned through loading of participant - /// **Id of ship call**. *Example: 52*. Id given in ship call list /// Index associated with the operation. - /// ApiResponse of Notification - public BreCalClient.misc.Client.ApiResponse NotificationsGetWithHttpInfo(int participantId, int shipcallId, int operationIndex = 0) + /// ApiResponse of List<History> + public BreCalClient.misc.Client.ApiResponse> HistoryGetWithHttpInfo(int operationIndex = 0) + { + BreCalClient.misc.Client.RequestOptions localVarRequestOptions = new BreCalClient.misc.Client.RequestOptions(); + string[] _contentTypes = new string[] { + }; + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + var localVarContentType = BreCalClient.misc.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + var localVarAccept = BreCalClient.misc.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + localVarRequestOptions.Operation = "StaticApi.HistoryGet"; + localVarRequestOptions.OperationIndex = operationIndex; + // authentication (ApiKey) required + if (!string.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("Authorization"))) + { + localVarRequestOptions.HeaderParameters.Add("Authorization", this.Configuration.GetApiKeyWithPrefix("Authorization")); + } + // make the HTTP request + var localVarResponse = this.Client.Get>("/history", localVarRequestOptions, this.Configuration); + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("HistoryGet", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + return localVarResponse; + } + /// + /// History data This endpoint returns a list of changes made to the specific shipcall + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of List<History> + public async System.Threading.Tasks.Task> HistoryGetAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + BreCalClient.misc.Client.ApiResponse> localVarResponse = await HistoryGetWithHttpInfoAsync(operationIndex, cancellationToken).ConfigureAwait(false); + return localVarResponse.Data; + } + /// + /// History data This endpoint returns a list of changes made to the specific shipcall + /// + /// Thrown when fails to make API call + /// Index associated with the operation. + /// Cancellation Token to cancel the request. + /// Task of ApiResponse (List<History>) + public async System.Threading.Tasks.Task>> HistoryGetWithHttpInfoAsync(int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + { + BreCalClient.misc.Client.RequestOptions localVarRequestOptions = new BreCalClient.misc.Client.RequestOptions(); + string[] _contentTypes = new string[] { + }; + // to determine the Accept header + string[] _accepts = new string[] { + "application/json" + }; + var localVarContentType = BreCalClient.misc.Client.ClientUtils.SelectHeaderContentType(_contentTypes); + if (localVarContentType != null) + { + localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType); + } + var localVarAccept = BreCalClient.misc.Client.ClientUtils.SelectHeaderAccept(_accepts); + if (localVarAccept != null) + { + localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); + } + localVarRequestOptions.Operation = "StaticApi.HistoryGet"; + localVarRequestOptions.OperationIndex = operationIndex; + // authentication (ApiKey) required + if (!string.IsNullOrEmpty(this.Configuration.GetApiKeyWithPrefix("Authorization"))) + { + localVarRequestOptions.HeaderParameters.Add("Authorization", this.Configuration.GetApiKeyWithPrefix("Authorization")); + } + // make the HTTP request + var localVarResponse = await this.AsynchronousClient.GetAsync>("/history", localVarRequestOptions, this.Configuration, cancellationToken).ConfigureAwait(false); + if (this.ExceptionFactory != null) + { + Exception _exception = this.ExceptionFactory("HistoryGet", localVarResponse); + if (_exception != null) + { + throw _exception; + } + } + return localVarResponse; + } + /// + /// 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 + /// Index associated with the operation. + /// Notification + public Notification NotificationsGet(int shipcallId, int operationIndex = 0) + { + BreCalClient.misc.Client.ApiResponse localVarResponse = NotificationsGetWithHttpInfo(shipcallId); + return localVarResponse.Data; + } + /// + /// 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 + /// Index associated with the operation. + /// ApiResponse of Notification + public BreCalClient.misc.Client.ApiResponse NotificationsGetWithHttpInfo(int shipcallId, int operationIndex = 0) { BreCalClient.misc.Client.RequestOptions localVarRequestOptions = new BreCalClient.misc.Client.RequestOptions(); string[] _contentTypes = new string[] { @@ -1160,7 +1308,6 @@ namespace BreCalClient.misc.Api { localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); } - localVarRequestOptions.QueryParameters.Add(BreCalClient.misc.Client.ClientUtils.ParameterToMultiMap("", "participant_id", participantId)); localVarRequestOptions.QueryParameters.Add(BreCalClient.misc.Client.ClientUtils.ParameterToMultiMap("", "shipcall_id", shipcallId)); localVarRequestOptions.Operation = "StaticApi.NotificationsGet"; localVarRequestOptions.OperationIndex = operationIndex; @@ -1185,26 +1332,24 @@ 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 participant**. *Example: 2*. Id returned through loading of participant /// **Id of ship call**. *Example: 52*. Id given in ship call list /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of Notification - public async System.Threading.Tasks.Task NotificationsGetAsync(int participantId, int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task NotificationsGetAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { - BreCalClient.misc.Client.ApiResponse localVarResponse = await NotificationsGetWithHttpInfoAsync(participantId, shipcallId, operationIndex, cancellationToken).ConfigureAwait(false); + BreCalClient.misc.Client.ApiResponse localVarResponse = await NotificationsGetWithHttpInfoAsync(shipcallId, operationIndex, cancellationToken).ConfigureAwait(false); return localVarResponse.Data; } /// /// 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 participant**. *Example: 2*. Id returned through loading of participant /// **Id of ship call**. *Example: 52*. Id given in ship call list /// Index associated with the operation. /// Cancellation Token to cancel the request. /// Task of ApiResponse (Notification) - public async System.Threading.Tasks.Task> NotificationsGetWithHttpInfoAsync(int participantId, int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) + public async System.Threading.Tasks.Task> NotificationsGetWithHttpInfoAsync(int shipcallId, int operationIndex = 0, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { BreCalClient.misc.Client.RequestOptions localVarRequestOptions = new BreCalClient.misc.Client.RequestOptions(); string[] _contentTypes = new string[] { @@ -1223,7 +1368,6 @@ namespace BreCalClient.misc.Api { localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept); } - localVarRequestOptions.QueryParameters.Add(BreCalClient.misc.Client.ClientUtils.ParameterToMultiMap("", "participant_id", participantId)); localVarRequestOptions.QueryParameters.Add(BreCalClient.misc.Client.ClientUtils.ParameterToMultiMap("", "shipcall_id", shipcallId)); localVarRequestOptions.Operation = "StaticApi.NotificationsGet"; localVarRequestOptions.OperationIndex = operationIndex; @@ -5872,6 +6016,193 @@ namespace BreCalClient.misc.Model } } +/* + * Bremen calling API + * + * Administer DEBRE ship calls, times and notifications + * + * The version of the OpenAPI document: 1.1.0 + * Contact: info@textbausteine.net + * Generated by: https://github.com/openapitools/openapi-generator.git + */ +namespace BreCalClient.misc.Model +{ + /// + /// Single history entry with references + /// + [DataContract(Name = "history")] + public partial class History : IEquatable, IValidatableObject + { + /// + /// Gets or Sets Operation + /// + [DataMember(Name = "operation", EmitDefaultValue = true)] + public OperationType? Operation { get; set; } + /// + /// Gets or Sets Type + /// + [DataMember(Name = "type", EmitDefaultValue = true)] + public ObjectType? Type { get; set; } + /// + /// Initializes a new instance of the class. + /// + /// id. + /// participantId. + /// shipcallId. + /// timestamp. + /// eta. + /// operation. + /// type. + public History(int id = default(int), int participantId = default(int), int shipcallId = default(int), DateTime timestamp = default(DateTime), DateTime eta = default(DateTime), OperationType? operation = default(OperationType?), ObjectType? type = default(ObjectType?)) + { + this.Id = id; + this.ParticipantId = participantId; + this.ShipcallId = shipcallId; + this.Timestamp = timestamp; + this.Eta = eta; + this.Operation = operation; + this.Type = type; + } + /// + /// Gets or Sets Id + /// + [DataMember(Name = "id", EmitDefaultValue = true)] + public int Id { get; set; } + /// + /// Gets or Sets ParticipantId + /// + [DataMember(Name = "participant_id", EmitDefaultValue = true)] + public int ParticipantId { get; set; } + /// + /// Gets or Sets ShipcallId + /// + [DataMember(Name = "shipcall_id", EmitDefaultValue = true)] + public int ShipcallId { get; set; } + /// + /// Gets or Sets Timestamp + /// + [DataMember(Name = "timestamp", EmitDefaultValue = true)] + public DateTime Timestamp { get; set; } + /// + /// Gets or Sets Eta + /// + [DataMember(Name = "eta", EmitDefaultValue = true)] + public DateTime Eta { get; set; } + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + StringBuilder sb = new StringBuilder(); + sb.Append("class History {\n"); + sb.Append(" Id: ").Append(Id).Append("\n"); + sb.Append(" ParticipantId: ").Append(ParticipantId).Append("\n"); + sb.Append(" ShipcallId: ").Append(ShipcallId).Append("\n"); + sb.Append(" Timestamp: ").Append(Timestamp).Append("\n"); + sb.Append(" Eta: ").Append(Eta).Append("\n"); + sb.Append(" Operation: ").Append(Operation).Append("\n"); + sb.Append(" Type: ").Append(Type).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public virtual string ToJson() + { + return Newtonsoft.Json.JsonConvert.SerializeObject(this, Newtonsoft.Json.Formatting.Indented); + } + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object input) + { + return this.Equals(input as History); + } + /// + /// Returns true if History instances are equal + /// + /// Instance of History to be compared + /// Boolean + public bool Equals(History input) + { + if (input == null) + { + return false; + } + return + ( + this.Id == input.Id || + this.Id.Equals(input.Id) + ) && + ( + this.ParticipantId == input.ParticipantId || + this.ParticipantId.Equals(input.ParticipantId) + ) && + ( + this.ShipcallId == input.ShipcallId || + this.ShipcallId.Equals(input.ShipcallId) + ) && + ( + this.Timestamp == input.Timestamp || + (this.Timestamp != null && + this.Timestamp.Equals(input.Timestamp)) + ) && + ( + this.Eta == input.Eta || + (this.Eta != null && + this.Eta.Equals(input.Eta)) + ) && + ( + this.Operation == input.Operation || + this.Operation.Equals(input.Operation) + ) && + ( + this.Type == input.Type || + this.Type.Equals(input.Type) + ); + } + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + int hashCode = 41; + hashCode = (hashCode * 59) + this.Id.GetHashCode(); + hashCode = (hashCode * 59) + this.ParticipantId.GetHashCode(); + hashCode = (hashCode * 59) + this.ShipcallId.GetHashCode(); + if (this.Timestamp != null) + { + hashCode = (hashCode * 59) + this.Timestamp.GetHashCode(); + } + if (this.Eta != null) + { + hashCode = (hashCode * 59) + this.Eta.GetHashCode(); + } + hashCode = (hashCode * 59) + this.Operation.GetHashCode(); + hashCode = (hashCode * 59) + this.Type.GetHashCode(); + return hashCode; + } + } + /// + /// To validate all properties of the instance + /// + /// Validation context + /// Validation Result + IEnumerable IValidatableObject.Validate(ValidationContext validationContext) + { + yield break; + } + } +} + /* * Bremen calling API * @@ -6228,21 +6559,17 @@ namespace BreCalClient.misc.Model /// Initializes a new instance of the class. /// /// id. - /// timesId. - /// participantId. + /// shipcallId. /// notificationType. - /// timestamp. - /// acknowledged. + /// message. /// Readonly field set by the database. /// Readonly field set by the database. - public Notification(int id = default(int), int timesId = default(int), int participantId = default(int), NotificationType? notificationType = default(NotificationType?), DateTime timestamp = default(DateTime), bool acknowledged = default(bool), DateTime created = default(DateTime), DateTime? modified = default(DateTime?)) + public Notification(int id = default(int), int shipcallId = default(int), NotificationType? notificationType = default(NotificationType?), string message = default(string), DateTime created = default(DateTime), DateTime? modified = default(DateTime?)) { this.Id = id; - this.TimesId = timesId; - this.ParticipantId = participantId; + this.ShipcallId = shipcallId; this.NotificationType = notificationType; - this.Timestamp = timestamp; - this.Acknowledged = acknowledged; + this.Message = message; this.Created = created; this.Modified = modified; } @@ -6252,25 +6579,15 @@ namespace BreCalClient.misc.Model [DataMember(Name = "id", EmitDefaultValue = true)] public int Id { get; set; } /// - /// Gets or Sets TimesId + /// Gets or Sets ShipcallId /// - [DataMember(Name = "times_id", EmitDefaultValue = true)] - public int TimesId { get; set; } + [DataMember(Name = "shipcall_id", EmitDefaultValue = true)] + public int ShipcallId { get; set; } /// - /// Gets or Sets ParticipantId + /// Gets or Sets Message /// - [DataMember(Name = "participant_id", EmitDefaultValue = true)] - public int ParticipantId { get; set; } - /// - /// Gets or Sets Timestamp - /// - [DataMember(Name = "timestamp", EmitDefaultValue = true)] - public DateTime Timestamp { get; set; } - /// - /// Gets or Sets Acknowledged - /// - [DataMember(Name = "acknowledged", EmitDefaultValue = true)] - public bool Acknowledged { get; set; } + [DataMember(Name = "message", EmitDefaultValue = true)] + public string Message { get; set; } /// /// Readonly field set by the database /// @@ -6292,11 +6609,9 @@ namespace BreCalClient.misc.Model StringBuilder sb = new StringBuilder(); sb.Append("class Notification {\n"); sb.Append(" Id: ").Append(Id).Append("\n"); - sb.Append(" TimesId: ").Append(TimesId).Append("\n"); - sb.Append(" ParticipantId: ").Append(ParticipantId).Append("\n"); + sb.Append(" ShipcallId: ").Append(ShipcallId).Append("\n"); sb.Append(" NotificationType: ").Append(NotificationType).Append("\n"); - sb.Append(" Timestamp: ").Append(Timestamp).Append("\n"); - sb.Append(" Acknowledged: ").Append(Acknowledged).Append("\n"); + sb.Append(" Message: ").Append(Message).Append("\n"); sb.Append(" Created: ").Append(Created).Append("\n"); sb.Append(" Modified: ").Append(Modified).Append("\n"); sb.Append("}\n"); @@ -6336,25 +6651,17 @@ namespace BreCalClient.misc.Model this.Id.Equals(input.Id) ) && ( - this.TimesId == input.TimesId || - this.TimesId.Equals(input.TimesId) - ) && - ( - this.ParticipantId == input.ParticipantId || - this.ParticipantId.Equals(input.ParticipantId) + this.ShipcallId == input.ShipcallId || + this.ShipcallId.Equals(input.ShipcallId) ) && ( this.NotificationType == input.NotificationType || this.NotificationType.Equals(input.NotificationType) ) && ( - this.Timestamp == input.Timestamp || - (this.Timestamp != null && - this.Timestamp.Equals(input.Timestamp)) - ) && - ( - this.Acknowledged == input.Acknowledged || - this.Acknowledged.Equals(input.Acknowledged) + this.Message == input.Message || + (this.Message != null && + this.Message.Equals(input.Message)) ) && ( this.Created == input.Created || @@ -6377,14 +6684,12 @@ namespace BreCalClient.misc.Model { int hashCode = 41; hashCode = (hashCode * 59) + this.Id.GetHashCode(); - hashCode = (hashCode * 59) + this.TimesId.GetHashCode(); - hashCode = (hashCode * 59) + this.ParticipantId.GetHashCode(); + hashCode = (hashCode * 59) + this.ShipcallId.GetHashCode(); hashCode = (hashCode * 59) + this.NotificationType.GetHashCode(); - if (this.Timestamp != null) + if (this.Message != null) { - hashCode = (hashCode * 59) + this.Timestamp.GetHashCode(); + hashCode = (hashCode * 59) + this.Message.GetHashCode(); } - hashCode = (hashCode * 59) + this.Acknowledged.GetHashCode(); if (this.Created != null) { hashCode = (hashCode * 59) + this.Created.GetHashCode(); @@ -6443,6 +6748,71 @@ namespace BreCalClient.misc.Model } } +/* + * Bremen calling API + * + * Administer DEBRE ship calls, times and notifications + * + * The version of the OpenAPI document: 1.1.0 + * Contact: info@textbausteine.net + * Generated by: https://github.com/openapitools/openapi-generator.git + */ +namespace BreCalClient.misc.Model +{ + /// + /// Defines ObjectType + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum ObjectType + { + /// + /// Enum Times for value: times + /// + [EnumMember(Value = "times")] + Times = 1, + /// + /// Enum Shipcall for value: shipcall + /// + [EnumMember(Value = "shipcall")] + Shipcall = 2 + } +} + +/* + * Bremen calling API + * + * Administer DEBRE ship calls, times and notifications + * + * The version of the OpenAPI document: 1.1.0 + * Contact: info@textbausteine.net + * Generated by: https://github.com/openapitools/openapi-generator.git + */ +namespace BreCalClient.misc.Model +{ + /// + /// Defines OperationType + /// + [JsonConverter(typeof(StringEnumConverter))] + public enum OperationType + { + /// + /// Enum Insert for value: insert + /// + [EnumMember(Value = "insert")] + Insert = 1, + /// + /// Enum Update for value: update + /// + [EnumMember(Value = "update")] + Update = 2, + /// + /// Enum Delete for value: delete + /// + [EnumMember(Value = "delete")] + Delete = 3 + } +} + /* * Bremen calling API * diff --git a/misc/BreCalApi.yaml b/misc/BreCalApi.yaml index f1ac93f..4f730c5 100644 --- a/misc/BreCalApi.yaml +++ b/misc/BreCalApi.yaml @@ -313,12 +313,6 @@ paths: - static operationId: notificationsGet parameters: - - name: participant_id - in: query - required: true - description: '**Id of participant**. *Example: 2*. Id returned through loading of participant' - schema: - type: integer - name: shipcall_id in: query required: true @@ -374,7 +368,7 @@ paths: description: list of history entries content: application/json: - schema: + schema: $ref: '#/components/schemas/history_list' '400': $ref: '#/components/responses/400' @@ -728,17 +722,12 @@ components: properties: id: type: integer - times_id: - type: integer - participant_id: + shipcall_id: type: integer notification_type: $ref: '#/components/schemas/NotificationType' - timestamp: + message: type: string - format: date-time - acknowledged: - type: boolean created: type: string format: date-time diff --git a/src/server/BreCal/api/notifications.py b/src/server/BreCal/api/notifications.py index 00dcf8d..48a2a44 100644 --- a/src/server/BreCal/api/notifications.py +++ b/src/server/BreCal/api/notifications.py @@ -10,12 +10,10 @@ bp = Blueprint('notifications', __name__) @bp.route('/notifications', methods=['get']) @auth_guard() # no restriction by role def GetNotifications(): - - if 'participant_id' in request.args: + if 'shipcall_id' in request.args: options = {} - options["participant_id"] = request.args.get("participant_id") options["shipcall_id"] = request.args.get("shipcall_id") return impl.notifications.GetNotifications(options) else: - logging.warning("attempt to load notifications without participant id") + logging.warning("attempt to load notifications without shipcall id") return json.dumps("missing argument"), 400 \ No newline at end of file diff --git a/src/server/BreCal/impl/notifications.py b/src/server/BreCal/impl/notifications.py index 1100230..9697b21 100644 --- a/src/server/BreCal/impl/notifications.py +++ b/src/server/BreCal/impl/notifications.py @@ -8,22 +8,25 @@ from .. import local_db def GetNotifications(options): """ :param options: A dictionary containing all the paramters for the Operations - options["participant_id"]: **Id of participant**. *Example: 2*. Id returned through loading of participant - options["shipcall_id"]: **Id of ship call**. *Example: 52*. Id given in ship call list + options["shipcall_id"]: **Id**. *Example: 42*. Id of referenced ship call. """ - # Implement your business logic here - # All the parameters are present in the options argument - - return json.dumps({ - "acknowledged": "", - "id": "", - "notification_type": "", - "participant_id": "", - "times_id": "", - "timestamp": "", - }), 200, {'Content-Type': 'application/json; charset=utf-8'} + try: + pooledConnection = local_db.getPoolConnection() + commands = pydapper.using(pooledConnection) + data = commands.query("SELECT id, shipcall_id, level, type, message, created, modified FROM notification " + + "WHERE shipcall_id = ?scid?", model=model.Notification, param={"scid" : options["shipcall_id"]}) + pooledConnection.close() + + except Exception as ex: + logging.error(ex) + print(ex) + result = {} + result["message"] = "call failed" + return json.dumps(result), 500, {'Content-Type': 'application/json; charset=utf-8'} + + return json.dumps(data, default=model.obj_dict), 200, {'Content-Type': 'application/json; charset=utf-8'} diff --git a/src/server/BreCal/schemas/model.py b/src/server/BreCal/schemas/model.py index beaca79..aec8866 100644 --- a/src/server/BreCal/schemas/model.py +++ b/src/server/BreCal/schemas/model.py @@ -67,11 +67,9 @@ class GetVerifyInlineResp(Schema): pass @dataclass -class Notification(Schema): - +class Notification: id: int - times_id: int - acknowledged: bool + shipcall_id: int level: int type: int message: str