@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,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ConnectionState.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 (ConnectionState).
|
|
30
|
+
*/
|
|
31
|
+
enum class ConnectionState {
|
|
32
|
+
DISCONNECTED SWIFT_NAME(disconnected) = 0,
|
|
33
|
+
CONNECTING SWIFT_NAME(connecting) = 1,
|
|
34
|
+
CONNECTED SWIFT_NAME(connected) = 2,
|
|
35
|
+
} CLOSED_ENUM;
|
|
36
|
+
|
|
37
|
+
} // namespace margelo::nitro::ecr17
|
|
38
|
+
|
|
39
|
+
namespace margelo::nitro {
|
|
40
|
+
|
|
41
|
+
// C++ ConnectionState <> JS ConnectionState (union)
|
|
42
|
+
template <>
|
|
43
|
+
struct JSIConverter<margelo::nitro::ecr17::ConnectionState> final {
|
|
44
|
+
static inline margelo::nitro::ecr17::ConnectionState 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("disconnected"): return margelo::nitro::ecr17::ConnectionState::DISCONNECTED;
|
|
48
|
+
case hashString("connecting"): return margelo::nitro::ecr17::ConnectionState::CONNECTING;
|
|
49
|
+
case hashString("connected"): return margelo::nitro::ecr17::ConnectionState::CONNECTED;
|
|
50
|
+
default: [[unlikely]]
|
|
51
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum ConnectionState - invalid value!");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::ecr17::ConnectionState arg) {
|
|
55
|
+
switch (arg) {
|
|
56
|
+
case margelo::nitro::ecr17::ConnectionState::DISCONNECTED: return JSIConverter<std::string>::toJSI(runtime, "disconnected");
|
|
57
|
+
case margelo::nitro::ecr17::ConnectionState::CONNECTING: return JSIConverter<std::string>::toJSI(runtime, "connecting");
|
|
58
|
+
case margelo::nitro::ecr17::ConnectionState::CONNECTED: return JSIConverter<std::string>::toJSI(runtime, "connected");
|
|
59
|
+
default: [[unlikely]]
|
|
60
|
+
throw std::invalid_argument("Cannot convert ConnectionState 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("disconnected"):
|
|
71
|
+
case hashString("connecting"):
|
|
72
|
+
case hashString("connected"):
|
|
73
|
+
return true;
|
|
74
|
+
default:
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// CurrencyExchange.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 <optional>
|
|
34
|
+
#include <string>
|
|
35
|
+
|
|
36
|
+
namespace margelo::nitro::ecr17 {
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A struct which can be represented as a JavaScript object (CurrencyExchange).
|
|
40
|
+
*/
|
|
41
|
+
struct CurrencyExchange final {
|
|
42
|
+
public:
|
|
43
|
+
bool applied SWIFT_PRIVATE;
|
|
44
|
+
std::optional<double> rate SWIFT_PRIVATE;
|
|
45
|
+
std::optional<std::string> currencyCode SWIFT_PRIVATE;
|
|
46
|
+
std::optional<double> amountCents SWIFT_PRIVATE;
|
|
47
|
+
std::optional<double> precision SWIFT_PRIVATE;
|
|
48
|
+
|
|
49
|
+
public:
|
|
50
|
+
CurrencyExchange() = default;
|
|
51
|
+
explicit CurrencyExchange(bool applied, std::optional<double> rate, std::optional<std::string> currencyCode, std::optional<double> amountCents, std::optional<double> precision): applied(applied), rate(rate), currencyCode(currencyCode), amountCents(amountCents), precision(precision) {}
|
|
52
|
+
|
|
53
|
+
public:
|
|
54
|
+
friend bool operator==(const CurrencyExchange& lhs, const CurrencyExchange& rhs) = default;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
} // namespace margelo::nitro::ecr17
|
|
58
|
+
|
|
59
|
+
namespace margelo::nitro {
|
|
60
|
+
|
|
61
|
+
// C++ CurrencyExchange <> JS CurrencyExchange (object)
|
|
62
|
+
template <>
|
|
63
|
+
struct JSIConverter<margelo::nitro::ecr17::CurrencyExchange> final {
|
|
64
|
+
static inline margelo::nitro::ecr17::CurrencyExchange fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
65
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
66
|
+
return margelo::nitro::ecr17::CurrencyExchange(
|
|
67
|
+
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "applied"))),
|
|
68
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rate"))),
|
|
69
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "currencyCode"))),
|
|
70
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "amountCents"))),
|
|
71
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "precision")))
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::ecr17::CurrencyExchange& arg) {
|
|
75
|
+
jsi::Object obj(runtime);
|
|
76
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "applied"), JSIConverter<bool>::toJSI(runtime, arg.applied));
|
|
77
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "rate"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.rate));
|
|
78
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "currencyCode"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.currencyCode));
|
|
79
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "amountCents"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.amountCents));
|
|
80
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "precision"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.precision));
|
|
81
|
+
return obj;
|
|
82
|
+
}
|
|
83
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
84
|
+
if (!value.isObject()) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
jsi::Object obj = value.getObject(runtime);
|
|
88
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
89
|
+
return false;
|
|
90
|
+
}
|
|
91
|
+
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "applied")))) return false;
|
|
92
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "rate")))) return false;
|
|
93
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "currencyCode")))) return false;
|
|
94
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "amountCents")))) return false;
|
|
95
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "precision")))) return false;
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// Ecr17Config.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 `LrcMode` to properly resolve imports.
|
|
32
|
+
namespace margelo::nitro::ecr17 { enum class LrcMode; }
|
|
33
|
+
|
|
34
|
+
#include <string>
|
|
35
|
+
#include <optional>
|
|
36
|
+
#include "LrcMode.hpp"
|
|
37
|
+
|
|
38
|
+
namespace margelo::nitro::ecr17 {
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* A struct which can be represented as a JavaScript object (Ecr17Config).
|
|
42
|
+
*/
|
|
43
|
+
struct Ecr17Config final {
|
|
44
|
+
public:
|
|
45
|
+
std::string host SWIFT_PRIVATE;
|
|
46
|
+
std::optional<double> port SWIFT_PRIVATE;
|
|
47
|
+
std::string terminalId SWIFT_PRIVATE;
|
|
48
|
+
std::string cashRegisterId SWIFT_PRIVATE;
|
|
49
|
+
std::optional<LrcMode> lrcMode SWIFT_PRIVATE;
|
|
50
|
+
std::optional<bool> keepAlive SWIFT_PRIVATE;
|
|
51
|
+
std::optional<bool> autoReconnect SWIFT_PRIVATE;
|
|
52
|
+
std::optional<double> connectionTimeoutMs SWIFT_PRIVATE;
|
|
53
|
+
std::optional<double> responseTimeoutMs SWIFT_PRIVATE;
|
|
54
|
+
std::optional<double> ackTimeoutMs SWIFT_PRIVATE;
|
|
55
|
+
std::optional<double> receiptDrainMs SWIFT_PRIVATE;
|
|
56
|
+
std::optional<double> retryCount SWIFT_PRIVATE;
|
|
57
|
+
std::optional<double> retryDelayMs SWIFT_PRIVATE;
|
|
58
|
+
std::optional<bool> debug SWIFT_PRIVATE;
|
|
59
|
+
|
|
60
|
+
public:
|
|
61
|
+
Ecr17Config() = default;
|
|
62
|
+
explicit Ecr17Config(std::string host, std::optional<double> port, std::string terminalId, std::string cashRegisterId, std::optional<LrcMode> lrcMode, std::optional<bool> keepAlive, std::optional<bool> autoReconnect, std::optional<double> connectionTimeoutMs, std::optional<double> responseTimeoutMs, std::optional<double> ackTimeoutMs, std::optional<double> receiptDrainMs, std::optional<double> retryCount, std::optional<double> retryDelayMs, std::optional<bool> debug): host(host), port(port), terminalId(terminalId), cashRegisterId(cashRegisterId), lrcMode(lrcMode), keepAlive(keepAlive), autoReconnect(autoReconnect), connectionTimeoutMs(connectionTimeoutMs), responseTimeoutMs(responseTimeoutMs), ackTimeoutMs(ackTimeoutMs), receiptDrainMs(receiptDrainMs), retryCount(retryCount), retryDelayMs(retryDelayMs), debug(debug) {}
|
|
63
|
+
|
|
64
|
+
public:
|
|
65
|
+
friend bool operator==(const Ecr17Config& lhs, const Ecr17Config& rhs) = default;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
} // namespace margelo::nitro::ecr17
|
|
69
|
+
|
|
70
|
+
namespace margelo::nitro {
|
|
71
|
+
|
|
72
|
+
// C++ Ecr17Config <> JS Ecr17Config (object)
|
|
73
|
+
template <>
|
|
74
|
+
struct JSIConverter<margelo::nitro::ecr17::Ecr17Config> final {
|
|
75
|
+
static inline margelo::nitro::ecr17::Ecr17Config fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
76
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
77
|
+
return margelo::nitro::ecr17::Ecr17Config(
|
|
78
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "host"))),
|
|
79
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "port"))),
|
|
80
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "terminalId"))),
|
|
81
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cashRegisterId"))),
|
|
82
|
+
JSIConverter<std::optional<margelo::nitro::ecr17::LrcMode>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "lrcMode"))),
|
|
83
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "keepAlive"))),
|
|
84
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "autoReconnect"))),
|
|
85
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "connectionTimeoutMs"))),
|
|
86
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "responseTimeoutMs"))),
|
|
87
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ackTimeoutMs"))),
|
|
88
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "receiptDrainMs"))),
|
|
89
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "retryCount"))),
|
|
90
|
+
JSIConverter<std::optional<double>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "retryDelayMs"))),
|
|
91
|
+
JSIConverter<std::optional<bool>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "debug")))
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::ecr17::Ecr17Config& arg) {
|
|
95
|
+
jsi::Object obj(runtime);
|
|
96
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "host"), JSIConverter<std::string>::toJSI(runtime, arg.host));
|
|
97
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "port"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.port));
|
|
98
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "terminalId"), JSIConverter<std::string>::toJSI(runtime, arg.terminalId));
|
|
99
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "cashRegisterId"), JSIConverter<std::string>::toJSI(runtime, arg.cashRegisterId));
|
|
100
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "lrcMode"), JSIConverter<std::optional<margelo::nitro::ecr17::LrcMode>>::toJSI(runtime, arg.lrcMode));
|
|
101
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "keepAlive"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.keepAlive));
|
|
102
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "autoReconnect"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.autoReconnect));
|
|
103
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "connectionTimeoutMs"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.connectionTimeoutMs));
|
|
104
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "responseTimeoutMs"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.responseTimeoutMs));
|
|
105
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "ackTimeoutMs"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.ackTimeoutMs));
|
|
106
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "receiptDrainMs"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.receiptDrainMs));
|
|
107
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "retryCount"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.retryCount));
|
|
108
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "retryDelayMs"), JSIConverter<std::optional<double>>::toJSI(runtime, arg.retryDelayMs));
|
|
109
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "debug"), JSIConverter<std::optional<bool>>::toJSI(runtime, arg.debug));
|
|
110
|
+
return obj;
|
|
111
|
+
}
|
|
112
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
113
|
+
if (!value.isObject()) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
jsi::Object obj = value.getObject(runtime);
|
|
117
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "host")))) return false;
|
|
121
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "port")))) return false;
|
|
122
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "terminalId")))) return false;
|
|
123
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "cashRegisterId")))) return false;
|
|
124
|
+
if (!JSIConverter<std::optional<margelo::nitro::ecr17::LrcMode>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "lrcMode")))) return false;
|
|
125
|
+
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "keepAlive")))) return false;
|
|
126
|
+
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "autoReconnect")))) return false;
|
|
127
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "connectionTimeoutMs")))) return false;
|
|
128
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "responseTimeoutMs")))) return false;
|
|
129
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ackTimeoutMs")))) return false;
|
|
130
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "receiptDrainMs")))) return false;
|
|
131
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "retryCount")))) return false;
|
|
132
|
+
if (!JSIConverter<std::optional<double>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "retryDelayMs")))) return false;
|
|
133
|
+
if (!JSIConverter<std::optional<bool>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "debug")))) return false;
|
|
134
|
+
return true;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridEcr17ClientSpec.cpp
|
|
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
|
+
#include "HybridEcr17ClientSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::ecr17 {
|
|
11
|
+
|
|
12
|
+
void HybridEcr17ClientSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridMethod("configure", &HybridEcr17ClientSpec::configure);
|
|
18
|
+
prototype.registerHybridMethod("configuration", &HybridEcr17ClientSpec::configuration);
|
|
19
|
+
prototype.registerHybridMethod("connect", &HybridEcr17ClientSpec::connect);
|
|
20
|
+
prototype.registerHybridMethod("disconnect", &HybridEcr17ClientSpec::disconnect);
|
|
21
|
+
prototype.registerHybridMethod("isConnected", &HybridEcr17ClientSpec::isConnected);
|
|
22
|
+
prototype.registerHybridMethod("status", &HybridEcr17ClientSpec::status);
|
|
23
|
+
prototype.registerHybridMethod("pay", &HybridEcr17ClientSpec::pay);
|
|
24
|
+
prototype.registerHybridMethod("payExtended", &HybridEcr17ClientSpec::payExtended);
|
|
25
|
+
prototype.registerHybridMethod("reverse", &HybridEcr17ClientSpec::reverse);
|
|
26
|
+
prototype.registerHybridMethod("preAuth", &HybridEcr17ClientSpec::preAuth);
|
|
27
|
+
prototype.registerHybridMethod("incrementalAuth", &HybridEcr17ClientSpec::incrementalAuth);
|
|
28
|
+
prototype.registerHybridMethod("preAuthClosure", &HybridEcr17ClientSpec::preAuthClosure);
|
|
29
|
+
prototype.registerHybridMethod("verifyCard", &HybridEcr17ClientSpec::verifyCard);
|
|
30
|
+
prototype.registerHybridMethod("closeSession", &HybridEcr17ClientSpec::closeSession);
|
|
31
|
+
prototype.registerHybridMethod("totals", &HybridEcr17ClientSpec::totals);
|
|
32
|
+
prototype.registerHybridMethod("sendLastResult", &HybridEcr17ClientSpec::sendLastResult);
|
|
33
|
+
prototype.registerHybridMethod("enableEcrPrinting", &HybridEcr17ClientSpec::enableEcrPrinting);
|
|
34
|
+
prototype.registerHybridMethod("reprint", &HybridEcr17ClientSpec::reprint);
|
|
35
|
+
prototype.registerHybridMethod("vas", &HybridEcr17ClientSpec::vas);
|
|
36
|
+
prototype.registerHybridMethod("setOnProgress", &HybridEcr17ClientSpec::setOnProgress);
|
|
37
|
+
prototype.registerHybridMethod("setOnReceiptLine", &HybridEcr17ClientSpec::setOnReceiptLine);
|
|
38
|
+
prototype.registerHybridMethod("setOnConnectionStateChange", &HybridEcr17ClientSpec::setOnConnectionStateChange);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
} // namespace margelo::nitro::ecr17
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridEcr17ClientSpec.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/HybridObject.hpp>)
|
|
11
|
+
#include <NitroModules/HybridObject.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
// Forward declaration of `Ecr17Config` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::ecr17 { struct Ecr17Config; }
|
|
18
|
+
// Forward declaration of `PosStatusResponse` to properly resolve imports.
|
|
19
|
+
namespace margelo::nitro::ecr17 { struct PosStatusResponse; }
|
|
20
|
+
// Forward declaration of `PaymentResult` to properly resolve imports.
|
|
21
|
+
namespace margelo::nitro::ecr17 { struct PaymentResult; }
|
|
22
|
+
// Forward declaration of `PaymentRequest` to properly resolve imports.
|
|
23
|
+
namespace margelo::nitro::ecr17 { struct PaymentRequest; }
|
|
24
|
+
// Forward declaration of `ReversalResult` to properly resolve imports.
|
|
25
|
+
namespace margelo::nitro::ecr17 { struct ReversalResult; }
|
|
26
|
+
// Forward declaration of `ReversalRequest` to properly resolve imports.
|
|
27
|
+
namespace margelo::nitro::ecr17 { struct ReversalRequest; }
|
|
28
|
+
// Forward declaration of `PreAuthResult` to properly resolve imports.
|
|
29
|
+
namespace margelo::nitro::ecr17 { struct PreAuthResult; }
|
|
30
|
+
// Forward declaration of `PreAuthRequest` to properly resolve imports.
|
|
31
|
+
namespace margelo::nitro::ecr17 { struct PreAuthRequest; }
|
|
32
|
+
// Forward declaration of `IncrementalAuthRequest` to properly resolve imports.
|
|
33
|
+
namespace margelo::nitro::ecr17 { struct IncrementalAuthRequest; }
|
|
34
|
+
// Forward declaration of `PreAuthClosureRequest` to properly resolve imports.
|
|
35
|
+
namespace margelo::nitro::ecr17 { struct PreAuthClosureRequest; }
|
|
36
|
+
// Forward declaration of `CardVerificationResult` to properly resolve imports.
|
|
37
|
+
namespace margelo::nitro::ecr17 { struct CardVerificationResult; }
|
|
38
|
+
// Forward declaration of `CardVerificationRequest` to properly resolve imports.
|
|
39
|
+
namespace margelo::nitro::ecr17 { struct CardVerificationRequest; }
|
|
40
|
+
// Forward declaration of `CloseSessionResult` to properly resolve imports.
|
|
41
|
+
namespace margelo::nitro::ecr17 { struct CloseSessionResult; }
|
|
42
|
+
// Forward declaration of `TotalsResult` to properly resolve imports.
|
|
43
|
+
namespace margelo::nitro::ecr17 { struct TotalsResult; }
|
|
44
|
+
// Forward declaration of `VasResult` to properly resolve imports.
|
|
45
|
+
namespace margelo::nitro::ecr17 { struct VasResult; }
|
|
46
|
+
// Forward declaration of `ProgressEvent` to properly resolve imports.
|
|
47
|
+
namespace margelo::nitro::ecr17 { struct ProgressEvent; }
|
|
48
|
+
// Forward declaration of `ReceiptLine` to properly resolve imports.
|
|
49
|
+
namespace margelo::nitro::ecr17 { struct ReceiptLine; }
|
|
50
|
+
// Forward declaration of `ConnectionState` to properly resolve imports.
|
|
51
|
+
namespace margelo::nitro::ecr17 { enum class ConnectionState; }
|
|
52
|
+
|
|
53
|
+
#include "Ecr17Config.hpp"
|
|
54
|
+
#include <NitroModules/Promise.hpp>
|
|
55
|
+
#include "PosStatusResponse.hpp"
|
|
56
|
+
#include "PaymentResult.hpp"
|
|
57
|
+
#include "PaymentRequest.hpp"
|
|
58
|
+
#include "ReversalResult.hpp"
|
|
59
|
+
#include "ReversalRequest.hpp"
|
|
60
|
+
#include "PreAuthResult.hpp"
|
|
61
|
+
#include "PreAuthRequest.hpp"
|
|
62
|
+
#include "IncrementalAuthRequest.hpp"
|
|
63
|
+
#include "PreAuthClosureRequest.hpp"
|
|
64
|
+
#include "CardVerificationResult.hpp"
|
|
65
|
+
#include "CardVerificationRequest.hpp"
|
|
66
|
+
#include "CloseSessionResult.hpp"
|
|
67
|
+
#include "TotalsResult.hpp"
|
|
68
|
+
#include "VasResult.hpp"
|
|
69
|
+
#include <string>
|
|
70
|
+
#include "ProgressEvent.hpp"
|
|
71
|
+
#include <functional>
|
|
72
|
+
#include "ReceiptLine.hpp"
|
|
73
|
+
#include "ConnectionState.hpp"
|
|
74
|
+
|
|
75
|
+
namespace margelo::nitro::ecr17 {
|
|
76
|
+
|
|
77
|
+
using namespace margelo::nitro;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* An abstract base class for `Ecr17Client`
|
|
81
|
+
* Inherit this class to create instances of `HybridEcr17ClientSpec` in C++.
|
|
82
|
+
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
83
|
+
* @example
|
|
84
|
+
* ```cpp
|
|
85
|
+
* class HybridEcr17Client: public HybridEcr17ClientSpec {
|
|
86
|
+
* public:
|
|
87
|
+
* HybridEcr17Client(...): HybridObject(TAG) { ... }
|
|
88
|
+
* // ...
|
|
89
|
+
* };
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
class HybridEcr17ClientSpec: public virtual HybridObject {
|
|
93
|
+
public:
|
|
94
|
+
// Constructor
|
|
95
|
+
explicit HybridEcr17ClientSpec(): HybridObject(TAG) { }
|
|
96
|
+
|
|
97
|
+
// Destructor
|
|
98
|
+
~HybridEcr17ClientSpec() override = default;
|
|
99
|
+
|
|
100
|
+
public:
|
|
101
|
+
// Properties
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
public:
|
|
105
|
+
// Methods
|
|
106
|
+
virtual void configure(const Ecr17Config& config) = 0;
|
|
107
|
+
virtual Ecr17Config configuration() = 0;
|
|
108
|
+
virtual std::shared_ptr<Promise<void>> connect() = 0;
|
|
109
|
+
virtual void disconnect() = 0;
|
|
110
|
+
virtual bool isConnected() = 0;
|
|
111
|
+
virtual std::shared_ptr<Promise<PosStatusResponse>> status() = 0;
|
|
112
|
+
virtual std::shared_ptr<Promise<PaymentResult>> pay(const PaymentRequest& request) = 0;
|
|
113
|
+
virtual std::shared_ptr<Promise<PaymentResult>> payExtended(const PaymentRequest& request) = 0;
|
|
114
|
+
virtual std::shared_ptr<Promise<ReversalResult>> reverse(const ReversalRequest& request) = 0;
|
|
115
|
+
virtual std::shared_ptr<Promise<PreAuthResult>> preAuth(const PreAuthRequest& request) = 0;
|
|
116
|
+
virtual std::shared_ptr<Promise<PreAuthResult>> incrementalAuth(const IncrementalAuthRequest& request) = 0;
|
|
117
|
+
virtual std::shared_ptr<Promise<PaymentResult>> preAuthClosure(const PreAuthClosureRequest& request) = 0;
|
|
118
|
+
virtual std::shared_ptr<Promise<CardVerificationResult>> verifyCard(const CardVerificationRequest& request) = 0;
|
|
119
|
+
virtual std::shared_ptr<Promise<CloseSessionResult>> closeSession() = 0;
|
|
120
|
+
virtual std::shared_ptr<Promise<TotalsResult>> totals() = 0;
|
|
121
|
+
virtual std::shared_ptr<Promise<PaymentResult>> sendLastResult() = 0;
|
|
122
|
+
virtual std::shared_ptr<Promise<void>> enableEcrPrinting(bool enabled) = 0;
|
|
123
|
+
virtual std::shared_ptr<Promise<void>> reprint(bool toEcr) = 0;
|
|
124
|
+
virtual std::shared_ptr<Promise<VasResult>> vas(const std::string& xmlRequest) = 0;
|
|
125
|
+
virtual void setOnProgress(const std::function<void(const ProgressEvent& /* event */)>& callback) = 0;
|
|
126
|
+
virtual void setOnReceiptLine(const std::function<void(const ReceiptLine& /* line */)>& callback) = 0;
|
|
127
|
+
virtual void setOnConnectionStateChange(const std::function<void(ConnectionState /* state */)>& callback) = 0;
|
|
128
|
+
|
|
129
|
+
protected:
|
|
130
|
+
// Hybrid Setup
|
|
131
|
+
void loadHybridMethods() override;
|
|
132
|
+
|
|
133
|
+
protected:
|
|
134
|
+
// Tag for logging
|
|
135
|
+
static constexpr auto TAG = "Ecr17Client";
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
} // namespace margelo::nitro::ecr17
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridEcr17TransportSpec.cpp
|
|
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
|
+
#include "HybridEcr17TransportSpec.hpp"
|
|
9
|
+
|
|
10
|
+
namespace margelo::nitro::ecr17 {
|
|
11
|
+
|
|
12
|
+
void HybridEcr17TransportSpec::loadHybridMethods() {
|
|
13
|
+
// load base methods/properties
|
|
14
|
+
HybridObject::loadHybridMethods();
|
|
15
|
+
// load custom methods/properties
|
|
16
|
+
registerHybrids(this, [](Prototype& prototype) {
|
|
17
|
+
prototype.registerHybridMethod("connect", &HybridEcr17TransportSpec::connect);
|
|
18
|
+
prototype.registerHybridMethod("disconnect", &HybridEcr17TransportSpec::disconnect);
|
|
19
|
+
prototype.registerHybridMethod("isConnected", &HybridEcr17TransportSpec::isConnected);
|
|
20
|
+
prototype.registerHybridMethod("send", &HybridEcr17TransportSpec::send);
|
|
21
|
+
prototype.registerHybridMethod("setOnData", &HybridEcr17TransportSpec::setOnData);
|
|
22
|
+
prototype.registerHybridMethod("setOnDisconnect", &HybridEcr17TransportSpec::setOnDisconnect);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
} // namespace margelo::nitro::ecr17
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridEcr17TransportSpec.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/HybridObject.hpp>)
|
|
11
|
+
#include <NitroModules/HybridObject.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
#include <NitroModules/Promise.hpp>
|
|
19
|
+
#include <string>
|
|
20
|
+
#include <NitroModules/ArrayBuffer.hpp>
|
|
21
|
+
#include <functional>
|
|
22
|
+
|
|
23
|
+
namespace margelo::nitro::ecr17 {
|
|
24
|
+
|
|
25
|
+
using namespace margelo::nitro;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* An abstract base class for `Ecr17Transport`
|
|
29
|
+
* Inherit this class to create instances of `HybridEcr17TransportSpec` in C++.
|
|
30
|
+
* You must explicitly call `HybridObject`'s constructor yourself, because it is virtual.
|
|
31
|
+
* @example
|
|
32
|
+
* ```cpp
|
|
33
|
+
* class HybridEcr17Transport: public HybridEcr17TransportSpec {
|
|
34
|
+
* public:
|
|
35
|
+
* HybridEcr17Transport(...): HybridObject(TAG) { ... }
|
|
36
|
+
* // ...
|
|
37
|
+
* };
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
40
|
+
class HybridEcr17TransportSpec: public virtual HybridObject {
|
|
41
|
+
public:
|
|
42
|
+
// Constructor
|
|
43
|
+
explicit HybridEcr17TransportSpec(): HybridObject(TAG) { }
|
|
44
|
+
|
|
45
|
+
// Destructor
|
|
46
|
+
~HybridEcr17TransportSpec() override = default;
|
|
47
|
+
|
|
48
|
+
public:
|
|
49
|
+
// Properties
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
public:
|
|
53
|
+
// Methods
|
|
54
|
+
virtual std::shared_ptr<Promise<void>> connect(const std::string& host, double port, double timeoutMs) = 0;
|
|
55
|
+
virtual void disconnect() = 0;
|
|
56
|
+
virtual bool isConnected() = 0;
|
|
57
|
+
virtual void send(const std::shared_ptr<ArrayBuffer>& bytes) = 0;
|
|
58
|
+
virtual void setOnData(const std::function<void(const std::shared_ptr<ArrayBuffer>& /* bytes */)>& callback) = 0;
|
|
59
|
+
virtual void setOnDisconnect(const std::function<void()>& callback) = 0;
|
|
60
|
+
|
|
61
|
+
protected:
|
|
62
|
+
// Hybrid Setup
|
|
63
|
+
void loadHybridMethods() override;
|
|
64
|
+
|
|
65
|
+
protected:
|
|
66
|
+
// Tag for logging
|
|
67
|
+
static constexpr auto TAG = "Ecr17Transport";
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
} // namespace margelo::nitro::ecr17
|