Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.52.0] - 2026-06-23

### Changed
- Updated LaReponse article properties

## [0.51.0] - 2026-06-14

### Changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ public final class LaReponseArticle: Hashable, Codable, DolibarrObject {

/// Article type
public var typeCode: Int

/// Article favorite
public var favorite: Int?

/// Article entity ID
///
/// - Mapped Dolibarr property: **entity**
public var entityId: String?

// MARK: - Computed properties

Expand Down Expand Up @@ -126,6 +134,17 @@ public final class LaReponseArticle: Hashable, Codable, DolibarrObject {
return nil
}
}

public var isFavorite: Bool? {
switch favorite {
case 0:
return false
case 1:
return true
default:
return nil
}
}

// MARK: - Enums

Expand All @@ -140,6 +159,8 @@ public final class LaReponseArticle: Hashable, Codable, DolibarrObject {
case visibilityCode = "private"
case publishToken = "publish_token"
case typeCode = "type"
case favorite
case entityId = "entity"
}

public enum ArticleType {
Expand All @@ -165,7 +186,9 @@ public final class LaReponseArticle: Hashable, Codable, DolibarrObject {
content: String? = nil,
visibilityCode: Int = 0,
publishToken: String? = nil,
typeCode: Int = 0
typeCode: Int = 0,
favorite: Int = 0,
entityId: String = ""
) {
self.id = id
self.dateCreate = dateCreate
Expand All @@ -177,6 +200,8 @@ public final class LaReponseArticle: Hashable, Codable, DolibarrObject {
self.visibilityCode = visibilityCode
self.publishToken = publishToken
self.typeCode = typeCode
self.favorite = favorite
self.entityId = entityId
}

public required init(from decoder: any Decoder) throws {
Expand All @@ -195,6 +220,8 @@ public final class LaReponseArticle: Hashable, Codable, DolibarrObject {
self.visibilityCode = try container.decode(Int.self, forKey: .visibilityCode)
self.publishToken = try container.decodeIfPresent(String.self, forKey: .publishToken)
self.typeCode = try container.decode(Int.self, forKey: .typeCode)
self.favorite = try container.decodeIfPresent(Int.self, forKey: .favorite)
self.entityId = try container.decodeIfPresent(MultiType.self, forKey: .entityId)?.stringValue
#if os(iOS) || os(macOS) || os(watchOS) || os(tvOS) || os(visionOS)
Logger.logWithoutSignal("\(Self.self).init.decoded", category: .api)
#endif
Expand Down Expand Up @@ -222,6 +249,8 @@ public final class LaReponseArticle: Hashable, Codable, DolibarrObject {
self.visibilityCode = source.visibilityCode
self.publishToken = source.publishToken
self.typeCode = source.typeCode
self.favorite = source.favorite
self.entityId = source.entityId
}

// MARK: - Methods
Expand All @@ -237,6 +266,8 @@ public final class LaReponseArticle: Hashable, Codable, DolibarrObject {
self.visibilityCode = source.visibilityCode
self.publishToken = source.publishToken
self.typeCode = source.typeCode
self.favorite = source.favorite
self.entityId = source.entityId
}

// MARK: - Protocol methods
Expand All @@ -252,6 +283,8 @@ public final class LaReponseArticle: Hashable, Codable, DolibarrObject {
hasher.combine(visibilityCode)
hasher.combine(optional: publishToken)
hasher.combine(typeCode)
hasher.combine(optional: favorite)
hasher.combine(optional: entityId)
}

public func encode(to encoder: any Encoder) throws {
Expand All @@ -266,6 +299,8 @@ public final class LaReponseArticle: Hashable, Codable, DolibarrObject {
try container.encode(visibilityCode, forKey: .visibilityCode)
try container.encodeIfPresent(publishToken, forKey: .publishToken)
try container.encode(typeCode, forKey: .typeCode)
try container.encodeIfPresent(favorite, forKey: .favorite)
try container.encodeIfPresent(entityId, forKey: .entityId)
}

public static func == (lhs: LaReponseArticle, rhs: LaReponseArticle) -> Bool {
Expand All @@ -279,6 +314,8 @@ public final class LaReponseArticle: Hashable, Codable, DolibarrObject {
&& lhs.visibilityCode == rhs.visibilityCode
&& lhs.publishToken == rhs.publishToken
&& lhs.typeCode == rhs.typeCode
&& lhs.favorite == rhs.favorite
&& lhs.entityId == rhs.entityId
}

}
Loading