apps-sdk 1.1.73 → 1.1.75
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 +184 -0
- package/config.js +1 -1
- package/index.js +2 -2
- package/package.json +1 -1
- package/src/libraries/Legal.js +30 -17
- package/types/index.d.ts +2 -2
package/EJEMPLO_USO_SDK.md
CHANGED
|
@@ -279,3 +279,187 @@ 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 Básico
|
|
286
|
+
|
|
287
|
+
```javascript
|
|
288
|
+
import SDK from 'apps-sdk';
|
|
289
|
+
|
|
290
|
+
// Obtener términos y condiciones en español
|
|
291
|
+
const response = await SDK.legal.getLegalText('chatconnect-ios-app', 'tc', 'es');
|
|
292
|
+
|
|
293
|
+
// Obtener política de privacidad en inglés
|
|
294
|
+
const response = await SDK.legal.getLegalText('chatconnect-ios-app', 'privacy_policy', 'en');
|
|
295
|
+
|
|
296
|
+
// Obtener política de reembolso en francés
|
|
297
|
+
const response = await SDK.legal.getLegalText('chatconnect-ios-app', 'refund_policy', 'fr');
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Tipos de Documentos Disponibles
|
|
301
|
+
|
|
302
|
+
| Tipo | Descripción |
|
|
303
|
+
|------|-------------|
|
|
304
|
+
| `'tc'` | Términos y Condiciones (Terms & Conditions) |
|
|
305
|
+
| `'contact'` | Información de Contacto Legal |
|
|
306
|
+
| `'privacy_policy'` | Política de Privacidad |
|
|
307
|
+
| `'refund_policy'` | Política de Reembolso |
|
|
308
|
+
| `'faqs'` | Preguntas Frecuentes (FAQs) |
|
|
309
|
+
|
|
310
|
+
### Idiomas Soportados
|
|
311
|
+
|
|
312
|
+
El parámetro `lang` acepta códigos de idioma ISO estándar:
|
|
313
|
+
|
|
314
|
+
- `'en'` - Inglés
|
|
315
|
+
- `'es'` - Español
|
|
316
|
+
- `'fr'` - Francés
|
|
317
|
+
- `'de'` - Alemán
|
|
318
|
+
- `'it'` - Italiano
|
|
319
|
+
- `'pt'` - Portugués
|
|
320
|
+
- Y otros códigos ISO estándar...
|
|
321
|
+
|
|
322
|
+
### Detalles Técnicos
|
|
323
|
+
|
|
324
|
+
**Endpoint**: `POST https://bc1742.gways.org/legal/get`
|
|
325
|
+
|
|
326
|
+
**Request Body**:
|
|
327
|
+
```json
|
|
328
|
+
{
|
|
329
|
+
"type": "tc",
|
|
330
|
+
"lang": "es",
|
|
331
|
+
"web_id": "chatconnect-ios-app"
|
|
332
|
+
}
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
**Respuesta Esperada**:
|
|
336
|
+
```json
|
|
337
|
+
{
|
|
338
|
+
"success": 1,
|
|
339
|
+
"data": {
|
|
340
|
+
"content": "Contenido del documento legal...",
|
|
341
|
+
"title": "Términos y Condiciones",
|
|
342
|
+
"last_updated": "2025-02-12"
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
### Ejemplo Completo en React Native
|
|
348
|
+
|
|
349
|
+
```javascript
|
|
350
|
+
import React, { useEffect, useState } from 'react';
|
|
351
|
+
import { View, Text, ScrollView } from 'react-native';
|
|
352
|
+
import SDK from 'apps-sdk';
|
|
353
|
+
|
|
354
|
+
const TermsAndConditionsScreen = () => {
|
|
355
|
+
const [termsContent, setTermsContent] = useState('');
|
|
356
|
+
const [loading, setLoading] = useState(true);
|
|
357
|
+
|
|
358
|
+
useEffect(() => {
|
|
359
|
+
loadTerms();
|
|
360
|
+
}, []);
|
|
361
|
+
|
|
362
|
+
const loadTerms = async () => {
|
|
363
|
+
try {
|
|
364
|
+
const response = await SDK.legal.getLegalText(
|
|
365
|
+
'chatconnect-ios-app',
|
|
366
|
+
'tc',
|
|
367
|
+
'es'
|
|
368
|
+
);
|
|
369
|
+
|
|
370
|
+
if (response && response.success) {
|
|
371
|
+
setTermsContent(response.data.content);
|
|
372
|
+
}
|
|
373
|
+
} catch (error) {
|
|
374
|
+
console.error('Error al cargar términos:', error);
|
|
375
|
+
} finally {
|
|
376
|
+
setLoading(false);
|
|
377
|
+
}
|
|
378
|
+
};
|
|
379
|
+
|
|
380
|
+
return (
|
|
381
|
+
<ScrollView>
|
|
382
|
+
{loading ? (
|
|
383
|
+
<Text>Cargando...</Text>
|
|
384
|
+
) : (
|
|
385
|
+
<Text>{termsContent}</Text>
|
|
386
|
+
)}
|
|
387
|
+
</ScrollView>
|
|
388
|
+
);
|
|
389
|
+
};
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
### Cargar Múltiples Documentos
|
|
393
|
+
|
|
394
|
+
```javascript
|
|
395
|
+
const loadAllLegalDocuments = async (webId, lang) => {
|
|
396
|
+
try {
|
|
397
|
+
const [terms, privacy, refund, contact, faqs] = await Promise.all([
|
|
398
|
+
SDK.legal.getLegalText(webId, 'tc', lang),
|
|
399
|
+
SDK.legal.getLegalText(webId, 'privacy_policy', lang),
|
|
400
|
+
SDK.legal.getLegalText(webId, 'refund_policy', lang),
|
|
401
|
+
SDK.legal.getLegalText(webId, 'contact', lang),
|
|
402
|
+
SDK.legal.getLegalText(webId, 'faqs', lang),
|
|
403
|
+
]);
|
|
404
|
+
|
|
405
|
+
return {
|
|
406
|
+
terms: terms.data,
|
|
407
|
+
privacy: privacy.data,
|
|
408
|
+
refund: refund.data,
|
|
409
|
+
contact: contact.data,
|
|
410
|
+
faqs: faqs.data,
|
|
411
|
+
};
|
|
412
|
+
} catch (error) {
|
|
413
|
+
console.error('Error al cargar documentos legales:', error);
|
|
414
|
+
throw error;
|
|
415
|
+
}
|
|
416
|
+
};
|
|
417
|
+
|
|
418
|
+
// Uso
|
|
419
|
+
const legalDocs = await loadAllLegalDocuments('chatconnect-ios-app', 'es');
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
### Manejo de Errores
|
|
423
|
+
|
|
424
|
+
```javascript
|
|
425
|
+
const getLegalDocumentSafely = async (webId, type, lang) => {
|
|
426
|
+
try {
|
|
427
|
+
const response = await SDK.legal.getLegalText(webId, type, lang);
|
|
428
|
+
|
|
429
|
+
if (response && response.success === 1) {
|
|
430
|
+
return {
|
|
431
|
+
success: true,
|
|
432
|
+
content: response.data
|
|
433
|
+
};
|
|
434
|
+
} else {
|
|
435
|
+
return {
|
|
436
|
+
success: false,
|
|
437
|
+
error: 'Documento no disponible'
|
|
438
|
+
};
|
|
439
|
+
}
|
|
440
|
+
} catch (error) {
|
|
441
|
+
console.error('Error al obtener documento legal:', error);
|
|
442
|
+
return {
|
|
443
|
+
success: false,
|
|
444
|
+
error: error.message
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
// Uso con manejo de errores
|
|
450
|
+
const result = await getLegalDocumentSafely('chatconnect-ios-app', 'tc', 'es');
|
|
451
|
+
if (result.success) {
|
|
452
|
+
console.log('Contenido:', result.content);
|
|
453
|
+
} else {
|
|
454
|
+
console.error('Error:', result.error);
|
|
455
|
+
}
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
### Validaciones
|
|
459
|
+
|
|
460
|
+
El método incluye validaciones automáticas:
|
|
461
|
+
|
|
462
|
+
1. **web_id requerido**: Lanza un error si no se proporciona
|
|
463
|
+
2. **type requerido**: Lanza un error si no se proporciona
|
|
464
|
+
3. **lang requerido**: Lanza un error si no se proporciona
|
|
465
|
+
4. **Tipo válido**: Solo acepta los 5 tipos de documentos especificados
|
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://bc1742.gways.org/legal",
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
export var EVENTS = {}
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {NotificationsPush, Networking, Storage, Session, Utils, PayWallLogic, Rating, AdJust, TrackingTransparency, Voice, MixPanel, Adapty, HomeActions, Facebook, Legal} from "./src/libraries";
|
|
2
2
|
import PayWall from "./src/components/PayWall";
|
|
3
|
-
import AdaptyOnboarding from "./src/components/AdaptyOnboarding";
|
|
3
|
+
import AdaptyOnboarding from "./src/components/AdaptyOnboarding.js";
|
|
4
4
|
|
|
5
5
|
class AppsSDK {
|
|
6
6
|
constructor() {
|
|
@@ -64,4 +64,4 @@ export default {
|
|
|
64
64
|
homeActions: HomeActions,
|
|
65
65
|
facebook: Facebook,
|
|
66
66
|
legal: Legal,
|
|
67
|
-
}
|
|
67
|
+
}
|
package/package.json
CHANGED
package/src/libraries/Legal.js
CHANGED
|
@@ -5,36 +5,49 @@ class Legal {
|
|
|
5
5
|
constructor() {}
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @param {string}
|
|
10
|
-
* @param {'tc' | '
|
|
11
|
-
* @param {string}
|
|
12
|
-
* @returns {Promise<any>}
|
|
8
|
+
* Get legal texts from backend
|
|
9
|
+
* @param {string} web_id - Web project ID
|
|
10
|
+
* @param {'tc' | 'contact' | 'privacy_policy' | 'refund_policy' | 'faqs'} type - Legal text type
|
|
11
|
+
* @param {string} lang - Language code (e.g. 'en', 'es', 'fr', 'de', etc.)
|
|
12
|
+
* @returns {Promise<any>} Legal text response
|
|
13
13
|
*/
|
|
14
|
-
async getLegalText(
|
|
15
|
-
config.DEBUG_MODE && console.debug("getLegalText", {
|
|
14
|
+
async getLegalText(web_id, type, lang) {
|
|
15
|
+
config.DEBUG_MODE && console.debug("getLegalText", { web_id, type, lang });
|
|
16
16
|
|
|
17
|
-
if (!
|
|
18
|
-
console.error('getLegalText:
|
|
19
|
-
throw new Error('
|
|
17
|
+
if (!web_id) {
|
|
18
|
+
console.error('getLegalText: web_id is required');
|
|
19
|
+
throw new Error('web_id is required');
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
if (!
|
|
23
|
-
console.error('getLegalText:
|
|
24
|
-
throw new Error('
|
|
22
|
+
if (!type) {
|
|
23
|
+
console.error('getLegalText: type is required');
|
|
24
|
+
throw new Error('type is required');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (!lang) {
|
|
28
|
+
console.error('getLegalText: lang is required');
|
|
29
|
+
throw new Error('lang is required');
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const validTypes = ['tc', 'contact', 'privacy_policy', 'refund_policy', 'faqs'];
|
|
33
|
+
if (!validTypes.includes(type)) {
|
|
34
|
+
console.error(`getLegalText: invalid type. Must be one of: ${validTypes.join(', ')}`);
|
|
35
|
+
throw new Error(`Invalid type. Must be one of: ${validTypes.join(', ')}`);
|
|
25
36
|
}
|
|
26
37
|
|
|
27
38
|
try {
|
|
28
|
-
const
|
|
29
|
-
|
|
39
|
+
const endpoint = `${config.ENDPOINTS.LEGAL_BASE}/get`;
|
|
40
|
+
|
|
41
|
+
const response = await Networking.request(endpoint, {
|
|
30
42
|
type,
|
|
31
|
-
|
|
43
|
+
lang,
|
|
44
|
+
web_id
|
|
32
45
|
});
|
|
33
46
|
|
|
34
47
|
config.DEBUG_MODE && console.debug("getLegalText response", response);
|
|
35
48
|
return response;
|
|
36
49
|
} catch (error) {
|
|
37
|
-
console.error(`Failed to fetch legal text (${type}) for
|
|
50
|
+
console.error(`Failed to fetch legal text (${type}) for web_id ${web_id}:`, error);
|
|
38
51
|
throw error;
|
|
39
52
|
}
|
|
40
53
|
}
|
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, type: '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
|
+
}
|