2 // ReadingStateModel.swift
5 // Created by Pawel Dabrowski on 29/08/2018.
6 // Copyright © 2018 Fundacja Nowoczesna Polska. All rights reserved.
11 class ReadingStateModel: Decodable{
13 public enum ReadingState : String {
14 case unknown = "unknown"
15 case not_started = "not_started"
16 case reading = "reading"
17 case complete = "complete"
20 var state = ReadingState.unknown
22 private enum ReadingStateModelCodingKeys: String, CodingKey {
26 convenience required init(from decoder: Decoder) throws {
27 let container = try decoder.container(keyedBy: ReadingStateModelCodingKeys.self)
29 let stateString = try container.decode(String.self, forKey: .state)
31 var returnState: ReadingState = .unknown
33 if let readingState = ReadingState(rawValue: stateString) {
34 returnState = readingState
37 self.init(state: returnState)
40 convenience init(state: ReadingState) {