princes-theatre-challenge

Prince's Theatre Challenge

View project on GitHub

Movie Model

2020.12.09 2300

QuickType to the rescue. I use QuickType to help generating the data models.

See: https://app.quicktype.io

// This file was generated from JSON Schema using quicktype, do not modify it directly.
// To parse the JSON, add this file to your project and do:
//
//   let movies = try? newJSONDecoder().decode(Movies.self, from: jsonData)

import Foundation

// MARK: - Movies
struct Movies: Codable {
    let provider: String
    let movies: [Movie]

    enum CodingKeys: String, CodingKey {
        case provider = "Provider"
        case movies = "Movies"
    }
}

// MARK: - Movie
struct Movie: Codable {
    let id, title: String
    let type: TypeEnum
    let poster: String

    enum CodingKeys: String, CodingKey {
        case id = "ID"
        case title = "Title"
        case type = "Type"
        case poster = "Poster"
    }
}

enum TypeEnum: String, Codable {
    case movie = "movie"
}