mirror of
https://github.com/RevenueCat/purchases-ios
synced 2026-11-11 22:55:55 +05:45
# API Testers cleanup - Moves all API Testers into main RevenueCat workspace - ensure that they all use the local build, not a hardcoded commit - kill all the separate projects, create a single project with a framework per test (objc api tests, swift api tests, etc, etc) - creates a single scheme that builds all of those targets in one pass - update relevant CI (to do) Here's what this actually looks like: a single scheme in Xcode, which you can test using command + U (or just build, since it effectively works too) <img width="515" alt="Screenshot 2024-07-31 at 6 09 33 PM" src="https://github.com/user-attachments/assets/53882e38-f34b-4878-a11e-5d9c304e57ec"> <img width="278" alt="Screenshot 2024-07-31 at 6 09 44 PM" src="https://github.com/user-attachments/assets/3a7a444c-36da-4c82-ab57-4aeab77adb5d"> *Note:* Okay, I'd directly recommend _not_ reviewing the diff, since it's kind of insane, and instead checking out the branch to see if things make sense.
72 lines
2.3 KiB
Swift
72 lines
2.3 KiB
Swift
//
|
|
// PurchasesReceiptParserAPI.swift
|
|
// SwiftAPITester
|
|
//
|
|
// Created by Nacho Soto on 12/14/22.
|
|
//
|
|
|
|
import Foundation
|
|
import RevenueCat_CustomEntitlementComputation
|
|
|
|
func checkReceiptParserAPI() {
|
|
let parser: PurchasesReceiptParser = .default
|
|
|
|
do {
|
|
let _: AppleReceipt = try parser.parse(from: Data())
|
|
let _: AppleReceipt = try parser.parse(base64String: "")
|
|
} catch {}
|
|
}
|
|
|
|
private func checkErrors(_ error: PurchasesReceiptParser.Error) {
|
|
switch error {
|
|
case .dataObjectIdentifierMissing: break
|
|
case let .asn1ParsingError(description): print(description)
|
|
case .receiptParsingError: break
|
|
case .inAppPurchaseParsingError: break
|
|
case .failedToDecodeBase64String: break
|
|
case .receiptNotPresent: break
|
|
case let .failedToLoadLocalReceipt(error): print(error)
|
|
case .foundEmptyLocalReceipt: break
|
|
}
|
|
}
|
|
|
|
func checkAppleReceiptAPI(_ receipt: AppleReceipt! = nil) {
|
|
let _: String = receipt.bundleId
|
|
let _: String = receipt.applicationVersion
|
|
let _: String? = receipt.originalApplicationVersion
|
|
let _: Data = receipt.opaqueValue
|
|
let _: Data = receipt.sha1Hash
|
|
let _: Date = receipt.creationDate
|
|
let _: Date? = receipt.expirationDate
|
|
let _: [AppleReceipt.InAppPurchase] = receipt.inAppPurchases
|
|
|
|
checkInAppPurchaseAPI()
|
|
checkProductTypeEnum()
|
|
}
|
|
|
|
func checkInAppPurchaseAPI(_ purchase: AppleReceipt.InAppPurchase! = nil) {
|
|
let _: Int = purchase.quantity
|
|
let _: String = purchase.productId
|
|
let _: String = purchase.transactionId
|
|
let _: String? = purchase.originalTransactionId
|
|
let _: AppleReceipt.InAppPurchase.ProductType = purchase.productType
|
|
let _: Date = purchase.purchaseDate
|
|
let _: Date? = purchase.originalPurchaseDate
|
|
let _: Date? = purchase.expiresDate
|
|
let _: Date? = purchase.cancellationDate
|
|
let _: Bool? = purchase.isInTrialPeriod
|
|
let _: Bool? = purchase.isInIntroOfferPeriod
|
|
let _: Int64? = purchase.webOrderLineItemId
|
|
let _: String? = purchase.promotionalOfferIdentifier
|
|
}
|
|
|
|
func checkProductTypeEnum(_ type: AppleReceipt.InAppPurchase.ProductType! = nil) {
|
|
switch type! {
|
|
case .unknown: break
|
|
case .nonConsumable: break
|
|
case .consumable: break
|
|
case .nonRenewingSubscription: break
|
|
case .autoRenewableSubscription: break
|
|
}
|
|
}
|