[AltStoreCore] Refactors PatreonAPI to reduce duplicate logic

This commit is contained in:
Riley Testut
2023-11-15 14:13:58 -06:00
parent 417837049f
commit 7ed2dc8291
15 changed files with 389 additions and 222 deletions

View File

@@ -10,18 +10,25 @@ import Foundation
extension PatreonAPI
{
struct BenefitResponse: Decodable
typealias BenefitResponse = DataResponse<BenefitAttributes, AnyRelationships>
struct BenefitAttributes: Decodable
{
var id: String
var title: String
}
}
public struct Benefit: Hashable
extension PatreonAPI
{
public var type: ALTPatreonBenefitType
init(response: PatreonAPI.BenefitResponse)
public struct Benefit: Hashable
{
self.type = ALTPatreonBenefitType(response.id)
public var name: String
public var identifier: ALTPatreonBenefitID
internal init(response: BenefitResponse)
{
self.name = response.attributes.title
self.identifier = ALTPatreonBenefitID(response.id)
}
}
}