@vitalfit/sdk 0.3.6 → 0.3.8

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/dist/index.cjs CHANGED
@@ -157,7 +157,8 @@ var Client = class {
157
157
  url: config.url,
158
158
  data: config.data,
159
159
  params: config.params,
160
- headers: {}
160
+ headers: {},
161
+ responseType: config.responseType
161
162
  };
162
163
  if (tokenToUse && axiosConfig.headers) {
163
164
  axiosConfig.headers["Authorization"] = `Bearer ${tokenToUse}`;
@@ -211,6 +212,48 @@ var Client = class {
211
212
  async delete(config) {
212
213
  return this.call("delete", config);
213
214
  }
215
+ async download(config) {
216
+ const tokenToUse = config.jwt || this.accessToken;
217
+ const axiosConfig = {
218
+ method: "get",
219
+ url: config.url,
220
+ params: config.params,
221
+ headers: {},
222
+ responseType: "blob"
223
+ };
224
+ if (tokenToUse && axiosConfig.headers) {
225
+ axiosConfig.headers["Authorization"] = `Bearer ${tokenToUse}`;
226
+ }
227
+ try {
228
+ const response = await this.client.request(axiosConfig);
229
+ let filename;
230
+ const disposition = response.headers["content-disposition"];
231
+ if (disposition) {
232
+ const matches = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/.exec(
233
+ disposition
234
+ );
235
+ if (matches != null && matches[1]) {
236
+ filename = matches[1].replace(/['"]/g, "");
237
+ }
238
+ }
239
+ return { blob: response.data, filename };
240
+ } catch (error) {
241
+ if (import_axios.default.isAxiosError(error) && error.response?.data instanceof Blob) {
242
+ const errorText = await error.response.data.text();
243
+ try {
244
+ const errorJson = JSON.parse(errorText);
245
+ const errorMessage = errorJson.error || "Ocurri\xF3 un error inesperado";
246
+ throw new APIError([errorMessage], error.response.status);
247
+ } catch (e) {
248
+ throw new APIError(
249
+ ["Error en la descarga del archivo"],
250
+ error.response.status
251
+ );
252
+ }
253
+ }
254
+ throw new Error(error);
255
+ }
256
+ }
214
257
  };
215
258
 
216
259
  // src/services/auth.ts
@@ -288,14 +331,16 @@ var AuthService = class {
288
331
  async login({
289
332
  email,
290
333
  password,
291
- context
334
+ context,
335
+ device_token
292
336
  }) {
293
337
  const response = await this.client.post({
294
338
  url: "/auth/login",
295
339
  data: {
296
340
  email,
297
341
  password,
298
- context
342
+ context,
343
+ device_token
299
344
  }
300
345
  });
301
346
  return response;
@@ -397,6 +442,7 @@ var UserService = class {
397
442
  this.deleteUser = this.deleteUser.bind(this);
398
443
  this.resendActivateOtp = this.resendActivateOtp.bind(this);
399
444
  this.UpgradePassword = this.UpgradePassword.bind(this);
445
+ this.blockUser = this.blockUser.bind(this);
400
446
  this.createMedicalProfile = this.createMedicalProfile.bind(this);
401
447
  this.getMedicalProfile = this.getMedicalProfile.bind(this);
402
448
  this.updateMedicalProfile = this.updateMedicalProfile.bind(this);
@@ -497,6 +543,13 @@ var UserService = class {
497
543
  }
498
544
  });
499
545
  }
546
+ async blockUser(userId, data, jwt) {
547
+ await this.client.put({
548
+ url: `/user/${userId}/block`,
549
+ jwt,
550
+ data
551
+ });
552
+ }
500
553
  //medical
501
554
  async createMedicalProfile(userId, data, jwt) {
502
555
  await this.client.post({
@@ -1416,11 +1469,16 @@ var ScheduleService = class {
1416
1469
  this.UpdateClass = this.UpdateClass.bind(this);
1417
1470
  this.DeleteClass = this.DeleteClass.bind(this);
1418
1471
  this.GetClassByID = this.GetClassByID.bind(this);
1472
+ this.GetClassesByInstructor = this.GetClassesByInstructor.bind(this);
1419
1473
  }
1420
- async ListBranchesClass(branchID, jwt) {
1474
+ async ListBranchesClass(branchID, jwt, month, year) {
1421
1475
  const response = await this.client.get({
1422
1476
  url: `/branches/${branchID}/schedule`,
1423
- jwt
1477
+ jwt,
1478
+ params: {
1479
+ month,
1480
+ year
1481
+ }
1424
1482
  });
1425
1483
  return response;
1426
1484
  }
@@ -1451,6 +1509,18 @@ var ScheduleService = class {
1451
1509
  jwt
1452
1510
  });
1453
1511
  }
1512
+ async GetClassesByInstructor(jwt, userId, month, year) {
1513
+ const response = await this.client.get({
1514
+ url: "/schedule/instructor",
1515
+ jwt,
1516
+ params: {
1517
+ user_id: userId,
1518
+ month,
1519
+ year
1520
+ }
1521
+ });
1522
+ return response;
1523
+ }
1454
1524
  };
1455
1525
 
1456
1526
  // src/services/packages.ts
@@ -1723,6 +1793,7 @@ var AccessService = class {
1723
1793
  this.checkIn = this.checkIn.bind(this);
1724
1794
  this.getClientAttendanceHistory = this.getClientAttendanceHistory.bind(this);
1725
1795
  this.getClientServiceUsage = this.getClientServiceUsage.bind(this);
1796
+ this.getClassAttendanceHistory = this.getClassAttendanceHistory.bind(this);
1726
1797
  }
1727
1798
  async checkIn(jwt, data) {
1728
1799
  const response = await this.client.post({
@@ -1760,6 +1831,18 @@ var AccessService = class {
1760
1831
  });
1761
1832
  return response;
1762
1833
  }
1834
+ async getClassAttendanceHistory(jwt, classId, start, end, status) {
1835
+ const response = await this.client.get({
1836
+ url: `/access/classes/${classId}/attendance`,
1837
+ jwt,
1838
+ params: {
1839
+ start_date: start,
1840
+ end_date: end,
1841
+ status
1842
+ }
1843
+ });
1844
+ return response;
1845
+ }
1763
1846
  };
1764
1847
 
1765
1848
  // src/services/reports.ts
@@ -2340,10 +2423,15 @@ var NotificationService = class {
2340
2423
  this.markAllAsRead = this.markAllAsRead.bind(this);
2341
2424
  this.sendBroadcast = this.sendBroadcast.bind(this);
2342
2425
  }
2343
- async getNotifications(jwt) {
2426
+ async getNotifications(jwt, { page = 10, limit = 10, sort = "desc" }) {
2344
2427
  const response = await this.client.get({
2345
2428
  url: "/notifications",
2346
- jwt
2429
+ jwt,
2430
+ params: {
2431
+ page,
2432
+ limit,
2433
+ sort
2434
+ }
2347
2435
  });
2348
2436
  return response;
2349
2437
  }
@@ -2375,6 +2463,126 @@ var NotificationService = class {
2375
2463
  }
2376
2464
  };
2377
2465
 
2466
+ // src/services/exports.ts
2467
+ var ExportsService = class {
2468
+ client;
2469
+ constructor(client) {
2470
+ this.client = client;
2471
+ this.exportFinancialReport = this.exportFinancialReport.bind(this);
2472
+ this.exportClientsReport = this.exportClientsReport.bind(this);
2473
+ this.exportSalesReport = this.exportSalesReport.bind(this);
2474
+ this.exportClients = this.exportClients.bind(this);
2475
+ this.exportStaff = this.exportStaff.bind(this);
2476
+ this.exportInstructors = this.exportInstructors.bind(this);
2477
+ this.exportEquipmentTypes = this.exportEquipmentTypes.bind(this);
2478
+ this.exportBranchEquipment = this.exportBranchEquipment.bind(this);
2479
+ this.exportServices = this.exportServices.bind(this);
2480
+ this.exportBranchServices = this.exportBranchServices.bind(this);
2481
+ this.exportMembershipPlans = this.exportMembershipPlans.bind(this);
2482
+ this.exportPackages = this.exportPackages.bind(this);
2483
+ this.exportPaymentMethods = this.exportPaymentMethods.bind(this);
2484
+ }
2485
+ // Reports
2486
+ async exportFinancialReport(jwt, start, end, branchId) {
2487
+ return await this.client.download({
2488
+ url: "/reports/export/financial",
2489
+ jwt,
2490
+ params: {
2491
+ start,
2492
+ end,
2493
+ branch_id: branchId
2494
+ }
2495
+ });
2496
+ }
2497
+ async exportClientsReport(jwt, start, end, branchId) {
2498
+ return await this.client.download({
2499
+ url: "/reports/export/clients",
2500
+ jwt,
2501
+ params: {
2502
+ start,
2503
+ end,
2504
+ branch_id: branchId
2505
+ }
2506
+ });
2507
+ }
2508
+ async exportSalesReport(jwt, start, end, branchId) {
2509
+ return await this.client.download({
2510
+ url: "/reports/export/sales",
2511
+ jwt,
2512
+ params: {
2513
+ start,
2514
+ end,
2515
+ branch_id: branchId
2516
+ }
2517
+ });
2518
+ }
2519
+ // Users & Staff
2520
+ async exportClients(jwt) {
2521
+ return await this.client.download({
2522
+ url: "/user/export/clients",
2523
+ jwt
2524
+ });
2525
+ }
2526
+ async exportStaff(jwt) {
2527
+ return await this.client.download({
2528
+ url: "/user/export/users",
2529
+ jwt
2530
+ });
2531
+ }
2532
+ async exportInstructors(jwt) {
2533
+ return await this.client.download({
2534
+ url: "/instructor/export",
2535
+ jwt
2536
+ });
2537
+ }
2538
+ // Inventory & Equipment
2539
+ async exportEquipmentTypes(jwt) {
2540
+ return await this.client.download({
2541
+ url: "/equipment-types/export",
2542
+ jwt
2543
+ });
2544
+ }
2545
+ async exportBranchEquipment(branchId, jwt) {
2546
+ return await this.client.download({
2547
+ url: `/branches/${branchId}/equipment/export`,
2548
+ jwt
2549
+ });
2550
+ }
2551
+ // Services & Products
2552
+ async exportServices(jwt) {
2553
+ return await this.client.download({
2554
+ url: "/services/export",
2555
+ jwt
2556
+ });
2557
+ }
2558
+ async exportBranchServices(branchId, jwt) {
2559
+ return await this.client.download({
2560
+ url: `/branches/${branchId}/services/export`,
2561
+ jwt
2562
+ });
2563
+ }
2564
+ // Memberships & Packages
2565
+ async exportMembershipPlans(jwt) {
2566
+ return await this.client.download({
2567
+ url: "/membership-plans/export",
2568
+ jwt
2569
+ });
2570
+ }
2571
+ async exportPackages(jwt) {
2572
+ return await this.client.download({
2573
+ url: "/packages/export",
2574
+ jwt
2575
+ });
2576
+ }
2577
+ // Billing
2578
+ async exportPaymentMethods(jwt) {
2579
+ return await this.client.download({
2580
+ url: "/billing/payment-methods/export",
2581
+ jwt
2582
+ });
2583
+ }
2584
+ };
2585
+
2378
2586
  // src/types/auth.ts
2379
2587
  var UserGender = /* @__PURE__ */ ((UserGender2) => {
2380
2588
  UserGender2["male"] = "male";
@@ -2501,6 +2709,7 @@ var VitalFit = class _VitalFit {
2501
2709
  policy;
2502
2710
  audit;
2503
2711
  notification;
2712
+ exports;
2504
2713
  constructor(isDevMode, origin) {
2505
2714
  this.client = new Client(isDevMode, origin);
2506
2715
  this.auth = new AuthService(this.client);
@@ -2525,6 +2734,7 @@ var VitalFit = class _VitalFit {
2525
2734
  this.policy = new PolicyService(this.client);
2526
2735
  this.audit = new AuditService(this.client);
2527
2736
  this.notification = new NotificationService(this.client);
2737
+ this.exports = new ExportsService(this.client);
2528
2738
  }
2529
2739
  static getInstance(isDevMode = false) {
2530
2740
  if (!_VitalFit.instance) {
@@ -2533,7 +2743,7 @@ var VitalFit = class _VitalFit {
2533
2743
  return _VitalFit.instance;
2534
2744
  }
2535
2745
  version() {
2536
- return "0.3.6";
2746
+ return "0.3.8";
2537
2747
  }
2538
2748
  };
2539
2749
  // Annotate the CommonJS export names for ESM import in node: