apps-sdk 1.1.74 → 1.1.76
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/EJEMPLO_USO_SDK.md +156 -0
- package/config.js +1 -1
- package/package.json +1 -1
- package/rest_client_collection/request.http +3 -2
- package/src/libraries/Legal.js +20 -16
- package/src/libraries/PayWallLogic.js +5 -5
- package/types/index.d.ts +2 -2
package/EJEMPLO_USO_SDK.md
CHANGED
|
@@ -279,3 +279,159 @@ npm install @apps-sdk/core @apps-sdk/expo @apps-sdk/web
|
|
|
279
279
|
```
|
|
280
280
|
|
|
281
281
|
Esta arquitectura permite que el 90% del código de tu aplicación sea idéntico entre plataformas, mientras que las diferencias específicas se manejan transparentemente en los adaptadores.
|
|
282
|
+
|
|
283
|
+
## 📄 Módulo Legal - Obtener Textos Legales
|
|
284
|
+
|
|
285
|
+
### Uso desde cualquier plataforma
|
|
286
|
+
|
|
287
|
+
```javascript
|
|
288
|
+
import SDK from '@apps-sdk/expo'; // o '@apps-sdk/web'
|
|
289
|
+
|
|
290
|
+
// Obtener términos y condiciones (idioma por defecto: 'en')
|
|
291
|
+
const termsResponse = await SDK.legal.getLegalText(
|
|
292
|
+
'chatconnect-ios-app', // web_id
|
|
293
|
+
'tc' // url_path: 'tc' | 'contact' | 'privacy_policy' | 'refund_policy' | 'faqs'
|
|
294
|
+
);
|
|
295
|
+
|
|
296
|
+
// Obtener términos y condiciones en inglés
|
|
297
|
+
const termsEnResponse = await SDK.legal.getLegalText(
|
|
298
|
+
'chatconnect-ios-app',
|
|
299
|
+
'tc',
|
|
300
|
+
'en' // lang (opcional, cualquier código de idioma: 'en', 'es', 'fr', 'de', etc.)
|
|
301
|
+
);
|
|
302
|
+
|
|
303
|
+
// Obtener política de privacidad en español
|
|
304
|
+
const privacyResponse = await SDK.legal.getLegalText(
|
|
305
|
+
'chatconnect-ios-app',
|
|
306
|
+
'privacy_policy',
|
|
307
|
+
'es'
|
|
308
|
+
);
|
|
309
|
+
|
|
310
|
+
// Obtener FAQs en francés
|
|
311
|
+
const faqsFrResponse = await SDK.legal.getLegalText(
|
|
312
|
+
'chatconnect-ios-app',
|
|
313
|
+
'faqs',
|
|
314
|
+
'fr'
|
|
315
|
+
);
|
|
316
|
+
|
|
317
|
+
// Obtener información de contacto
|
|
318
|
+
const contactResponse = await SDK.legal.getLegalText(
|
|
319
|
+
'chatconnect-ios-app',
|
|
320
|
+
'contact',
|
|
321
|
+
'en'
|
|
322
|
+
);
|
|
323
|
+
|
|
324
|
+
// Obtener política de reembolsos
|
|
325
|
+
const refundResponse = await SDK.legal.getLegalText(
|
|
326
|
+
'chatconnect-ios-app',
|
|
327
|
+
'refund_policy',
|
|
328
|
+
'en'
|
|
329
|
+
);
|
|
330
|
+
|
|
331
|
+
// Obtener FAQs
|
|
332
|
+
const faqsResponse = await SDK.legal.getLegalText(
|
|
333
|
+
'chatconnect-ios-app',
|
|
334
|
+
'faqs',
|
|
335
|
+
'en'
|
|
336
|
+
);
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### Endpoints disponibles
|
|
340
|
+
|
|
341
|
+
La API construye automáticamente las URLs basándose en el `url_path`:
|
|
342
|
+
|
|
343
|
+
```
|
|
344
|
+
Base URL: https://api.fluver-ai.com/content/andromeda/legal
|
|
345
|
+
|
|
346
|
+
Endpoints:
|
|
347
|
+
- /tc → Términos y condiciones
|
|
348
|
+
- /contact → Información de contacto
|
|
349
|
+
- /privacy_policy → Política de privacidad
|
|
350
|
+
- /refund_policy → Política de reembolsos
|
|
351
|
+
- /faqs → Preguntas frecuentes
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### Payload enviado
|
|
355
|
+
|
|
356
|
+
```javascript
|
|
357
|
+
{
|
|
358
|
+
"url_path": "tc", // El tipo de documento legal
|
|
359
|
+
"lang": "en", // Idioma del contenido
|
|
360
|
+
"web_id": "chatconnect-ios-app" // Identificador del proyecto
|
|
361
|
+
}
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
### Ejemplo completo en React Native
|
|
365
|
+
|
|
366
|
+
```javascript
|
|
367
|
+
import React, { useState, useEffect } from 'react';
|
|
368
|
+
import { View, Text, ScrollView } from 'react-native';
|
|
369
|
+
import SDK from '@apps-sdk/expo';
|
|
370
|
+
|
|
371
|
+
const TermsScreen = () => {
|
|
372
|
+
const [terms, setTerms] = useState(null);
|
|
373
|
+
const [loading, setLoading] = useState(true);
|
|
374
|
+
|
|
375
|
+
useEffect(() => {
|
|
376
|
+
const loadTerms = async () => {
|
|
377
|
+
try {
|
|
378
|
+
const response = await SDK.legal.getLegalText(
|
|
379
|
+
'chatconnect-ios-app',
|
|
380
|
+
'tc',
|
|
381
|
+
'en'
|
|
382
|
+
);
|
|
383
|
+
setTerms(response);
|
|
384
|
+
} catch (error) {
|
|
385
|
+
console.error('Error loading terms:', error);
|
|
386
|
+
} finally {
|
|
387
|
+
setLoading(false);
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
loadTerms();
|
|
392
|
+
}, []);
|
|
393
|
+
|
|
394
|
+
if (loading) return <Text>Loading...</Text>;
|
|
395
|
+
|
|
396
|
+
return (
|
|
397
|
+
<ScrollView>
|
|
398
|
+
<Text>{terms?.content}</Text>
|
|
399
|
+
</ScrollView>
|
|
400
|
+
);
|
|
401
|
+
};
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
### Ejemplo completo en Next.js/Web
|
|
405
|
+
|
|
406
|
+
```javascript
|
|
407
|
+
import { useEffect, useState } from 'react';
|
|
408
|
+
import SDK from '@apps-sdk/web';
|
|
409
|
+
|
|
410
|
+
export default function PrivacyPolicy() {
|
|
411
|
+
const [policy, setPolicy] = useState(null);
|
|
412
|
+
|
|
413
|
+
useEffect(() => {
|
|
414
|
+
const loadPolicy = async () => {
|
|
415
|
+
try {
|
|
416
|
+
const response = await SDK.legal.getLegalText(
|
|
417
|
+
'chatconnect-ios-app',
|
|
418
|
+
'privacy_policy',
|
|
419
|
+
'en'
|
|
420
|
+
);
|
|
421
|
+
setPolicy(response);
|
|
422
|
+
} catch (error) {
|
|
423
|
+
console.error('Error loading privacy policy:', error);
|
|
424
|
+
}
|
|
425
|
+
};
|
|
426
|
+
|
|
427
|
+
loadPolicy();
|
|
428
|
+
}, []);
|
|
429
|
+
|
|
430
|
+
return (
|
|
431
|
+
<div>
|
|
432
|
+
<h1>Privacy Policy</h1>
|
|
433
|
+
<div dangerouslySetInnerHTML={{ __html: policy?.content }} />
|
|
434
|
+
</div>
|
|
435
|
+
);
|
|
436
|
+
}
|
|
437
|
+
```
|
package/config.js
CHANGED
|
@@ -13,7 +13,7 @@ export var ENDPOINTS = {
|
|
|
13
13
|
AUDIENCES: "https://backend.ailandsapp.com",
|
|
14
14
|
CONTENTS: "https://backend.ailandsapp.com",
|
|
15
15
|
EVENTS: "https://ap0404.gways.org",
|
|
16
|
-
|
|
16
|
+
LEGAL_BASE: "https://api.fluver-ai.com/content/andromeda/legal",
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export var EVENTS = {}
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
###
|
|
1
|
+
### Get Legal Text
|
|
2
2
|
POST https://api.fluver-ai.com/content/andromeda/get-legal-text HTTP/1.1
|
|
3
3
|
Content-Type: application/json
|
|
4
4
|
|
|
@@ -30,7 +30,8 @@ Content-Type: application/json
|
|
|
30
30
|
"dev": false,
|
|
31
31
|
"lang": "en",
|
|
32
32
|
"package": "com.mobileawareservices.chatconnect",
|
|
33
|
-
"webId": "chatconnect-
|
|
33
|
+
"webId": "chatconnect-ios-app",
|
|
34
34
|
"type": "tc",
|
|
35
35
|
"language": "en"
|
|
36
36
|
}
|
|
37
|
+
|
package/src/libraries/Legal.js
CHANGED
|
@@ -6,35 +6,39 @@ class Legal {
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Obtiene textos legales desde el backend
|
|
9
|
-
* @param {string}
|
|
10
|
-
* @param {'tc' | '
|
|
11
|
-
* @param {string}
|
|
9
|
+
* @param {string} web_id - ID del proyecto web
|
|
10
|
+
* @param {'tc' | 'contact' | 'privacy_policy' | 'refund_policy' | 'faqs'} url_path - Tipo de texto legal
|
|
11
|
+
* @param {string} lang - Código de idioma ISO (ej: 'en', 'es', 'fr', 'de', etc. Por defecto: 'en')
|
|
12
12
|
* @returns {Promise<any>} Respuesta con el texto legal
|
|
13
13
|
*/
|
|
14
|
-
async getLegalText(
|
|
15
|
-
config.DEBUG_MODE && console.debug("getLegalText", {
|
|
14
|
+
async getLegalText(web_id, url_path, lang = 'en') {
|
|
15
|
+
config.DEBUG_MODE && console.debug("getLegalText", { web_id, url_path, lang });
|
|
16
16
|
|
|
17
|
-
if (!
|
|
18
|
-
console.error('getLegalText:
|
|
19
|
-
throw new Error('
|
|
17
|
+
if (!web_id) {
|
|
18
|
+
console.error('getLegalText: web_id es requerido');
|
|
19
|
+
throw new Error('web_id es requerido');
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
22
|
+
const validTypes = ['tc', 'contact', 'privacy_policy', 'refund_policy', 'faqs'];
|
|
23
|
+
if (!validTypes.includes(url_path)) {
|
|
24
|
+
console.error(`getLegalText: tipo inválido. Debe ser uno de: ${validTypes.join(', ')}`);
|
|
25
|
+
throw new Error(`Tipo inválido. Debe ser uno de: ${validTypes.join(', ')}`);
|
|
25
26
|
}
|
|
26
27
|
|
|
27
28
|
try {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
// Construir la URL completa añadiendo el url_path al endpoint base
|
|
30
|
+
const endpoint = `${config.ENDPOINTS.LEGAL_BASE}/${url_path}`;
|
|
31
|
+
|
|
32
|
+
const response = await Networking.request(endpoint, {
|
|
33
|
+
url_path,
|
|
34
|
+
lang,
|
|
35
|
+
web_id
|
|
32
36
|
});
|
|
33
37
|
|
|
34
38
|
config.DEBUG_MODE && console.debug("getLegalText response", response);
|
|
35
39
|
return response;
|
|
36
40
|
} catch (error) {
|
|
37
|
-
console.error(`Failed to fetch legal text (${
|
|
41
|
+
console.error(`Failed to fetch legal text (${url_path}) for web_id ${web_id}:`, error);
|
|
38
42
|
throw error;
|
|
39
43
|
}
|
|
40
44
|
}
|
|
@@ -29,11 +29,11 @@ class PayWallLogic {
|
|
|
29
29
|
await initConnection();
|
|
30
30
|
|
|
31
31
|
if(Platform.OS === 'android'){
|
|
32
|
-
try {
|
|
33
|
-
|
|
34
|
-
} catch (error) {
|
|
35
|
-
|
|
36
|
-
}
|
|
32
|
+
// try {
|
|
33
|
+
// await flushFailedPurchasesCachedAsPendingAndroid();
|
|
34
|
+
// } catch (error) {
|
|
35
|
+
// console.log('Error en flushFailedPurchasesCachedAsPendingAndroid', error);
|
|
36
|
+
// }
|
|
37
37
|
|
|
38
38
|
this.purchaseUpdateSubscription = purchaseUpdatedListener(
|
|
39
39
|
async (purchase) => {
|
package/types/index.d.ts
CHANGED
|
@@ -288,7 +288,7 @@ declare module 'apps-sdk' {
|
|
|
288
288
|
}
|
|
289
289
|
|
|
290
290
|
export class Legal {
|
|
291
|
-
getLegalText(
|
|
291
|
+
getLegalText(web_id: string, url_path: 'tc' | 'contact' | 'privacy_policy' | 'refund_policy' | 'faqs', lang?: string): Promise<any>;
|
|
292
292
|
}
|
|
293
293
|
|
|
294
294
|
export class AppsSDK {
|
|
@@ -319,4 +319,4 @@ declare module 'apps-sdk' {
|
|
|
319
319
|
|
|
320
320
|
const Core: AppsSDK;
|
|
321
321
|
export default Core;
|
|
322
|
-
}
|
|
322
|
+
}
|