react-native-iap 16.0.2 → 16.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +4 -32
  2. package/android/gradle.properties +3 -3
  3. package/android/src/main/cpp/cpp-adapter.cpp +4 -1
  4. package/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt +7 -7
  5. package/android/src/main/java/com/margelo/nitro/iap/NitroIapPackage.java +2 -6
  6. package/ios/RnIapHelper.swift +22 -0
  7. package/lib/module/hooks/useIAP.js +12 -4
  8. package/lib/module/hooks/useIAP.js.map +1 -1
  9. package/lib/module/index.js +6 -6
  10. package/lib/module/index.js.map +1 -1
  11. package/lib/module/types.js.map +1 -1
  12. package/lib/module/utils/type-bridge.js.map +1 -1
  13. package/lib/typescript/src/hooks/useIAP.d.ts +1 -3
  14. package/lib/typescript/src/hooks/useIAP.d.ts.map +1 -1
  15. package/lib/typescript/src/index.d.ts +13 -13
  16. package/lib/typescript/src/index.d.ts.map +1 -1
  17. package/lib/typescript/src/index.kepler.d.ts +7 -7
  18. package/lib/typescript/src/index.kepler.d.ts.map +1 -1
  19. package/lib/typescript/src/specs/RnIap.nitro.d.ts +5 -3
  20. package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -1
  21. package/lib/typescript/src/types.d.ts +23 -7
  22. package/lib/typescript/src/types.d.ts.map +1 -1
  23. package/lib/typescript/src/utils/available-purchases.d.ts +1 -1
  24. package/lib/typescript/src/utils/available-purchases.d.ts.map +1 -1
  25. package/lib/typescript/src/utils/error.d.ts +1 -1
  26. package/lib/typescript/src/utils/error.d.ts.map +1 -1
  27. package/lib/typescript/src/utils/errorMapping.d.ts +1 -1
  28. package/lib/typescript/src/utils/errorMapping.d.ts.map +1 -1
  29. package/lib/typescript/src/utils/purchase.d.ts +1 -1
  30. package/lib/typescript/src/utils/purchase.d.ts.map +1 -1
  31. package/lib/typescript/src/utils/type-bridge.d.ts +2 -2
  32. package/lib/typescript/src/utils/type-bridge.d.ts.map +1 -1
  33. package/lib/typescript/src/utils.d.ts +1 -1
  34. package/lib/typescript/src/utils.d.ts.map +1 -1
  35. package/lib/typescript/src/vega-adapter.d.ts +1 -1
  36. package/lib/typescript/src/vega-adapter.d.ts.map +1 -1
  37. package/lib/typescript/src/vega.d.ts +1 -1
  38. package/lib/typescript/src/vega.d.ts.map +1 -1
  39. package/lib/typescript/src/vega.kepler.d.ts +1 -1
  40. package/lib/typescript/src/vega.kepler.d.ts.map +1 -1
  41. package/nitrogen/generated/android/NitroIap+autolinking.cmake +1 -0
  42. package/nitrogen/generated/android/c++/JAdvancedCommerceInfoIOS.hpp +10 -1
  43. package/nitrogen/generated/android/c++/JFunc_void_NitroPurchase.hpp +5 -0
  44. package/nitrogen/generated/android/c++/JHybridRnIapSpec.cpp +9 -0
  45. package/nitrogen/generated/android/c++/JNitroPurchase.hpp +5 -0
  46. package/nitrogen/generated/android/c++/JNitroPurchaseVerificationResultIOS.hpp +5 -0
  47. package/nitrogen/generated/android/c++/JPurchase.hpp +5 -0
  48. package/nitrogen/generated/android/c++/JPurchaseIOS.hpp +5 -0
  49. package/nitrogen/generated/android/c++/JRequestPurchaseResult.hpp +5 -0
  50. package/nitrogen/generated/android/c++/JSubscriptionPeriodIOS.hpp +67 -0
  51. package/nitrogen/generated/android/c++/JSubscriptionPeriodValueIOS.hpp +62 -0
  52. package/nitrogen/generated/android/c++/JVariant_NitroPurchaseVerificationResultIOS_NitroPurchaseVerificationResultAndroid.hpp +5 -0
  53. package/nitrogen/generated/android/c++/JVariant_NullType_AdvancedCommerceInfoIOS.hpp +5 -0
  54. package/nitrogen/generated/android/c++/JVariant_NullType_NitroPurchase.hpp +5 -0
  55. package/nitrogen/generated/android/c++/JVariant_NullType_SubscriptionPeriodValueIOS.cpp +26 -0
  56. package/nitrogen/generated/android/c++/JVariant_NullType_SubscriptionPeriodValueIOS.hpp +73 -0
  57. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/AdvancedCommerceInfoIOS.kt +7 -2
  58. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Func_void_DeveloperProvidedBillingDetailsAndroid.kt +0 -2
  59. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Func_void_NitroProduct.kt +0 -2
  60. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Func_void_NitroPurchase.kt +0 -2
  61. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Func_void_NitroPurchaseResult.kt +0 -2
  62. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Func_void_UserChoiceBillingDetails.kt +0 -2
  63. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/HybridRnIapSpec.kt +2 -0
  64. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/SubscriptionPeriodIOS.kt +26 -0
  65. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/SubscriptionPeriodValueIOS.kt +56 -0
  66. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Variant_NullType_SubscriptionPeriodValueIOS.kt +62 -0
  67. package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.hpp +50 -0
  68. package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Umbrella.hpp +6 -0
  69. package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.hpp +6 -0
  70. package/nitrogen/generated/ios/swift/AdvancedCommerceInfoIOS.swift +38 -1
  71. package/nitrogen/generated/ios/swift/SubscriptionPeriodIOS.swift +52 -0
  72. package/nitrogen/generated/ios/swift/SubscriptionPeriodValueIOS.swift +34 -0
  73. package/nitrogen/generated/ios/swift/Variant_NullType_SubscriptionPeriodValueIOS.swift +30 -0
  74. package/nitrogen/generated/shared/c++/AdvancedCommerceInfoIOS.hpp +8 -1
  75. package/nitrogen/generated/shared/c++/SubscriptionPeriodIOS.hpp +88 -0
  76. package/nitrogen/generated/shared/c++/SubscriptionPeriodValueIOS.hpp +88 -0
  77. package/openiap-versions.json +3 -3
  78. package/package.json +34 -37
  79. package/src/hooks/useIAP.ts +50 -31
  80. package/src/index.ts +19 -22
  81. package/src/specs/RnIap.nitro.ts +9 -15
  82. package/src/types.ts +23 -7
  83. package/src/utils/type-bridge.ts +0 -2
  84. package/lib/module/types/react-test-renderer.d.js +0 -2
  85. package/lib/module/types/react-test-renderer.d.js.map +0 -1
  86. package/src/types/react-test-renderer.d.ts +0 -7
@@ -152,6 +152,10 @@ namespace margelo::nitro::iap { struct RenewalInfoIOS; }
152
152
  namespace margelo::nitro::iap { enum class SubResponseCodeAndroid; }
153
153
  // Forward declaration of `SubscriptionBillingPlanTypeIOS` to properly resolve imports.
154
154
  namespace margelo::nitro::iap { enum class SubscriptionBillingPlanTypeIOS; }
155
+ // Forward declaration of `SubscriptionPeriodIOS` to properly resolve imports.
156
+ namespace margelo::nitro::iap { enum class SubscriptionPeriodIOS; }
157
+ // Forward declaration of `SubscriptionPeriodValueIOS` to properly resolve imports.
158
+ namespace margelo::nitro::iap { struct SubscriptionPeriodValueIOS; }
155
159
  // Forward declaration of `SubscriptionProductReplacementParamsAndroid` to properly resolve imports.
156
160
  namespace margelo::nitro::iap { struct SubscriptionProductReplacementParamsAndroid; }
157
161
  // Forward declaration of `SubscriptionReplacementModeAndroid` to properly resolve imports.
@@ -240,6 +244,8 @@ namespace NitroIap { class HybridRnIapSpec_cxx; }
240
244
  #include "RenewalInfoIOS.hpp"
241
245
  #include "SubResponseCodeAndroid.hpp"
242
246
  #include "SubscriptionBillingPlanTypeIOS.hpp"
247
+ #include "SubscriptionPeriodIOS.hpp"
248
+ #include "SubscriptionPeriodValueIOS.hpp"
243
249
  #include "SubscriptionProductReplacementParamsAndroid.hpp"
244
250
  #include "SubscriptionReplacementModeAndroid.hpp"
245
251
  #include "TransactionCommitmentInfoIOS.hpp"
@@ -795,6 +801,50 @@ namespace margelo::nitro::iap::bridge::swift {
795
801
  return vector;
796
802
  }
797
803
 
804
+ // pragma MARK: std::variant<nitro::NullType, SubscriptionPeriodValueIOS>
805
+ /**
806
+ * Wrapper struct for `std::variant<nitro::NullType, SubscriptionPeriodValueIOS>`.
807
+ * std::variant cannot be used in Swift because of a Swift bug.
808
+ * Not even specializing it works. So we create a wrapper struct.
809
+ */
810
+ struct std__variant_nitro__NullType__SubscriptionPeriodValueIOS_ final {
811
+ std::variant<nitro::NullType, SubscriptionPeriodValueIOS> variant;
812
+ std__variant_nitro__NullType__SubscriptionPeriodValueIOS_(std::variant<nitro::NullType, SubscriptionPeriodValueIOS> variant): variant(variant) { }
813
+ operator std::variant<nitro::NullType, SubscriptionPeriodValueIOS>() const noexcept {
814
+ return variant;
815
+ }
816
+ inline size_t index() const noexcept {
817
+ return variant.index();
818
+ }
819
+ inline nitro::NullType get_0() const noexcept {
820
+ return std::get<0>(variant);
821
+ }
822
+ inline SubscriptionPeriodValueIOS get_1() const noexcept {
823
+ return std::get<1>(variant);
824
+ }
825
+ };
826
+ inline std__variant_nitro__NullType__SubscriptionPeriodValueIOS_ create_std__variant_nitro__NullType__SubscriptionPeriodValueIOS_(nitro::NullType value) noexcept {
827
+ return std__variant_nitro__NullType__SubscriptionPeriodValueIOS_(value);
828
+ }
829
+ inline std__variant_nitro__NullType__SubscriptionPeriodValueIOS_ create_std__variant_nitro__NullType__SubscriptionPeriodValueIOS_(const SubscriptionPeriodValueIOS& value) noexcept {
830
+ return std__variant_nitro__NullType__SubscriptionPeriodValueIOS_(value);
831
+ }
832
+
833
+ // pragma MARK: std::optional<std::variant<nitro::NullType, SubscriptionPeriodValueIOS>>
834
+ /**
835
+ * Specialized version of `std::optional<std::variant<nitro::NullType, SubscriptionPeriodValueIOS>>`.
836
+ */
837
+ using std__optional_std__variant_nitro__NullType__SubscriptionPeriodValueIOS__ = std::optional<std::variant<nitro::NullType, SubscriptionPeriodValueIOS>>;
838
+ inline std::optional<std::variant<nitro::NullType, SubscriptionPeriodValueIOS>> create_std__optional_std__variant_nitro__NullType__SubscriptionPeriodValueIOS__(const std::variant<nitro::NullType, SubscriptionPeriodValueIOS>& value) noexcept {
839
+ return std::optional<std::variant<nitro::NullType, SubscriptionPeriodValueIOS>>(value);
840
+ }
841
+ inline bool has_value_std__optional_std__variant_nitro__NullType__SubscriptionPeriodValueIOS__(const std::optional<std::variant<nitro::NullType, SubscriptionPeriodValueIOS>>& optional) noexcept {
842
+ return optional.has_value();
843
+ }
844
+ inline std::variant<nitro::NullType, SubscriptionPeriodValueIOS> get_std__optional_std__variant_nitro__NullType__SubscriptionPeriodValueIOS__(const std::optional<std::variant<nitro::NullType, SubscriptionPeriodValueIOS>>& optional) noexcept {
845
+ return optional.value();
846
+ }
847
+
798
848
  // pragma MARK: std::variant<nitro::NullType, AdvancedCommerceInfoIOS>
799
849
  /**
800
850
  * Wrapper struct for `std::variant<nitro::NullType, AdvancedCommerceInfoIOS>`.
@@ -178,6 +178,10 @@ namespace margelo::nitro::iap { struct RenewalInfoIOS; }
178
178
  namespace margelo::nitro::iap { enum class SubResponseCodeAndroid; }
179
179
  // Forward declaration of `SubscriptionBillingPlanTypeIOS` to properly resolve imports.
180
180
  namespace margelo::nitro::iap { enum class SubscriptionBillingPlanTypeIOS; }
181
+ // Forward declaration of `SubscriptionPeriodIOS` to properly resolve imports.
182
+ namespace margelo::nitro::iap { enum class SubscriptionPeriodIOS; }
183
+ // Forward declaration of `SubscriptionPeriodValueIOS` to properly resolve imports.
184
+ namespace margelo::nitro::iap { struct SubscriptionPeriodValueIOS; }
181
185
  // Forward declaration of `SubscriptionProductReplacementParamsAndroid` to properly resolve imports.
182
186
  namespace margelo::nitro::iap { struct SubscriptionProductReplacementParamsAndroid; }
183
187
  // Forward declaration of `SubscriptionReplacementModeAndroid` to properly resolve imports.
@@ -275,6 +279,8 @@ namespace margelo::nitro::iap { struct WinBackOfferInputIOS; }
275
279
  #include "RenewalInfoIOS.hpp"
276
280
  #include "SubResponseCodeAndroid.hpp"
277
281
  #include "SubscriptionBillingPlanTypeIOS.hpp"
282
+ #include "SubscriptionPeriodIOS.hpp"
283
+ #include "SubscriptionPeriodValueIOS.hpp"
278
284
  #include "SubscriptionProductReplacementParamsAndroid.hpp"
279
285
  #include "SubscriptionReplacementModeAndroid.hpp"
280
286
  #include "TransactionCommitmentInfoIOS.hpp"
@@ -42,6 +42,10 @@ namespace margelo::nitro::iap { struct AdvancedCommerceItemIOS; }
42
42
  namespace margelo::nitro::iap { struct AdvancedCommerceItemDetailsIOS; }
43
43
  // Forward declaration of `AdvancedCommerceRefundIOS` to properly resolve imports.
44
44
  namespace margelo::nitro::iap { struct AdvancedCommerceRefundIOS; }
45
+ // Forward declaration of `SubscriptionPeriodValueIOS` to properly resolve imports.
46
+ namespace margelo::nitro::iap { struct SubscriptionPeriodValueIOS; }
47
+ // Forward declaration of `SubscriptionPeriodIOS` to properly resolve imports.
48
+ namespace margelo::nitro::iap { enum class SubscriptionPeriodIOS; }
45
49
  // Forward declaration of `SubscriptionBillingPlanTypeIOS` to properly resolve imports.
46
50
  namespace margelo::nitro::iap { enum class SubscriptionBillingPlanTypeIOS; }
47
51
  // Forward declaration of `TransactionCommitmentInfoIOS` to properly resolve imports.
@@ -212,6 +216,8 @@ namespace margelo::nitro::iap { enum class ExternalPurchaseCustomLinkNoticeTypeI
212
216
  #include "AdvancedCommerceItemIOS.hpp"
213
217
  #include "AdvancedCommerceItemDetailsIOS.hpp"
214
218
  #include "AdvancedCommerceRefundIOS.hpp"
219
+ #include "SubscriptionPeriodValueIOS.hpp"
220
+ #include "SubscriptionPeriodIOS.hpp"
215
221
  #include "SubscriptionBillingPlanTypeIOS.hpp"
216
222
  #include "TransactionCommitmentInfoIOS.hpp"
217
223
  #include "PurchaseOfferIOS.hpp"
@@ -18,7 +18,7 @@ public extension AdvancedCommerceInfoIOS {
18
18
  /**
19
19
  * Create a new instance of `AdvancedCommerceInfoIOS`.
20
20
  */
21
- init(description: Variant_NullType_String?, displayName: Variant_NullType_String?, estimatedTax: Variant_NullType_String?, items: [AdvancedCommerceItemIOS], requestReferenceId: Variant_NullType_String?, taxCode: Variant_NullType_String?, taxExclusivePrice: Variant_NullType_String?, taxRate: Variant_NullType_String?) {
21
+ init(description: Variant_NullType_String?, displayName: Variant_NullType_String?, estimatedTax: Variant_NullType_String?, items: [AdvancedCommerceItemIOS], period: Variant_NullType_SubscriptionPeriodValueIOS?, requestReferenceId: Variant_NullType_String?, taxCode: Variant_NullType_String?, taxExclusivePrice: Variant_NullType_String?, taxRate: Variant_NullType_String?) {
22
22
  self.init({ () -> bridge.std__optional_std__variant_nitro__NullType__std__string__ in
23
23
  if let __unwrappedValue = description {
24
24
  return bridge.create_std__optional_std__variant_nitro__NullType__std__string__({ () -> bridge.std__variant_nitro__NullType__std__string_ in
@@ -64,6 +64,19 @@ public extension AdvancedCommerceInfoIOS {
64
64
  __vector.push_back(__item)
65
65
  }
66
66
  return __vector
67
+ }(), { () -> bridge.std__optional_std__variant_nitro__NullType__SubscriptionPeriodValueIOS__ in
68
+ if let __unwrappedValue = period {
69
+ return bridge.create_std__optional_std__variant_nitro__NullType__SubscriptionPeriodValueIOS__({ () -> bridge.std__variant_nitro__NullType__SubscriptionPeriodValueIOS_ in
70
+ switch __unwrappedValue {
71
+ case .first(let __value):
72
+ return bridge.create_std__variant_nitro__NullType__SubscriptionPeriodValueIOS_(margelo.nitro.NullType.null)
73
+ case .second(let __value):
74
+ return bridge.create_std__variant_nitro__NullType__SubscriptionPeriodValueIOS_(__value)
75
+ }
76
+ }().variant)
77
+ } else {
78
+ return .init()
79
+ }
67
80
  }(), { () -> bridge.std__optional_std__variant_nitro__NullType__std__string__ in
68
81
  if let __unwrappedValue = requestReferenceId {
69
82
  return bridge.create_std__optional_std__variant_nitro__NullType__std__string__({ () -> bridge.std__variant_nitro__NullType__std__string_ in
@@ -196,6 +209,30 @@ public extension AdvancedCommerceInfoIOS {
196
209
  return self.__items.map({ __item in __item })
197
210
  }
198
211
 
212
+ @inline(__always)
213
+ var period: Variant_NullType_SubscriptionPeriodValueIOS? {
214
+ return { () -> Variant_NullType_SubscriptionPeriodValueIOS? in
215
+ if bridge.has_value_std__optional_std__variant_nitro__NullType__SubscriptionPeriodValueIOS__(self.__period) {
216
+ let __unwrapped = bridge.get_std__optional_std__variant_nitro__NullType__SubscriptionPeriodValueIOS__(self.__period)
217
+ return { () -> Variant_NullType_SubscriptionPeriodValueIOS in
218
+ let __variant = bridge.std__variant_nitro__NullType__SubscriptionPeriodValueIOS_(__unwrapped)
219
+ switch __variant.index() {
220
+ case 0:
221
+ let __actual = __variant.get_0()
222
+ return .first(NullType.null)
223
+ case 1:
224
+ let __actual = __variant.get_1()
225
+ return .second(__actual)
226
+ default:
227
+ fatalError("Variant can never have index \(__variant.index())!")
228
+ }
229
+ }()
230
+ } else {
231
+ return nil
232
+ }
233
+ }()
234
+ }
235
+
199
236
  @inline(__always)
200
237
  var requestReferenceId: Variant_NullType_String? {
201
238
  return { () -> Variant_NullType_String? in
@@ -0,0 +1,52 @@
1
+ ///
2
+ /// SubscriptionPeriodIOS.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ /**
9
+ * Represents the JS union `SubscriptionPeriodIOS`, backed by a C++ enum.
10
+ */
11
+ public typealias SubscriptionPeriodIOS = margelo.nitro.iap.SubscriptionPeriodIOS
12
+
13
+ public extension SubscriptionPeriodIOS {
14
+ /**
15
+ * Get a SubscriptionPeriodIOS for the given String value, or
16
+ * return `nil` if the given value was invalid/unknown.
17
+ */
18
+ init?(fromString string: String) {
19
+ switch string {
20
+ case "empty":
21
+ self = .empty
22
+ case "day":
23
+ self = .day
24
+ case "week":
25
+ self = .week
26
+ case "month":
27
+ self = .month
28
+ case "year":
29
+ self = .year
30
+ default:
31
+ return nil
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Get the String value this SubscriptionPeriodIOS represents.
37
+ */
38
+ var stringValue: String {
39
+ switch self {
40
+ case .empty:
41
+ return "empty"
42
+ case .day:
43
+ return "day"
44
+ case .week:
45
+ return "week"
46
+ case .month:
47
+ return "month"
48
+ case .year:
49
+ return "year"
50
+ }
51
+ }
52
+ }
@@ -0,0 +1,34 @@
1
+ ///
2
+ /// SubscriptionPeriodValueIOS.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /**
11
+ * Represents an instance of `SubscriptionPeriodValueIOS`, backed by a C++ struct.
12
+ */
13
+ public typealias SubscriptionPeriodValueIOS = margelo.nitro.iap.SubscriptionPeriodValueIOS
14
+
15
+ public extension SubscriptionPeriodValueIOS {
16
+ private typealias bridge = margelo.nitro.iap.bridge.swift
17
+
18
+ /**
19
+ * Create a new instance of `SubscriptionPeriodValueIOS`.
20
+ */
21
+ init(unit: SubscriptionPeriodIOS, value: Double) {
22
+ self.init(unit, value)
23
+ }
24
+
25
+ @inline(__always)
26
+ var unit: SubscriptionPeriodIOS {
27
+ return self.__unit
28
+ }
29
+
30
+ @inline(__always)
31
+ var value: Double {
32
+ return self.__value
33
+ }
34
+ }
@@ -0,0 +1,30 @@
1
+ ///
2
+ /// Variant_NullType_SubscriptionPeriodValueIOS.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /**
11
+ * An Swift enum with associated values representing a Variant/Union type.
12
+ * JS type: `null | struct`
13
+ */
14
+ @frozen
15
+ public indirect enum Variant_NullType_SubscriptionPeriodValueIOS {
16
+ case first(NullType)
17
+ case second(SubscriptionPeriodValueIOS)
18
+ }
19
+
20
+ public extension Variant_NullType_SubscriptionPeriodValueIOS {
21
+ func asType<T>(_ type: T.Type = T.self) -> T? {
22
+ switch self {
23
+ case .first(let value): return value as? T
24
+ case .second(let value): return value as? T
25
+ }
26
+ }
27
+ func isType<T>(_ type: T.Type = T.self) -> Bool {
28
+ return self.asType(type) != nil
29
+ }
30
+ }
@@ -30,6 +30,8 @@
30
30
 
31
31
  // Forward declaration of `AdvancedCommerceItemIOS` to properly resolve imports.
32
32
  namespace margelo::nitro::iap { struct AdvancedCommerceItemIOS; }
33
+ // Forward declaration of `SubscriptionPeriodValueIOS` to properly resolve imports.
34
+ namespace margelo::nitro::iap { struct SubscriptionPeriodValueIOS; }
33
35
 
34
36
  #include <NitroModules/Null.hpp>
35
37
  #include <string>
@@ -37,6 +39,7 @@ namespace margelo::nitro::iap { struct AdvancedCommerceItemIOS; }
37
39
  #include <optional>
38
40
  #include "AdvancedCommerceItemIOS.hpp"
39
41
  #include <vector>
42
+ #include "SubscriptionPeriodValueIOS.hpp"
40
43
 
41
44
  namespace margelo::nitro::iap {
42
45
 
@@ -49,6 +52,7 @@ namespace margelo::nitro::iap {
49
52
  std::optional<std::variant<nitro::NullType, std::string>> displayName SWIFT_PRIVATE;
50
53
  std::optional<std::variant<nitro::NullType, std::string>> estimatedTax SWIFT_PRIVATE;
51
54
  std::vector<AdvancedCommerceItemIOS> items SWIFT_PRIVATE;
55
+ std::optional<std::variant<nitro::NullType, SubscriptionPeriodValueIOS>> period SWIFT_PRIVATE;
52
56
  std::optional<std::variant<nitro::NullType, std::string>> requestReferenceId SWIFT_PRIVATE;
53
57
  std::optional<std::variant<nitro::NullType, std::string>> taxCode SWIFT_PRIVATE;
54
58
  std::optional<std::variant<nitro::NullType, std::string>> taxExclusivePrice SWIFT_PRIVATE;
@@ -56,7 +60,7 @@ namespace margelo::nitro::iap {
56
60
 
57
61
  public:
58
62
  AdvancedCommerceInfoIOS() = default;
59
- explicit AdvancedCommerceInfoIOS(std::optional<std::variant<nitro::NullType, std::string>> description, std::optional<std::variant<nitro::NullType, std::string>> displayName, std::optional<std::variant<nitro::NullType, std::string>> estimatedTax, std::vector<AdvancedCommerceItemIOS> items, std::optional<std::variant<nitro::NullType, std::string>> requestReferenceId, std::optional<std::variant<nitro::NullType, std::string>> taxCode, std::optional<std::variant<nitro::NullType, std::string>> taxExclusivePrice, std::optional<std::variant<nitro::NullType, std::string>> taxRate): description(description), displayName(displayName), estimatedTax(estimatedTax), items(items), requestReferenceId(requestReferenceId), taxCode(taxCode), taxExclusivePrice(taxExclusivePrice), taxRate(taxRate) {}
63
+ explicit AdvancedCommerceInfoIOS(std::optional<std::variant<nitro::NullType, std::string>> description, std::optional<std::variant<nitro::NullType, std::string>> displayName, std::optional<std::variant<nitro::NullType, std::string>> estimatedTax, std::vector<AdvancedCommerceItemIOS> items, std::optional<std::variant<nitro::NullType, SubscriptionPeriodValueIOS>> period, std::optional<std::variant<nitro::NullType, std::string>> requestReferenceId, std::optional<std::variant<nitro::NullType, std::string>> taxCode, std::optional<std::variant<nitro::NullType, std::string>> taxExclusivePrice, std::optional<std::variant<nitro::NullType, std::string>> taxRate): description(description), displayName(displayName), estimatedTax(estimatedTax), items(items), period(period), requestReferenceId(requestReferenceId), taxCode(taxCode), taxExclusivePrice(taxExclusivePrice), taxRate(taxRate) {}
60
64
 
61
65
  public:
62
66
  // AdvancedCommerceInfoIOS is not equatable because these properties are not equatable: items
@@ -76,6 +80,7 @@ namespace margelo::nitro {
76
80
  JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "displayName"))),
77
81
  JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "estimatedTax"))),
78
82
  JSIConverter<std::vector<margelo::nitro::iap::AdvancedCommerceItemIOS>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "items"))),
83
+ JSIConverter<std::optional<std::variant<nitro::NullType, margelo::nitro::iap::SubscriptionPeriodValueIOS>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "period"))),
79
84
  JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "requestReferenceId"))),
80
85
  JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "taxCode"))),
81
86
  JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "taxExclusivePrice"))),
@@ -88,6 +93,7 @@ namespace margelo::nitro {
88
93
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "displayName"), JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::toJSI(runtime, arg.displayName));
89
94
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "estimatedTax"), JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::toJSI(runtime, arg.estimatedTax));
90
95
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "items"), JSIConverter<std::vector<margelo::nitro::iap::AdvancedCommerceItemIOS>>::toJSI(runtime, arg.items));
96
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "period"), JSIConverter<std::optional<std::variant<nitro::NullType, margelo::nitro::iap::SubscriptionPeriodValueIOS>>>::toJSI(runtime, arg.period));
91
97
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "requestReferenceId"), JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::toJSI(runtime, arg.requestReferenceId));
92
98
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "taxCode"), JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::toJSI(runtime, arg.taxCode));
93
99
  obj.setProperty(runtime, PropNameIDCache::get(runtime, "taxExclusivePrice"), JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::toJSI(runtime, arg.taxExclusivePrice));
@@ -106,6 +112,7 @@ namespace margelo::nitro {
106
112
  if (!JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "displayName")))) return false;
107
113
  if (!JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "estimatedTax")))) return false;
108
114
  if (!JSIConverter<std::vector<margelo::nitro::iap::AdvancedCommerceItemIOS>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "items")))) return false;
115
+ if (!JSIConverter<std::optional<std::variant<nitro::NullType, margelo::nitro::iap::SubscriptionPeriodValueIOS>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "period")))) return false;
109
116
  if (!JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "requestReferenceId")))) return false;
110
117
  if (!JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "taxCode")))) return false;
111
118
  if (!JSIConverter<std::optional<std::variant<nitro::NullType, std::string>>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "taxExclusivePrice")))) return false;
@@ -0,0 +1,88 @@
1
+ ///
2
+ /// SubscriptionPeriodIOS.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/NitroHash.hpp>)
11
+ #include <NitroModules/NitroHash.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
16
+ #include <NitroModules/JSIConverter.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
21
+ #include <NitroModules/NitroDefines.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+
26
+ namespace margelo::nitro::iap {
27
+
28
+ /**
29
+ * An enum which can be represented as a JavaScript union (SubscriptionPeriodIOS).
30
+ */
31
+ enum class SubscriptionPeriodIOS {
32
+ EMPTY SWIFT_NAME(empty) = 0,
33
+ DAY SWIFT_NAME(day) = 1,
34
+ WEEK SWIFT_NAME(week) = 2,
35
+ MONTH SWIFT_NAME(month) = 3,
36
+ YEAR SWIFT_NAME(year) = 4,
37
+ } CLOSED_ENUM;
38
+
39
+ } // namespace margelo::nitro::iap
40
+
41
+ namespace margelo::nitro {
42
+
43
+ // C++ SubscriptionPeriodIOS <> JS SubscriptionPeriodIOS (union)
44
+ template <>
45
+ struct JSIConverter<margelo::nitro::iap::SubscriptionPeriodIOS> final {
46
+ static inline margelo::nitro::iap::SubscriptionPeriodIOS fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
47
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
48
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
49
+ case hashString("empty"): return margelo::nitro::iap::SubscriptionPeriodIOS::EMPTY;
50
+ case hashString("day"): return margelo::nitro::iap::SubscriptionPeriodIOS::DAY;
51
+ case hashString("week"): return margelo::nitro::iap::SubscriptionPeriodIOS::WEEK;
52
+ case hashString("month"): return margelo::nitro::iap::SubscriptionPeriodIOS::MONTH;
53
+ case hashString("year"): return margelo::nitro::iap::SubscriptionPeriodIOS::YEAR;
54
+ default: [[unlikely]]
55
+ throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum SubscriptionPeriodIOS - invalid value!");
56
+ }
57
+ }
58
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::iap::SubscriptionPeriodIOS arg) {
59
+ switch (arg) {
60
+ case margelo::nitro::iap::SubscriptionPeriodIOS::EMPTY: return JSIConverter<std::string>::toJSI(runtime, "empty");
61
+ case margelo::nitro::iap::SubscriptionPeriodIOS::DAY: return JSIConverter<std::string>::toJSI(runtime, "day");
62
+ case margelo::nitro::iap::SubscriptionPeriodIOS::WEEK: return JSIConverter<std::string>::toJSI(runtime, "week");
63
+ case margelo::nitro::iap::SubscriptionPeriodIOS::MONTH: return JSIConverter<std::string>::toJSI(runtime, "month");
64
+ case margelo::nitro::iap::SubscriptionPeriodIOS::YEAR: return JSIConverter<std::string>::toJSI(runtime, "year");
65
+ default: [[unlikely]]
66
+ throw std::invalid_argument("Cannot convert SubscriptionPeriodIOS to JS - invalid value: "
67
+ + std::to_string(static_cast<int>(arg)) + "!");
68
+ }
69
+ }
70
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
71
+ if (!value.isString()) {
72
+ return false;
73
+ }
74
+ std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
75
+ switch (hashString(unionValue.c_str(), unionValue.size())) {
76
+ case hashString("empty"):
77
+ case hashString("day"):
78
+ case hashString("week"):
79
+ case hashString("month"):
80
+ case hashString("year"):
81
+ return true;
82
+ default:
83
+ return false;
84
+ }
85
+ }
86
+ };
87
+
88
+ } // namespace margelo::nitro
@@ -0,0 +1,88 @@
1
+ ///
2
+ /// SubscriptionPeriodValueIOS.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
25
+ #if __has_include(<NitroModules/PropNameIDCache.hpp>)
26
+ #include <NitroModules/PropNameIDCache.hpp>
27
+ #else
28
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
29
+ #endif
30
+
31
+ // Forward declaration of `SubscriptionPeriodIOS` to properly resolve imports.
32
+ namespace margelo::nitro::iap { enum class SubscriptionPeriodIOS; }
33
+
34
+ #include "SubscriptionPeriodIOS.hpp"
35
+
36
+ namespace margelo::nitro::iap {
37
+
38
+ /**
39
+ * A struct which can be represented as a JavaScript object (SubscriptionPeriodValueIOS).
40
+ */
41
+ struct SubscriptionPeriodValueIOS final {
42
+ public:
43
+ SubscriptionPeriodIOS unit SWIFT_PRIVATE;
44
+ double value SWIFT_PRIVATE;
45
+
46
+ public:
47
+ SubscriptionPeriodValueIOS() = default;
48
+ explicit SubscriptionPeriodValueIOS(SubscriptionPeriodIOS unit, double value): unit(unit), value(value) {}
49
+
50
+ public:
51
+ friend bool operator==(const SubscriptionPeriodValueIOS& lhs, const SubscriptionPeriodValueIOS& rhs) = default;
52
+ };
53
+
54
+ } // namespace margelo::nitro::iap
55
+
56
+ namespace margelo::nitro {
57
+
58
+ // C++ SubscriptionPeriodValueIOS <> JS SubscriptionPeriodValueIOS (object)
59
+ template <>
60
+ struct JSIConverter<margelo::nitro::iap::SubscriptionPeriodValueIOS> final {
61
+ static inline margelo::nitro::iap::SubscriptionPeriodValueIOS fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
62
+ jsi::Object obj = arg.asObject(runtime);
63
+ return margelo::nitro::iap::SubscriptionPeriodValueIOS(
64
+ JSIConverter<margelo::nitro::iap::SubscriptionPeriodIOS>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "unit"))),
65
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "value")))
66
+ );
67
+ }
68
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::iap::SubscriptionPeriodValueIOS& arg) {
69
+ jsi::Object obj(runtime);
70
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "unit"), JSIConverter<margelo::nitro::iap::SubscriptionPeriodIOS>::toJSI(runtime, arg.unit));
71
+ obj.setProperty(runtime, PropNameIDCache::get(runtime, "value"), JSIConverter<double>::toJSI(runtime, arg.value));
72
+ return obj;
73
+ }
74
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
75
+ if (!value.isObject()) {
76
+ return false;
77
+ }
78
+ jsi::Object obj = value.getObject(runtime);
79
+ if (!nitro::isPlainObject(runtime, obj)) {
80
+ return false;
81
+ }
82
+ if (!JSIConverter<margelo::nitro::iap::SubscriptionPeriodIOS>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "unit")))) return false;
83
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "value")))) return false;
84
+ return true;
85
+ }
86
+ };
87
+
88
+ } // namespace margelo::nitro
@@ -1,5 +1,5 @@
1
1
  {
2
- "spec": "3.0.1",
3
- "google": "3.0.1",
4
- "apple": "3.0.1"
2
+ "spec": "3.1.0",
3
+ "google": "3.2.0",
4
+ "apple": "3.1.0"
5
5
  }