// // WebSeriesShowListDM.swift // WOKA // // Created by MacBook Pro on 19/06/24. // import Foundation // MARK: - WebSeriesShowListDM struct WebSeriesShowListDM: Codable { let showData: [ShowDatum]? let totalRecords: Int? enum CodingKeys: String, CodingKey { case showData = "show_data" case totalRecords = "total_records" } // MARK: - ShowDatum struct ShowDatum: Codable { let id: Int? let title, description: String? let thumbnailPath: String? let showType: String? let totalSeasons, totalEpisodes: Int? let categoryMasterID: String? let ageRangeMasterID, genderMasterID: String? let contentMoreDetails: [MoreDetail]? let seasonData: [SeasonDatum]? let categoryData: [CategoryDatum]? let ageRangeData: [AgeRangeDatum]? let genderData: [GenderDatum]? var markAsFavourite, isLiked: Bool? let likedCategoryIDS: LikedCategoryIDS? var favouriteCategoryIDS: ValueWrapper? var likesCount : Int? let viewsCount, bookmarkCount: Int? enum CodingKeys: String, CodingKey { case id, title, description case thumbnailPath = "thumbnail_path" case showType = "show_type" case totalSeasons = "total_seasons" case totalEpisodes = "total_episodes" case categoryMasterID = "category_master_id" case ageRangeMasterID = "age_range_master_id" case genderMasterID = "gender_master_id" case contentMoreDetails = "content_more_details" case seasonData = "season_data" case categoryData = "category_data" case ageRangeData = "age_range_data" case genderData = "gender_data" case markAsFavourite = "mark_as_favourite" case isLiked = "is_liked" case likedCategoryIDS = "liked_category_ids" case favouriteCategoryIDS = "favourite_category_ids" case viewsCount = "views_count" case likesCount = "likes_count" case bookmarkCount = "bookmark_count" } } // MARK: - AgeRangeDatum struct AgeRangeDatum: Codable { let id: Int? let ageRange: String? enum CodingKeys: String, CodingKey { case id case ageRange = "age_range" } } // MARK: - CategoryDatum struct CategoryDatum: Codable { let id: Int? let categoryName: CategoryName? enum CodingKeys: String, CodingKey { case id case categoryName = "category_name" } } enum CategoryName: String, Codable { case english = "English" case hindi = "Hindi" } // enum CategoryMasterID: String, Codable { // case the118 = "1,18" // } // MARK: - MoreDetail struct MoreDetail: Codable { let id, contentID, postType, languageMasterID: Int? let title, description, tagsKeywords: String? let trailerHDURL, trailerSDURL: String? enum CodingKeys: String, CodingKey { case id case contentID = "content_id" case postType = "post_type" case languageMasterID = "language_master_id" case title, description case tagsKeywords = "tags_keywords" case trailerHDURL = "trailer_hd_url" case trailerSDURL = "trailer_sd_url" } } // MARK: - GenderDatum struct GenderDatum: Codable { let id: Int? let genderName: String? enum CodingKeys: String, CodingKey { case id case genderName = "gender_name" } } enum LikedCategoryIDS: Codable { case integer(Int) case string(String) case null init(from decoder: Decoder) throws { let container = try decoder.singleValueContainer() if let x = try? container.decode(Int.self) { self = .integer(x) return } if let x = try? container.decode(String.self) { self = .string(x) return } if container.decodeNil() { self = .null return } throw DecodingError.typeMismatch(LikedCategoryIDS.self, DecodingError.Context(codingPath: decoder.codingPath, debugDescription: "Wrong type for LikedCategoryIDS")) } func encode(to encoder: Encoder) throws { var container = encoder.singleValueContainer() switch self { case .integer(let x): try container.encode(x) case .string(let x): try container.encode(x) case .null: try container.encodeNil() } } } // MARK: - SeasonDatum struct SeasonDatum: Codable { let id, watchShowsMasterID: Int? let seasonNumber: String? let noOfEpisodes: Int? let seasonDescription: String? let releaseYear: Int? let seasonTitle: String? let trailerURL: String? let thumbnailPath: String? let thumbnailImgURL: String? let tagsKeyword, releaseDate: String? let seasonMoreDetails: [MoreDetail]? enum CodingKeys: String, CodingKey { case id case watchShowsMasterID = "watch_shows_master_id" case seasonNumber = "season_number" case noOfEpisodes = "no_of_episodes" case seasonDescription = "season_description" case releaseYear = "release_year" case seasonTitle = "season_title" case trailerURL = "trailer_url" case thumbnailPath = "thumbnail_path" case thumbnailImgURL = "thumbnail_img_url" case tagsKeyword = "tags_keyword" case releaseDate = "release_date" case seasonMoreDetails = "season_more_details" } } }