From de0d6a49a4e0fe7c919b4b0ba39715cccd16f912 Mon Sep 17 00:00:00 2001 From: William Mead Date: Thu, 21 May 2026 14:20:21 +0200 Subject: [PATCH] Fixed DolibarrIntervention decoding/encoding. Updated CHANGELOG. --- CHANGELOG.md | 5 +++++ .../Core/Intervention/DolibarrInterventionLine.swift | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98bc5dd..47f4f56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org) using the following scheme: MAJOR.MINOR.PATCH +## [0.43.0] - 2026-05-21 + +### Changed +- Fixed DolibarrIntervention decoding/encoding + ## [0.42.0] - 2026-05-21 ### Changed diff --git a/Sources/SwiftDolibarr/Models/Core/Intervention/DolibarrInterventionLine.swift b/Sources/SwiftDolibarr/Models/Core/Intervention/DolibarrInterventionLine.swift index b93628c..d69fbca 100644 --- a/Sources/SwiftDolibarr/Models/Core/Intervention/DolibarrInterventionLine.swift +++ b/Sources/SwiftDolibarr/Models/Core/Intervention/DolibarrInterventionLine.swift @@ -82,8 +82,10 @@ public final class DolibarrInterventionLine: CommonBusinessObjectLine { enum CodingKeys: String, CodingKey { case dateIntervene = "datei" case durationSeconds = "duration" + case durationSecondsV21 = "duree" case interventionId = "fk_fichinter" - case description = "desc" + case desc = "desc" + case description = "description" } // MARK: - Inits @@ -112,8 +114,11 @@ public final class DolibarrInterventionLine: CommonBusinessObjectLine { self.dateIntervene = try container.decode(Int.self, forKey: .dateIntervene) self.durationSeconds = try container.decode(String.self, forKey: .durationSeconds) self.interventionId = try container.decode(String.self, forKey: .interventionId) - self.description = try container.decodeIfPresent(String.self, forKey: .description) + self.description = try container.decodeIfPresent(String.self, forKey: .desc) try super.init(from: decoder) + if self.durationSeconds.isEmpty { + self.durationSeconds = try container.decode(String.self, forKey: .durationSecondsV21) + } #if os(iOS) || os(macOS) || os(watchOS) || os(tvOS) || os(visionOS) Logger.logWithoutSignal("\(Self.self).init.decoded", category: .api) #endif @@ -162,6 +167,7 @@ public final class DolibarrInterventionLine: CommonBusinessObjectLine { var container = encoder.container(keyedBy: CodingKeys.self) try container.encode(dateIntervene, forKey: .dateIntervene) try container.encode(durationSeconds, forKey: .durationSeconds) + try container.encode(durationSeconds, forKey: .durationSecondsV21) try container.encode(interventionId, forKey: .interventionId) try container.encodeIfPresent(description, forKey: .description) try super.encode(to: encoder)