@padosoft/react-native-ecr17 0.0.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.
- package/Ecr17.podspec +39 -0
- package/README.md +348 -0
- package/android/CMakeLists.txt +41 -0
- package/android/build.gradle +149 -0
- package/android/fix-prefab.gradle +51 -0
- package/android/gradle.properties +5 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +9 -0
- package/android/src/main/java/com/margelo/nitro/ecr17/HybridEcr17Transport.kt +233 -0
- package/android/src/main/java/com/padosoft/ecr17/Ecr17Package.kt +30 -0
- package/cpp/Ecr17.cpp +1 -0
- package/cpp/Ecr17.hpp +2 -0
- package/cpp/Ecr17Client/HybridEcr17Client.cpp +598 -0
- package/cpp/Ecr17Client/HybridEcr17Client.hpp +85 -0
- package/cpp/Ecr17Protocol/Ecr17Protocol.cpp +277 -0
- package/cpp/Ecr17Protocol/Ecr17Protocol.hpp +103 -0
- package/cpp/Ecr17Response/Ecr17Response.cpp +155 -0
- package/cpp/Ecr17Response/Ecr17Response.hpp +113 -0
- package/cpp/Lcr/Lcr.cpp +42 -0
- package/cpp/Lcr/Lcr.hpp +22 -0
- package/cpp/PacketCodec/PacketCodec.cpp +146 -0
- package/cpp/PacketCodec/PacketCodec.hpp +48 -0
- package/cpp/Session/Ecr17Session.cpp +260 -0
- package/cpp/Session/Ecr17Session.hpp +97 -0
- package/cpp/Session/RetryPolicy.hpp +23 -0
- package/cpp/Transport/FakeTransport.hpp +95 -0
- package/cpp/Transport/NativeTransportAdapter.cpp +42 -0
- package/cpp/Transport/NativeTransportAdapter.hpp +32 -0
- package/cpp/Transport/Transport.hpp +31 -0
- package/cpp/tests/CMakeLists.txt +55 -0
- package/cpp/tests/PosixTcpTransport.hpp +105 -0
- package/cpp/tests/stubs/LrcMode.hpp +25 -0
- package/cpp/tests/test_flows.cpp +148 -0
- package/cpp/tests/test_integration_terminal.cpp +72 -0
- package/cpp/tests/test_lrc.cpp +66 -0
- package/cpp/tests/test_packet_codec.cpp +164 -0
- package/cpp/tests/test_protocol.cpp +102 -0
- package/cpp/tests/test_protocol_commands.cpp +190 -0
- package/cpp/tests/test_response.cpp +164 -0
- package/cpp/tests/test_retry_policy.cpp +28 -0
- package/cpp/tests/test_session.cpp +262 -0
- package/ios/Bridge.h +1 -0
- package/ios/HybridEcr17Transport.swift +103 -0
- package/nitro.json +30 -0
- package/nitrogen/generated/.gitattributes +1 -0
- package/nitrogen/generated/android/Ecr17+autolinking.cmake +82 -0
- package/nitrogen/generated/android/Ecr17+autolinking.gradle +27 -0
- package/nitrogen/generated/android/Ecr17OnLoad.cpp +68 -0
- package/nitrogen/generated/android/Ecr17OnLoad.hpp +34 -0
- package/nitrogen/generated/android/c++/JFunc_void.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__shared_ptr_ArrayBuffer_.hpp +77 -0
- package/nitrogen/generated/android/c++/JHybridEcr17TransportSpec.cpp +93 -0
- package/nitrogen/generated/android/c++/JHybridEcr17TransportSpec.hpp +68 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/ecr17/Ecr17OnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/ecr17/Func_void.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/ecr17/Func_void_std__shared_ptr_ArrayBuffer_.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/ecr17/HybridEcr17TransportSpec.kt +86 -0
- package/nitrogen/generated/ios/Ecr17+autolinking.rb +62 -0
- package/nitrogen/generated/ios/Ecr17-Swift-Cxx-Bridge.cpp +57 -0
- package/nitrogen/generated/ios/Ecr17-Swift-Cxx-Bridge.hpp +154 -0
- package/nitrogen/generated/ios/Ecr17-Swift-Cxx-Umbrella.hpp +47 -0
- package/nitrogen/generated/ios/Ecr17Autolinking.mm +43 -0
- package/nitrogen/generated/ios/Ecr17Autolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridEcr17TransportSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridEcr17TransportSpecSwift.hpp +119 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__shared_ptr_ArrayBuffer_.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridEcr17TransportSpec.swift +60 -0
- package/nitrogen/generated/ios/swift/HybridEcr17TransportSpec_cxx.swift +211 -0
- package/nitrogen/generated/shared/c++/CardType.hpp +84 -0
- package/nitrogen/generated/shared/c++/CardVerificationRequest.hpp +97 -0
- package/nitrogen/generated/shared/c++/CardVerificationResult.hpp +136 -0
- package/nitrogen/generated/shared/c++/CloseSessionResult.hpp +106 -0
- package/nitrogen/generated/shared/c++/ConnectionState.hpp +80 -0
- package/nitrogen/generated/shared/c++/CurrencyExchange.hpp +100 -0
- package/nitrogen/generated/shared/c++/Ecr17Config.hpp +138 -0
- package/nitrogen/generated/shared/c++/HybridEcr17ClientSpec.cpp +42 -0
- package/nitrogen/generated/shared/c++/HybridEcr17ClientSpec.hpp +138 -0
- package/nitrogen/generated/shared/c++/HybridEcr17TransportSpec.cpp +26 -0
- package/nitrogen/generated/shared/c++/HybridEcr17TransportSpec.hpp +70 -0
- package/nitrogen/generated/shared/c++/IncrementalAuthRequest.hpp +96 -0
- package/nitrogen/generated/shared/c++/LrcMode.hpp +84 -0
- package/nitrogen/generated/shared/c++/PaymentCardType.hpp +84 -0
- package/nitrogen/generated/shared/c++/PaymentRequest.hpp +109 -0
- package/nitrogen/generated/shared/c++/PaymentResult.hpp +139 -0
- package/nitrogen/generated/shared/c++/PosStatusResponse.hpp +96 -0
- package/nitrogen/generated/shared/c++/PreAuthClosureRequest.hpp +96 -0
- package/nitrogen/generated/shared/c++/PreAuthRequest.hpp +109 -0
- package/nitrogen/generated/shared/c++/PreAuthResult.hpp +144 -0
- package/nitrogen/generated/shared/c++/ProgressEvent.hpp +83 -0
- package/nitrogen/generated/shared/c++/ReceiptLine.hpp +83 -0
- package/nitrogen/generated/shared/c++/ReversalRequest.hpp +88 -0
- package/nitrogen/generated/shared/c++/ReversalResult.hpp +132 -0
- package/nitrogen/generated/shared/c++/TokenizationRequest.hpp +89 -0
- package/nitrogen/generated/shared/c++/TokenizationService.hpp +76 -0
- package/nitrogen/generated/shared/c++/TotalsResult.hpp +93 -0
- package/nitrogen/generated/shared/c++/TransactionEntryMode.hpp +92 -0
- package/nitrogen/generated/shared/c++/TransactionOutcome.hpp +88 -0
- package/nitrogen/generated/shared/c++/VasResult.hpp +96 -0
- package/package.json +102 -0
- package/react-native.config.js +18 -0
- package/src/index.ts +4 -0
- package/src/specs/client.nitro.ts +102 -0
- package/src/specs/transport.nitro.ts +25 -0
- package/src/types/client.ts +196 -0
- package/src/utils/client.ts +10 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// IncrementalAuthRequest.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
|
+
|
|
32
|
+
|
|
33
|
+
#include <string>
|
|
34
|
+
#include <optional>
|
|
35
|
+
|
|
36
|
+
namespace margelo::nitro::ecr17 {
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A struct which can be represented as a JavaScript object (IncrementalAuthRequest).
|
|
40
|
+
*/
|
|
41
|
+
struct IncrementalAuthRequest final {
|
|
42
|
+
public:
|
|
43
|
+
double amountCents SWIFT_PRIVATE;
|
|
44
|
+
std::string originalPreAuthCode SWIFT_PRIVATE;
|
|
45
|
+
std::optional<std::string> cashRegisterId SWIFT_PRIVATE;
|
|
46
|
+
std::optional<std::string> receiptText SWIFT_PRIVATE;
|
|
47
|
+
|
|
48
|
+
public:
|
|
49
|
+
IncrementalAuthRequest() = default;
|
|
50
|
+
explicit IncrementalAuthRequest(double amountCents, std::string originalPreAuthCode, std::optional<std::string> cashRegisterId, std::optional<std::string> receiptText): amountCents(amountCents), originalPreAuthCode(originalPreAuthCode), cashRegisterId(cashRegisterId), receiptText(receiptText) {}
|
|
51
|
+
|
|
52
|
+
public:
|
|
53
|
+
friend bool operator==(const IncrementalAuthRequest& lhs, const IncrementalAuthRequest& rhs) = default;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
} // namespace margelo::nitro::ecr17
|
|
57
|
+
|
|
58
|
+
namespace margelo::nitro {
|
|
59
|
+
|
|
60
|
+
// C++ IncrementalAuthRequest <> JS IncrementalAuthRequest (object)
|
|
61
|
+
template <>
|
|
62
|
+
struct JSIConverter<margelo::nitro::ecr17::IncrementalAuthRequest> final {
|
|
63
|
+
static inline margelo::nitro::ecr17::IncrementalAuthRequest fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
64
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
65
|
+
return margelo::nitro::ecr17::IncrementalAuthRequest(
|
|
66
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "amountCents"))),
|
|
67
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "originalPreAuthCode"))),
|
|
68
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cashRegisterId"))),
|
|
69
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "receiptText")))
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::ecr17::IncrementalAuthRequest& arg) {
|
|
73
|
+
jsi::Object obj(runtime);
|
|
74
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "amountCents"), JSIConverter<double>::toJSI(runtime, arg.amountCents));
|
|
75
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "originalPreAuthCode"), JSIConverter<std::string>::toJSI(runtime, arg.originalPreAuthCode));
|
|
76
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "cashRegisterId"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.cashRegisterId));
|
|
77
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "receiptText"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.receiptText));
|
|
78
|
+
return obj;
|
|
79
|
+
}
|
|
80
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
81
|
+
if (!value.isObject()) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
jsi::Object obj = value.getObject(runtime);
|
|
85
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "amountCents")))) return false;
|
|
89
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "originalPreAuthCode")))) return false;
|
|
90
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cashRegisterId")))) return false;
|
|
91
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "receiptText")))) return false;
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// LrcMode.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::ecr17 {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (LrcMode).
|
|
30
|
+
*/
|
|
31
|
+
enum class LrcMode {
|
|
32
|
+
STX SWIFT_NAME(stx) = 0,
|
|
33
|
+
STD SWIFT_NAME(std) = 1,
|
|
34
|
+
NOEXT SWIFT_NAME(noext) = 2,
|
|
35
|
+
STX_NOEXT SWIFT_NAME(stxNoext) = 3,
|
|
36
|
+
} CLOSED_ENUM;
|
|
37
|
+
|
|
38
|
+
} // namespace margelo::nitro::ecr17
|
|
39
|
+
|
|
40
|
+
namespace margelo::nitro {
|
|
41
|
+
|
|
42
|
+
// C++ LrcMode <> JS LrcMode (union)
|
|
43
|
+
template <>
|
|
44
|
+
struct JSIConverter<margelo::nitro::ecr17::LrcMode> final {
|
|
45
|
+
static inline margelo::nitro::ecr17::LrcMode fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
46
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
47
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
48
|
+
case hashString("stx"): return margelo::nitro::ecr17::LrcMode::STX;
|
|
49
|
+
case hashString("std"): return margelo::nitro::ecr17::LrcMode::STD;
|
|
50
|
+
case hashString("noext"): return margelo::nitro::ecr17::LrcMode::NOEXT;
|
|
51
|
+
case hashString("stx_noext"): return margelo::nitro::ecr17::LrcMode::STX_NOEXT;
|
|
52
|
+
default: [[unlikely]]
|
|
53
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum LrcMode - invalid value!");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::ecr17::LrcMode arg) {
|
|
57
|
+
switch (arg) {
|
|
58
|
+
case margelo::nitro::ecr17::LrcMode::STX: return JSIConverter<std::string>::toJSI(runtime, "stx");
|
|
59
|
+
case margelo::nitro::ecr17::LrcMode::STD: return JSIConverter<std::string>::toJSI(runtime, "std");
|
|
60
|
+
case margelo::nitro::ecr17::LrcMode::NOEXT: return JSIConverter<std::string>::toJSI(runtime, "noext");
|
|
61
|
+
case margelo::nitro::ecr17::LrcMode::STX_NOEXT: return JSIConverter<std::string>::toJSI(runtime, "stx_noext");
|
|
62
|
+
default: [[unlikely]]
|
|
63
|
+
throw std::invalid_argument("Cannot convert LrcMode to JS - invalid value: "
|
|
64
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
68
|
+
if (!value.isString()) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
72
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
73
|
+
case hashString("stx"):
|
|
74
|
+
case hashString("std"):
|
|
75
|
+
case hashString("noext"):
|
|
76
|
+
case hashString("stx_noext"):
|
|
77
|
+
return true;
|
|
78
|
+
default:
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// PaymentCardType.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::ecr17 {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (PaymentCardType).
|
|
30
|
+
*/
|
|
31
|
+
enum class PaymentCardType {
|
|
32
|
+
DEBIT SWIFT_NAME(debit) = 0,
|
|
33
|
+
CREDIT SWIFT_NAME(credit) = 1,
|
|
34
|
+
OTHER SWIFT_NAME(other) = 2,
|
|
35
|
+
AUTO SWIFT_NAME(auto) = 3,
|
|
36
|
+
} CLOSED_ENUM;
|
|
37
|
+
|
|
38
|
+
} // namespace margelo::nitro::ecr17
|
|
39
|
+
|
|
40
|
+
namespace margelo::nitro {
|
|
41
|
+
|
|
42
|
+
// C++ PaymentCardType <> JS PaymentCardType (union)
|
|
43
|
+
template <>
|
|
44
|
+
struct JSIConverter<margelo::nitro::ecr17::PaymentCardType> final {
|
|
45
|
+
static inline margelo::nitro::ecr17::PaymentCardType fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
46
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
47
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
48
|
+
case hashString("debit"): return margelo::nitro::ecr17::PaymentCardType::DEBIT;
|
|
49
|
+
case hashString("credit"): return margelo::nitro::ecr17::PaymentCardType::CREDIT;
|
|
50
|
+
case hashString("other"): return margelo::nitro::ecr17::PaymentCardType::OTHER;
|
|
51
|
+
case hashString("auto"): return margelo::nitro::ecr17::PaymentCardType::AUTO;
|
|
52
|
+
default: [[unlikely]]
|
|
53
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum PaymentCardType - invalid value!");
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::ecr17::PaymentCardType arg) {
|
|
57
|
+
switch (arg) {
|
|
58
|
+
case margelo::nitro::ecr17::PaymentCardType::DEBIT: return JSIConverter<std::string>::toJSI(runtime, "debit");
|
|
59
|
+
case margelo::nitro::ecr17::PaymentCardType::CREDIT: return JSIConverter<std::string>::toJSI(runtime, "credit");
|
|
60
|
+
case margelo::nitro::ecr17::PaymentCardType::OTHER: return JSIConverter<std::string>::toJSI(runtime, "other");
|
|
61
|
+
case margelo::nitro::ecr17::PaymentCardType::AUTO: return JSIConverter<std::string>::toJSI(runtime, "auto");
|
|
62
|
+
default: [[unlikely]]
|
|
63
|
+
throw std::invalid_argument("Cannot convert PaymentCardType to JS - invalid value: "
|
|
64
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
68
|
+
if (!value.isString()) {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
72
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
73
|
+
case hashString("debit"):
|
|
74
|
+
case hashString("credit"):
|
|
75
|
+
case hashString("other"):
|
|
76
|
+
case hashString("auto"):
|
|
77
|
+
return true;
|
|
78
|
+
default:
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// PaymentRequest.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 `PaymentCardType` to properly resolve imports.
|
|
32
|
+
namespace margelo::nitro::ecr17 { enum class PaymentCardType; }
|
|
33
|
+
// Forward declaration of `TokenizationRequest` to properly resolve imports.
|
|
34
|
+
namespace margelo::nitro::ecr17 { struct TokenizationRequest; }
|
|
35
|
+
|
|
36
|
+
#include <string>
|
|
37
|
+
#include <optional>
|
|
38
|
+
#include "PaymentCardType.hpp"
|
|
39
|
+
#include "TokenizationRequest.hpp"
|
|
40
|
+
|
|
41
|
+
namespace margelo::nitro::ecr17 {
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* A struct which can be represented as a JavaScript object (PaymentRequest).
|
|
45
|
+
*/
|
|
46
|
+
struct PaymentRequest final {
|
|
47
|
+
public:
|
|
48
|
+
double amountCents SWIFT_PRIVATE;
|
|
49
|
+
std::optional<std::string> cashRegisterId SWIFT_PRIVATE;
|
|
50
|
+
std::optional<PaymentCardType> paymentType SWIFT_PRIVATE;
|
|
51
|
+
std::optional<bool> cardAlreadyPresent SWIFT_PRIVATE;
|
|
52
|
+
std::optional<std::string> receiptText SWIFT_PRIVATE;
|
|
53
|
+
std::optional<TokenizationRequest> tokenization SWIFT_PRIVATE;
|
|
54
|
+
|
|
55
|
+
public:
|
|
56
|
+
PaymentRequest() = default;
|
|
57
|
+
explicit PaymentRequest(double amountCents, std::optional<std::string> cashRegisterId, std::optional<PaymentCardType> paymentType, std::optional<bool> cardAlreadyPresent, std::optional<std::string> receiptText, std::optional<TokenizationRequest> tokenization): amountCents(amountCents), cashRegisterId(cashRegisterId), paymentType(paymentType), cardAlreadyPresent(cardAlreadyPresent), receiptText(receiptText), tokenization(tokenization) {}
|
|
58
|
+
|
|
59
|
+
public:
|
|
60
|
+
friend bool operator==(const PaymentRequest& lhs, const PaymentRequest& rhs) = default;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
} // namespace margelo::nitro::ecr17
|
|
64
|
+
|
|
65
|
+
namespace margelo::nitro {
|
|
66
|
+
|
|
67
|
+
// C++ PaymentRequest <> JS PaymentRequest (object)
|
|
68
|
+
template <>
|
|
69
|
+
struct JSIConverter<margelo::nitro::ecr17::PaymentRequest> final {
|
|
70
|
+
static inline margelo::nitro::ecr17::PaymentRequest fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
71
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
72
|
+
return margelo::nitro::ecr17::PaymentRequest(
|
|
73
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "amountCents"))),
|
|
74
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cashRegisterId"))),
|
|
75
|
+
JSIConverter<std::optional<margelo::nitro::ecr17::PaymentCardType>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "paymentType"))),
|
|
76
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cardAlreadyPresent"))),
|
|
77
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "receiptText"))),
|
|
78
|
+
JSIConverter<std::optional<margelo::nitro::ecr17::TokenizationRequest>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "tokenization")))
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::ecr17::PaymentRequest& arg) {
|
|
82
|
+
jsi::Object obj(runtime);
|
|
83
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "amountCents"), JSIConverter<double>::toJSI(runtime, arg.amountCents));
|
|
84
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "cashRegisterId"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.cashRegisterId));
|
|
85
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "paymentType"), JSIConverter<std::optional<margelo::nitro::ecr17::PaymentCardType>>::toJSI(runtime, arg.paymentType));
|
|
86
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "cardAlreadyPresent"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.cardAlreadyPresent));
|
|
87
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "receiptText"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.receiptText));
|
|
88
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "tokenization"), JSIConverter<std::optional<margelo::nitro::ecr17::TokenizationRequest>>::toJSI(runtime, arg.tokenization));
|
|
89
|
+
return obj;
|
|
90
|
+
}
|
|
91
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
92
|
+
if (!value.isObject()) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
jsi::Object obj = value.getObject(runtime);
|
|
96
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "amountCents")))) return false;
|
|
100
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cashRegisterId")))) return false;
|
|
101
|
+
if (!JSIConverter<std::optional<margelo::nitro::ecr17::PaymentCardType>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "paymentType")))) return false;
|
|
102
|
+
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cardAlreadyPresent")))) return false;
|
|
103
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "receiptText")))) return false;
|
|
104
|
+
if (!JSIConverter<std::optional<margelo::nitro::ecr17::TokenizationRequest>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "tokenization")))) return false;
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// PaymentResult.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 `TransactionOutcome` to properly resolve imports.
|
|
32
|
+
namespace margelo::nitro::ecr17 { enum class TransactionOutcome; }
|
|
33
|
+
// Forward declaration of `TransactionEntryMode` to properly resolve imports.
|
|
34
|
+
namespace margelo::nitro::ecr17 { enum class TransactionEntryMode; }
|
|
35
|
+
// Forward declaration of `CardType` to properly resolve imports.
|
|
36
|
+
namespace margelo::nitro::ecr17 { enum class CardType; }
|
|
37
|
+
// Forward declaration of `CurrencyExchange` to properly resolve imports.
|
|
38
|
+
namespace margelo::nitro::ecr17 { struct CurrencyExchange; }
|
|
39
|
+
|
|
40
|
+
#include "TransactionOutcome.hpp"
|
|
41
|
+
#include <string>
|
|
42
|
+
#include <optional>
|
|
43
|
+
#include "TransactionEntryMode.hpp"
|
|
44
|
+
#include "CardType.hpp"
|
|
45
|
+
#include "CurrencyExchange.hpp"
|
|
46
|
+
|
|
47
|
+
namespace margelo::nitro::ecr17 {
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* A struct which can be represented as a JavaScript object (PaymentResult).
|
|
51
|
+
*/
|
|
52
|
+
struct PaymentResult final {
|
|
53
|
+
public:
|
|
54
|
+
TransactionOutcome outcome SWIFT_PRIVATE;
|
|
55
|
+
std::string resultCode SWIFT_PRIVATE;
|
|
56
|
+
std::optional<std::string> pan SWIFT_PRIVATE;
|
|
57
|
+
std::optional<TransactionEntryMode> entryMode SWIFT_PRIVATE;
|
|
58
|
+
std::optional<std::string> authCode SWIFT_PRIVATE;
|
|
59
|
+
std::optional<std::string> hostDateTime SWIFT_PRIVATE;
|
|
60
|
+
std::optional<CardType> cardType SWIFT_PRIVATE;
|
|
61
|
+
std::optional<std::string> acquirerId SWIFT_PRIVATE;
|
|
62
|
+
std::optional<std::string> stan SWIFT_PRIVATE;
|
|
63
|
+
std::optional<std::string> onlineId SWIFT_PRIVATE;
|
|
64
|
+
std::optional<std::string> errorDescription SWIFT_PRIVATE;
|
|
65
|
+
std::optional<CurrencyExchange> currencyExchange SWIFT_PRIVATE;
|
|
66
|
+
|
|
67
|
+
public:
|
|
68
|
+
PaymentResult() = default;
|
|
69
|
+
explicit PaymentResult(TransactionOutcome outcome, std::string resultCode, std::optional<std::string> pan, std::optional<TransactionEntryMode> entryMode, std::optional<std::string> authCode, std::optional<std::string> hostDateTime, std::optional<CardType> cardType, std::optional<std::string> acquirerId, std::optional<std::string> stan, std::optional<std::string> onlineId, std::optional<std::string> errorDescription, std::optional<CurrencyExchange> currencyExchange): outcome(outcome), resultCode(resultCode), pan(pan), entryMode(entryMode), authCode(authCode), hostDateTime(hostDateTime), cardType(cardType), acquirerId(acquirerId), stan(stan), onlineId(onlineId), errorDescription(errorDescription), currencyExchange(currencyExchange) {}
|
|
70
|
+
|
|
71
|
+
public:
|
|
72
|
+
friend bool operator==(const PaymentResult& lhs, const PaymentResult& rhs) = default;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
} // namespace margelo::nitro::ecr17
|
|
76
|
+
|
|
77
|
+
namespace margelo::nitro {
|
|
78
|
+
|
|
79
|
+
// C++ PaymentResult <> JS PaymentResult (object)
|
|
80
|
+
template <>
|
|
81
|
+
struct JSIConverter<margelo::nitro::ecr17::PaymentResult> final {
|
|
82
|
+
static inline margelo::nitro::ecr17::PaymentResult fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
83
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
84
|
+
return margelo::nitro::ecr17::PaymentResult(
|
|
85
|
+
JSIConverter<margelo::nitro::ecr17::TransactionOutcome>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "outcome"))),
|
|
86
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "resultCode"))),
|
|
87
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "pan"))),
|
|
88
|
+
JSIConverter<std::optional<margelo::nitro::ecr17::TransactionEntryMode>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "entryMode"))),
|
|
89
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "authCode"))),
|
|
90
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "hostDateTime"))),
|
|
91
|
+
JSIConverter<std::optional<margelo::nitro::ecr17::CardType>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cardType"))),
|
|
92
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "acquirerId"))),
|
|
93
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "stan"))),
|
|
94
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onlineId"))),
|
|
95
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "errorDescription"))),
|
|
96
|
+
JSIConverter<std::optional<margelo::nitro::ecr17::CurrencyExchange>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "currencyExchange")))
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::ecr17::PaymentResult& arg) {
|
|
100
|
+
jsi::Object obj(runtime);
|
|
101
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "outcome"), JSIConverter<margelo::nitro::ecr17::TransactionOutcome>::toJSI(runtime, arg.outcome));
|
|
102
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "resultCode"), JSIConverter<std::string>::toJSI(runtime, arg.resultCode));
|
|
103
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "pan"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.pan));
|
|
104
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "entryMode"), JSIConverter<std::optional<margelo::nitro::ecr17::TransactionEntryMode>>::toJSI(runtime, arg.entryMode));
|
|
105
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "authCode"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.authCode));
|
|
106
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "hostDateTime"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.hostDateTime));
|
|
107
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "cardType"), JSIConverter<std::optional<margelo::nitro::ecr17::CardType>>::toJSI(runtime, arg.cardType));
|
|
108
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "acquirerId"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.acquirerId));
|
|
109
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "stan"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.stan));
|
|
110
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "onlineId"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.onlineId));
|
|
111
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "errorDescription"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.errorDescription));
|
|
112
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "currencyExchange"), JSIConverter<std::optional<margelo::nitro::ecr17::CurrencyExchange>>::toJSI(runtime, arg.currencyExchange));
|
|
113
|
+
return obj;
|
|
114
|
+
}
|
|
115
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
116
|
+
if (!value.isObject()) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
jsi::Object obj = value.getObject(runtime);
|
|
120
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
if (!JSIConverter<margelo::nitro::ecr17::TransactionOutcome>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "outcome")))) return false;
|
|
124
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "resultCode")))) return false;
|
|
125
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "pan")))) return false;
|
|
126
|
+
if (!JSIConverter<std::optional<margelo::nitro::ecr17::TransactionEntryMode>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "entryMode")))) return false;
|
|
127
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "authCode")))) return false;
|
|
128
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "hostDateTime")))) return false;
|
|
129
|
+
if (!JSIConverter<std::optional<margelo::nitro::ecr17::CardType>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cardType")))) return false;
|
|
130
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "acquirerId")))) return false;
|
|
131
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "stan")))) return false;
|
|
132
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "onlineId")))) return false;
|
|
133
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "errorDescription")))) return false;
|
|
134
|
+
if (!JSIConverter<std::optional<margelo::nitro::ecr17::CurrencyExchange>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "currencyExchange")))) return false;
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// PosStatusResponse.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
|
+
|
|
32
|
+
|
|
33
|
+
#include <string>
|
|
34
|
+
#include <chrono>
|
|
35
|
+
|
|
36
|
+
namespace margelo::nitro::ecr17 {
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A struct which can be represented as a JavaScript object (PosStatusResponse).
|
|
40
|
+
*/
|
|
41
|
+
struct PosStatusResponse final {
|
|
42
|
+
public:
|
|
43
|
+
std::string terminalId SWIFT_PRIVATE;
|
|
44
|
+
std::chrono::system_clock::time_point terminalDateTime SWIFT_PRIVATE;
|
|
45
|
+
double status SWIFT_PRIVATE;
|
|
46
|
+
std::string softwareRelease SWIFT_PRIVATE;
|
|
47
|
+
|
|
48
|
+
public:
|
|
49
|
+
PosStatusResponse() = default;
|
|
50
|
+
explicit PosStatusResponse(std::string terminalId, std::chrono::system_clock::time_point terminalDateTime, double status, std::string softwareRelease): terminalId(terminalId), terminalDateTime(terminalDateTime), status(status), softwareRelease(softwareRelease) {}
|
|
51
|
+
|
|
52
|
+
public:
|
|
53
|
+
friend bool operator==(const PosStatusResponse& lhs, const PosStatusResponse& rhs) = default;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
} // namespace margelo::nitro::ecr17
|
|
57
|
+
|
|
58
|
+
namespace margelo::nitro {
|
|
59
|
+
|
|
60
|
+
// C++ PosStatusResponse <> JS PosStatusResponse (object)
|
|
61
|
+
template <>
|
|
62
|
+
struct JSIConverter<margelo::nitro::ecr17::PosStatusResponse> final {
|
|
63
|
+
static inline margelo::nitro::ecr17::PosStatusResponse fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
64
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
65
|
+
return margelo::nitro::ecr17::PosStatusResponse(
|
|
66
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "terminalId"))),
|
|
67
|
+
JSIConverter<std::chrono::system_clock::time_point>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "terminalDateTime"))),
|
|
68
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "status"))),
|
|
69
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "softwareRelease")))
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::ecr17::PosStatusResponse& arg) {
|
|
73
|
+
jsi::Object obj(runtime);
|
|
74
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "terminalId"), JSIConverter<std::string>::toJSI(runtime, arg.terminalId));
|
|
75
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "terminalDateTime"), JSIConverter<std::chrono::system_clock::time_point>::toJSI(runtime, arg.terminalDateTime));
|
|
76
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "status"), JSIConverter<double>::toJSI(runtime, arg.status));
|
|
77
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "softwareRelease"), JSIConverter<std::string>::toJSI(runtime, arg.softwareRelease));
|
|
78
|
+
return obj;
|
|
79
|
+
}
|
|
80
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
81
|
+
if (!value.isObject()) {
|
|
82
|
+
return false;
|
|
83
|
+
}
|
|
84
|
+
jsi::Object obj = value.getObject(runtime);
|
|
85
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
86
|
+
return false;
|
|
87
|
+
}
|
|
88
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "terminalId")))) return false;
|
|
89
|
+
if (!JSIConverter<std::chrono::system_clock::time_point>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "terminalDateTime")))) return false;
|
|
90
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "status")))) return false;
|
|
91
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "softwareRelease")))) return false;
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
} // namespace margelo::nitro
|