cordova-plugin-netcontroll-integration-getnet 1.0.113 → 1.0.115

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- Versao 1.0.113
1
+ Versao 1.0.115
2
2
 
3
3
  Funções internas de integração XMenu / NetControll / GetNet
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-netcontroll-integration-getnet",
3
- "version": "1.0.113",
3
+ "version": "1.0.115",
4
4
  "description": "Plugin cordova de integracao para uso interno (NetControll/ XMenu)",
5
5
  "cordova": {
6
6
  "id": "cordova-plugin-netcontroll-integration-getnet",
package/plugin.xml CHANGED
@@ -1,5 +1,5 @@
1
1
  <?xml version='1.0' encoding='utf-8'?>
2
- <plugin id="cordova-plugin-netcontroll-integration-getnet" version="1.0.113"
2
+ <plugin id="cordova-plugin-netcontroll-integration-getnet" version="1.0.115"
3
3
  xmlns="http://apache.org/cordova/ns/plugins/1.0"
4
4
  xmlns:android="http://schemas.android.com/apk/res/android">
5
5
 
@@ -37,8 +37,10 @@ import java.io.BufferedReader;
37
37
  import java.io.ByteArrayOutputStream;
38
38
  import java.io.InputStream;
39
39
  import java.io.InputStreamReader;
40
+ import java.io.OutputStream;
40
41
  import java.net.HttpURLConnection;
41
42
  import java.net.URL;
43
+ import java.nio.charset.StandardCharsets;
42
44
  import java.util.Base64;
43
45
 
44
46
  //Json Serialize
@@ -139,7 +141,7 @@ public class GetNetSumni {
139
141
  callbackContext.error(callbackContextMessageBase + "Error Detail: " + error);
140
142
  }
141
143
  return false;
142
- } else if (action.equals("TestarHttp")) {
144
+ } else if (action.equals("ProxyHttpGet")) {
143
145
  JSONObject params = args.getJSONObject(0);
144
146
  try {
145
147
  String httpMethod = params.getString("httpMethod");
@@ -177,6 +179,55 @@ public class GetNetSumni {
177
179
  callbackContext.error(callbackContextMessageBase + "Error Detail: " + error);
178
180
  }
179
181
  return false;
182
+ } else if (action.equals("ProxyHttpPost")) {
183
+ JSONObject params = args.getJSONObject(0);
184
+ try {
185
+ String httpMethod = params.getString("httpMethod");
186
+ String httpUrl = params.getString("httpUrl");
187
+ String httpBody = params.getString("httpBody");
188
+ String resultCallBackJs = params.getString("resultCallBackJs");
189
+
190
+ // URL da API
191
+ String apiUrl = httpUrl;
192
+
193
+ // Parâmetros da requisição
194
+ String parameters = "IDTerminal=18&IDTipoAplicacao=11&NSU=000000008&AUT=164550&Operacao=Venda&Valor=2&format=JSON&IDPost=-1&user=NETWEB&key=netweb@xmenu&GuidTerminal=05f58496-fab1-497b-920a-9e982e394b76&VersaoPDV=1.3.40.5&T=5292024012029AM";
195
+ parameters = httpBody;
196
+
197
+ // Criação da conexão
198
+ URL url = new URL(apiUrl);
199
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
200
+ connection.setRequestMethod(httpMethod);
201
+ connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
202
+ connection.setDoOutput(true);
203
+
204
+ // Envio dos parâmetros
205
+ try (OutputStream os = connection.getOutputStream()) {
206
+ byte[] input = parameters.getBytes(StandardCharsets.UTF_8);
207
+ os.write(input, 0, input.length);
208
+ }
209
+
210
+ // Leitura da resposta
211
+ try (BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) {
212
+ String responseLine;
213
+ StringBuilder response = new StringBuilder();
214
+ while ((responseLine = br.readLine()) != null) {
215
+ response.append(responseLine.trim());
216
+ }
217
+ // executeGlobalJavascript(response.toString());
218
+ callbackContext.success("Resposta do servidor: " + response.toString());
219
+ //System.out.println("Resposta do servidor: " + response.toString());
220
+ }
221
+
222
+ // Fechamento da conexão
223
+ connection.disconnect();
224
+
225
+
226
+ return true;
227
+ } catch (Exception error) {
228
+ callbackContext.error(callbackContextMessageBase + "Error Detail: " + error);
229
+ }
230
+ return false;
180
231
  } else if (action.equals("TestarHttpImg")) {
181
232
  JSONObject params = args.getJSONObject(0);
182
233
  try {
@@ -4,8 +4,12 @@ exports.InitializeSdk = function (params, success, error) {
4
4
  exec(success, error, 'NetControllCordovaPluginsIntegrationGetNet', 'GetNet.Sumni.InitializeSdk', [params]);
5
5
  }
6
6
 
7
- exports.TestarHttp = function (params, success, error) {
8
- exec(success, error, 'NetControllCordovaPluginsIntegrationGetNet', 'GetNet.Sumni.TestarHttp', [params]);
7
+ exports.ProxyHttpGet = function (params, success, error) {
8
+ exec(success, error, 'NetControllCordovaPluginsIntegrationGetNet', 'GetNet.Sumni.ProxyHttpGet', [params]);
9
+ }
10
+
11
+ exports.ProxyHttpPost = function (params, success, error) {
12
+ exec(success, error, 'NetControllCordovaPluginsIntegrationGetNet', 'GetNet.Sumni.ProxyHttpPost', [params]);
9
13
  }
10
14
 
11
15
  exports.TestarHttpImg = function (params, success, error) {