@vitalfit/sdk 0.3.7 → 0.3.9

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({
@@ -684,6 +737,7 @@ var InstructorService = class {
684
737
  this.deleteInstructor = this.deleteInstructor.bind(this);
685
738
  this.addSpecialty = this.addSpecialty.bind(this);
686
739
  this.removeSpecialty = this.removeSpecialty.bind(this);
740
+ this.getAssignedClients = this.getAssignedClients.bind(this);
687
741
  this.addBranchInstructor = this.addBranchInstructor.bind(this);
688
742
  this.removeBranchInstructor = this.removeBranchInstructor.bind(this);
689
743
  this.getBranchInstructors = this.getBranchInstructors.bind(this);
@@ -750,6 +804,19 @@ var InstructorService = class {
750
804
  jwt
751
805
  });
752
806
  }
807
+ async getAssignedClients(instructorId, jwt, { page = 1, limit = 10, sort = "desc", search } = {}) {
808
+ const response = await this.client.get({
809
+ url: `/instructor/${instructorId}/clients`,
810
+ jwt,
811
+ params: {
812
+ page,
813
+ limit,
814
+ sort,
815
+ search
816
+ }
817
+ });
818
+ return response;
819
+ }
753
820
  async addBranchInstructor(branchId, instructorIDs, jwt) {
754
821
  await this.client.post({
755
822
  url: `/branches/${branchId}/instructor`,
@@ -1198,6 +1265,7 @@ var ProductsService = class {
1198
1265
  this.createService = this.createService.bind(this);
1199
1266
  this.getServices = this.getServices.bind(this);
1200
1267
  this.getSummary = this.getSummary.bind(this);
1268
+ this.getClientBalances = this.getClientBalances.bind(this);
1201
1269
  this.getServiceByID = this.getServiceByID.bind(this);
1202
1270
  this.updateService = this.updateService.bind(this);
1203
1271
  this.deleteService = this.deleteService.bind(this);
@@ -1242,6 +1310,16 @@ var ProductsService = class {
1242
1310
  });
1243
1311
  return response;
1244
1312
  }
1313
+ async getClientBalances(jwt, userId) {
1314
+ const response = await this.client.get({
1315
+ url: "/services/balances",
1316
+ jwt,
1317
+ params: {
1318
+ user_id: userId
1319
+ }
1320
+ });
1321
+ return response;
1322
+ }
1245
1323
  async getServiceByID(serviceId, jwt) {
1246
1324
  const response = await this.client.get({
1247
1325
  url: `/services/${serviceId}`,
@@ -1416,11 +1494,16 @@ var ScheduleService = class {
1416
1494
  this.UpdateClass = this.UpdateClass.bind(this);
1417
1495
  this.DeleteClass = this.DeleteClass.bind(this);
1418
1496
  this.GetClassByID = this.GetClassByID.bind(this);
1497
+ this.GetClassesByInstructor = this.GetClassesByInstructor.bind(this);
1419
1498
  }
1420
- async ListBranchesClass(branchID, jwt) {
1499
+ async ListBranchesClass(branchID, jwt, month, year) {
1421
1500
  const response = await this.client.get({
1422
1501
  url: `/branches/${branchID}/schedule`,
1423
- jwt
1502
+ jwt,
1503
+ params: {
1504
+ month,
1505
+ year
1506
+ }
1424
1507
  });
1425
1508
  return response;
1426
1509
  }
@@ -1451,6 +1534,18 @@ var ScheduleService = class {
1451
1534
  jwt
1452
1535
  });
1453
1536
  }
1537
+ async GetClassesByInstructor(jwt, userId, month, year) {
1538
+ const response = await this.client.get({
1539
+ url: "/schedule/instructor",
1540
+ jwt,
1541
+ params: {
1542
+ user_id: userId,
1543
+ month,
1544
+ year
1545
+ }
1546
+ });
1547
+ return response;
1548
+ }
1454
1549
  };
1455
1550
 
1456
1551
  // src/services/packages.ts
@@ -1721,8 +1816,10 @@ var AccessService = class {
1721
1816
  constructor(client) {
1722
1817
  this.client = client;
1723
1818
  this.checkIn = this.checkIn.bind(this);
1819
+ this.checkInManual = this.checkInManual.bind(this);
1724
1820
  this.getClientAttendanceHistory = this.getClientAttendanceHistory.bind(this);
1725
1821
  this.getClientServiceUsage = this.getClientServiceUsage.bind(this);
1822
+ this.getClassAttendanceHistory = this.getClassAttendanceHistory.bind(this);
1726
1823
  }
1727
1824
  async checkIn(jwt, data) {
1728
1825
  const response = await this.client.post({
@@ -1732,6 +1829,14 @@ var AccessService = class {
1732
1829
  });
1733
1830
  return response;
1734
1831
  }
1832
+ async checkInManual(jwt, data) {
1833
+ const response = await this.client.post({
1834
+ url: "/access/check-in/manual",
1835
+ jwt,
1836
+ data
1837
+ });
1838
+ return response;
1839
+ }
1735
1840
  async getClientAttendanceHistory(jwt, userId, start, end, { page = 1, limit = 10, sort = "desc" } = {}) {
1736
1841
  const response = await this.client.get({
1737
1842
  url: `/clients/${userId}/attendance-history`,
@@ -1760,6 +1865,18 @@ var AccessService = class {
1760
1865
  });
1761
1866
  return response;
1762
1867
  }
1868
+ async getClassAttendanceHistory(jwt, classId, start, end, status) {
1869
+ const response = await this.client.get({
1870
+ url: `/access/classes/${classId}/attendance`,
1871
+ jwt,
1872
+ params: {
1873
+ start_date: start,
1874
+ end_date: end,
1875
+ status
1876
+ }
1877
+ });
1878
+ return response;
1879
+ }
1763
1880
  };
1764
1881
 
1765
1882
  // src/services/reports.ts
@@ -2380,6 +2497,126 @@ var NotificationService = class {
2380
2497
  }
2381
2498
  };
2382
2499
 
2500
+ // src/services/exports.ts
2501
+ var ExportsService = class {
2502
+ client;
2503
+ constructor(client) {
2504
+ this.client = client;
2505
+ this.exportFinancialReport = this.exportFinancialReport.bind(this);
2506
+ this.exportClientsReport = this.exportClientsReport.bind(this);
2507
+ this.exportSalesReport = this.exportSalesReport.bind(this);
2508
+ this.exportClients = this.exportClients.bind(this);
2509
+ this.exportStaff = this.exportStaff.bind(this);
2510
+ this.exportInstructors = this.exportInstructors.bind(this);
2511
+ this.exportEquipmentTypes = this.exportEquipmentTypes.bind(this);
2512
+ this.exportBranchEquipment = this.exportBranchEquipment.bind(this);
2513
+ this.exportServices = this.exportServices.bind(this);
2514
+ this.exportBranchServices = this.exportBranchServices.bind(this);
2515
+ this.exportMembershipPlans = this.exportMembershipPlans.bind(this);
2516
+ this.exportPackages = this.exportPackages.bind(this);
2517
+ this.exportPaymentMethods = this.exportPaymentMethods.bind(this);
2518
+ }
2519
+ // Reports
2520
+ async exportFinancialReport(jwt, start, end, branchId) {
2521
+ return await this.client.download({
2522
+ url: "/reports/export/financial",
2523
+ jwt,
2524
+ params: {
2525
+ start,
2526
+ end,
2527
+ branch_id: branchId
2528
+ }
2529
+ });
2530
+ }
2531
+ async exportClientsReport(jwt, start, end, branchId) {
2532
+ return await this.client.download({
2533
+ url: "/reports/export/clients",
2534
+ jwt,
2535
+ params: {
2536
+ start,
2537
+ end,
2538
+ branch_id: branchId
2539
+ }
2540
+ });
2541
+ }
2542
+ async exportSalesReport(jwt, start, end, branchId) {
2543
+ return await this.client.download({
2544
+ url: "/reports/export/sales",
2545
+ jwt,
2546
+ params: {
2547
+ start,
2548
+ end,
2549
+ branch_id: branchId
2550
+ }
2551
+ });
2552
+ }
2553
+ // Users & Staff
2554
+ async exportClients(jwt) {
2555
+ return await this.client.download({
2556
+ url: "/user/export/clients",
2557
+ jwt
2558
+ });
2559
+ }
2560
+ async exportStaff(jwt) {
2561
+ return await this.client.download({
2562
+ url: "/user/export/users",
2563
+ jwt
2564
+ });
2565
+ }
2566
+ async exportInstructors(jwt) {
2567
+ return await this.client.download({
2568
+ url: "/instructor/export",
2569
+ jwt
2570
+ });
2571
+ }
2572
+ // Inventory & Equipment
2573
+ async exportEquipmentTypes(jwt) {
2574
+ return await this.client.download({
2575
+ url: "/equipment-types/export",
2576
+ jwt
2577
+ });
2578
+ }
2579
+ async exportBranchEquipment(branchId, jwt) {
2580
+ return await this.client.download({
2581
+ url: `/branches/${branchId}/equipment/export`,
2582
+ jwt
2583
+ });
2584
+ }
2585
+ // Services & Products
2586
+ async exportServices(jwt) {
2587
+ return await this.client.download({
2588
+ url: "/services/export",
2589
+ jwt
2590
+ });
2591
+ }
2592
+ async exportBranchServices(branchId, jwt) {
2593
+ return await this.client.download({
2594
+ url: `/branches/${branchId}/services/export`,
2595
+ jwt
2596
+ });
2597
+ }
2598
+ // Memberships & Packages
2599
+ async exportMembershipPlans(jwt) {
2600
+ return await this.client.download({
2601
+ url: "/membership-plans/export",
2602
+ jwt
2603
+ });
2604
+ }
2605
+ async exportPackages(jwt) {
2606
+ return await this.client.download({
2607
+ url: "/packages/export",
2608
+ jwt
2609
+ });
2610
+ }
2611
+ // Billing
2612
+ async exportPaymentMethods(jwt) {
2613
+ return await this.client.download({
2614
+ url: "/billing/payment-methods/export",
2615
+ jwt
2616
+ });
2617
+ }
2618
+ };
2619
+
2383
2620
  // src/types/auth.ts
2384
2621
  var UserGender = /* @__PURE__ */ ((UserGender2) => {
2385
2622
  UserGender2["male"] = "male";
@@ -2506,6 +2743,7 @@ var VitalFit = class _VitalFit {
2506
2743
  policy;
2507
2744
  audit;
2508
2745
  notification;
2746
+ exports;
2509
2747
  constructor(isDevMode, origin) {
2510
2748
  this.client = new Client(isDevMode, origin);
2511
2749
  this.auth = new AuthService(this.client);
@@ -2530,6 +2768,7 @@ var VitalFit = class _VitalFit {
2530
2768
  this.policy = new PolicyService(this.client);
2531
2769
  this.audit = new AuditService(this.client);
2532
2770
  this.notification = new NotificationService(this.client);
2771
+ this.exports = new ExportsService(this.client);
2533
2772
  }
2534
2773
  static getInstance(isDevMode = false) {
2535
2774
  if (!_VitalFit.instance) {
@@ -2538,7 +2777,7 @@ var VitalFit = class _VitalFit {
2538
2777
  return _VitalFit.instance;
2539
2778
  }
2540
2779
  version() {
2541
- return "0.3.7";
2780
+ return "0.3.9";
2542
2781
  }
2543
2782
  };
2544
2783
  // Annotate the CommonJS export names for ESM import in node: