2018-09-11 14:52:21 +00:00
|
|
|
//
|
|
|
|
// Application.swift
|
|
|
|
// Pachyderm
|
|
|
|
//
|
|
|
|
// Created by Shadowfacts on 9/9/18.
|
|
|
|
// Copyright © 2018 Shadowfacts. All rights reserved.
|
|
|
|
//
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
2018-09-17 23:22:37 +00:00
|
|
|
public class Application: Decodable {
|
2018-09-11 14:52:21 +00:00
|
|
|
public let name: String
|
|
|
|
public let website: URL?
|
|
|
|
|
2020-01-05 04:13:55 +00:00
|
|
|
public required init(from decoder: Decoder) throws {
|
|
|
|
let container = try decoder.container(keyedBy: CodingKeys.self)
|
|
|
|
|
|
|
|
self.name = try container.decode(String.self, forKey: .name)
|
|
|
|
|
|
|
|
if let websiteStr = try container.decodeIfPresent(String.self, forKey: .website),
|
|
|
|
let url = URL(string: websiteStr) {
|
|
|
|
self.website = url
|
|
|
|
} else {
|
|
|
|
self.website = nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-11 14:52:21 +00:00
|
|
|
private enum CodingKeys: String, CodingKey {
|
|
|
|
case name
|
|
|
|
case website
|
|
|
|
}
|
|
|
|
}
|