[AltStoreCore] Refactors PatreonAPI to reduce duplicate logic

This commit is contained in:
Riley Testut
2023-11-15 14:13:58 -06:00
committed by Magesh K
parent 6ba642335b
commit 99a3746e1a
15 changed files with 386 additions and 233 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)
}
}
}