@gmisoftware/react-native-pay 0.0.4
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/NitroPay.podspec +31 -0
- package/README.md +455 -0
- package/android/CMakeLists.txt +29 -0
- package/android/build.gradle +144 -0
- package/android/fix-prefab.gradle +51 -0
- package/android/gradle.properties +8 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/pay/Constants.kt +49 -0
- package/android/src/main/java/com/margelo/nitro/pay/GooglePayButtonFactory.kt +95 -0
- package/android/src/main/java/com/margelo/nitro/pay/GooglePayRequestBuilder.kt +170 -0
- package/android/src/main/java/com/margelo/nitro/pay/HybridGooglePayButton.kt +146 -0
- package/android/src/main/java/com/margelo/nitro/pay/HybridPaymentHandler.kt +184 -0
- package/android/src/main/java/com/margelo/nitro/pay/NitroPayPackage.kt +26 -0
- package/android/src/main/java/com/margelo/nitro/pay/PaymentMapper.kt +89 -0
- package/app.plugin.js +1 -0
- package/ios/ApplePayButtonFactory.swift +53 -0
- package/ios/Bridge.h +8 -0
- package/ios/HybridApplePayButton.swift +60 -0
- package/ios/HybridPaymentHandler.swift +248 -0
- package/ios/PassKitTypeMapper.swift +192 -0
- package/lib/hooks/index.d.ts +7 -0
- package/lib/hooks/index.js +10 -0
- package/lib/hooks/usePaymentCheckout.d.ts +95 -0
- package/lib/hooks/usePaymentCheckout.js +183 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.js +29 -0
- package/lib/plugin/index.d.ts +4 -0
- package/lib/plugin/index.js +10 -0
- package/lib/plugin/type.d.ts +4 -0
- package/lib/plugin/type.js +2 -0
- package/lib/plugin/withApplePay.d.ts +4 -0
- package/lib/plugin/withApplePay.js +32 -0
- package/lib/plugin/withGooglePay.d.ts +4 -0
- package/lib/plugin/withGooglePay.js +24 -0
- package/lib/specs/ApplePayButton.nitro.d.ts +13 -0
- package/lib/specs/ApplePayButton.nitro.js +2 -0
- package/lib/specs/GooglePayButton.nitro.d.ts +14 -0
- package/lib/specs/GooglePayButton.nitro.js +2 -0
- package/lib/specs/PaymentHandler.nitro.d.ts +10 -0
- package/lib/specs/PaymentHandler.nitro.js +2 -0
- package/lib/types/Contact.d.ts +51 -0
- package/lib/types/Contact.js +6 -0
- package/lib/types/Payment.d.ts +67 -0
- package/lib/types/Payment.js +6 -0
- package/lib/types/index.d.ts +2 -0
- package/lib/types/index.js +18 -0
- package/lib/utils/index.d.ts +4 -0
- package/lib/utils/index.js +20 -0
- package/lib/utils/paymentHelpers.d.ts +144 -0
- package/lib/utils/paymentHelpers.js +190 -0
- package/nitro.json +30 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/NitroPay+autolinking.cmake +87 -0
- package/nitrogen/generated/android/NitroPay+autolinking.gradle +27 -0
- package/nitrogen/generated/android/NitroPayOnLoad.cpp +58 -0
- package/nitrogen/generated/android/NitroPayOnLoad.hpp +25 -0
- package/nitrogen/generated/android/c++/JCNContact.hpp +202 -0
- package/nitrogen/generated/android/c++/JCNContactType.hpp +59 -0
- package/nitrogen/generated/android/c++/JCNLabeledEmailAddress.hpp +62 -0
- package/nitrogen/generated/android/c++/JCNLabeledPhoneNumber.hpp +64 -0
- package/nitrogen/generated/android/c++/JCNLabeledPostalAddress.hpp +64 -0
- package/nitrogen/generated/android/c++/JCNPhoneNumber.hpp +57 -0
- package/nitrogen/generated/android/c++/JCNPostalAddress.hpp +78 -0
- package/nitrogen/generated/android/c++/JFunc_void.hpp +74 -0
- package/nitrogen/generated/android/c++/JGooglePayButtonTheme.hpp +59 -0
- package/nitrogen/generated/android/c++/JGooglePayButtonType.hpp +77 -0
- package/nitrogen/generated/android/c++/JGooglePayEnvironment.hpp +59 -0
- package/nitrogen/generated/android/c++/JHybridGooglePayButtonSpec.cpp +96 -0
- package/nitrogen/generated/android/c++/JHybridGooglePayButtonSpec.hpp +71 -0
- package/nitrogen/generated/android/c++/JHybridPaymentHandlerSpec.cpp +154 -0
- package/nitrogen/generated/android/c++/JHybridPaymentHandlerSpec.hpp +66 -0
- package/nitrogen/generated/android/c++/JPKSecureElementPass.hpp +96 -0
- package/nitrogen/generated/android/c++/JPassActivationState.hpp +68 -0
- package/nitrogen/generated/android/c++/JPayServiceStatus.hpp +61 -0
- package/nitrogen/generated/android/c++/JPaymentItem.hpp +67 -0
- package/nitrogen/generated/android/c++/JPaymentItemType.hpp +59 -0
- package/nitrogen/generated/android/c++/JPaymentMethod.hpp +97 -0
- package/nitrogen/generated/android/c++/JPaymentMethodType.hpp +68 -0
- package/nitrogen/generated/android/c++/JPaymentNetwork.hpp +86 -0
- package/nitrogen/generated/android/c++/JPaymentRequest.hpp +181 -0
- package/nitrogen/generated/android/c++/JPaymentResult.hpp +97 -0
- package/nitrogen/generated/android/c++/JPaymentToken.hpp +91 -0
- package/nitrogen/generated/android/c++/views/JHybridGooglePayButtonStateUpdater.cpp +68 -0
- package/nitrogen/generated/android/c++/views/JHybridGooglePayButtonStateUpdater.hpp +49 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/CNContact.kt +96 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/CNContactType.kt +21 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/CNLabeledEmailAddress.kt +39 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/CNLabeledPhoneNumber.kt +39 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/CNLabeledPostalAddress.kt +39 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/CNPhoneNumber.kt +36 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/CNPostalAddress.kt +51 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/Func_void.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/GooglePayButtonTheme.kt +21 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/GooglePayButtonType.kt +27 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/GooglePayEnvironment.kt +21 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/HybridGooglePayButtonSpec.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/HybridPaymentHandlerSpec.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/NitroPayOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PKSecureElementPass.kt +63 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PassActivationState.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PayServiceStatus.kt +39 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentItem.kt +42 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentItemType.kt +21 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentMethod.kt +48 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentMethodType.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentNetwork.kt +30 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentRequest.kt +72 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentResult.kt +45 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/PaymentToken.kt +42 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/views/HybridGooglePayButtonManager.kt +50 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pay/views/HybridGooglePayButtonStateUpdater.kt +23 -0
- package/nitrogen/generated/ios/NitroPay+autolinking.rb +60 -0
- package/nitrogen/generated/ios/NitroPay-Swift-Cxx-Bridge.cpp +73 -0
- package/nitrogen/generated/ios/NitroPay-Swift-Cxx-Bridge.hpp +415 -0
- package/nitrogen/generated/ios/NitroPay-Swift-Cxx-Umbrella.hpp +116 -0
- package/nitrogen/generated/ios/NitroPayAutolinking.mm +41 -0
- package/nitrogen/generated/ios/NitroPayAutolinking.swift +40 -0
- package/nitrogen/generated/ios/c++/HybridApplePayButtonSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridApplePayButtonSpecSwift.hpp +92 -0
- package/nitrogen/generated/ios/c++/HybridPaymentHandlerSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridPaymentHandlerSpecSwift.hpp +148 -0
- package/nitrogen/generated/ios/c++/views/HybridApplePayButtonComponent.mm +106 -0
- package/nitrogen/generated/ios/swift/ApplePayButtonStyle.swift +44 -0
- package/nitrogen/generated/ios/swift/ApplePayButtonType.swift +84 -0
- package/nitrogen/generated/ios/swift/CNContact.swift +329 -0
- package/nitrogen/generated/ios/swift/CNContactType.swift +40 -0
- package/nitrogen/generated/ios/swift/CNLabeledEmailAddress.swift +65 -0
- package/nitrogen/generated/ios/swift/CNLabeledPhoneNumber.swift +65 -0
- package/nitrogen/generated/ios/swift/CNLabeledPostalAddress.swift +65 -0
- package/nitrogen/generated/ios/swift/CNPhoneNumber.swift +35 -0
- package/nitrogen/generated/ios/swift/CNPostalAddress.swift +204 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_PaymentResult.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +47 -0
- package/nitrogen/generated/ios/swift/GooglePayEnvironment.swift +40 -0
- package/nitrogen/generated/ios/swift/HybridApplePayButtonSpec.swift +51 -0
- package/nitrogen/generated/ios/swift/HybridApplePayButtonSpec_cxx.swift +175 -0
- package/nitrogen/generated/ios/swift/HybridPaymentHandlerSpec.swift +52 -0
- package/nitrogen/generated/ios/swift/HybridPaymentHandlerSpec_cxx.swift +155 -0
- package/nitrogen/generated/ios/swift/PKSecureElementPass.swift +191 -0
- package/nitrogen/generated/ios/swift/PassActivationState.swift +52 -0
- package/nitrogen/generated/ios/swift/PayServiceStatus.swift +46 -0
- package/nitrogen/generated/ios/swift/PaymentItem.swift +57 -0
- package/nitrogen/generated/ios/swift/PaymentItemType.swift +40 -0
- package/nitrogen/generated/ios/swift/PaymentMethod.swift +134 -0
- package/nitrogen/generated/ios/swift/PaymentMethodType.swift +52 -0
- package/nitrogen/generated/ios/swift/PaymentNetwork.swift +76 -0
- package/nitrogen/generated/ios/swift/PaymentRequest.swift +341 -0
- package/nitrogen/generated/ios/swift/PaymentResult.swift +118 -0
- package/nitrogen/generated/ios/swift/PaymentToken.swift +57 -0
- package/nitrogen/generated/shared/c++/ApplePayButtonStyle.hpp +80 -0
- package/nitrogen/generated/shared/c++/ApplePayButtonType.hpp +120 -0
- package/nitrogen/generated/shared/c++/CNContact.hpp +168 -0
- package/nitrogen/generated/shared/c++/CNContactType.hpp +76 -0
- package/nitrogen/generated/shared/c++/CNLabeledEmailAddress.hpp +80 -0
- package/nitrogen/generated/shared/c++/CNLabeledPhoneNumber.hpp +82 -0
- package/nitrogen/generated/shared/c++/CNLabeledPostalAddress.hpp +82 -0
- package/nitrogen/generated/shared/c++/CNPhoneNumber.hpp +75 -0
- package/nitrogen/generated/shared/c++/CNPostalAddress.hpp +96 -0
- package/nitrogen/generated/shared/c++/GooglePayButtonTheme.hpp +76 -0
- package/nitrogen/generated/shared/c++/GooglePayButtonType.hpp +100 -0
- package/nitrogen/generated/shared/c++/GooglePayEnvironment.hpp +76 -0
- package/nitrogen/generated/shared/c++/HybridApplePayButtonSpec.cpp +26 -0
- package/nitrogen/generated/shared/c++/HybridApplePayButtonSpec.hpp +73 -0
- package/nitrogen/generated/shared/c++/HybridGooglePayButtonSpec.cpp +28 -0
- package/nitrogen/generated/shared/c++/HybridGooglePayButtonSpec.hpp +75 -0
- package/nitrogen/generated/shared/c++/HybridPaymentHandlerSpec.cpp +23 -0
- package/nitrogen/generated/shared/c++/HybridPaymentHandlerSpec.hpp +74 -0
- package/nitrogen/generated/shared/c++/PKSecureElementPass.hpp +114 -0
- package/nitrogen/generated/shared/c++/PassActivationState.hpp +88 -0
- package/nitrogen/generated/shared/c++/PayServiceStatus.hpp +79 -0
- package/nitrogen/generated/shared/c++/PaymentItem.hpp +85 -0
- package/nitrogen/generated/shared/c++/PaymentItemType.hpp +76 -0
- package/nitrogen/generated/shared/c++/PaymentMethod.hpp +103 -0
- package/nitrogen/generated/shared/c++/PaymentMethodType.hpp +88 -0
- package/nitrogen/generated/shared/c++/PaymentNetwork.hpp +112 -0
- package/nitrogen/generated/shared/c++/PaymentRequest.hpp +130 -0
- package/nitrogen/generated/shared/c++/PaymentResult.hpp +90 -0
- package/nitrogen/generated/shared/c++/PaymentToken.hpp +85 -0
- package/nitrogen/generated/shared/c++/views/HybridApplePayButtonComponent.cpp +111 -0
- package/nitrogen/generated/shared/c++/views/HybridApplePayButtonComponent.hpp +111 -0
- package/nitrogen/generated/shared/c++/views/HybridGooglePayButtonComponent.cpp +123 -0
- package/nitrogen/generated/shared/c++/views/HybridGooglePayButtonComponent.hpp +112 -0
- package/nitrogen/generated/shared/json/ApplePayButtonConfig.json +12 -0
- package/nitrogen/generated/shared/json/GooglePayButtonConfig.json +13 -0
- package/package.json +116 -0
- package/react-native.config.js +16 -0
- package/src/hooks/index.ts +12 -0
- package/src/hooks/usePaymentCheckout.ts +281 -0
- package/src/index.ts +32 -0
- package/src/plugin/index.ts +17 -0
- package/src/plugin/type.ts +4 -0
- package/src/plugin/withApplePay.ts +44 -0
- package/src/plugin/withGooglePay.ts +41 -0
- package/src/specs/ApplePayButton.nitro.ts +37 -0
- package/src/specs/GooglePayButton.nitro.ts +34 -0
- package/src/specs/PaymentHandler.nitro.ts +13 -0
- package/src/types/Contact.ts +58 -0
- package/src/types/Payment.ts +104 -0
- package/src/types/index.ts +2 -0
- package/src/utils/index.ts +5 -0
- package/src/utils/paymentHelpers.ts +215 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ApplePayButtonStyle.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
|
+
#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::pay {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (ApplePayButtonStyle).
|
|
30
|
+
*/
|
|
31
|
+
enum class ApplePayButtonStyle {
|
|
32
|
+
WHITE SWIFT_NAME(white) = 0,
|
|
33
|
+
WHITEOUTLINE SWIFT_NAME(whiteoutline) = 1,
|
|
34
|
+
BLACK SWIFT_NAME(black) = 2,
|
|
35
|
+
} CLOSED_ENUM;
|
|
36
|
+
|
|
37
|
+
} // namespace margelo::nitro::pay
|
|
38
|
+
|
|
39
|
+
namespace margelo::nitro {
|
|
40
|
+
|
|
41
|
+
// C++ ApplePayButtonStyle <> JS ApplePayButtonStyle (union)
|
|
42
|
+
template <>
|
|
43
|
+
struct JSIConverter<margelo::nitro::pay::ApplePayButtonStyle> final {
|
|
44
|
+
static inline margelo::nitro::pay::ApplePayButtonStyle fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
45
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
46
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
47
|
+
case hashString("white"): return margelo::nitro::pay::ApplePayButtonStyle::WHITE;
|
|
48
|
+
case hashString("whiteOutline"): return margelo::nitro::pay::ApplePayButtonStyle::WHITEOUTLINE;
|
|
49
|
+
case hashString("black"): return margelo::nitro::pay::ApplePayButtonStyle::BLACK;
|
|
50
|
+
default: [[unlikely]]
|
|
51
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum ApplePayButtonStyle - invalid value!");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::pay::ApplePayButtonStyle arg) {
|
|
55
|
+
switch (arg) {
|
|
56
|
+
case margelo::nitro::pay::ApplePayButtonStyle::WHITE: return JSIConverter<std::string>::toJSI(runtime, "white");
|
|
57
|
+
case margelo::nitro::pay::ApplePayButtonStyle::WHITEOUTLINE: return JSIConverter<std::string>::toJSI(runtime, "whiteOutline");
|
|
58
|
+
case margelo::nitro::pay::ApplePayButtonStyle::BLACK: return JSIConverter<std::string>::toJSI(runtime, "black");
|
|
59
|
+
default: [[unlikely]]
|
|
60
|
+
throw std::invalid_argument("Cannot convert ApplePayButtonStyle to JS - invalid value: "
|
|
61
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
65
|
+
if (!value.isString()) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
69
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
70
|
+
case hashString("white"):
|
|
71
|
+
case hashString("whiteOutline"):
|
|
72
|
+
case hashString("black"):
|
|
73
|
+
return true;
|
|
74
|
+
default:
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ApplePayButtonType.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
|
+
#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::pay {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (ApplePayButtonType).
|
|
30
|
+
*/
|
|
31
|
+
enum class ApplePayButtonType {
|
|
32
|
+
BUY SWIFT_NAME(buy) = 0,
|
|
33
|
+
SETUP SWIFT_NAME(setup) = 1,
|
|
34
|
+
BOOK SWIFT_NAME(book) = 2,
|
|
35
|
+
DONATE SWIFT_NAME(donate) = 3,
|
|
36
|
+
CONTINUE SWIFT_NAME(continue) = 4,
|
|
37
|
+
RELOAD SWIFT_NAME(reload) = 5,
|
|
38
|
+
ADDMONEY SWIFT_NAME(addmoney) = 6,
|
|
39
|
+
TOPUP SWIFT_NAME(topup) = 7,
|
|
40
|
+
ORDER SWIFT_NAME(order) = 8,
|
|
41
|
+
RENT SWIFT_NAME(rent) = 9,
|
|
42
|
+
SUPPORT SWIFT_NAME(support) = 10,
|
|
43
|
+
CONTRIBUTE SWIFT_NAME(contribute) = 11,
|
|
44
|
+
TIP SWIFT_NAME(tip) = 12,
|
|
45
|
+
} CLOSED_ENUM;
|
|
46
|
+
|
|
47
|
+
} // namespace margelo::nitro::pay
|
|
48
|
+
|
|
49
|
+
namespace margelo::nitro {
|
|
50
|
+
|
|
51
|
+
// C++ ApplePayButtonType <> JS ApplePayButtonType (union)
|
|
52
|
+
template <>
|
|
53
|
+
struct JSIConverter<margelo::nitro::pay::ApplePayButtonType> final {
|
|
54
|
+
static inline margelo::nitro::pay::ApplePayButtonType fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
55
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
56
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
57
|
+
case hashString("buy"): return margelo::nitro::pay::ApplePayButtonType::BUY;
|
|
58
|
+
case hashString("setUp"): return margelo::nitro::pay::ApplePayButtonType::SETUP;
|
|
59
|
+
case hashString("book"): return margelo::nitro::pay::ApplePayButtonType::BOOK;
|
|
60
|
+
case hashString("donate"): return margelo::nitro::pay::ApplePayButtonType::DONATE;
|
|
61
|
+
case hashString("continue"): return margelo::nitro::pay::ApplePayButtonType::CONTINUE;
|
|
62
|
+
case hashString("reload"): return margelo::nitro::pay::ApplePayButtonType::RELOAD;
|
|
63
|
+
case hashString("addMoney"): return margelo::nitro::pay::ApplePayButtonType::ADDMONEY;
|
|
64
|
+
case hashString("topUp"): return margelo::nitro::pay::ApplePayButtonType::TOPUP;
|
|
65
|
+
case hashString("order"): return margelo::nitro::pay::ApplePayButtonType::ORDER;
|
|
66
|
+
case hashString("rent"): return margelo::nitro::pay::ApplePayButtonType::RENT;
|
|
67
|
+
case hashString("support"): return margelo::nitro::pay::ApplePayButtonType::SUPPORT;
|
|
68
|
+
case hashString("contribute"): return margelo::nitro::pay::ApplePayButtonType::CONTRIBUTE;
|
|
69
|
+
case hashString("tip"): return margelo::nitro::pay::ApplePayButtonType::TIP;
|
|
70
|
+
default: [[unlikely]]
|
|
71
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum ApplePayButtonType - invalid value!");
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::pay::ApplePayButtonType arg) {
|
|
75
|
+
switch (arg) {
|
|
76
|
+
case margelo::nitro::pay::ApplePayButtonType::BUY: return JSIConverter<std::string>::toJSI(runtime, "buy");
|
|
77
|
+
case margelo::nitro::pay::ApplePayButtonType::SETUP: return JSIConverter<std::string>::toJSI(runtime, "setUp");
|
|
78
|
+
case margelo::nitro::pay::ApplePayButtonType::BOOK: return JSIConverter<std::string>::toJSI(runtime, "book");
|
|
79
|
+
case margelo::nitro::pay::ApplePayButtonType::DONATE: return JSIConverter<std::string>::toJSI(runtime, "donate");
|
|
80
|
+
case margelo::nitro::pay::ApplePayButtonType::CONTINUE: return JSIConverter<std::string>::toJSI(runtime, "continue");
|
|
81
|
+
case margelo::nitro::pay::ApplePayButtonType::RELOAD: return JSIConverter<std::string>::toJSI(runtime, "reload");
|
|
82
|
+
case margelo::nitro::pay::ApplePayButtonType::ADDMONEY: return JSIConverter<std::string>::toJSI(runtime, "addMoney");
|
|
83
|
+
case margelo::nitro::pay::ApplePayButtonType::TOPUP: return JSIConverter<std::string>::toJSI(runtime, "topUp");
|
|
84
|
+
case margelo::nitro::pay::ApplePayButtonType::ORDER: return JSIConverter<std::string>::toJSI(runtime, "order");
|
|
85
|
+
case margelo::nitro::pay::ApplePayButtonType::RENT: return JSIConverter<std::string>::toJSI(runtime, "rent");
|
|
86
|
+
case margelo::nitro::pay::ApplePayButtonType::SUPPORT: return JSIConverter<std::string>::toJSI(runtime, "support");
|
|
87
|
+
case margelo::nitro::pay::ApplePayButtonType::CONTRIBUTE: return JSIConverter<std::string>::toJSI(runtime, "contribute");
|
|
88
|
+
case margelo::nitro::pay::ApplePayButtonType::TIP: return JSIConverter<std::string>::toJSI(runtime, "tip");
|
|
89
|
+
default: [[unlikely]]
|
|
90
|
+
throw std::invalid_argument("Cannot convert ApplePayButtonType to JS - invalid value: "
|
|
91
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
95
|
+
if (!value.isString()) {
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
99
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
100
|
+
case hashString("buy"):
|
|
101
|
+
case hashString("setUp"):
|
|
102
|
+
case hashString("book"):
|
|
103
|
+
case hashString("donate"):
|
|
104
|
+
case hashString("continue"):
|
|
105
|
+
case hashString("reload"):
|
|
106
|
+
case hashString("addMoney"):
|
|
107
|
+
case hashString("topUp"):
|
|
108
|
+
case hashString("order"):
|
|
109
|
+
case hashString("rent"):
|
|
110
|
+
case hashString("support"):
|
|
111
|
+
case hashString("contribute"):
|
|
112
|
+
case hashString("tip"):
|
|
113
|
+
return true;
|
|
114
|
+
default:
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// CNContact.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
|
+
#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
|
+
|
|
26
|
+
// Forward declaration of `CNContactType` to properly resolve imports.
|
|
27
|
+
namespace margelo::nitro::pay { enum class CNContactType; }
|
|
28
|
+
// Forward declaration of `CNLabeledPhoneNumber` to properly resolve imports.
|
|
29
|
+
namespace margelo::nitro::pay { struct CNLabeledPhoneNumber; }
|
|
30
|
+
// Forward declaration of `CNLabeledEmailAddress` to properly resolve imports.
|
|
31
|
+
namespace margelo::nitro::pay { struct CNLabeledEmailAddress; }
|
|
32
|
+
// Forward declaration of `CNLabeledPostalAddress` to properly resolve imports.
|
|
33
|
+
namespace margelo::nitro::pay { struct CNLabeledPostalAddress; }
|
|
34
|
+
|
|
35
|
+
#include <string>
|
|
36
|
+
#include "CNContactType.hpp"
|
|
37
|
+
#include <optional>
|
|
38
|
+
#include "CNLabeledPhoneNumber.hpp"
|
|
39
|
+
#include <vector>
|
|
40
|
+
#include "CNLabeledEmailAddress.hpp"
|
|
41
|
+
#include "CNLabeledPostalAddress.hpp"
|
|
42
|
+
|
|
43
|
+
namespace margelo::nitro::pay {
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A struct which can be represented as a JavaScript object (CNContact).
|
|
47
|
+
*/
|
|
48
|
+
struct CNContact {
|
|
49
|
+
public:
|
|
50
|
+
std::string identifier SWIFT_PRIVATE;
|
|
51
|
+
CNContactType contactType SWIFT_PRIVATE;
|
|
52
|
+
std::string namePrefix SWIFT_PRIVATE;
|
|
53
|
+
std::string givenName SWIFT_PRIVATE;
|
|
54
|
+
std::string middleName SWIFT_PRIVATE;
|
|
55
|
+
std::string familyName SWIFT_PRIVATE;
|
|
56
|
+
std::string previousFamilyName SWIFT_PRIVATE;
|
|
57
|
+
std::string nameSuffix SWIFT_PRIVATE;
|
|
58
|
+
std::string nickname SWIFT_PRIVATE;
|
|
59
|
+
std::string organizationName SWIFT_PRIVATE;
|
|
60
|
+
std::string departmentName SWIFT_PRIVATE;
|
|
61
|
+
std::string jobTitle SWIFT_PRIVATE;
|
|
62
|
+
std::string phoneticGivenName SWIFT_PRIVATE;
|
|
63
|
+
std::string phoneticMiddleName SWIFT_PRIVATE;
|
|
64
|
+
std::string phoneticFamilyName SWIFT_PRIVATE;
|
|
65
|
+
std::optional<std::string> phoneticOrganizationName SWIFT_PRIVATE;
|
|
66
|
+
std::string note SWIFT_PRIVATE;
|
|
67
|
+
std::optional<bool> imageDataAvailable SWIFT_PRIVATE;
|
|
68
|
+
std::vector<CNLabeledPhoneNumber> phoneNumbers SWIFT_PRIVATE;
|
|
69
|
+
std::vector<CNLabeledEmailAddress> emailAddresses SWIFT_PRIVATE;
|
|
70
|
+
std::vector<CNLabeledPostalAddress> postalAddresses SWIFT_PRIVATE;
|
|
71
|
+
|
|
72
|
+
public:
|
|
73
|
+
CNContact() = default;
|
|
74
|
+
explicit CNContact(std::string identifier, CNContactType contactType, std::string namePrefix, std::string givenName, std::string middleName, std::string familyName, std::string previousFamilyName, std::string nameSuffix, std::string nickname, std::string organizationName, std::string departmentName, std::string jobTitle, std::string phoneticGivenName, std::string phoneticMiddleName, std::string phoneticFamilyName, std::optional<std::string> phoneticOrganizationName, std::string note, std::optional<bool> imageDataAvailable, std::vector<CNLabeledPhoneNumber> phoneNumbers, std::vector<CNLabeledEmailAddress> emailAddresses, std::vector<CNLabeledPostalAddress> postalAddresses): identifier(identifier), contactType(contactType), namePrefix(namePrefix), givenName(givenName), middleName(middleName), familyName(familyName), previousFamilyName(previousFamilyName), nameSuffix(nameSuffix), nickname(nickname), organizationName(organizationName), departmentName(departmentName), jobTitle(jobTitle), phoneticGivenName(phoneticGivenName), phoneticMiddleName(phoneticMiddleName), phoneticFamilyName(phoneticFamilyName), phoneticOrganizationName(phoneticOrganizationName), note(note), imageDataAvailable(imageDataAvailable), phoneNumbers(phoneNumbers), emailAddresses(emailAddresses), postalAddresses(postalAddresses) {}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
} // namespace margelo::nitro::pay
|
|
78
|
+
|
|
79
|
+
namespace margelo::nitro {
|
|
80
|
+
|
|
81
|
+
// C++ CNContact <> JS CNContact (object)
|
|
82
|
+
template <>
|
|
83
|
+
struct JSIConverter<margelo::nitro::pay::CNContact> final {
|
|
84
|
+
static inline margelo::nitro::pay::CNContact fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
85
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
86
|
+
return margelo::nitro::pay::CNContact(
|
|
87
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "identifier")),
|
|
88
|
+
JSIConverter<margelo::nitro::pay::CNContactType>::fromJSI(runtime, obj.getProperty(runtime, "contactType")),
|
|
89
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "namePrefix")),
|
|
90
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "givenName")),
|
|
91
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "middleName")),
|
|
92
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "familyName")),
|
|
93
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "previousFamilyName")),
|
|
94
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "nameSuffix")),
|
|
95
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "nickname")),
|
|
96
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "organizationName")),
|
|
97
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "departmentName")),
|
|
98
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "jobTitle")),
|
|
99
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "phoneticGivenName")),
|
|
100
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "phoneticMiddleName")),
|
|
101
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "phoneticFamilyName")),
|
|
102
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "phoneticOrganizationName")),
|
|
103
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "note")),
|
|
104
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, "imageDataAvailable")),
|
|
105
|
+
JSIConverter<std::vector<margelo::nitro::pay::CNLabeledPhoneNumber>>::fromJSI(runtime, obj.getProperty(runtime, "phoneNumbers")),
|
|
106
|
+
JSIConverter<std::vector<margelo::nitro::pay::CNLabeledEmailAddress>>::fromJSI(runtime, obj.getProperty(runtime, "emailAddresses")),
|
|
107
|
+
JSIConverter<std::vector<margelo::nitro::pay::CNLabeledPostalAddress>>::fromJSI(runtime, obj.getProperty(runtime, "postalAddresses"))
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::pay::CNContact& arg) {
|
|
111
|
+
jsi::Object obj(runtime);
|
|
112
|
+
obj.setProperty(runtime, "identifier", JSIConverter<std::string>::toJSI(runtime, arg.identifier));
|
|
113
|
+
obj.setProperty(runtime, "contactType", JSIConverter<margelo::nitro::pay::CNContactType>::toJSI(runtime, arg.contactType));
|
|
114
|
+
obj.setProperty(runtime, "namePrefix", JSIConverter<std::string>::toJSI(runtime, arg.namePrefix));
|
|
115
|
+
obj.setProperty(runtime, "givenName", JSIConverter<std::string>::toJSI(runtime, arg.givenName));
|
|
116
|
+
obj.setProperty(runtime, "middleName", JSIConverter<std::string>::toJSI(runtime, arg.middleName));
|
|
117
|
+
obj.setProperty(runtime, "familyName", JSIConverter<std::string>::toJSI(runtime, arg.familyName));
|
|
118
|
+
obj.setProperty(runtime, "previousFamilyName", JSIConverter<std::string>::toJSI(runtime, arg.previousFamilyName));
|
|
119
|
+
obj.setProperty(runtime, "nameSuffix", JSIConverter<std::string>::toJSI(runtime, arg.nameSuffix));
|
|
120
|
+
obj.setProperty(runtime, "nickname", JSIConverter<std::string>::toJSI(runtime, arg.nickname));
|
|
121
|
+
obj.setProperty(runtime, "organizationName", JSIConverter<std::string>::toJSI(runtime, arg.organizationName));
|
|
122
|
+
obj.setProperty(runtime, "departmentName", JSIConverter<std::string>::toJSI(runtime, arg.departmentName));
|
|
123
|
+
obj.setProperty(runtime, "jobTitle", JSIConverter<std::string>::toJSI(runtime, arg.jobTitle));
|
|
124
|
+
obj.setProperty(runtime, "phoneticGivenName", JSIConverter<std::string>::toJSI(runtime, arg.phoneticGivenName));
|
|
125
|
+
obj.setProperty(runtime, "phoneticMiddleName", JSIConverter<std::string>::toJSI(runtime, arg.phoneticMiddleName));
|
|
126
|
+
obj.setProperty(runtime, "phoneticFamilyName", JSIConverter<std::string>::toJSI(runtime, arg.phoneticFamilyName));
|
|
127
|
+
obj.setProperty(runtime, "phoneticOrganizationName", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.phoneticOrganizationName));
|
|
128
|
+
obj.setProperty(runtime, "note", JSIConverter<std::string>::toJSI(runtime, arg.note));
|
|
129
|
+
obj.setProperty(runtime, "imageDataAvailable", JSIConverter<std::optional<bool>>::toJSI(runtime, arg.imageDataAvailable));
|
|
130
|
+
obj.setProperty(runtime, "phoneNumbers", JSIConverter<std::vector<margelo::nitro::pay::CNLabeledPhoneNumber>>::toJSI(runtime, arg.phoneNumbers));
|
|
131
|
+
obj.setProperty(runtime, "emailAddresses", JSIConverter<std::vector<margelo::nitro::pay::CNLabeledEmailAddress>>::toJSI(runtime, arg.emailAddresses));
|
|
132
|
+
obj.setProperty(runtime, "postalAddresses", JSIConverter<std::vector<margelo::nitro::pay::CNLabeledPostalAddress>>::toJSI(runtime, arg.postalAddresses));
|
|
133
|
+
return obj;
|
|
134
|
+
}
|
|
135
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
136
|
+
if (!value.isObject()) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
jsi::Object obj = value.getObject(runtime);
|
|
140
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "identifier"))) return false;
|
|
144
|
+
if (!JSIConverter<margelo::nitro::pay::CNContactType>::canConvert(runtime, obj.getProperty(runtime, "contactType"))) return false;
|
|
145
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "namePrefix"))) return false;
|
|
146
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "givenName"))) return false;
|
|
147
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "middleName"))) return false;
|
|
148
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "familyName"))) return false;
|
|
149
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "previousFamilyName"))) return false;
|
|
150
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "nameSuffix"))) return false;
|
|
151
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "nickname"))) return false;
|
|
152
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "organizationName"))) return false;
|
|
153
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "departmentName"))) return false;
|
|
154
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "jobTitle"))) return false;
|
|
155
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "phoneticGivenName"))) return false;
|
|
156
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "phoneticMiddleName"))) return false;
|
|
157
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "phoneticFamilyName"))) return false;
|
|
158
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "phoneticOrganizationName"))) return false;
|
|
159
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "note"))) return false;
|
|
160
|
+
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, "imageDataAvailable"))) return false;
|
|
161
|
+
if (!JSIConverter<std::vector<margelo::nitro::pay::CNLabeledPhoneNumber>>::canConvert(runtime, obj.getProperty(runtime, "phoneNumbers"))) return false;
|
|
162
|
+
if (!JSIConverter<std::vector<margelo::nitro::pay::CNLabeledEmailAddress>>::canConvert(runtime, obj.getProperty(runtime, "emailAddresses"))) return false;
|
|
163
|
+
if (!JSIConverter<std::vector<margelo::nitro::pay::CNLabeledPostalAddress>>::canConvert(runtime, obj.getProperty(runtime, "postalAddresses"))) return false;
|
|
164
|
+
return true;
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// CNContactType.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
|
+
#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::pay {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (CNContactType).
|
|
30
|
+
*/
|
|
31
|
+
enum class CNContactType {
|
|
32
|
+
PERSON SWIFT_NAME(person) = 0,
|
|
33
|
+
ORGANIZATION SWIFT_NAME(organization) = 1,
|
|
34
|
+
} CLOSED_ENUM;
|
|
35
|
+
|
|
36
|
+
} // namespace margelo::nitro::pay
|
|
37
|
+
|
|
38
|
+
namespace margelo::nitro {
|
|
39
|
+
|
|
40
|
+
// C++ CNContactType <> JS CNContactType (union)
|
|
41
|
+
template <>
|
|
42
|
+
struct JSIConverter<margelo::nitro::pay::CNContactType> final {
|
|
43
|
+
static inline margelo::nitro::pay::CNContactType fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
44
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
45
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
46
|
+
case hashString("person"): return margelo::nitro::pay::CNContactType::PERSON;
|
|
47
|
+
case hashString("organization"): return margelo::nitro::pay::CNContactType::ORGANIZATION;
|
|
48
|
+
default: [[unlikely]]
|
|
49
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum CNContactType - invalid value!");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::pay::CNContactType arg) {
|
|
53
|
+
switch (arg) {
|
|
54
|
+
case margelo::nitro::pay::CNContactType::PERSON: return JSIConverter<std::string>::toJSI(runtime, "person");
|
|
55
|
+
case margelo::nitro::pay::CNContactType::ORGANIZATION: return JSIConverter<std::string>::toJSI(runtime, "organization");
|
|
56
|
+
default: [[unlikely]]
|
|
57
|
+
throw std::invalid_argument("Cannot convert CNContactType to JS - invalid value: "
|
|
58
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
62
|
+
if (!value.isString()) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
66
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
67
|
+
case hashString("person"):
|
|
68
|
+
case hashString("organization"):
|
|
69
|
+
return true;
|
|
70
|
+
default:
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// CNLabeledEmailAddress.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
|
+
#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
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
#include <string>
|
|
29
|
+
#include <optional>
|
|
30
|
+
|
|
31
|
+
namespace margelo::nitro::pay {
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* A struct which can be represented as a JavaScript object (CNLabeledEmailAddress).
|
|
35
|
+
*/
|
|
36
|
+
struct CNLabeledEmailAddress {
|
|
37
|
+
public:
|
|
38
|
+
std::optional<std::string> label SWIFT_PRIVATE;
|
|
39
|
+
std::string value SWIFT_PRIVATE;
|
|
40
|
+
|
|
41
|
+
public:
|
|
42
|
+
CNLabeledEmailAddress() = default;
|
|
43
|
+
explicit CNLabeledEmailAddress(std::optional<std::string> label, std::string value): label(label), value(value) {}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
} // namespace margelo::nitro::pay
|
|
47
|
+
|
|
48
|
+
namespace margelo::nitro {
|
|
49
|
+
|
|
50
|
+
// C++ CNLabeledEmailAddress <> JS CNLabeledEmailAddress (object)
|
|
51
|
+
template <>
|
|
52
|
+
struct JSIConverter<margelo::nitro::pay::CNLabeledEmailAddress> final {
|
|
53
|
+
static inline margelo::nitro::pay::CNLabeledEmailAddress fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
54
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
55
|
+
return margelo::nitro::pay::CNLabeledEmailAddress(
|
|
56
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "label")),
|
|
57
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "value"))
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::pay::CNLabeledEmailAddress& arg) {
|
|
61
|
+
jsi::Object obj(runtime);
|
|
62
|
+
obj.setProperty(runtime, "label", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.label));
|
|
63
|
+
obj.setProperty(runtime, "value", JSIConverter<std::string>::toJSI(runtime, arg.value));
|
|
64
|
+
return obj;
|
|
65
|
+
}
|
|
66
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
67
|
+
if (!value.isObject()) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
jsi::Object obj = value.getObject(runtime);
|
|
71
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "label"))) return false;
|
|
75
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "value"))) return false;
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// CNLabeledPhoneNumber.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
|
+
#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
|
+
|
|
26
|
+
// Forward declaration of `CNPhoneNumber` to properly resolve imports.
|
|
27
|
+
namespace margelo::nitro::pay { struct CNPhoneNumber; }
|
|
28
|
+
|
|
29
|
+
#include <string>
|
|
30
|
+
#include <optional>
|
|
31
|
+
#include "CNPhoneNumber.hpp"
|
|
32
|
+
|
|
33
|
+
namespace margelo::nitro::pay {
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* A struct which can be represented as a JavaScript object (CNLabeledPhoneNumber).
|
|
37
|
+
*/
|
|
38
|
+
struct CNLabeledPhoneNumber {
|
|
39
|
+
public:
|
|
40
|
+
std::optional<std::string> label SWIFT_PRIVATE;
|
|
41
|
+
CNPhoneNumber value SWIFT_PRIVATE;
|
|
42
|
+
|
|
43
|
+
public:
|
|
44
|
+
CNLabeledPhoneNumber() = default;
|
|
45
|
+
explicit CNLabeledPhoneNumber(std::optional<std::string> label, CNPhoneNumber value): label(label), value(value) {}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
} // namespace margelo::nitro::pay
|
|
49
|
+
|
|
50
|
+
namespace margelo::nitro {
|
|
51
|
+
|
|
52
|
+
// C++ CNLabeledPhoneNumber <> JS CNLabeledPhoneNumber (object)
|
|
53
|
+
template <>
|
|
54
|
+
struct JSIConverter<margelo::nitro::pay::CNLabeledPhoneNumber> final {
|
|
55
|
+
static inline margelo::nitro::pay::CNLabeledPhoneNumber fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
56
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
57
|
+
return margelo::nitro::pay::CNLabeledPhoneNumber(
|
|
58
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "label")),
|
|
59
|
+
JSIConverter<margelo::nitro::pay::CNPhoneNumber>::fromJSI(runtime, obj.getProperty(runtime, "value"))
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::pay::CNLabeledPhoneNumber& arg) {
|
|
63
|
+
jsi::Object obj(runtime);
|
|
64
|
+
obj.setProperty(runtime, "label", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.label));
|
|
65
|
+
obj.setProperty(runtime, "value", JSIConverter<margelo::nitro::pay::CNPhoneNumber>::toJSI(runtime, arg.value));
|
|
66
|
+
return obj;
|
|
67
|
+
}
|
|
68
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
69
|
+
if (!value.isObject()) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
jsi::Object obj = value.getObject(runtime);
|
|
73
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "label"))) return false;
|
|
77
|
+
if (!JSIConverter<margelo::nitro::pay::CNPhoneNumber>::canConvert(runtime, obj.getProperty(runtime, "value"))) return false;
|
|
78
|
+
return true;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
} // namespace margelo::nitro
|