mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Clean up JSON classes
This commit is contained in:
parent
eafa351266
commit
bf1b374dc5
1 changed files with 5 additions and 8 deletions
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
import Foundation
|
||||
|
||||
/// Device Hardware API
|
||||
struct DeviceHardware: Codable {
|
||||
let hwModel: Int
|
||||
let hwModelSlug, platformioTarget: String
|
||||
|
|
@ -14,7 +15,6 @@ struct DeviceHardware: Codable {
|
|||
let activelySupported: Bool
|
||||
let displayName: String
|
||||
}
|
||||
|
||||
enum Architecture: String, Codable {
|
||||
case esp32 = "esp32"
|
||||
case esp32C3 = "esp32-c3"
|
||||
|
|
@ -23,11 +23,14 @@ enum Architecture: String, Codable {
|
|||
case rp2040 = "rp2040"
|
||||
}
|
||||
|
||||
/// Firmware Release Lists
|
||||
struct FirmwareReleases: Codable {
|
||||
let releases: Releases
|
||||
let pullRequests: [FirmwareRelease]
|
||||
}
|
||||
|
||||
struct Releases: Codable {
|
||||
let stable, alpha: [FirmwareRelease]
|
||||
}
|
||||
struct FirmwareRelease: Codable {
|
||||
let id, title: String
|
||||
let pageURL: String
|
||||
|
|
@ -40,11 +43,6 @@ struct FirmwareRelease: Codable {
|
|||
}
|
||||
}
|
||||
|
||||
// MARK: - Releases
|
||||
struct Releases: Codable {
|
||||
let stable, alpha: [FirmwareRelease]
|
||||
}
|
||||
|
||||
class Api : ObservableObject{
|
||||
|
||||
func loadDeviceHardwareData(completion:@escaping ([DeviceHardware]) -> ()) {
|
||||
|
|
@ -54,7 +52,6 @@ class Api : ObservableObject{
|
|||
}
|
||||
URLSession.shared.dataTask(with: url) { data, response, error in
|
||||
let deviceHardware = try! JSONDecoder().decode([DeviceHardware].self, from: data!)
|
||||
//print(deviceHardware)
|
||||
DispatchQueue.main.async {
|
||||
completion(deviceHardware)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue