2019-08-28 11:13:22 -07:00
|
|
|
//
|
|
|
|
|
// Tier.swift
|
|
|
|
|
// AltStore
|
|
|
|
|
//
|
|
|
|
|
// Created by Riley Testut on 8/21/19.
|
|
|
|
|
// Copyright © 2019 Riley Testut. All rights reserved.
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
import Foundation
|
|
|
|
|
|
|
|
|
|
extension PatreonAPI
|
|
|
|
|
{
|
|
|
|
|
struct TierResponse: Decodable
|
|
|
|
|
{
|
|
|
|
|
struct Attributes: Decodable
|
|
|
|
|
{
|
|
|
|
|
var title: String
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
struct Relationships: Decodable
|
|
|
|
|
{
|
|
|
|
|
struct Benefits: Decodable
|
|
|
|
|
{
|
|
|
|
|
var data: [BenefitResponse]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var benefits: Benefits
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var id: String
|
|
|
|
|
var attributes: Attributes
|
|
|
|
|
|
|
|
|
|
var relationships: Relationships
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-03 16:39:08 -07:00
|
|
|
public struct Tier
|
2019-08-28 11:13:22 -07:00
|
|
|
{
|
2020-09-03 16:39:08 -07:00
|
|
|
public var name: String
|
|
|
|
|
public var identifier: String
|
2019-08-28 11:13:22 -07:00
|
|
|
|
2020-09-03 16:39:08 -07:00
|
|
|
public var benefits: [Benefit] = []
|
2019-08-28 11:13:22 -07:00
|
|
|
|
|
|
|
|
init(response: PatreonAPI.TierResponse)
|
|
|
|
|
{
|
|
|
|
|
self.name = response.attributes.title
|
|
|
|
|
self.identifier = response.id
|
|
|
|
|
self.benefits = response.relationships.benefits.data.map(Benefit.init(response:))
|
|
|
|
|
}
|
|
|
|
|
}
|