Skip to content

Commit

Permalink
fix models
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrew Farquharson authored and Andrew Farquharson committed Nov 1, 2023
1 parent 87cc7e0 commit b1a2124
Show file tree
Hide file tree
Showing 13 changed files with 57 additions and 53 deletions.
2 changes: 1 addition & 1 deletion Sources/RCKit/Models/RCCancelReason.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 5 additions & 5 deletions Sources/RCKit/Models/RCEntitlement.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion Sources/RCKit/Models/RCEnvironment.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

enum RCEnvironment: String, Decodable {
public enum RCEnvironment: String, Decodable {
case sandbox = "SANDBOX"
case production = "PRODUCTION"
}
50 changes: 25 additions & 25 deletions Sources/RCKit/Models/RCEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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

Check warning on line 11 in Sources/RCKit/Models/RCEvent.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Identifier Name Violation: Variable name should be between 3 and 40 characters long: 'id' (identifier_name)

Check warning on line 11 in Sources/RCKit/Models/RCEvent.swift

View workflow job for this annotation

GitHub Actions / SwiftLint

Identifier Name Violation: Variable name should be between 3 and 40 characters long: 'id' (identifier_name)
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 {
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions Sources/RCKit/Models/RCEventBody.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion Sources/RCKit/Models/RCEventType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion Sources/RCKit/Models/RCPeriodType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Foundation

enum RCPeriodType: String, Decodable {
public enum RCPeriodType: String, Decodable {
case trial = "TRIAL"
case intro = "INTRO"
case normal = "NORMAL"
Expand Down
2 changes: 1 addition & 1 deletion Sources/RCKit/Models/RCStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 8 additions & 8 deletions Sources/RCKit/Models/RCSubscriber.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

import Vapor

struct RCSubscriber<E: Content>: 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<E: Content>: 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
Expand Down
4 changes: 2 additions & 2 deletions Sources/RCKit/Models/RCSubscriberRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@

import Vapor

struct RCSubscriberRequest<E: Content>: Content {
let subscriber: RCSubscriber<E>
public struct RCSubscriberRequest<E: Content>: Content {
public let subscriber: RCSubscriber<E>
}
8 changes: 4 additions & 4 deletions Sources/RCKit/RevenueCatClient+Application.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -39,7 +39,7 @@ extension Application {

// MARK: - RevenueCat

extension Application.RevenueCat {
public extension Application.RevenueCat {
func getSubscriber<E: Content>(_ revenueCatID: String) async throws -> RCSubscriber<E> {
return try await client.getSubscriber(revenueCatID)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/RCKit/RevenueCatClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import Vapor

class RevenueCatClient {
public class RevenueCatClient {

// MARK: - Properties

Expand Down
4 changes: 4 additions & 0 deletions Sources/RCKit/RevenueCatConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ import Vapor

public struct RevenueCatConfiguration: Content {
let token: String

public init(token: String) {
self.token = token
}
}

0 comments on commit b1a2124

Please sign in to comment.