diff --git a/Sources/RCKit/Models/RCCancelReason.swift b/Sources/RCKit/Models/RCCancelReason.swift index 80ce1c0..456e4cd 100644 --- a/Sources/RCKit/Models/RCCancelReason.swift +++ b/Sources/RCKit/Models/RCCancelReason.swift @@ -7,7 +7,7 @@ import Foundation -enum RCCancelReason: String, Decodable { +public enum RCCancelReason: String, Decodable { case unsubscribe = "UNSUBSCRIBE" case billingError = "BILLING_ERROR" case developerInitiated = "DEVELOPER_INITIATED" diff --git a/Sources/RCKit/Models/RCEntitlement.swift b/Sources/RCKit/Models/RCEntitlement.swift index 56a8ec6..c93e1d5 100644 --- a/Sources/RCKit/Models/RCEntitlement.swift +++ b/Sources/RCKit/Models/RCEntitlement.swift @@ -7,11 +7,11 @@ import Vapor -struct RCEntitlement: Content { - let expiresAt: Date - let gracePeriodExpiresAt: Date? - let productIdentifier: String - let purchasedAt: Date +public struct RCEntitlement: Content { + public let expiresAt: Date + public let gracePeriodExpiresAt: Date? + public let productIdentifier: String + public let purchasedAt: Date enum CodingKeys: String, CodingKey { case expiresAt = "expires_date" diff --git a/Sources/RCKit/Models/RCEnvironment.swift b/Sources/RCKit/Models/RCEnvironment.swift index 52904b1..2be3699 100644 --- a/Sources/RCKit/Models/RCEnvironment.swift +++ b/Sources/RCKit/Models/RCEnvironment.swift @@ -7,7 +7,7 @@ import Foundation -enum RCEnvironment: String, Decodable { +public enum RCEnvironment: String, Decodable { case sandbox = "SANDBOX" case production = "PRODUCTION" } diff --git a/Sources/RCKit/Models/RCEvent.swift b/Sources/RCKit/Models/RCEvent.swift index 6863f27..85005d2 100644 --- a/Sources/RCKit/Models/RCEvent.swift +++ b/Sources/RCKit/Models/RCEvent.swift @@ -7,30 +7,30 @@ import Foundation -struct RCEvent { - let id: String - let aliases: [String]? - let appUserId: String? - let currency: String? - let entitlementId: String? // Deprecated. See entitlement_ids. - let entitlementIds: [String]? - let environment: RCEnvironment - let eventTimestamp: Date - let expirationAt: Date? - let isFamilyShare: Bool? - let originalAppUserId: String? - let originalTransactionId: String? - let periodType: RCPeriodType? - let presentedOfferingId: String? - let price: Double? - let priceInPurchasedCurrency: Double? - let productId: String? - let purchasedAt: Date - let store: RCStore - let takehomePercentage: Float? - let transactionId: String? - let type: RCEventType - let cancelReason: RCCancelReason? +public struct RCEvent { + public let id: String + public let aliases: [String]? + public let appUserId: String? + public let currency: String? + public let entitlementId: String? // Deprecated. See entitlement_ids. + public let entitlementIds: [String]? + public let environment: RCEnvironment + public let eventTimestamp: Date + public let expirationAt: Date? + public let isFamilyShare: Bool? + public let originalAppUserId: String? + public let originalTransactionId: String? + public let periodType: RCPeriodType? + public let presentedOfferingId: String? + public let price: Double? + public let priceInPurchasedCurrency: Double? + public let productId: String? + public let purchasedAt: Date + public let store: RCStore + public let takehomePercentage: Float? + public let transactionId: String? + public let type: RCEventType + public let cancelReason: RCCancelReason? } extension RCEvent: Decodable { @@ -60,7 +60,7 @@ extension RCEvent: Decodable { case cancelReason = "cancel_reason" } - init(from decoder: Decoder) throws { + public init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) self.id = try container.decode(String.self, forKey: .id) self.aliases = try container.decodeIfPresent([String].self, forKey: .aliases) diff --git a/Sources/RCKit/Models/RCEventBody.swift b/Sources/RCKit/Models/RCEventBody.swift index 44f9478..cb8eb5b 100644 --- a/Sources/RCKit/Models/RCEventBody.swift +++ b/Sources/RCKit/Models/RCEventBody.swift @@ -7,9 +7,9 @@ import Foundation -struct RCEventBody: Decodable { - let version: String - let event: RCEvent +public struct RCEventBody: Decodable { + public let version: String + public let event: RCEvent enum CodingKeys: String, CodingKey { case version = "api_version" diff --git a/Sources/RCKit/Models/RCEventType.swift b/Sources/RCKit/Models/RCEventType.swift index 8a5c34d..cd5b43c 100644 --- a/Sources/RCKit/Models/RCEventType.swift +++ b/Sources/RCKit/Models/RCEventType.swift @@ -7,7 +7,7 @@ import Foundation -enum RCEventType: String, Decodable, CaseIterable { +public enum RCEventType: String, Decodable, CaseIterable { case test = "TEST" case expiration = "EXPIRATION" case initialPurchase = "INITIAL_PURCHASE" diff --git a/Sources/RCKit/Models/RCPeriodType.swift b/Sources/RCKit/Models/RCPeriodType.swift index d5536d4..109ba4b 100644 --- a/Sources/RCKit/Models/RCPeriodType.swift +++ b/Sources/RCKit/Models/RCPeriodType.swift @@ -7,7 +7,7 @@ import Foundation -enum RCPeriodType: String, Decodable { +public enum RCPeriodType: String, Decodable { case trial = "TRIAL" case intro = "INTRO" case normal = "NORMAL" diff --git a/Sources/RCKit/Models/RCStore.swift b/Sources/RCKit/Models/RCStore.swift index 9585856..3f40f81 100644 --- a/Sources/RCKit/Models/RCStore.swift +++ b/Sources/RCKit/Models/RCStore.swift @@ -7,7 +7,7 @@ import Foundation -enum RCStore: String, Decodable { +public enum RCStore: String, Decodable { case playStore = "PLAY_STORE" case appStore = "APP_STORE" case stripe = "STRIPE" diff --git a/Sources/RCKit/Models/RCSubscriber.swift b/Sources/RCKit/Models/RCSubscriber.swift index ac9d900..d026e56 100644 --- a/Sources/RCKit/Models/RCSubscriber.swift +++ b/Sources/RCKit/Models/RCSubscriber.swift @@ -7,14 +7,14 @@ import Vapor -struct RCSubscriber: Content { - let entitlements: E - let firstSeen: Date? - let lastSeen: Date? - let managementUrl: String? - let originalAppUserId: String? - let originalApplicationVersion: String? - let originalPurchaseDate: Date? +public struct RCSubscriber: Content { + public let entitlements: E + public let firstSeen: Date? + public let lastSeen: Date? + public let managementUrl: String? + public let originalAppUserId: String? + public let originalApplicationVersion: String? + public let originalPurchaseDate: Date? enum CodingKeys: String, CodingKey { case entitlements diff --git a/Sources/RCKit/Models/RCSubscriberRequest.swift b/Sources/RCKit/Models/RCSubscriberRequest.swift index 60c2b7c..0f05e4f 100644 --- a/Sources/RCKit/Models/RCSubscriberRequest.swift +++ b/Sources/RCKit/Models/RCSubscriberRequest.swift @@ -7,6 +7,6 @@ import Vapor -struct RCSubscriberRequest: Content { - let subscriber: RCSubscriber +public struct RCSubscriberRequest: Content { + public let subscriber: RCSubscriber } diff --git a/Sources/RCKit/RevenueCatClient+Application.swift b/Sources/RCKit/RevenueCatClient+Application.swift index fc4cd05..cc415fe 100644 --- a/Sources/RCKit/RevenueCatClient+Application.swift +++ b/Sources/RCKit/RevenueCatClient+Application.swift @@ -7,12 +7,12 @@ import Vapor -extension Application { - public var revenueCat: RevenueCat { +public extension Application { + var revenueCat: RevenueCat { .init(application: self) } - public struct RevenueCat { + struct RevenueCat { let application: Application struct ConfigurationKey: StorageKey { @@ -39,7 +39,7 @@ extension Application { // MARK: - RevenueCat -extension Application.RevenueCat { +public extension Application.RevenueCat { func getSubscriber(_ revenueCatID: String) async throws -> RCSubscriber { return try await client.getSubscriber(revenueCatID) } diff --git a/Sources/RCKit/RevenueCatClient.swift b/Sources/RCKit/RevenueCatClient.swift index 466df83..1757074 100644 --- a/Sources/RCKit/RevenueCatClient.swift +++ b/Sources/RCKit/RevenueCatClient.swift @@ -7,7 +7,7 @@ import Vapor -class RevenueCatClient { +public class RevenueCatClient { // MARK: - Properties diff --git a/Sources/RCKit/RevenueCatConfiguration.swift b/Sources/RCKit/RevenueCatConfiguration.swift index e15064e..7dcab09 100644 --- a/Sources/RCKit/RevenueCatConfiguration.swift +++ b/Sources/RCKit/RevenueCatConfiguration.swift @@ -9,4 +9,8 @@ import Vapor public struct RevenueCatConfiguration: Content { let token: String + + public init(token: String) { + self.token = token + } }