Create swift package

This commit is contained in:
Joe Mattiello
2023-03-01 00:48:36 -05:00
parent 4669227567
commit 493b3783f0
409 changed files with 13707 additions and 16923 deletions

View File

@@ -0,0 +1,65 @@
//
// Patron.swift
// AltStore
//
// Created by Riley Testut on 8/21/19.
// Copyright © 2019 Riley Testut. All rights reserved.
//
import Foundation
extension PatreonAPI {
struct PatronResponse: Decodable {
struct Attributes: Decodable {
var full_name: String
var patron_status: String?
}
struct Relationships: Decodable {
struct Tiers: Decodable {
struct TierID: Decodable {
var id: String
var type: String
}
var data: [TierID]
}
var currently_entitled_tiers: Tiers
}
var id: String
var attributes: Attributes
var relationships: Relationships?
}
}
public extension Patron {
enum Status: String, Decodable {
case active = "active_patron"
case declined = "declined_patron"
case former = "former_patron"
case unknown
}
}
public class Patron {
public var name: String
public var identifier: String
public var status: Status
public var benefits: Set<Benefit> = []
init(response: PatreonAPI.PatronResponse) {
name = response.attributes.full_name
identifier = response.id
if let status = response.attributes.patron_status {
self.status = Status(rawValue: status) ?? .unknown
} else {
status = .unknown
}
}
}