tiki-deprecated / publish-sdk-ios

TIKI SDK (iOS) - Consumer Data Licensing
https://mytiki.com/docs/sdk-overview
MIT License
3 stars 2 forks source link

Implement custom Codable methods for JSON serialization/deserialization of TitleTag and LicenseUsecase #191

Closed ricardobrg closed 1 year ago

ricardobrg commented 1 year ago

Currently, the TitleTag and LicenseUsecase are not being properly serialized to their string representations during JSON serialization/deserialization. This can lead to issues with data consistency and accuracy.

To address this issue, we should implement custom Codable methods for these that will ensure they are serialized to the string representations of the respective enums.

The following is a sample method that should be added

init(from decoder: Decoder) throws {
    let container = try decoder.singleValueContainer()
    let value = try container.decode(String.self)
    self.init(value)
}

func encode(to encoder: Encoder) throws {
    var container = encoder.singleValueContainer()
    try container.encode(value)
}