@oxyhq/services 5.10.4 → 5.10.6
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/README.md +62 -14
- package/lib/commonjs/core/OxyServices.js +797 -5
- package/lib/commonjs/core/OxyServices.js.map +1 -1
- package/lib/commonjs/core/index.js +8 -83
- package/lib/commonjs/core/index.js.map +1 -1
- package/lib/commonjs/index.js +31 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/ui/screens/FileManagementScreen.js +12 -12
- package/lib/commonjs/ui/screens/FileManagementScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/ProfileScreen.js +2 -2
- package/lib/commonjs/ui/screens/ProfileScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/SignInScreen.js +1 -1
- package/lib/commonjs/ui/screens/SignInScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaCenterScreen.js +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaCenterScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaLeaderboardScreen.js +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaLeaderboardScreen.js.map +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaRulesScreen.js +1 -1
- package/lib/commonjs/ui/screens/karma/KarmaRulesScreen.js.map +1 -1
- package/lib/commonjs/ui/stores/followStore.js +4 -4
- package/lib/commonjs/ui/stores/followStore.js.map +1 -1
- package/lib/commonjs/utils/s3FileManager.js +243 -0
- package/lib/commonjs/utils/s3FileManager.js.map +1 -0
- package/lib/commonjs/utils/s3FileManagerExample.js +407 -0
- package/lib/commonjs/utils/s3FileManagerExample.js.map +1 -0
- package/lib/commonjs/utils/s3FileManagerRN.js +274 -0
- package/lib/commonjs/utils/s3FileManagerRN.js.map +1 -0
- package/lib/module/core/OxyServices.js +796 -4
- package/lib/module/core/OxyServices.js.map +1 -1
- package/lib/module/core/index.js +9 -24
- package/lib/module/core/index.js.map +1 -1
- package/lib/module/index.js +4 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/ui/screens/FileManagementScreen.js +12 -12
- package/lib/module/ui/screens/FileManagementScreen.js.map +1 -1
- package/lib/module/ui/screens/ProfileScreen.js +2 -2
- package/lib/module/ui/screens/ProfileScreen.js.map +1 -1
- package/lib/module/ui/screens/SignInScreen.js +1 -1
- package/lib/module/ui/screens/SignInScreen.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaCenterScreen.js +1 -1
- package/lib/module/ui/screens/karma/KarmaCenterScreen.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaLeaderboardScreen.js +1 -1
- package/lib/module/ui/screens/karma/KarmaLeaderboardScreen.js.map +1 -1
- package/lib/module/ui/screens/karma/KarmaRulesScreen.js +1 -1
- package/lib/module/ui/screens/karma/KarmaRulesScreen.js.map +1 -1
- package/lib/module/ui/stores/followStore.js +4 -4
- package/lib/module/ui/stores/followStore.js.map +1 -1
- package/lib/module/utils/s3FileManager.js +237 -0
- package/lib/module/utils/s3FileManager.js.map +1 -0
- package/lib/module/utils/s3FileManagerExample.js +400 -0
- package/lib/module/utils/s3FileManagerExample.js.map +1 -0
- package/lib/module/utils/s3FileManagerRN.js +268 -0
- package/lib/module/utils/s3FileManagerRN.js.map +1 -0
- package/lib/typescript/core/OxyServices.d.ts +292 -3
- package/lib/typescript/core/OxyServices.d.ts.map +1 -1
- package/lib/typescript/core/index.d.ts +7 -16
- package/lib/typescript/core/index.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +4 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/utils/s3FileManager.d.ts +81 -0
- package/lib/typescript/utils/s3FileManager.d.ts.map +1 -0
- package/lib/typescript/utils/s3FileManagerExample.d.ts +87 -0
- package/lib/typescript/utils/s3FileManagerExample.d.ts.map +1 -0
- package/lib/typescript/utils/s3FileManagerRN.d.ts +104 -0
- package/lib/typescript/utils/s3FileManagerRN.d.ts.map +1 -0
- package/package.json +3 -1
- package/src/core/OxyServices.ts +881 -46
- package/src/core/index.ts +9 -24
- package/src/index.ts +17 -1
- package/src/ui/screens/FileManagementScreen.tsx +12 -12
- package/src/ui/screens/ProfileScreen.tsx +3 -3
- package/src/ui/screens/SignInScreen.tsx +1 -1
- package/src/ui/screens/karma/KarmaCenterScreen.tsx +2 -2
- package/src/ui/screens/karma/KarmaLeaderboardScreen.tsx +1 -1
- package/src/ui/screens/karma/KarmaRulesScreen.tsx +1 -1
- package/src/ui/stores/followStore.ts +4 -4
- package/src/utils/s3FileManager.ts +281 -0
- package/src/utils/s3FileManagerExample.ts +432 -0
- package/src/utils/s3FileManagerRN.ts +322 -0
- package/lib/commonjs/core/OxyServicesMain.js +0 -51
- package/lib/commonjs/core/OxyServicesMain.js.map +0 -1
- package/lib/commonjs/core/analytics/AnalyticsService.js +0 -67
- package/lib/commonjs/core/analytics/AnalyticsService.js.map +0 -1
- package/lib/commonjs/core/auth/AuthService.js +0 -538
- package/lib/commonjs/core/auth/AuthService.js.map +0 -1
- package/lib/commonjs/core/devices/DeviceService.js +0 -61
- package/lib/commonjs/core/devices/DeviceService.js.map +0 -1
- package/lib/commonjs/core/files/FileService.js +0 -180
- package/lib/commonjs/core/files/FileService.js.map +0 -1
- package/lib/commonjs/core/karma/KarmaService.js +0 -100
- package/lib/commonjs/core/karma/KarmaService.js.map +0 -1
- package/lib/commonjs/core/locations/LocationService.js +0 -131
- package/lib/commonjs/core/locations/LocationService.js.map +0 -1
- package/lib/commonjs/core/payments/PaymentService.js +0 -124
- package/lib/commonjs/core/payments/PaymentService.js.map +0 -1
- package/lib/commonjs/core/users/UserService.js +0 -234
- package/lib/commonjs/core/users/UserService.js.map +0 -1
- package/lib/module/core/OxyServicesMain.js +0 -47
- package/lib/module/core/OxyServicesMain.js.map +0 -1
- package/lib/module/core/analytics/AnalyticsService.js +0 -62
- package/lib/module/core/analytics/AnalyticsService.js.map +0 -1
- package/lib/module/core/auth/AuthService.js +0 -533
- package/lib/module/core/auth/AuthService.js.map +0 -1
- package/lib/module/core/devices/DeviceService.js +0 -57
- package/lib/module/core/devices/DeviceService.js.map +0 -1
- package/lib/module/core/files/FileService.js +0 -175
- package/lib/module/core/files/FileService.js.map +0 -1
- package/lib/module/core/karma/KarmaService.js +0 -95
- package/lib/module/core/karma/KarmaService.js.map +0 -1
- package/lib/module/core/locations/LocationService.js +0 -127
- package/lib/module/core/locations/LocationService.js.map +0 -1
- package/lib/module/core/payments/PaymentService.js +0 -119
- package/lib/module/core/payments/PaymentService.js.map +0 -1
- package/lib/module/core/users/UserService.js +0 -230
- package/lib/module/core/users/UserService.js.map +0 -1
- package/lib/typescript/core/OxyServicesMain.d.ts +0 -33
- package/lib/typescript/core/OxyServicesMain.d.ts.map +0 -1
- package/lib/typescript/core/analytics/AnalyticsService.d.ts +0 -26
- package/lib/typescript/core/analytics/AnalyticsService.d.ts.map +0 -1
- package/lib/typescript/core/auth/AuthService.d.ts +0 -165
- package/lib/typescript/core/auth/AuthService.d.ts.map +0 -1
- package/lib/typescript/core/devices/DeviceService.d.ts +0 -20
- package/lib/typescript/core/devices/DeviceService.d.ts.map +0 -1
- package/lib/typescript/core/files/FileService.d.ts +0 -59
- package/lib/typescript/core/files/FileService.d.ts.map +0 -1
- package/lib/typescript/core/karma/KarmaService.d.ts +0 -50
- package/lib/typescript/core/karma/KarmaService.d.ts.map +0 -1
- package/lib/typescript/core/locations/LocationService.d.ts +0 -39
- package/lib/typescript/core/locations/LocationService.d.ts.map +0 -1
- package/lib/typescript/core/payments/PaymentService.d.ts +0 -50
- package/lib/typescript/core/payments/PaymentService.d.ts.map +0 -1
- package/lib/typescript/core/users/UserService.d.ts +0 -111
- package/lib/typescript/core/users/UserService.d.ts.map +0 -1
- package/src/core/OxyServicesMain.ts +0 -57
- package/src/core/analytics/AnalyticsService.ts +0 -64
- package/src/core/auth/AuthService.ts +0 -560
- package/src/core/devices/DeviceService.ts +0 -55
- package/src/core/files/FileService.ts +0 -198
- package/src/core/karma/KarmaService.ts +0 -104
- package/src/core/locations/LocationService.ts +0 -141
- package/src/core/payments/PaymentService.ts +0 -133
- package/src/core/users/UserService.ts +0 -241
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import { OxyServices } from '../OxyServices';
|
|
2
|
-
import {
|
|
3
|
-
FileMetadata,
|
|
4
|
-
FileUploadResponse,
|
|
5
|
-
FileListResponse,
|
|
6
|
-
FileUpdateRequest,
|
|
7
|
-
FileDeleteResponse
|
|
8
|
-
} from '../../models/interfaces';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Default cloud URL for Oxy services, cloud is where the user files are. (e.g. images, videos, etc.). Not the API.
|
|
12
|
-
*/
|
|
13
|
-
export const OXY_CLOUD_URL = 'https://cloud.oxy.so';
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* File service for handling file operations and management
|
|
17
|
-
*/
|
|
18
|
-
export class FileService extends OxyServices {
|
|
19
|
-
/**
|
|
20
|
-
* Upload a single file
|
|
21
|
-
* Note: This method is deprecated. Use the new raw upload approach instead.
|
|
22
|
-
*/
|
|
23
|
-
async uploadFile(
|
|
24
|
-
file: File | Blob | any, // Use 'any' to handle Buffer type in cross-platform scenarios
|
|
25
|
-
filename: string,
|
|
26
|
-
metadata?: Record<string, any>
|
|
27
|
-
): Promise<FileMetadata> {
|
|
28
|
-
try {
|
|
29
|
-
const formData = new FormData();
|
|
30
|
-
formData.append('file', file, filename);
|
|
31
|
-
|
|
32
|
-
if (metadata) {
|
|
33
|
-
formData.append('metadata', JSON.stringify(metadata));
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const res = await this.getClient().post('/files/upload', formData, {
|
|
37
|
-
headers: {
|
|
38
|
-
'Content-Type': 'multipart/form-data'
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
return res.data;
|
|
42
|
-
} catch (error) {
|
|
43
|
-
throw this.handleError(error);
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Upload multiple files
|
|
49
|
-
* Note: This method is deprecated. Use the new raw upload approach instead.
|
|
50
|
-
*/
|
|
51
|
-
async uploadFiles(
|
|
52
|
-
files: (File | Blob | any)[],
|
|
53
|
-
filenames: string[],
|
|
54
|
-
metadata?: Record<string, any>
|
|
55
|
-
): Promise<FileUploadResponse> {
|
|
56
|
-
try {
|
|
57
|
-
const formData = new FormData();
|
|
58
|
-
|
|
59
|
-
files.forEach((file, index) => {
|
|
60
|
-
formData.append('files', file, filenames[index]);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
if (metadata) {
|
|
64
|
-
formData.append('metadata', JSON.stringify(metadata));
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const res = await this.getClient().post('/files/upload-multiple', formData, {
|
|
68
|
-
headers: {
|
|
69
|
-
'Content-Type': 'multipart/form-data'
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
return res.data;
|
|
73
|
-
} catch (error) {
|
|
74
|
-
throw this.handleError(error);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Get file metadata
|
|
80
|
-
*/
|
|
81
|
-
async getFileMetadata(fileId: string): Promise<FileMetadata> {
|
|
82
|
-
try {
|
|
83
|
-
const res = await this.getClient().get(`/api/files/meta/${fileId}`);
|
|
84
|
-
return res.data;
|
|
85
|
-
} catch (error) {
|
|
86
|
-
throw this.handleError(error);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Update file metadata
|
|
92
|
-
*/
|
|
93
|
-
async updateFileMetadata(fileId: string, updates: FileUpdateRequest): Promise<FileMetadata> {
|
|
94
|
-
try {
|
|
95
|
-
const res = await this.getClient().put(`/api/files/meta/${fileId}`, updates);
|
|
96
|
-
return res.data;
|
|
97
|
-
} catch (error) {
|
|
98
|
-
throw this.handleError(error);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Delete file
|
|
104
|
-
*/
|
|
105
|
-
async deleteFile(fileId: string): Promise<FileDeleteResponse> {
|
|
106
|
-
try {
|
|
107
|
-
const res = await this.getClient().delete(`/api/files/${fileId}`);
|
|
108
|
-
return res.data;
|
|
109
|
-
} catch (error) {
|
|
110
|
-
throw this.handleError(error);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Get file download URL
|
|
116
|
-
*/
|
|
117
|
-
getFileDownloadUrl(fileId: string): string {
|
|
118
|
-
return `${OXY_CLOUD_URL}/files/${fileId}/download`;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Get file stream URL
|
|
123
|
-
*/
|
|
124
|
-
getFileStreamUrl(fileId: string): string {
|
|
125
|
-
return `${OXY_CLOUD_URL}/files/${fileId}/stream`;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* List user files
|
|
130
|
-
*/
|
|
131
|
-
async listUserFiles(
|
|
132
|
-
userId: string,
|
|
133
|
-
limit?: number,
|
|
134
|
-
offset?: number,
|
|
135
|
-
filters?: Record<string, any>
|
|
136
|
-
): Promise<FileListResponse> {
|
|
137
|
-
try {
|
|
138
|
-
const params = new URLSearchParams();
|
|
139
|
-
if (limit) params.append('limit', limit.toString());
|
|
140
|
-
if (offset) params.append('offset', offset.toString());
|
|
141
|
-
|
|
142
|
-
if (filters) {
|
|
143
|
-
Object.entries(filters).forEach(([key, value]) => {
|
|
144
|
-
params.append(key, value.toString());
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
const res = await this.getClient().get(`/api/files/list/${userId}?${params.toString()}`);
|
|
149
|
-
return res.data;
|
|
150
|
-
} catch (error) {
|
|
151
|
-
throw this.handleError(error);
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* Download file content
|
|
157
|
-
*/
|
|
158
|
-
async downloadFileContent(fileId: string): Promise<Response> {
|
|
159
|
-
try {
|
|
160
|
-
const res = await this.getClient().get(`/api/files/${fileId}`, {
|
|
161
|
-
responseType: 'blob'
|
|
162
|
-
});
|
|
163
|
-
return res.data;
|
|
164
|
-
} catch (error) {
|
|
165
|
-
throw this.handleError(error);
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* Get file content as text
|
|
171
|
-
*/
|
|
172
|
-
async getFileContentAsText(fileId: string): Promise<string> {
|
|
173
|
-
try {
|
|
174
|
-
const res = await this.getClient().get(`/api/files/${fileId}`, {
|
|
175
|
-
headers: {
|
|
176
|
-
'Accept': 'text/plain'
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
return res.data;
|
|
180
|
-
} catch (error) {
|
|
181
|
-
throw this.handleError(error);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* Get file content as blob
|
|
187
|
-
*/
|
|
188
|
-
async getFileContentAsBlob(fileId: string): Promise<Blob> {
|
|
189
|
-
try {
|
|
190
|
-
const res = await this.getClient().get(`/api/files/${fileId}`, {
|
|
191
|
-
responseType: 'blob'
|
|
192
|
-
});
|
|
193
|
-
return res.data;
|
|
194
|
-
} catch (error) {
|
|
195
|
-
throw this.handleError(error);
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { OxyServices } from '../OxyServices';
|
|
2
|
-
import {
|
|
3
|
-
KarmaRule,
|
|
4
|
-
KarmaHistory,
|
|
5
|
-
KarmaLeaderboardEntry,
|
|
6
|
-
KarmaAwardRequest
|
|
7
|
-
} from '../../models/interfaces';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Karma service for handling karma system operations
|
|
11
|
-
*/
|
|
12
|
-
export class KarmaService extends OxyServices {
|
|
13
|
-
/**
|
|
14
|
-
* Get karma leaderboard
|
|
15
|
-
*/
|
|
16
|
-
async getKarmaLeaderboard(): Promise<KarmaLeaderboardEntry[]> {
|
|
17
|
-
try {
|
|
18
|
-
const res = await this.getClient().get('/karma/leaderboard');
|
|
19
|
-
return res.data;
|
|
20
|
-
} catch (error) {
|
|
21
|
-
throw this.handleError(error);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Get karma rules
|
|
27
|
-
*/
|
|
28
|
-
async getKarmaRules(): Promise<KarmaRule[]> {
|
|
29
|
-
try {
|
|
30
|
-
const res = await this.getClient().get('/karma/rules');
|
|
31
|
-
return res.data;
|
|
32
|
-
} catch (error) {
|
|
33
|
-
throw this.handleError(error);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Get user karma total
|
|
39
|
-
*/
|
|
40
|
-
async getUserKarmaTotal(userId: string): Promise<{ total: number }> {
|
|
41
|
-
try {
|
|
42
|
-
const res = await this.getClient().get(`/api/karma/${userId}/total`);
|
|
43
|
-
return res.data;
|
|
44
|
-
} catch (error) {
|
|
45
|
-
throw this.handleError(error);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Get user karma history
|
|
51
|
-
*/
|
|
52
|
-
async getUserKarmaHistory(
|
|
53
|
-
userId: string,
|
|
54
|
-
limit?: number,
|
|
55
|
-
offset?: number
|
|
56
|
-
): Promise<{ history: KarmaHistory[]; total: number; hasMore: boolean }> {
|
|
57
|
-
try {
|
|
58
|
-
const params = new URLSearchParams();
|
|
59
|
-
if (limit) params.append('limit', limit.toString());
|
|
60
|
-
if (offset) params.append('offset', offset.toString());
|
|
61
|
-
|
|
62
|
-
const res = await this.getClient().get(`/api/karma/${userId}/history?${params.toString()}`);
|
|
63
|
-
return res.data;
|
|
64
|
-
} catch (error) {
|
|
65
|
-
throw this.handleError(error);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Award karma to user
|
|
71
|
-
*/
|
|
72
|
-
async awardKarma(data: KarmaAwardRequest): Promise<{ success: boolean; message: string; history: KarmaHistory }> {
|
|
73
|
-
try {
|
|
74
|
-
const res = await this.getClient().post('/karma/award', data);
|
|
75
|
-
return res.data;
|
|
76
|
-
} catch (error) {
|
|
77
|
-
throw this.handleError(error);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Deduct karma from user
|
|
83
|
-
*/
|
|
84
|
-
async deductKarma(data: KarmaAwardRequest): Promise<{ success: boolean; message: string; history: KarmaHistory }> {
|
|
85
|
-
try {
|
|
86
|
-
const res = await this.getClient().post('/karma/deduct', data);
|
|
87
|
-
return res.data;
|
|
88
|
-
} catch (error) {
|
|
89
|
-
throw this.handleError(error);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Create or update karma rule
|
|
95
|
-
*/
|
|
96
|
-
async createOrUpdateKarmaRule(data: Partial<KarmaRule>): Promise<KarmaRule> {
|
|
97
|
-
try {
|
|
98
|
-
const res = await this.getClient().post('/karma/rules', data);
|
|
99
|
-
return res.data;
|
|
100
|
-
} catch (error) {
|
|
101
|
-
throw this.handleError(error);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
}
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { OxyServices } from '../OxyServices';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Location service for handling location search and geolocation features
|
|
5
|
-
*/
|
|
6
|
-
export class LocationService extends OxyServices {
|
|
7
|
-
/**
|
|
8
|
-
* Search locations
|
|
9
|
-
*/
|
|
10
|
-
async searchLocations(query: string, limit: number = 5, countrycodes?: string): Promise<any[]> {
|
|
11
|
-
try {
|
|
12
|
-
const params = new URLSearchParams({
|
|
13
|
-
query,
|
|
14
|
-
limit: limit.toString()
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
if (countrycodes) {
|
|
18
|
-
params.append('countrycodes', countrycodes);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const res = await this.getClient().get(`/api/location-search/search?${params.toString()}`);
|
|
22
|
-
return res.data;
|
|
23
|
-
} catch (error) {
|
|
24
|
-
throw this.handleError(error);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Get location details by coordinates
|
|
30
|
-
*/
|
|
31
|
-
async getLocationDetails(lat: number, lon: number): Promise<any> {
|
|
32
|
-
try {
|
|
33
|
-
const res = await this.getClient().get(`/api/location-search/reverse?lat=${lat}&lon=${lon}`);
|
|
34
|
-
return res.data;
|
|
35
|
-
} catch (error) {
|
|
36
|
-
throw this.handleError(error);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Find locations near coordinates
|
|
42
|
-
*/
|
|
43
|
-
async findLocationsNear(
|
|
44
|
-
lat: number,
|
|
45
|
-
lon: number,
|
|
46
|
-
maxDistance: number = 10000,
|
|
47
|
-
limit: number = 10,
|
|
48
|
-
skip: number = 0
|
|
49
|
-
): Promise<any> {
|
|
50
|
-
try {
|
|
51
|
-
const params = new URLSearchParams({
|
|
52
|
-
lat: lat.toString(),
|
|
53
|
-
lon: lon.toString(),
|
|
54
|
-
maxDistance: maxDistance.toString(),
|
|
55
|
-
limit: limit.toString(),
|
|
56
|
-
skip: skip.toString()
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
const res = await this.getClient().get(`/api/location-search/near?${params.toString()}`);
|
|
60
|
-
return res.data;
|
|
61
|
-
} catch (error) {
|
|
62
|
-
throw this.handleError(error);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Search locations in database
|
|
68
|
-
*/
|
|
69
|
-
async searchLocationsInDB(
|
|
70
|
-
query: string,
|
|
71
|
-
limit: number = 10,
|
|
72
|
-
skip: number = 0,
|
|
73
|
-
type?: string,
|
|
74
|
-
country?: string,
|
|
75
|
-
city?: string
|
|
76
|
-
): Promise<any> {
|
|
77
|
-
try {
|
|
78
|
-
const params = new URLSearchParams({
|
|
79
|
-
query,
|
|
80
|
-
limit: limit.toString(),
|
|
81
|
-
skip: skip.toString()
|
|
82
|
-
});
|
|
83
|
-
if (type) params.append('type', type);
|
|
84
|
-
if (country) params.append('country', country);
|
|
85
|
-
if (city) params.append('city', city);
|
|
86
|
-
|
|
87
|
-
const res = await this.getClient().get(`/api/location-search/db-search?${params.toString()}`);
|
|
88
|
-
return res.data;
|
|
89
|
-
} catch (error) {
|
|
90
|
-
throw this.handleError(error);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Get location statistics
|
|
96
|
-
*/
|
|
97
|
-
async getLocationStats(): Promise<any> {
|
|
98
|
-
try {
|
|
99
|
-
const res = await this.getClient().get('/location-search/stats');
|
|
100
|
-
return res.data.stats;
|
|
101
|
-
} catch (error) {
|
|
102
|
-
throw this.handleError(error);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Get cache statistics
|
|
108
|
-
*/
|
|
109
|
-
async getLocationCacheStats(): Promise<any> {
|
|
110
|
-
try {
|
|
111
|
-
const res = await this.getClient().get('/location-search/cache/stats');
|
|
112
|
-
return res.data.stats;
|
|
113
|
-
} catch (error) {
|
|
114
|
-
throw this.handleError(error);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Clear location cache
|
|
120
|
-
*/
|
|
121
|
-
async clearLocationCache(): Promise<any> {
|
|
122
|
-
try {
|
|
123
|
-
const res = await this.getClient().delete('/location-search/cache');
|
|
124
|
-
return res.data;
|
|
125
|
-
} catch (error) {
|
|
126
|
-
throw this.handleError(error);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Get performance statistics
|
|
132
|
-
*/
|
|
133
|
-
async getLocationPerformanceStats(): Promise<any> {
|
|
134
|
-
try {
|
|
135
|
-
const res = await this.getClient().get('/location-search/performance');
|
|
136
|
-
return res.data;
|
|
137
|
-
} catch (error) {
|
|
138
|
-
throw this.handleError(error);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import { OxyServices } from '../OxyServices';
|
|
2
|
-
import {
|
|
3
|
-
Wallet,
|
|
4
|
-
Transaction,
|
|
5
|
-
TransferFundsRequest,
|
|
6
|
-
PurchaseRequest,
|
|
7
|
-
WithdrawalRequest,
|
|
8
|
-
TransactionResponse,
|
|
9
|
-
PaymentMethod,
|
|
10
|
-
PaymentRequest,
|
|
11
|
-
PaymentResponse
|
|
12
|
-
} from '../../models/interfaces';
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Payment service for handling payments, wallet operations, and transactions
|
|
16
|
-
*/
|
|
17
|
-
export class PaymentService extends OxyServices {
|
|
18
|
-
/**
|
|
19
|
-
* Process payment
|
|
20
|
-
*/
|
|
21
|
-
async processPayment(data: PaymentRequest): Promise<PaymentResponse> {
|
|
22
|
-
try {
|
|
23
|
-
const res = await this.getClient().post('/payments/process', data);
|
|
24
|
-
return res.data;
|
|
25
|
-
} catch (error) {
|
|
26
|
-
throw this.handleError(error);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Validate payment method
|
|
32
|
-
*/
|
|
33
|
-
async validatePaymentMethod(paymentMethod: any): Promise<{ valid: boolean }> {
|
|
34
|
-
try {
|
|
35
|
-
const res = await this.getClient().post('/payments/validate-method', paymentMethod);
|
|
36
|
-
return res.data;
|
|
37
|
-
} catch (error) {
|
|
38
|
-
throw this.handleError(error);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Get payment methods for user
|
|
44
|
-
*/
|
|
45
|
-
async getPaymentMethods(userId: string): Promise<PaymentMethod[]> {
|
|
46
|
-
try {
|
|
47
|
-
const res = await this.getClient().get(`/api/payments/methods/${userId}`);
|
|
48
|
-
return res.data;
|
|
49
|
-
} catch (error) {
|
|
50
|
-
throw this.handleError(error);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Get user wallet
|
|
56
|
-
*/
|
|
57
|
-
async getWallet(userId: string): Promise<Wallet> {
|
|
58
|
-
try {
|
|
59
|
-
const res = await this.getClient().get(`/api/wallet/${userId}`);
|
|
60
|
-
return res.data;
|
|
61
|
-
} catch (error) {
|
|
62
|
-
throw this.handleError(error);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Get transaction history
|
|
68
|
-
*/
|
|
69
|
-
async getTransactionHistory(
|
|
70
|
-
userId: string,
|
|
71
|
-
limit?: number,
|
|
72
|
-
offset?: number
|
|
73
|
-
): Promise<{ transactions: Transaction[]; total: number; hasMore: boolean }> {
|
|
74
|
-
try {
|
|
75
|
-
const params = new URLSearchParams();
|
|
76
|
-
if (limit) params.append('limit', limit.toString());
|
|
77
|
-
if (offset) params.append('offset', offset.toString());
|
|
78
|
-
|
|
79
|
-
const res = await this.getClient().get(`/api/wallet/${userId}/transactions?${params.toString()}`);
|
|
80
|
-
return res.data;
|
|
81
|
-
} catch (error) {
|
|
82
|
-
throw this.handleError(error);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Get specific transaction
|
|
88
|
-
*/
|
|
89
|
-
async getTransaction(transactionId: string): Promise<Transaction> {
|
|
90
|
-
try {
|
|
91
|
-
const res = await this.getClient().get(`/api/transactions/${transactionId}`);
|
|
92
|
-
return res.data;
|
|
93
|
-
} catch (error) {
|
|
94
|
-
throw this.handleError(error);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Transfer funds between users
|
|
100
|
-
*/
|
|
101
|
-
async transferFunds(data: TransferFundsRequest): Promise<TransactionResponse> {
|
|
102
|
-
try {
|
|
103
|
-
const res = await this.getClient().post('/wallet/transfer', data);
|
|
104
|
-
return res.data;
|
|
105
|
-
} catch (error) {
|
|
106
|
-
throw this.handleError(error);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Process purchase
|
|
112
|
-
*/
|
|
113
|
-
async processPurchase(data: PurchaseRequest): Promise<TransactionResponse> {
|
|
114
|
-
try {
|
|
115
|
-
const res = await this.getClient().post('/wallet/purchase', data);
|
|
116
|
-
return res.data;
|
|
117
|
-
} catch (error) {
|
|
118
|
-
throw this.handleError(error);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Request withdrawal
|
|
124
|
-
*/
|
|
125
|
-
async requestWithdrawal(data: WithdrawalRequest): Promise<TransactionResponse> {
|
|
126
|
-
try {
|
|
127
|
-
const res = await this.getClient().post('/wallet/withdraw', data);
|
|
128
|
-
return res.data;
|
|
129
|
-
} catch (error) {
|
|
130
|
-
throw this.handleError(error);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|