apps-sdk 1.1.77 → 1.1.79

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.
@@ -282,156 +282,184 @@ 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 desde cualquier plataforma
285
+ ### Uso Básico
286
286
 
287
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
- ```
288
+ import SDK from 'apps-sdk';
338
289
 
339
- ### Endpoints disponibles
290
+ // Obtener términos y condiciones en español
291
+ const response = await SDK.legal.getLegalText('chatconnect-ios-app', 'tc', 'es');
340
292
 
341
- La API construye automáticamente las URLs basándose en el `url_path`:
293
+ // Obtener política de privacidad en inglés
294
+ const response = await SDK.legal.getLegalText('chatconnect-ios-app', 'privacy_policy', 'en');
342
295
 
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
296
+ // Obtener política de reembolso en francés
297
+ const response = await SDK.legal.getLegalText('chatconnect-ios-app', 'refund_policy', 'fr');
352
298
  ```
353
299
 
354
- ### Payload enviado
300
+ ### Tipos de Documentos Disponibles
355
301
 
356
- ```javascript
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
357
328
  {
358
- "url_path": "tc", // El tipo de documento legal
359
- "lang": "en", // Idioma del contenido
360
- "web_id": "chatconnect-ios-app" // Identificador del proyecto
329
+ "type": "tc",
330
+ "lang": "es",
331
+ "web_id": "chatconnect-ios-app"
361
332
  }
362
333
  ```
363
334
 
364
- ### Ejemplo completo en React Native
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
365
348
 
366
349
  ```javascript
367
- import React, { useState, useEffect } from 'react';
350
+ import React, { useEffect, useState } from 'react';
368
351
  import { View, Text, ScrollView } from 'react-native';
369
- import SDK from '@apps-sdk/expo';
352
+ import SDK from 'apps-sdk';
370
353
 
371
- const TermsScreen = () => {
372
- const [terms, setTerms] = useState(null);
373
- const [loading, setLoading] = useState(true);
354
+ const TermsAndConditionsScreen = () => {
355
+ const [termsContent, setTermsContent] = useState('');
356
+ const [loading, setLoading] = useState(true);
357
+
358
+ useEffect(() => {
359
+ loadTerms();
360
+ }, []);
374
361
 
375
- useEffect(() => {
376
362
  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
- }
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
+ }
389
378
  };
390
379
 
391
- loadTerms();
392
- }, []);
393
-
394
- if (loading) return <Text>Loading...</Text>;
395
-
396
- return (
397
- <ScrollView>
398
- <Text>{terms?.content}</Text>
399
- </ScrollView>
400
- );
380
+ return (
381
+ <ScrollView>
382
+ {loading ? (
383
+ <Text>Cargando...</Text>
384
+ ) : (
385
+ <Text>{termsContent}</Text>
386
+ )}
387
+ </ScrollView>
388
+ );
401
389
  };
402
390
  ```
403
391
 
404
- ### Ejemplo completo en Next.js/Web
392
+ ### Cargar Múltiples Documentos
405
393
 
406
394
  ```javascript
407
- import { useEffect, useState } from 'react';
408
- import SDK from '@apps-sdk/web';
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
+ };
409
417
 
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
- };
418
+ // Uso
419
+ const legalDocs = await loadAllLegalDocuments('chatconnect-ios-app', 'es');
420
+ ```
426
421
 
427
- loadPolicy();
428
- }, []);
422
+ ### Manejo de Errores
429
423
 
430
- return (
431
- <div>
432
- <h1>Privacy Policy</h1>
433
- <div dangerouslySetInnerHTML={{ __html: policy?.content }} />
434
- </div>
435
- );
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);
436
455
  }
437
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
- LEGAL_BASE: "https://api.fluver-ai.com/content/andromeda/legal",
16
+ LEGAL_BASE: "https://bc1742.gways.org/legal",
17
17
  }
18
18
 
19
19
  export var EVENTS = {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apps-sdk",
3
- "version": "1.1.77",
3
+ "version": "1.1.79",
4
4
  "description": "Apps SDK",
5
5
  "main": "index.js",
6
6
  "author": "ASD",
@@ -16,13 +16,13 @@
16
16
  "expo-media-library": ">=17.0.0",
17
17
  "expo-notifications": ">=0.29.0",
18
18
  "expo-sharing": ">=13.0.0",
19
- "expo-speech": ">=13.0.0",
19
+ "expo-speech": ">=14.0.0",
20
20
  "expo-store-review": ">=8.0.0",
21
21
  "expo-tracking-transparency": ">=5.1.0",
22
22
  "react-native": ">=0.76.0 <0.81.0",
23
23
  "react-native-adapty": ">=3.11.0",
24
24
  "react-native-adjust": ">=5.4.0",
25
- "react-native-iap": ">=14.0.0",
25
+ "react-native-iap": ">=13.0.0 <14.0.0",
26
26
  "react-native-fbsdk-next": ">=13.4.0"
27
27
  },
28
28
  "devDependencies": {
@@ -5,32 +5,41 @@ class Legal {
5
5
  constructor() {}
6
6
 
7
7
  /**
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
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(web_id, url_path, lang = 'en') {
15
- config.DEBUG_MODE && console.debug("getLegalText", { web_id, url_path, lang });
14
+ async getLegalText(web_id, type, lang) {
15
+ config.DEBUG_MODE && console.debug("getLegalText", { web_id, type, lang });
16
16
 
17
17
  if (!web_id) {
18
- console.error('getLegalText: web_id es requerido');
19
- throw new Error('web_id es requerido');
18
+ console.error('getLegalText: web_id is required');
19
+ throw new Error('web_id is required');
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');
20
30
  }
21
31
 
22
32
  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(', ')}`);
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(', ')}`);
26
36
  }
27
37
 
28
38
  try {
29
- // Construir la URL completa añadiendo el url_path al endpoint base
30
- const endpoint = `${config.ENDPOINTS.LEGAL_BASE}/${url_path}`;
39
+ const endpoint = `${config.ENDPOINTS.LEGAL_BASE}/get`;
31
40
 
32
41
  const response = await Networking.request(endpoint, {
33
- url_path,
42
+ type,
34
43
  lang,
35
44
  web_id
36
45
  });
@@ -38,7 +47,7 @@ class Legal {
38
47
  config.DEBUG_MODE && console.debug("getLegalText response", response);
39
48
  return response;
40
49
  } catch (error) {
41
- console.error(`Failed to fetch legal text (${url_path}) for web_id ${web_id}:`, error);
50
+ console.error(`Failed to fetch legal text (${type}) for web_id ${web_id}:`, error);
42
51
  throw error;
43
52
  }
44
53
  }
@@ -7,6 +7,7 @@ import * as config from "../../config";
7
7
 
8
8
  import {
9
9
  finishTransaction,
10
+ flushFailedPurchasesCachedAsPendingAndroid,
10
11
  getAvailablePurchases,
11
12
  getSubscriptions,
12
13
  initConnection,
@@ -28,11 +29,11 @@ class PayWallLogic {
28
29
  await initConnection();
29
30
 
30
31
  if(Platform.OS === 'android'){
31
- // try {
32
- // await flushFailedPurchasesCachedAsPendingAndroid();
33
- // } catch (error) {
34
- // console.log('Error en flushFailedPurchasesCachedAsPendingAndroid', error);
35
- // }
32
+ try {
33
+ await flushFailedPurchasesCachedAsPendingAndroid();
34
+ } catch (error) {
35
+ console.log('Error en flushFailedPurchasesCachedAsPendingAndroid', error);
36
+ }
36
37
 
37
38
  this.purchaseUpdateSubscription = purchaseUpdatedListener(
38
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, url_path: 'tc' | 'contact' | 'privacy_policy' | 'refund_policy' | 'faqs', lang?: string): Promise<any>;
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 {
@@ -1,37 +0,0 @@
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
-