react-native-iap 14.3.4 → 14.3.5
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.
- package/NitroIap.podspec +1 -1
- package/README.md +1 -1
- package/android/CMakeLists.txt +4 -0
- package/android/build.gradle +2 -2
- package/android/src/main/cpp/cpp-adapter.cpp +8 -0
- package/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt +93 -51
- package/ios/HybridRnIap.swift +38 -30
- package/lib/module/hooks/useIAP.js +4 -4
- package/lib/module/hooks/useIAP.js.map +1 -1
- package/lib/module/index.js +54 -53
- package/lib/module/index.js.map +1 -1
- package/lib/module/types.js +1 -59
- package/lib/module/types.js.map +1 -1
- package/lib/module/utils/type-bridge.js +44 -33
- package/lib/module/utils/type-bridge.js.map +1 -1
- package/lib/typescript/src/hooks/useIAP.d.ts +4 -4
- package/lib/typescript/src/hooks/useIAP.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +8 -7
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/RnIap.nitro.d.ts +2 -1
- package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -1
- package/lib/typescript/src/types.d.ts +159 -204
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/lib/typescript/src/utils/type-bridge.d.ts.map +1 -1
- package/nitrogen/generated/android/NitroIap+autolinking.cmake +9 -4
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.cpp +32 -5
- package/nitrogen/generated/android/c++/JHybridRnIapSpec.hpp +1 -1
- package/nitrogen/generated/android/c++/JIapPlatform.hpp +59 -0
- package/nitrogen/generated/android/c++/JPurchase.cpp +26 -0
- package/nitrogen/generated/android/c++/JPurchase.hpp +80 -0
- package/nitrogen/generated/android/c++/JPurchaseAndroid.hpp +140 -0
- package/nitrogen/generated/android/c++/JPurchaseIOS.hpp +194 -0
- package/nitrogen/generated/android/c++/JPurchaseOfferIOS.hpp +61 -0
- package/nitrogen/generated/android/c++/JPurchaseState.hpp +71 -0
- package/nitrogen/generated/android/c++/JRequestPurchaseResult.hpp +89 -0
- package/nitrogen/generated/android/c++/JVariant_PurchaseAndroid_PurchaseIOS.cpp +26 -0
- package/nitrogen/generated/android/c++/JVariant_PurchaseAndroid_PurchaseIOS.hpp +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/HybridRnIapSpec.kt +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/IapPlatform.kt +21 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Purchase.kt +42 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseAndroid.kt +77 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseIOS.kt +116 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseOfferIOS.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseState.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/RequestPurchaseResult.kt +32 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/Variant_PurchaseAndroid_PurchaseIOS.kt +42 -0
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.cpp +13 -5
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.hpp +186 -25
- package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Umbrella.hpp +18 -0
- package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.hpp +20 -2
- package/nitrogen/generated/ios/swift/Func_void_RequestPurchaseResult.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridRnIapSpec.swift +1 -1
- package/nitrogen/generated/ios/swift/HybridRnIapSpec_cxx.swift +7 -7
- package/nitrogen/generated/ios/swift/IapPlatform.swift +40 -0
- package/nitrogen/generated/ios/swift/Purchase.swift +18 -0
- package/nitrogen/generated/ios/swift/PurchaseAndroid.swift +399 -0
- package/nitrogen/generated/ios/swift/PurchaseIOS.swift +768 -0
- package/nitrogen/generated/ios/swift/PurchaseOfferIOS.swift +57 -0
- package/nitrogen/generated/ios/swift/PurchaseState.swift +56 -0
- package/nitrogen/generated/ios/swift/RequestPurchaseResult.swift +148 -0
- package/nitrogen/generated/ios/swift/Variant_PurchaseAndroid_PurchaseIOS.swift +18 -0
- package/nitrogen/generated/shared/c++/HybridRnIapSpec.hpp +4 -1
- package/nitrogen/generated/shared/c++/IapPlatform.hpp +76 -0
- package/nitrogen/generated/shared/c++/PurchaseAndroid.hpp +138 -0
- package/nitrogen/generated/shared/c++/PurchaseIOS.hpp +193 -0
- package/nitrogen/generated/shared/c++/PurchaseOfferIOS.hpp +75 -0
- package/nitrogen/generated/shared/c++/PurchaseState.hpp +92 -0
- package/nitrogen/generated/shared/c++/RequestPurchaseResult.hpp +78 -0
- package/package.json +5 -4
- package/plugin/build/withIAP.js +1 -1
- package/plugin/src/withIAP.ts +1 -1
- package/src/hooks/useIAP.ts +14 -8
- package/src/index.ts +73 -74
- package/src/specs/RnIap.nitro.ts +4 -1
- package/src/types.ts +183 -216
- package/src/utils/type-bridge.ts +55 -43
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JPurchaseIOS.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "PurchaseIOS.hpp"
|
|
12
|
+
|
|
13
|
+
#include "IapPlatform.hpp"
|
|
14
|
+
#include "JIapPlatform.hpp"
|
|
15
|
+
#include "JPurchaseOfferIOS.hpp"
|
|
16
|
+
#include "JPurchaseState.hpp"
|
|
17
|
+
#include "PurchaseOfferIOS.hpp"
|
|
18
|
+
#include "PurchaseState.hpp"
|
|
19
|
+
#include <optional>
|
|
20
|
+
#include <string>
|
|
21
|
+
#include <vector>
|
|
22
|
+
|
|
23
|
+
namespace margelo::nitro::iap {
|
|
24
|
+
|
|
25
|
+
using namespace facebook;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The C++ JNI bridge between the C++ struct "PurchaseIOS" and the the Kotlin data class "PurchaseIOS".
|
|
29
|
+
*/
|
|
30
|
+
struct JPurchaseIOS final: public jni::JavaClass<JPurchaseIOS> {
|
|
31
|
+
public:
|
|
32
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/iap/PurchaseIOS;";
|
|
33
|
+
|
|
34
|
+
public:
|
|
35
|
+
/**
|
|
36
|
+
* Convert this Java/Kotlin-based struct to the C++ struct PurchaseIOS by copying all values to C++.
|
|
37
|
+
*/
|
|
38
|
+
[[maybe_unused]]
|
|
39
|
+
[[nodiscard]]
|
|
40
|
+
PurchaseIOS toCpp() const {
|
|
41
|
+
static const auto clazz = javaClassStatic();
|
|
42
|
+
static const auto fieldAppAccountToken = clazz->getField<jni::JString>("appAccountToken");
|
|
43
|
+
jni::local_ref<jni::JString> appAccountToken = this->getFieldValue(fieldAppAccountToken);
|
|
44
|
+
static const auto fieldAppBundleIdIOS = clazz->getField<jni::JString>("appBundleIdIOS");
|
|
45
|
+
jni::local_ref<jni::JString> appBundleIdIOS = this->getFieldValue(fieldAppBundleIdIOS);
|
|
46
|
+
static const auto fieldCountryCodeIOS = clazz->getField<jni::JString>("countryCodeIOS");
|
|
47
|
+
jni::local_ref<jni::JString> countryCodeIOS = this->getFieldValue(fieldCountryCodeIOS);
|
|
48
|
+
static const auto fieldCurrencyCodeIOS = clazz->getField<jni::JString>("currencyCodeIOS");
|
|
49
|
+
jni::local_ref<jni::JString> currencyCodeIOS = this->getFieldValue(fieldCurrencyCodeIOS);
|
|
50
|
+
static const auto fieldCurrencySymbolIOS = clazz->getField<jni::JString>("currencySymbolIOS");
|
|
51
|
+
jni::local_ref<jni::JString> currencySymbolIOS = this->getFieldValue(fieldCurrencySymbolIOS);
|
|
52
|
+
static const auto fieldEnvironmentIOS = clazz->getField<jni::JString>("environmentIOS");
|
|
53
|
+
jni::local_ref<jni::JString> environmentIOS = this->getFieldValue(fieldEnvironmentIOS);
|
|
54
|
+
static const auto fieldExpirationDateIOS = clazz->getField<jni::JDouble>("expirationDateIOS");
|
|
55
|
+
jni::local_ref<jni::JDouble> expirationDateIOS = this->getFieldValue(fieldExpirationDateIOS);
|
|
56
|
+
static const auto fieldId = clazz->getField<jni::JString>("id");
|
|
57
|
+
jni::local_ref<jni::JString> id = this->getFieldValue(fieldId);
|
|
58
|
+
static const auto fieldIds = clazz->getField<jni::JArrayClass<jni::JString>>("ids");
|
|
59
|
+
jni::local_ref<jni::JArrayClass<jni::JString>> ids = this->getFieldValue(fieldIds);
|
|
60
|
+
static const auto fieldIsAutoRenewing = clazz->getField<jboolean>("isAutoRenewing");
|
|
61
|
+
jboolean isAutoRenewing = this->getFieldValue(fieldIsAutoRenewing);
|
|
62
|
+
static const auto fieldIsUpgradedIOS = clazz->getField<jni::JBoolean>("isUpgradedIOS");
|
|
63
|
+
jni::local_ref<jni::JBoolean> isUpgradedIOS = this->getFieldValue(fieldIsUpgradedIOS);
|
|
64
|
+
static const auto fieldOfferIOS = clazz->getField<JPurchaseOfferIOS>("offerIOS");
|
|
65
|
+
jni::local_ref<JPurchaseOfferIOS> offerIOS = this->getFieldValue(fieldOfferIOS);
|
|
66
|
+
static const auto fieldOriginalTransactionDateIOS = clazz->getField<jni::JDouble>("originalTransactionDateIOS");
|
|
67
|
+
jni::local_ref<jni::JDouble> originalTransactionDateIOS = this->getFieldValue(fieldOriginalTransactionDateIOS);
|
|
68
|
+
static const auto fieldOriginalTransactionIdentifierIOS = clazz->getField<jni::JString>("originalTransactionIdentifierIOS");
|
|
69
|
+
jni::local_ref<jni::JString> originalTransactionIdentifierIOS = this->getFieldValue(fieldOriginalTransactionIdentifierIOS);
|
|
70
|
+
static const auto fieldOwnershipTypeIOS = clazz->getField<jni::JString>("ownershipTypeIOS");
|
|
71
|
+
jni::local_ref<jni::JString> ownershipTypeIOS = this->getFieldValue(fieldOwnershipTypeIOS);
|
|
72
|
+
static const auto fieldPlatform = clazz->getField<JIapPlatform>("platform");
|
|
73
|
+
jni::local_ref<JIapPlatform> platform = this->getFieldValue(fieldPlatform);
|
|
74
|
+
static const auto fieldProductId = clazz->getField<jni::JString>("productId");
|
|
75
|
+
jni::local_ref<jni::JString> productId = this->getFieldValue(fieldProductId);
|
|
76
|
+
static const auto fieldPurchaseState = clazz->getField<JPurchaseState>("purchaseState");
|
|
77
|
+
jni::local_ref<JPurchaseState> purchaseState = this->getFieldValue(fieldPurchaseState);
|
|
78
|
+
static const auto fieldPurchaseToken = clazz->getField<jni::JString>("purchaseToken");
|
|
79
|
+
jni::local_ref<jni::JString> purchaseToken = this->getFieldValue(fieldPurchaseToken);
|
|
80
|
+
static const auto fieldQuantity = clazz->getField<double>("quantity");
|
|
81
|
+
double quantity = this->getFieldValue(fieldQuantity);
|
|
82
|
+
static const auto fieldQuantityIOS = clazz->getField<jni::JDouble>("quantityIOS");
|
|
83
|
+
jni::local_ref<jni::JDouble> quantityIOS = this->getFieldValue(fieldQuantityIOS);
|
|
84
|
+
static const auto fieldReasonIOS = clazz->getField<jni::JString>("reasonIOS");
|
|
85
|
+
jni::local_ref<jni::JString> reasonIOS = this->getFieldValue(fieldReasonIOS);
|
|
86
|
+
static const auto fieldReasonStringRepresentationIOS = clazz->getField<jni::JString>("reasonStringRepresentationIOS");
|
|
87
|
+
jni::local_ref<jni::JString> reasonStringRepresentationIOS = this->getFieldValue(fieldReasonStringRepresentationIOS);
|
|
88
|
+
static const auto fieldRevocationDateIOS = clazz->getField<jni::JDouble>("revocationDateIOS");
|
|
89
|
+
jni::local_ref<jni::JDouble> revocationDateIOS = this->getFieldValue(fieldRevocationDateIOS);
|
|
90
|
+
static const auto fieldRevocationReasonIOS = clazz->getField<jni::JString>("revocationReasonIOS");
|
|
91
|
+
jni::local_ref<jni::JString> revocationReasonIOS = this->getFieldValue(fieldRevocationReasonIOS);
|
|
92
|
+
static const auto fieldStorefrontCountryCodeIOS = clazz->getField<jni::JString>("storefrontCountryCodeIOS");
|
|
93
|
+
jni::local_ref<jni::JString> storefrontCountryCodeIOS = this->getFieldValue(fieldStorefrontCountryCodeIOS);
|
|
94
|
+
static const auto fieldSubscriptionGroupIdIOS = clazz->getField<jni::JString>("subscriptionGroupIdIOS");
|
|
95
|
+
jni::local_ref<jni::JString> subscriptionGroupIdIOS = this->getFieldValue(fieldSubscriptionGroupIdIOS);
|
|
96
|
+
static const auto fieldTransactionDate = clazz->getField<double>("transactionDate");
|
|
97
|
+
double transactionDate = this->getFieldValue(fieldTransactionDate);
|
|
98
|
+
static const auto fieldTransactionReasonIOS = clazz->getField<jni::JString>("transactionReasonIOS");
|
|
99
|
+
jni::local_ref<jni::JString> transactionReasonIOS = this->getFieldValue(fieldTransactionReasonIOS);
|
|
100
|
+
static const auto fieldWebOrderLineItemIdIOS = clazz->getField<jni::JString>("webOrderLineItemIdIOS");
|
|
101
|
+
jni::local_ref<jni::JString> webOrderLineItemIdIOS = this->getFieldValue(fieldWebOrderLineItemIdIOS);
|
|
102
|
+
return PurchaseIOS(
|
|
103
|
+
appAccountToken != nullptr ? std::make_optional(appAccountToken->toStdString()) : std::nullopt,
|
|
104
|
+
appBundleIdIOS != nullptr ? std::make_optional(appBundleIdIOS->toStdString()) : std::nullopt,
|
|
105
|
+
countryCodeIOS != nullptr ? std::make_optional(countryCodeIOS->toStdString()) : std::nullopt,
|
|
106
|
+
currencyCodeIOS != nullptr ? std::make_optional(currencyCodeIOS->toStdString()) : std::nullopt,
|
|
107
|
+
currencySymbolIOS != nullptr ? std::make_optional(currencySymbolIOS->toStdString()) : std::nullopt,
|
|
108
|
+
environmentIOS != nullptr ? std::make_optional(environmentIOS->toStdString()) : std::nullopt,
|
|
109
|
+
expirationDateIOS != nullptr ? std::make_optional(expirationDateIOS->value()) : std::nullopt,
|
|
110
|
+
id->toStdString(),
|
|
111
|
+
ids != nullptr ? std::make_optional([&]() {
|
|
112
|
+
size_t __size = ids->size();
|
|
113
|
+
std::vector<std::string> __vector;
|
|
114
|
+
__vector.reserve(__size);
|
|
115
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
116
|
+
auto __element = ids->getElement(__i);
|
|
117
|
+
__vector.push_back(__element->toStdString());
|
|
118
|
+
}
|
|
119
|
+
return __vector;
|
|
120
|
+
}()) : std::nullopt,
|
|
121
|
+
static_cast<bool>(isAutoRenewing),
|
|
122
|
+
isUpgradedIOS != nullptr ? std::make_optional(static_cast<bool>(isUpgradedIOS->value())) : std::nullopt,
|
|
123
|
+
offerIOS != nullptr ? std::make_optional(offerIOS->toCpp()) : std::nullopt,
|
|
124
|
+
originalTransactionDateIOS != nullptr ? std::make_optional(originalTransactionDateIOS->value()) : std::nullopt,
|
|
125
|
+
originalTransactionIdentifierIOS != nullptr ? std::make_optional(originalTransactionIdentifierIOS->toStdString()) : std::nullopt,
|
|
126
|
+
ownershipTypeIOS != nullptr ? std::make_optional(ownershipTypeIOS->toStdString()) : std::nullopt,
|
|
127
|
+
platform->toCpp(),
|
|
128
|
+
productId->toStdString(),
|
|
129
|
+
purchaseState->toCpp(),
|
|
130
|
+
purchaseToken != nullptr ? std::make_optional(purchaseToken->toStdString()) : std::nullopt,
|
|
131
|
+
quantity,
|
|
132
|
+
quantityIOS != nullptr ? std::make_optional(quantityIOS->value()) : std::nullopt,
|
|
133
|
+
reasonIOS != nullptr ? std::make_optional(reasonIOS->toStdString()) : std::nullopt,
|
|
134
|
+
reasonStringRepresentationIOS != nullptr ? std::make_optional(reasonStringRepresentationIOS->toStdString()) : std::nullopt,
|
|
135
|
+
revocationDateIOS != nullptr ? std::make_optional(revocationDateIOS->value()) : std::nullopt,
|
|
136
|
+
revocationReasonIOS != nullptr ? std::make_optional(revocationReasonIOS->toStdString()) : std::nullopt,
|
|
137
|
+
storefrontCountryCodeIOS != nullptr ? std::make_optional(storefrontCountryCodeIOS->toStdString()) : std::nullopt,
|
|
138
|
+
subscriptionGroupIdIOS != nullptr ? std::make_optional(subscriptionGroupIdIOS->toStdString()) : std::nullopt,
|
|
139
|
+
transactionDate,
|
|
140
|
+
transactionReasonIOS != nullptr ? std::make_optional(transactionReasonIOS->toStdString()) : std::nullopt,
|
|
141
|
+
webOrderLineItemIdIOS != nullptr ? std::make_optional(webOrderLineItemIdIOS->toStdString()) : std::nullopt
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
public:
|
|
146
|
+
/**
|
|
147
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
148
|
+
*/
|
|
149
|
+
[[maybe_unused]]
|
|
150
|
+
static jni::local_ref<JPurchaseIOS::javaobject> fromCpp(const PurchaseIOS& value) {
|
|
151
|
+
return newInstance(
|
|
152
|
+
value.appAccountToken.has_value() ? jni::make_jstring(value.appAccountToken.value()) : nullptr,
|
|
153
|
+
value.appBundleIdIOS.has_value() ? jni::make_jstring(value.appBundleIdIOS.value()) : nullptr,
|
|
154
|
+
value.countryCodeIOS.has_value() ? jni::make_jstring(value.countryCodeIOS.value()) : nullptr,
|
|
155
|
+
value.currencyCodeIOS.has_value() ? jni::make_jstring(value.currencyCodeIOS.value()) : nullptr,
|
|
156
|
+
value.currencySymbolIOS.has_value() ? jni::make_jstring(value.currencySymbolIOS.value()) : nullptr,
|
|
157
|
+
value.environmentIOS.has_value() ? jni::make_jstring(value.environmentIOS.value()) : nullptr,
|
|
158
|
+
value.expirationDateIOS.has_value() ? jni::JDouble::valueOf(value.expirationDateIOS.value()) : nullptr,
|
|
159
|
+
jni::make_jstring(value.id),
|
|
160
|
+
value.ids.has_value() ? [&]() {
|
|
161
|
+
size_t __size = value.ids.value().size();
|
|
162
|
+
jni::local_ref<jni::JArrayClass<jni::JString>> __array = jni::JArrayClass<jni::JString>::newArray(__size);
|
|
163
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
164
|
+
const auto& __element = value.ids.value()[__i];
|
|
165
|
+
__array->setElement(__i, *jni::make_jstring(__element));
|
|
166
|
+
}
|
|
167
|
+
return __array;
|
|
168
|
+
}() : nullptr,
|
|
169
|
+
value.isAutoRenewing,
|
|
170
|
+
value.isUpgradedIOS.has_value() ? jni::JBoolean::valueOf(value.isUpgradedIOS.value()) : nullptr,
|
|
171
|
+
value.offerIOS.has_value() ? JPurchaseOfferIOS::fromCpp(value.offerIOS.value()) : nullptr,
|
|
172
|
+
value.originalTransactionDateIOS.has_value() ? jni::JDouble::valueOf(value.originalTransactionDateIOS.value()) : nullptr,
|
|
173
|
+
value.originalTransactionIdentifierIOS.has_value() ? jni::make_jstring(value.originalTransactionIdentifierIOS.value()) : nullptr,
|
|
174
|
+
value.ownershipTypeIOS.has_value() ? jni::make_jstring(value.ownershipTypeIOS.value()) : nullptr,
|
|
175
|
+
JIapPlatform::fromCpp(value.platform),
|
|
176
|
+
jni::make_jstring(value.productId),
|
|
177
|
+
JPurchaseState::fromCpp(value.purchaseState),
|
|
178
|
+
value.purchaseToken.has_value() ? jni::make_jstring(value.purchaseToken.value()) : nullptr,
|
|
179
|
+
value.quantity,
|
|
180
|
+
value.quantityIOS.has_value() ? jni::JDouble::valueOf(value.quantityIOS.value()) : nullptr,
|
|
181
|
+
value.reasonIOS.has_value() ? jni::make_jstring(value.reasonIOS.value()) : nullptr,
|
|
182
|
+
value.reasonStringRepresentationIOS.has_value() ? jni::make_jstring(value.reasonStringRepresentationIOS.value()) : nullptr,
|
|
183
|
+
value.revocationDateIOS.has_value() ? jni::JDouble::valueOf(value.revocationDateIOS.value()) : nullptr,
|
|
184
|
+
value.revocationReasonIOS.has_value() ? jni::make_jstring(value.revocationReasonIOS.value()) : nullptr,
|
|
185
|
+
value.storefrontCountryCodeIOS.has_value() ? jni::make_jstring(value.storefrontCountryCodeIOS.value()) : nullptr,
|
|
186
|
+
value.subscriptionGroupIdIOS.has_value() ? jni::make_jstring(value.subscriptionGroupIdIOS.value()) : nullptr,
|
|
187
|
+
value.transactionDate,
|
|
188
|
+
value.transactionReasonIOS.has_value() ? jni::make_jstring(value.transactionReasonIOS.value()) : nullptr,
|
|
189
|
+
value.webOrderLineItemIdIOS.has_value() ? jni::make_jstring(value.webOrderLineItemIdIOS.value()) : nullptr
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
} // namespace margelo::nitro::iap
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JPurchaseOfferIOS.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "PurchaseOfferIOS.hpp"
|
|
12
|
+
|
|
13
|
+
#include <string>
|
|
14
|
+
|
|
15
|
+
namespace margelo::nitro::iap {
|
|
16
|
+
|
|
17
|
+
using namespace facebook;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The C++ JNI bridge between the C++ struct "PurchaseOfferIOS" and the the Kotlin data class "PurchaseOfferIOS".
|
|
21
|
+
*/
|
|
22
|
+
struct JPurchaseOfferIOS final: public jni::JavaClass<JPurchaseOfferIOS> {
|
|
23
|
+
public:
|
|
24
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/iap/PurchaseOfferIOS;";
|
|
25
|
+
|
|
26
|
+
public:
|
|
27
|
+
/**
|
|
28
|
+
* Convert this Java/Kotlin-based struct to the C++ struct PurchaseOfferIOS by copying all values to C++.
|
|
29
|
+
*/
|
|
30
|
+
[[maybe_unused]]
|
|
31
|
+
[[nodiscard]]
|
|
32
|
+
PurchaseOfferIOS toCpp() const {
|
|
33
|
+
static const auto clazz = javaClassStatic();
|
|
34
|
+
static const auto fieldId = clazz->getField<jni::JString>("id");
|
|
35
|
+
jni::local_ref<jni::JString> id = this->getFieldValue(fieldId);
|
|
36
|
+
static const auto fieldPaymentMode = clazz->getField<jni::JString>("paymentMode");
|
|
37
|
+
jni::local_ref<jni::JString> paymentMode = this->getFieldValue(fieldPaymentMode);
|
|
38
|
+
static const auto fieldType = clazz->getField<jni::JString>("type");
|
|
39
|
+
jni::local_ref<jni::JString> type = this->getFieldValue(fieldType);
|
|
40
|
+
return PurchaseOfferIOS(
|
|
41
|
+
id->toStdString(),
|
|
42
|
+
paymentMode->toStdString(),
|
|
43
|
+
type->toStdString()
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
/**
|
|
49
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
50
|
+
*/
|
|
51
|
+
[[maybe_unused]]
|
|
52
|
+
static jni::local_ref<JPurchaseOfferIOS::javaobject> fromCpp(const PurchaseOfferIOS& value) {
|
|
53
|
+
return newInstance(
|
|
54
|
+
jni::make_jstring(value.id),
|
|
55
|
+
jni::make_jstring(value.paymentMode),
|
|
56
|
+
jni::make_jstring(value.type)
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
} // namespace margelo::nitro::iap
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JPurchaseState.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "PurchaseState.hpp"
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::iap {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The C++ JNI bridge between the C++ enum "PurchaseState" and the the Kotlin enum "PurchaseState".
|
|
19
|
+
*/
|
|
20
|
+
struct JPurchaseState final: public jni::JavaClass<JPurchaseState> {
|
|
21
|
+
public:
|
|
22
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/iap/PurchaseState;";
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
/**
|
|
26
|
+
* Convert this Java/Kotlin-based enum to the C++ enum PurchaseState.
|
|
27
|
+
*/
|
|
28
|
+
[[maybe_unused]]
|
|
29
|
+
[[nodiscard]]
|
|
30
|
+
PurchaseState toCpp() const {
|
|
31
|
+
static const auto clazz = javaClassStatic();
|
|
32
|
+
static const auto fieldOrdinal = clazz->getField<int>("value");
|
|
33
|
+
int ordinal = this->getFieldValue(fieldOrdinal);
|
|
34
|
+
return static_cast<PurchaseState>(ordinal);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public:
|
|
38
|
+
/**
|
|
39
|
+
* Create a Java/Kotlin-based enum with the given C++ enum's value.
|
|
40
|
+
*/
|
|
41
|
+
[[maybe_unused]]
|
|
42
|
+
static jni::alias_ref<JPurchaseState> fromCpp(PurchaseState value) {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
static const auto fieldDEFERRED = clazz->getStaticField<JPurchaseState>("DEFERRED");
|
|
45
|
+
static const auto fieldFAILED = clazz->getStaticField<JPurchaseState>("FAILED");
|
|
46
|
+
static const auto fieldPENDING = clazz->getStaticField<JPurchaseState>("PENDING");
|
|
47
|
+
static const auto fieldPURCHASED = clazz->getStaticField<JPurchaseState>("PURCHASED");
|
|
48
|
+
static const auto fieldRESTORED = clazz->getStaticField<JPurchaseState>("RESTORED");
|
|
49
|
+
static const auto fieldUNKNOWN = clazz->getStaticField<JPurchaseState>("UNKNOWN");
|
|
50
|
+
|
|
51
|
+
switch (value) {
|
|
52
|
+
case PurchaseState::DEFERRED:
|
|
53
|
+
return clazz->getStaticFieldValue(fieldDEFERRED);
|
|
54
|
+
case PurchaseState::FAILED:
|
|
55
|
+
return clazz->getStaticFieldValue(fieldFAILED);
|
|
56
|
+
case PurchaseState::PENDING:
|
|
57
|
+
return clazz->getStaticFieldValue(fieldPENDING);
|
|
58
|
+
case PurchaseState::PURCHASED:
|
|
59
|
+
return clazz->getStaticFieldValue(fieldPURCHASED);
|
|
60
|
+
case PurchaseState::RESTORED:
|
|
61
|
+
return clazz->getStaticFieldValue(fieldRESTORED);
|
|
62
|
+
case PurchaseState::UNKNOWN:
|
|
63
|
+
return clazz->getStaticFieldValue(fieldUNKNOWN);
|
|
64
|
+
default:
|
|
65
|
+
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
66
|
+
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
} // namespace margelo::nitro::iap
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JRequestPurchaseResult.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "RequestPurchaseResult.hpp"
|
|
12
|
+
|
|
13
|
+
#include "IapPlatform.hpp"
|
|
14
|
+
#include "JIapPlatform.hpp"
|
|
15
|
+
#include "JPurchase.hpp"
|
|
16
|
+
#include "JPurchaseAndroid.hpp"
|
|
17
|
+
#include "JPurchaseIOS.hpp"
|
|
18
|
+
#include "JPurchaseOfferIOS.hpp"
|
|
19
|
+
#include "JPurchaseState.hpp"
|
|
20
|
+
#include "JVariant_PurchaseAndroid_PurchaseIOS.hpp"
|
|
21
|
+
#include "PurchaseAndroid.hpp"
|
|
22
|
+
#include "PurchaseIOS.hpp"
|
|
23
|
+
#include "PurchaseOfferIOS.hpp"
|
|
24
|
+
#include "PurchaseState.hpp"
|
|
25
|
+
#include <optional>
|
|
26
|
+
#include <string>
|
|
27
|
+
#include <variant>
|
|
28
|
+
#include <vector>
|
|
29
|
+
|
|
30
|
+
namespace margelo::nitro::iap {
|
|
31
|
+
|
|
32
|
+
using namespace facebook;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The C++ JNI bridge between the C++ struct "RequestPurchaseResult" and the the Kotlin data class "RequestPurchaseResult".
|
|
36
|
+
*/
|
|
37
|
+
struct JRequestPurchaseResult final: public jni::JavaClass<JRequestPurchaseResult> {
|
|
38
|
+
public:
|
|
39
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/iap/RequestPurchaseResult;";
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
/**
|
|
43
|
+
* Convert this Java/Kotlin-based struct to the C++ struct RequestPurchaseResult by copying all values to C++.
|
|
44
|
+
*/
|
|
45
|
+
[[maybe_unused]]
|
|
46
|
+
[[nodiscard]]
|
|
47
|
+
RequestPurchaseResult toCpp() const {
|
|
48
|
+
static const auto clazz = javaClassStatic();
|
|
49
|
+
static const auto fieldPurchase = clazz->getField<JVariant_PurchaseAndroid_PurchaseIOS>("purchase");
|
|
50
|
+
jni::local_ref<JVariant_PurchaseAndroid_PurchaseIOS> purchase = this->getFieldValue(fieldPurchase);
|
|
51
|
+
static const auto fieldPurchases = clazz->getField<jni::JArrayClass<JPurchase>>("purchases");
|
|
52
|
+
jni::local_ref<jni::JArrayClass<JPurchase>> purchases = this->getFieldValue(fieldPurchases);
|
|
53
|
+
return RequestPurchaseResult(
|
|
54
|
+
purchase != nullptr ? std::make_optional(purchase->toCpp()) : std::nullopt,
|
|
55
|
+
purchases != nullptr ? std::make_optional([&]() {
|
|
56
|
+
size_t __size = purchases->size();
|
|
57
|
+
std::vector<std::variant<PurchaseAndroid, PurchaseIOS>> __vector;
|
|
58
|
+
__vector.reserve(__size);
|
|
59
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
60
|
+
auto __element = purchases->getElement(__i);
|
|
61
|
+
__vector.push_back(__element->toCpp());
|
|
62
|
+
}
|
|
63
|
+
return __vector;
|
|
64
|
+
}()) : std::nullopt
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
public:
|
|
69
|
+
/**
|
|
70
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
71
|
+
*/
|
|
72
|
+
[[maybe_unused]]
|
|
73
|
+
static jni::local_ref<JRequestPurchaseResult::javaobject> fromCpp(const RequestPurchaseResult& value) {
|
|
74
|
+
return newInstance(
|
|
75
|
+
value.purchase.has_value() ? JVariant_PurchaseAndroid_PurchaseIOS::fromCpp(value.purchase.value()) : nullptr,
|
|
76
|
+
value.purchases.has_value() ? [&]() {
|
|
77
|
+
size_t __size = value.purchases.value().size();
|
|
78
|
+
jni::local_ref<jni::JArrayClass<JPurchase>> __array = jni::JArrayClass<JPurchase>::newArray(__size);
|
|
79
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
80
|
+
const auto& __element = value.purchases.value()[__i];
|
|
81
|
+
__array->setElement(__i, *JPurchase::fromCpp(__element));
|
|
82
|
+
}
|
|
83
|
+
return __array;
|
|
84
|
+
}() : nullptr
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
} // namespace margelo::nitro::iap
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JVariant_PurchaseAndroid_PurchaseIOS.cpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#include "JVariant_PurchaseAndroid_PurchaseIOS.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::iap {
|
|
11
|
+
/**
|
|
12
|
+
* Converts JVariant_PurchaseAndroid_PurchaseIOS to std::variant<PurchaseAndroid, PurchaseIOS>
|
|
13
|
+
*/
|
|
14
|
+
std::variant<PurchaseAndroid, PurchaseIOS> JVariant_PurchaseAndroid_PurchaseIOS::toCpp() const {
|
|
15
|
+
if (isInstanceOf(JVariant_PurchaseAndroid_PurchaseIOS_impl::First::javaClassStatic())) {
|
|
16
|
+
// It's a `PurchaseAndroid`
|
|
17
|
+
auto jniValue = static_cast<const JVariant_PurchaseAndroid_PurchaseIOS_impl::First*>(this)->getValue();
|
|
18
|
+
return jniValue->toCpp();
|
|
19
|
+
} else if (isInstanceOf(JVariant_PurchaseAndroid_PurchaseIOS_impl::Second::javaClassStatic())) {
|
|
20
|
+
// It's a `PurchaseIOS`
|
|
21
|
+
auto jniValue = static_cast<const JVariant_PurchaseAndroid_PurchaseIOS_impl::Second*>(this)->getValue();
|
|
22
|
+
return jniValue->toCpp();
|
|
23
|
+
}
|
|
24
|
+
throw std::invalid_argument("Variant is unknown Kotlin instance!");
|
|
25
|
+
}
|
|
26
|
+
} // namespace margelo::nitro::iap
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JVariant_PurchaseAndroid_PurchaseIOS.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include <variant>
|
|
12
|
+
|
|
13
|
+
#include "PurchaseAndroid.hpp"
|
|
14
|
+
#include "PurchaseIOS.hpp"
|
|
15
|
+
#include <variant>
|
|
16
|
+
#include "JPurchaseAndroid.hpp"
|
|
17
|
+
#include <optional>
|
|
18
|
+
#include <string>
|
|
19
|
+
#include <vector>
|
|
20
|
+
#include "IapPlatform.hpp"
|
|
21
|
+
#include "JIapPlatform.hpp"
|
|
22
|
+
#include "PurchaseState.hpp"
|
|
23
|
+
#include "JPurchaseState.hpp"
|
|
24
|
+
#include "JPurchaseIOS.hpp"
|
|
25
|
+
#include "PurchaseOfferIOS.hpp"
|
|
26
|
+
#include "JPurchaseOfferIOS.hpp"
|
|
27
|
+
|
|
28
|
+
namespace margelo::nitro::iap {
|
|
29
|
+
|
|
30
|
+
using namespace facebook;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The C++ JNI bridge between the C++ std::variant and the Java class "Variant_PurchaseAndroid_PurchaseIOS".
|
|
34
|
+
*/
|
|
35
|
+
class JVariant_PurchaseAndroid_PurchaseIOS: public jni::JavaClass<JVariant_PurchaseAndroid_PurchaseIOS> {
|
|
36
|
+
public:
|
|
37
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/iap/Variant_PurchaseAndroid_PurchaseIOS;";
|
|
38
|
+
|
|
39
|
+
static jni::local_ref<JVariant_PurchaseAndroid_PurchaseIOS> create_0(jni::alias_ref<JPurchaseAndroid> value) {
|
|
40
|
+
static const auto method = javaClassStatic()->getStaticMethod<JVariant_PurchaseAndroid_PurchaseIOS(jni::alias_ref<JPurchaseAndroid>)>("create");
|
|
41
|
+
return method(javaClassStatic(), value);
|
|
42
|
+
}
|
|
43
|
+
static jni::local_ref<JVariant_PurchaseAndroid_PurchaseIOS> create_1(jni::alias_ref<JPurchaseIOS> value) {
|
|
44
|
+
static const auto method = javaClassStatic()->getStaticMethod<JVariant_PurchaseAndroid_PurchaseIOS(jni::alias_ref<JPurchaseIOS>)>("create");
|
|
45
|
+
return method(javaClassStatic(), value);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static jni::local_ref<JVariant_PurchaseAndroid_PurchaseIOS> fromCpp(const std::variant<PurchaseAndroid, PurchaseIOS>& variant) {
|
|
49
|
+
switch (variant.index()) {
|
|
50
|
+
case 0: return create_0(JPurchaseAndroid::fromCpp(std::get<0>(variant)));
|
|
51
|
+
case 1: return create_1(JPurchaseIOS::fromCpp(std::get<1>(variant)));
|
|
52
|
+
default: throw std::invalid_argument("Variant holds unknown index! (" + std::to_string(variant.index()) + ")");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
[[nodiscard]] std::variant<PurchaseAndroid, PurchaseIOS> toCpp() const;
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
namespace JVariant_PurchaseAndroid_PurchaseIOS_impl {
|
|
60
|
+
class First: public jni::JavaClass<First, JVariant_PurchaseAndroid_PurchaseIOS> {
|
|
61
|
+
public:
|
|
62
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/iap/Variant_PurchaseAndroid_PurchaseIOS$First;";
|
|
63
|
+
|
|
64
|
+
[[nodiscard]] jni::local_ref<JPurchaseAndroid> getValue() const {
|
|
65
|
+
static const auto field = javaClassStatic()->getField<JPurchaseAndroid>("value");
|
|
66
|
+
return getFieldValue(field);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
class Second: public jni::JavaClass<Second, JVariant_PurchaseAndroid_PurchaseIOS> {
|
|
71
|
+
public:
|
|
72
|
+
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/iap/Variant_PurchaseAndroid_PurchaseIOS$Second;";
|
|
73
|
+
|
|
74
|
+
[[nodiscard]] jni::local_ref<JPurchaseIOS> getValue() const {
|
|
75
|
+
static const auto field = javaClassStatic()->getField<JPurchaseIOS>("value");
|
|
76
|
+
return getFieldValue(field);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
} // namespace JVariant_PurchaseAndroid_PurchaseIOS_impl
|
|
80
|
+
} // namespace margelo::nitro::iap
|
|
@@ -54,7 +54,7 @@ abstract class HybridRnIapSpec: HybridObject() {
|
|
|
54
54
|
|
|
55
55
|
@DoNotStrip
|
|
56
56
|
@Keep
|
|
57
|
-
abstract fun requestPurchase(request: NitroPurchaseRequest): Promise<
|
|
57
|
+
abstract fun requestPurchase(request: NitroPurchaseRequest): Promise<RequestPurchaseResult>
|
|
58
58
|
|
|
59
59
|
@DoNotStrip
|
|
60
60
|
@Keep
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// IapPlatform.kt
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
package com.margelo.nitro.iap
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Represents the JavaScript enum/union "IapPlatform".
|
|
15
|
+
*/
|
|
16
|
+
@DoNotStrip
|
|
17
|
+
@Keep
|
|
18
|
+
enum class IapPlatform(@DoNotStrip @Keep val value: Int) {
|
|
19
|
+
ANDROID(0),
|
|
20
|
+
IOS(1);
|
|
21
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Purchase.kt
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © 2025 Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
package com.margelo.nitro.iap
|
|
9
|
+
|
|
10
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Represents the TypeScript variant "PurchaseAndroid|PurchaseIOS".
|
|
15
|
+
*/
|
|
16
|
+
@Suppress("ClassName")
|
|
17
|
+
@DoNotStrip
|
|
18
|
+
sealed class Purchase {
|
|
19
|
+
@DoNotStrip
|
|
20
|
+
data class First(@DoNotStrip val value: PurchaseAndroid): Purchase()
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
data class Second(@DoNotStrip val value: PurchaseIOS): Purchase()
|
|
23
|
+
|
|
24
|
+
inline fun <reified T> getAs(): T? = when (this) {
|
|
25
|
+
is First -> value as? T
|
|
26
|
+
is Second -> value as? T
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
val isFirst: Boolean
|
|
30
|
+
get() = this is First
|
|
31
|
+
val isSecond: Boolean
|
|
32
|
+
get() = this is Second
|
|
33
|
+
|
|
34
|
+
companion object {
|
|
35
|
+
@JvmStatic
|
|
36
|
+
@DoNotStrip
|
|
37
|
+
fun create(value: PurchaseAndroid): Purchase = First(value)
|
|
38
|
+
@JvmStatic
|
|
39
|
+
@DoNotStrip
|
|
40
|
+
fun create(value: PurchaseIOS): Purchase = Second(value)
|
|
41
|
+
}
|
|
42
|
+
}
|