mirror of
https://github.com/SideStore/SideStore.git
synced 2026-02-18 19:23:43 +01:00
[AltStoreCore] Adds Pledge, PledgeReward, and PledgeTier
Allows us to cache pledges for current user, which can be used to determine if user has access to Patreon-only apps.
This commit is contained in:
@@ -15,6 +15,7 @@ extension PatreonAPI
|
||||
struct TierAttributes: Decodable
|
||||
{
|
||||
var title: String
|
||||
var amount_cents: Int32 // In USD
|
||||
}
|
||||
|
||||
struct TierRelationships: Decodable
|
||||
@@ -29,6 +30,7 @@ extension PatreonAPI
|
||||
{
|
||||
public var name: String
|
||||
public var identifier: String
|
||||
public var amount: Decimal
|
||||
|
||||
// Relationships
|
||||
public var benefits: [Benefit] = []
|
||||
@@ -38,6 +40,9 @@ extension PatreonAPI
|
||||
self.name = response.attributes.title
|
||||
self.identifier = response.id
|
||||
|
||||
let amount = Decimal(response.attributes.amount_cents) / 100
|
||||
self.amount = amount
|
||||
|
||||
guard let included, let benefitIDs = response.relationships?.benefits?.data.map(\.id) else { return }
|
||||
|
||||
let benefits = benefitIDs.compactMap { included.benefits[$0] }.map(Benefit.init(response:))
|
||||
|
||||
Reference in New Issue
Block a user