Ferrite-backup/Ferrite/API/GithubWrapper.swift
kingbri 664c57b751 Ferrite: Add updater
Updates are sent via an alert on starting the app. This can be
disabled in the settings menu.

A full version struct has been completed for flexible comparisons.

Version history can also be viewed in settings in case a user wants
to download an earlier version of the app.

Updates track Github releases.

Signed-off-by: kingbri <bdashore3@gmail.com>
2022-08-31 18:47:02 -04:00

28 lines
829 B
Swift

//
// GithubWrapper.swift
// Ferrite
//
// Created by Brian Dashore on 8/28/22.
//
import Foundation
public class Github {
public func fetchLatestRelease() async throws -> GithubRelease? {
let url = URL(string: "https://api.github.com/repos/bdashore3/Ferrite/releases/latest")!
let (data, _) = try await URLSession.shared.data(from: url)
let rawResponse = try JSONDecoder().decode(GithubRelease.self, from: data)
return rawResponse
}
public func fetchReleases() async throws -> [GithubRelease]? {
let url = URL(string: "https://api.github.com/repos/bdashore3/Ferrite/releases")!
let (data, _) = try await URLSession.shared.data(from: url)
let rawResponse = try JSONDecoder().decode([GithubRelease].self, from: data)
return rawResponse
}
}