|
12 | 12 | <a href="https://github.com/hyodotdev/openiap-apple"> |
13 | 13 | <img src="https://img.shields.io/github/v/tag/hyodotdev/openiap-apple?label=Swift%20Package&logo=swift&color=orange" alt="Swift Package" /> |
14 | 14 | </a> |
15 | | - |
16 | 15 | <a href="https://cocoapods.org/pods/openiap"> |
17 | 16 | <img src="https://img.shields.io/cocoapods/v/openiap?color=E35A5F&label=CocoaPods&logo=cocoapods" alt="CocoaPods" /> |
18 | 17 | </a> |
19 | | - |
20 | 18 | <a href="https://github.com/hyodotdev/openiap-apple/actions/workflows/test.yml"> |
21 | 19 | <img src="https://github.com/hyodotdev/openiap-apple/actions/workflows/test.yml/badge.svg" alt="Tests" /> |
22 | 20 | </a> |
@@ -299,68 +297,59 @@ class StoreViewModel: ObservableObject { |
299 | 297 |
|
300 | 298 | ## 📚 Data Models |
301 | 299 |
|
302 | | -### ProductIOS |
| 300 | +Our Swift data models are generated from the shared GraphQL schema in [`openiap-gql`](https://github.com/hyodotdev/openiap-gql). Run `./scripts/generate-types.sh` (or the equivalent tooling in that repo) to update `Sources/Models/Types.swift`, and every consumer—including the example app—should rely on those generated definitions instead of hand-written structs. |
| 301 | + |
| 302 | +<details> |
| 303 | +<summary>ProductIOS snapshot</summary> |
303 | 304 |
|
304 | 305 | ```swift |
305 | 306 | struct ProductIOS { |
306 | | - // Common properties |
307 | 307 | let id: String |
308 | 308 | let title: String |
309 | 309 | let description: String |
310 | | - let type: String // "in-app" (preferred) or legacy "inapp" (deprecated, removal in 1.2.0) or "subs" |
| 310 | + let type: ProductType |
311 | 311 | let displayPrice: String |
312 | 312 | let currency: String |
313 | 313 | let price: Double? |
314 | | - let platform: String |
| 314 | + let platform: IapPlatform |
315 | 315 |
|
316 | 316 | // iOS-specific properties |
317 | 317 | let displayNameIOS: String |
318 | 318 | let typeIOS: ProductTypeIOS |
319 | | - let subscriptionInfoIOS: SubscriptionInfo? |
320 | | - let discountsIOS: [Discount]? |
| 319 | + let subscriptionInfoIOS: SubscriptionInfoIOS? |
| 320 | + let discountsIOS: [DiscountIOS]? |
321 | 321 | let isFamilyShareableIOS: Bool |
322 | 322 | } |
323 | | - |
324 | | -enum ProductTypeIOS { |
325 | | - case consumable |
326 | | - case nonConsumable |
327 | | - case autoRenewableSubscription |
328 | | - case nonRenewingSubscription |
329 | | - |
330 | | - var isSubs: Bool { /* returns true for autoRenewableSubscription */ } |
331 | | -} |
332 | 323 | ``` |
333 | 324 |
|
334 | | -### PurchaseIOS |
| 325 | +</details> |
| 326 | + |
| 327 | +<details> |
| 328 | +<summary>PurchaseIOS snapshot</summary> |
335 | 329 |
|
336 | 330 | ```swift |
337 | 331 | struct PurchaseIOS { |
338 | | - // Common properties |
339 | | - let id: String // Transaction ID |
| 332 | + let id: String |
340 | 333 | let productId: String |
341 | | - let transactionDate: Double // Unix timestamp in milliseconds |
342 | | - let purchaseToken: String |
| 334 | + let transactionDate: Double |
| 335 | + let purchaseToken: String? |
343 | 336 | let purchaseState: PurchaseState |
344 | 337 | let isAutoRenewing: Bool |
345 | 338 | let quantity: Int |
346 | | - let platform: String |
| 339 | + let platform: IapPlatform |
347 | 340 |
|
348 | 341 | // iOS-specific properties |
349 | 342 | let appAccountToken: String? |
350 | 343 | let environmentIOS: String? |
351 | 344 | let storefrontCountryCodeIOS: String? |
352 | | - let productTypeIOS: String? |
353 | 345 | let subscriptionGroupIdIOS: String? |
354 | | - let transactionReasonIOS: String? // "PURCHASE" | "RENEWAL" |
355 | | - let offerIOS: PurchaseOffer? |
356 | | - // ... additional properties |
357 | | -} |
358 | | - |
359 | | -enum PurchaseState { |
360 | | - case pending, purchased, failed, restored, deferred, unknown |
| 346 | + let transactionReasonIOS: String? |
| 347 | + let offerIOS: PurchaseOfferIOS? |
361 | 348 | } |
362 | 349 | ``` |
363 | 350 |
|
| 351 | +</details> |
| 352 | + |
364 | 353 | ### DiscountOffer |
365 | 354 |
|
366 | 355 | ```swift |
|
0 commit comments