Add extra initialization methods

This commit is contained in:
Pavel Tikhonenko
2021-05-25 00:09:22 +03:00
parent b15fcc3717
commit 4205371b89
+20 -1
View File
@@ -23,16 +23,35 @@ import TPInAppReceipt
return try InAppReceipt_Objc(receiptData: data)
}
/// Creates and returns the 'InAppReceipt' instance from data object
///
/// - Returns: 'InAppReceipt' instance
/// - throws: An error in the InAppReceipt domain, if `InAppReceipt` cannot be created.
@objc public class func receipt(from data: Data) -> InAppReceipt_Objc?
{
return try? InAppReceipt_Objc(receiptData: data)
}
/// Creates and returns the 'InAppReceipt' instance using local receipt
///
/// - Returns: 'InAppReceipt' instance
/// - throws: An error in the InAppReceipt domain, if `InAppReceipt` cannot be created.
@objc public class func localReceipt() throws -> InAppReceipt_Objc
@objc public class func local() throws -> InAppReceipt_Objc
{
let data = try Bundle.main.appStoreReceiptData()
return try InAppReceipt_Objc.receipt(from: data)
}
/// Creates and returns the 'InAppReceipt' instance using local receipt
///
/// - Returns: 'InAppReceipt' instance
/// - throws: An error in the InAppReceipt domain, if `InAppReceipt` cannot be created.
@objc public class func local() -> InAppReceipt_Objc?
{
guard let data = try? Bundle.main.appStoreReceiptData() else { return nil }
return InAppReceipt_Objc.receipt(from: data)
}
///
///
/// Initialize a `InAppReceipt` with asn1 payload