apps-sdk 1.1.75 → 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 +123 -151
- package/config.js +1 -1
- package/index.js +2 -2
- package/package.json +1 -1
- package/rest_client_collection/request.http +37 -0
- package/src/libraries/Legal.js +16 -25
- package/src/libraries/PayWallLogic.js +5 -5
- package/types/index.d.ts +1 -1
package/EJEMPLO_USO_SDK.md
CHANGED
|
@@ -282,184 +282,156 @@ Esta arquitectura permite que el 90% del código de tu aplicación sea idéntico
|
|
|
282
282
|
|
|
283
283
|
## 📄 Módulo Legal - Obtener Textos Legales
|
|
284
284
|
|
|
285
|
-
### Uso
|
|
285
|
+
### Uso desde cualquier plataforma
|
|
286
286
|
|
|
287
287
|
```javascript
|
|
288
|
-
import SDK from 'apps-sdk';
|
|
289
|
-
|
|
290
|
-
// Obtener términos y condiciones en
|
|
291
|
-
const
|
|
292
|
-
|
|
293
|
-
//
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
// Obtener
|
|
297
|
-
const
|
|
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
|
+
);
|
|
298
337
|
```
|
|
299
338
|
|
|
300
|
-
###
|
|
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) |
|
|
339
|
+
### Endpoints disponibles
|
|
309
340
|
|
|
310
|
-
|
|
341
|
+
La API construye automáticamente las URLs basándose en el `url_path`:
|
|
311
342
|
|
|
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
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
|
|
334
355
|
|
|
335
|
-
|
|
336
|
-
```json
|
|
356
|
+
```javascript
|
|
337
357
|
{
|
|
338
|
-
"
|
|
339
|
-
"
|
|
340
|
-
|
|
341
|
-
"title": "Términos y Condiciones",
|
|
342
|
-
"last_updated": "2025-02-12"
|
|
343
|
-
}
|
|
358
|
+
"url_path": "tc", // El tipo de documento legal
|
|
359
|
+
"lang": "en", // Idioma del contenido
|
|
360
|
+
"web_id": "chatconnect-ios-app" // Identificador del proyecto
|
|
344
361
|
}
|
|
345
362
|
```
|
|
346
363
|
|
|
347
|
-
### Ejemplo
|
|
364
|
+
### Ejemplo completo en React Native
|
|
348
365
|
|
|
349
366
|
```javascript
|
|
350
|
-
import React, {
|
|
367
|
+
import React, { useState, useEffect } from 'react';
|
|
351
368
|
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);
|
|
369
|
+
import SDK from '@apps-sdk/expo';
|
|
357
370
|
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
371
|
+
const TermsScreen = () => {
|
|
372
|
+
const [terms, setTerms] = useState(null);
|
|
373
|
+
const [loading, setLoading] = useState(true);
|
|
361
374
|
|
|
375
|
+
useEffect(() => {
|
|
362
376
|
const loadTerms = async () => {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
} finally {
|
|
376
|
-
setLoading(false);
|
|
377
|
-
}
|
|
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
|
+
}
|
|
378
389
|
};
|
|
379
390
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
{loading ? (
|
|
383
|
-
<Text>Cargando...</Text>
|
|
384
|
-
) : (
|
|
385
|
-
<Text>{termsContent}</Text>
|
|
386
|
-
)}
|
|
387
|
-
</ScrollView>
|
|
388
|
-
);
|
|
389
|
-
};
|
|
390
|
-
```
|
|
391
|
+
loadTerms();
|
|
392
|
+
}, []);
|
|
391
393
|
|
|
392
|
-
|
|
394
|
+
if (loading) return <Text>Loading...</Text>;
|
|
393
395
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
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
|
-
}
|
|
396
|
+
return (
|
|
397
|
+
<ScrollView>
|
|
398
|
+
<Text>{terms?.content}</Text>
|
|
399
|
+
</ScrollView>
|
|
400
|
+
);
|
|
416
401
|
};
|
|
417
|
-
|
|
418
|
-
// Uso
|
|
419
|
-
const legalDocs = await loadAllLegalDocuments('chatconnect-ios-app', 'es');
|
|
420
402
|
```
|
|
421
403
|
|
|
422
|
-
###
|
|
404
|
+
### Ejemplo completo en Next.js/Web
|
|
423
405
|
|
|
424
406
|
```javascript
|
|
425
|
-
|
|
426
|
-
|
|
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
|
-
```
|
|
407
|
+
import { useEffect, useState } from 'react';
|
|
408
|
+
import SDK from '@apps-sdk/web';
|
|
457
409
|
|
|
458
|
-
|
|
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
|
+
};
|
|
459
426
|
|
|
460
|
-
|
|
427
|
+
loadPolicy();
|
|
428
|
+
}, []);
|
|
461
429
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
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
|
-
LEGAL_BASE: "https://
|
|
16
|
+
LEGAL_BASE: "https://api.fluver-ai.com/content/andromeda/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";
|
|
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
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
### Get Legal Text
|
|
2
|
+
POST https://api.fluver-ai.com/content/andromeda/get-legal-text HTTP/1.1
|
|
3
|
+
Content-Type: application/json
|
|
4
|
+
|
|
5
|
+
{
|
|
6
|
+
"user_id": "20251107104348_57131690dbf5452eae",
|
|
7
|
+
"isFirstOpen": false,
|
|
8
|
+
"app": {
|
|
9
|
+
"shortVersion": "1.1.73",
|
|
10
|
+
"package": "com.mobileawareservices.chatconnect",
|
|
11
|
+
"languageCode": "en",
|
|
12
|
+
"regionCode": "DZ",
|
|
13
|
+
"buildVersionNumber": "1.1.73"
|
|
14
|
+
},
|
|
15
|
+
"device": {
|
|
16
|
+
"name": "iPhone 16 Plus",
|
|
17
|
+
"systemName": "iOS",
|
|
18
|
+
"systemVersion": "18.6",
|
|
19
|
+
"model": "Simulator iOS"
|
|
20
|
+
},
|
|
21
|
+
"sandbox": {
|
|
22
|
+
"domains": "0"
|
|
23
|
+
},
|
|
24
|
+
"adjust": {
|
|
25
|
+
"attribution_id": "",
|
|
26
|
+
"idfa": "",
|
|
27
|
+
"googleAdid": "",
|
|
28
|
+
"attribution": {}
|
|
29
|
+
},
|
|
30
|
+
"dev": false,
|
|
31
|
+
"lang": "en",
|
|
32
|
+
"package": "com.mobileawareservices.chatconnect",
|
|
33
|
+
"webId": "chatconnect-ios-app",
|
|
34
|
+
"type": "tc",
|
|
35
|
+
"language": "en"
|
|
36
|
+
}
|
|
37
|
+
|
package/src/libraries/Legal.js
CHANGED
|
@@ -5,41 +5,32 @@ class Legal {
|
|
|
5
5
|
constructor() {}
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
9
|
-
* @param {string} web_id -
|
|
10
|
-
* @param {'tc' | 'contact' | 'privacy_policy' | 'refund_policy' | 'faqs'}
|
|
11
|
-
* @param {string} lang -
|
|
12
|
-
* @returns {Promise<any>}
|
|
8
|
+
* Obtiene textos legales desde el backend
|
|
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
|
+
* @returns {Promise<any>} Respuesta con el texto legal
|
|
13
13
|
*/
|
|
14
|
-
async getLegalText(web_id,
|
|
15
|
-
config.DEBUG_MODE && console.debug("getLegalText", { web_id,
|
|
14
|
+
async getLegalText(web_id, url_path, lang = 'en') {
|
|
15
|
+
config.DEBUG_MODE && console.debug("getLegalText", { web_id, url_path, lang });
|
|
16
16
|
|
|
17
17
|
if (!web_id) {
|
|
18
|
-
console.error('getLegalText: web_id
|
|
19
|
-
throw new Error('web_id
|
|
20
|
-
}
|
|
21
|
-
|
|
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');
|
|
18
|
+
console.error('getLegalText: web_id es requerido');
|
|
19
|
+
throw new Error('web_id es requerido');
|
|
30
20
|
}
|
|
31
21
|
|
|
32
22
|
const validTypes = ['tc', 'contact', 'privacy_policy', 'refund_policy', 'faqs'];
|
|
33
|
-
if (!validTypes.includes(
|
|
34
|
-
console.error(`getLegalText:
|
|
35
|
-
throw new Error(`
|
|
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(', ')}`);
|
|
36
26
|
}
|
|
37
27
|
|
|
38
28
|
try {
|
|
39
|
-
|
|
29
|
+
// Construir la URL completa añadiendo el url_path al endpoint base
|
|
30
|
+
const endpoint = `${config.ENDPOINTS.LEGAL_BASE}/${url_path}`;
|
|
40
31
|
|
|
41
32
|
const response = await Networking.request(endpoint, {
|
|
42
|
-
|
|
33
|
+
url_path,
|
|
43
34
|
lang,
|
|
44
35
|
web_id
|
|
45
36
|
});
|
|
@@ -47,7 +38,7 @@ class Legal {
|
|
|
47
38
|
config.DEBUG_MODE && console.debug("getLegalText response", response);
|
|
48
39
|
return response;
|
|
49
40
|
} catch (error) {
|
|
50
|
-
console.error(`Failed to fetch legal text (${
|
|
41
|
+
console.error(`Failed to fetch legal text (${url_path}) for web_id ${web_id}:`, error);
|
|
51
42
|
throw error;
|
|
52
43
|
}
|
|
53
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(web_id: string,
|
|
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 {
|