Skip to content

Commit

Permalink
update store kit model
Browse files Browse the repository at this point in the history
  • Loading branch information
saroar committed Oct 27, 2022
1 parent 540e117 commit 72a92d1
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,17 @@ public struct VerifyReceiptInput: Equatable, Codable {

public init(
receiptData: Data,
excludeOldTransactions: Bool? = nil,
password: String
excludeOldTransactions: Bool? = nil
) {
self.receiptData = receiptData
self.excludeOldTransactions = excludeOldTransactions
self.password = password
}
public let receiptData: Data
public let excludeOldTransactions: Bool?
public let password: String

enum CodingKeys: String, CodingKey {
case receiptData = "receipt-data"
case excludeOldTransactions = "exclude-old-transactions"
case password
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,25 @@ public struct AppleVerifyReceiptResponse: Equatable, Sendable {
public var receipt: Receipt
public var status: Int

public init(
environment: AppleVerifyReceiptResponse.Environment? = nil,
isRetryable: Bool,
receipt: AppleVerifyReceiptResponse.Receipt,
status: Int
) {
self.environment = environment
self.isRetryable = isRetryable
self.receipt = receipt
self.status = status
}

public enum Environment: String, Codable, Equatable, Sendable {
case sandbox = "Sandbox"
case production = "Production"
}

public struct Receipt: Equatable, Sendable {
public struct Receipt: Equatable, Sendable {

public var appItemId: Int
public var applicationVersion: String
public var bundleId: String
Expand All @@ -20,13 +33,47 @@ public struct AppleVerifyReceiptResponse: Equatable, Sendable {
public var receiptCreationDate: Date
public var requestDate: Date

public struct InApp: Equatable, Sendable {
public var originalPurchaseDate: Date
public var originalTransactionId: String
public var productId: String
public var purchaseDate: Date
public var quantity: Int
public var transactionId: String
public init(
appItemId: Int,
applicationVersion: String,
bundleId: String,
inApp: [AppleVerifyReceiptResponse.Receipt.InApp],
originalPurchaseDate: Date,
receiptCreationDate: Date,
requestDate: Date
) {
self.appItemId = appItemId
self.applicationVersion = applicationVersion
self.bundleId = bundleId
self.inApp = inApp
self.originalPurchaseDate = originalPurchaseDate
self.receiptCreationDate = receiptCreationDate
self.requestDate = requestDate
}

public struct InApp: Equatable, Sendable {
public var originalPurchaseDate: Date
public var originalTransactionId: String
public var productId: String
public var purchaseDate: Date
public var quantity: Int
public var transactionId: String

public init(
originalPurchaseDate: Date,
originalTransactionId: String,
productId: String,
purchaseDate: Date,
quantity: Int,
transactionId: String
) {
self.originalPurchaseDate = originalPurchaseDate
self.originalTransactionId = originalTransactionId
self.productId = productId
self.purchaseDate = purchaseDate
self.quantity = quantity
self.transactionId = transactionId
}
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions Sources/NWSharedModels/Route/AppStoreRoute.swift
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import URLRouting
import Foundation

public enum AppStoreRoute: Equatable {
case verifyReceipt(input: VerifyReceiptInput)
case verifyReceipt(Data)
}

public let appStoreRouter = OneOf {
Route(.case(AppStoreRoute.verifyReceipt)) {
Path { "verify_receipt" }
Method.post
Body(.json(VerifyReceiptInput.self))
Path { "verify-receipt" }
Body()
}
}

0 comments on commit 72a92d1

Please sign in to comment.