-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
178 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Leo Dion on 1/11/24. | ||
// | ||
import Foundation | ||
|
||
public struct Board { | ||
public let boardconfig: String | ||
public let platform: String | ||
public let cpid: Int | ||
public let bdid: Int | ||
|
||
public init(boardconfig: String, platform: String, cpid: Int, bdid: Int) { | ||
self.boardconfig = boardconfig | ||
self.platform = platform | ||
self.cpid = cpid | ||
self.bdid = bdid | ||
} | ||
} | ||
|
||
extension Board { | ||
init(component: Components.Schemas.Board) { | ||
self.init( | ||
boardconfig: component.boardconfig, | ||
platform: component.platform, | ||
cpid: component.cpid, | ||
bdid: component.bdid | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Leo Dion on 1/11/24. | ||
// | ||
import Foundation | ||
|
||
public struct Device { | ||
public let name: String | ||
public let identifier: String | ||
public let firmwares: [Firmware] | ||
public let boards: [Board] | ||
|
||
public init(name: String, identifier: String, firmwares: [Firmware], boards: [Board]) { | ||
self.name = name | ||
self.identifier = identifier | ||
self.firmwares = firmwares | ||
self.boards = boards | ||
} | ||
} | ||
|
||
extension Device { | ||
init(component: Components.Schemas.Device) throws { | ||
try self.init( | ||
name: component.name, | ||
identifier: component.identifier, | ||
firmwares: component.firmwares.map(Firmware.init(component:)), | ||
boards: component.boards.map(Board.init(component:)) | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Leo Dion on 1/11/24. | ||
// | ||
import Foundation | ||
|
||
public struct Firmware { | ||
public let identifier: String | ||
public let version: String | ||
public let buildid: String | ||
public let sha1sum: String | ||
public let md5sum: String | ||
public let filesize: Int | ||
public let url: URL | ||
public let releasedate: Date | ||
public let uploaddate: Date | ||
public let signed: Bool | ||
|
||
public init( | ||
identifier: String, | ||
version: String, | ||
buildid: String, | ||
sha1sum: String, | ||
md5sum: String, | ||
filesize: Int, | ||
url: URL, | ||
releasedate: Date, | ||
uploaddate: Date, | ||
signed: Bool | ||
) { | ||
self.identifier = identifier | ||
self.version = version | ||
self.buildid = buildid | ||
self.sha1sum = sha1sum | ||
self.md5sum = md5sum | ||
self.filesize = filesize | ||
self.url = url | ||
self.releasedate = releasedate | ||
self.uploaddate = uploaddate | ||
self.signed = signed | ||
} | ||
} | ||
|
||
extension Firmware { | ||
init(component: Components.Schemas.Firmware) throws { | ||
try self.init( | ||
identifier: component.identifier, | ||
version: component.version, | ||
buildid: component.buildid, | ||
sha1sum: component.sha1sum, | ||
md5sum: component.md5sum, | ||
filesize: component.filesize, | ||
url: URL(validatingURL: component.url), | ||
releasedate: component.releasedate, | ||
uploaddate: component.uploaddate, | ||
signed: component.signed | ||
) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Leo Dion on 1/11/24. | ||
// | ||
import Foundation | ||
|
||
public enum FirmwareType: String { | ||
case ipsw | ||
case ota | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Leo Dion on 1/11/24. | ||
// | ||
import Foundation | ||
|
||
enum RuntimeError: Error { | ||
case invalidURL(String) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// File.swift | ||
// | ||
// | ||
// Created by Leo Dion on 1/11/24. | ||
// | ||
import Foundation | ||
|
||
extension URL { | ||
/// Returns a validated server URL, or throws an error. | ||
/// - Parameter string: A URL string. | ||
/// - Throws: If the provided string doesn't convert to URL. | ||
public init(validatingURL string: String) throws { | ||
guard let url = Self(string: string) else { throw RuntimeError.invalidURL(string) } | ||
self = url | ||
} | ||
} |