@clix-so/react-native-sdk 0.0.1 → 0.0.2-beta.1

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.
Files changed (47) hide show
  1. package/README.md +51 -5
  2. package/lib/module/core/Clix.js +9 -7
  3. package/lib/module/core/Clix.js.map +1 -1
  4. package/lib/module/core/ClixNotification.js +122 -0
  5. package/lib/module/core/ClixNotification.js.map +1 -0
  6. package/lib/module/services/DeviceService.js +27 -19
  7. package/lib/module/services/DeviceService.js.map +1 -1
  8. package/lib/module/services/EventAPIService.js +7 -1
  9. package/lib/module/services/EventAPIService.js.map +1 -1
  10. package/lib/module/services/EventService.js +8 -5
  11. package/lib/module/services/EventService.js.map +1 -1
  12. package/lib/module/services/NotificationService.js +91 -49
  13. package/lib/module/services/NotificationService.js.map +1 -1
  14. package/lib/module/services/StorageService.js +52 -15
  15. package/lib/module/services/StorageService.js.map +1 -1
  16. package/lib/module/services/TokenService.js +13 -13
  17. package/lib/module/services/TokenService.js.map +1 -1
  18. package/lib/module/utils/ClixDateFormatter.js +19 -0
  19. package/lib/module/utils/ClixDateFormatter.js.map +1 -0
  20. package/lib/typescript/src/core/Clix.d.ts +11 -11
  21. package/lib/typescript/src/core/Clix.d.ts.map +1 -1
  22. package/lib/typescript/src/core/ClixNotification.d.ts +25 -0
  23. package/lib/typescript/src/core/ClixNotification.d.ts.map +1 -0
  24. package/lib/typescript/src/services/DeviceService.d.ts +3 -2
  25. package/lib/typescript/src/services/DeviceService.d.ts.map +1 -1
  26. package/lib/typescript/src/services/EventAPIService.d.ts +1 -1
  27. package/lib/typescript/src/services/EventAPIService.d.ts.map +1 -1
  28. package/lib/typescript/src/services/EventService.d.ts +1 -1
  29. package/lib/typescript/src/services/EventService.d.ts.map +1 -1
  30. package/lib/typescript/src/services/NotificationService.d.ts +21 -1
  31. package/lib/typescript/src/services/NotificationService.d.ts.map +1 -1
  32. package/lib/typescript/src/services/StorageService.d.ts +11 -6
  33. package/lib/typescript/src/services/StorageService.d.ts.map +1 -1
  34. package/lib/typescript/src/services/TokenService.d.ts +5 -5
  35. package/lib/typescript/src/services/TokenService.d.ts.map +1 -1
  36. package/lib/typescript/src/utils/ClixDateFormatter.d.ts +4 -0
  37. package/lib/typescript/src/utils/ClixDateFormatter.d.ts.map +1 -0
  38. package/package.json +2 -2
  39. package/src/core/Clix.ts +17 -21
  40. package/src/core/ClixNotification.ts +157 -0
  41. package/src/services/DeviceService.ts +35 -20
  42. package/src/services/EventAPIService.ts +5 -1
  43. package/src/services/EventService.ts +13 -5
  44. package/src/services/NotificationService.ts +145 -54
  45. package/src/services/StorageService.ts +60 -16
  46. package/src/services/TokenService.ts +13 -15
  47. package/src/utils/ClixDateFormatter.ts +19 -0
@@ -8,20 +8,18 @@ export class TokenService {
8
8
 
9
9
  constructor(private readonly storageService: StorageService) {}
10
10
 
11
- async getCurrentToken(): Promise<string | undefined> {
11
+ getCurrentToken(): string | undefined {
12
12
  try {
13
- return await this.storageService.get<string>(
14
- TokenService.CURRENT_TOKEN_KEY
15
- );
13
+ return this.storageService.get<string>(TokenService.CURRENT_TOKEN_KEY);
16
14
  } catch (error) {
17
15
  ClixLogger.error('Failed to get current token', error);
18
16
  return undefined;
19
17
  }
20
18
  }
21
19
 
22
- async getPreviousTokens(): Promise<string[]> {
20
+ getPreviousTokens(): string[] {
23
21
  try {
24
- const result = await this.storageService.get<string[]>(
22
+ const result = this.storageService.get<string[]>(
25
23
  TokenService.PREVIOUS_TOKENS_KEY
26
24
  );
27
25
  if (result === undefined) return [];
@@ -33,11 +31,11 @@ export class TokenService {
33
31
  }
34
32
  }
35
33
 
36
- async saveToken(token: string): Promise<void> {
34
+ saveToken(token: string) {
37
35
  try {
38
- await this.storageService.set(TokenService.CURRENT_TOKEN_KEY, token);
36
+ this.storageService.set(TokenService.CURRENT_TOKEN_KEY, token);
39
37
 
40
- let tokens = await this.getPreviousTokens();
38
+ let tokens = this.getPreviousTokens();
41
39
 
42
40
  // Remove existing token if present
43
41
  const currentIndex = tokens.indexOf(token);
@@ -53,7 +51,7 @@ export class TokenService {
53
51
  tokens = tokens.slice(-TokenService.MAX_TOKENS);
54
52
  }
55
53
 
56
- await this.storageService.set(TokenService.PREVIOUS_TOKENS_KEY, tokens);
54
+ this.storageService.set(TokenService.PREVIOUS_TOKENS_KEY, tokens);
57
55
  ClixLogger.debug('Token saved successfully');
58
56
  } catch (error) {
59
57
  ClixLogger.error('Failed to save token', error);
@@ -61,10 +59,10 @@ export class TokenService {
61
59
  }
62
60
  }
63
61
 
64
- async clearTokens(): Promise<void> {
62
+ clearTokens() {
65
63
  try {
66
- await this.storageService.remove(TokenService.PREVIOUS_TOKENS_KEY);
67
- await this.storageService.remove(TokenService.CURRENT_TOKEN_KEY);
64
+ this.storageService.remove(TokenService.PREVIOUS_TOKENS_KEY);
65
+ this.storageService.remove(TokenService.CURRENT_TOKEN_KEY);
68
66
  ClixLogger.debug('All tokens cleared');
69
67
  } catch (error) {
70
68
  ClixLogger.error('Failed to clear tokens', error);
@@ -78,7 +76,7 @@ export class TokenService {
78
76
  .join('');
79
77
  }
80
78
 
81
- async reset(): Promise<void> {
82
- await this.clearTokens();
79
+ reset() {
80
+ this.clearTokens();
83
81
  }
84
82
  }
@@ -0,0 +1,19 @@
1
+ export class ClixDateFormatter {
2
+ static format(date: Date): string {
3
+ const pad = (num: number) => num.toString().padStart(2, '0');
4
+
5
+ const year = date.getFullYear();
6
+ const month = pad(date.getMonth() + 1);
7
+ const day = pad(date.getDate());
8
+ const hours = pad(date.getHours());
9
+ const minutes = pad(date.getMinutes());
10
+ const seconds = pad(date.getSeconds());
11
+
12
+ const offsetMinutes = date.getTimezoneOffset();
13
+ const offsetSign = offsetMinutes <= 0 ? '+' : '-';
14
+ const offsetHours = pad(Math.floor(Math.abs(offsetMinutes) / 60));
15
+ const offsetMinutesPart = pad(Math.abs(offsetMinutes) % 60);
16
+
17
+ return `${year}-${month}-${day}T${hours}:${minutes}:${seconds}${offsetSign}${offsetHours}:${offsetMinutesPart}`;
18
+ }
19
+ }