@vitalfit/sdk 0.3.13 → 0.4.0

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
@@ -212,6 +212,37 @@ var Client = class {
212
212
  async delete(config) {
213
213
  return this.call("delete", config);
214
214
  }
215
+ async upload(config) {
216
+ const tokenToUse = config.jwt || this.accessToken;
217
+ const axiosConfig = {
218
+ method: "post",
219
+ url: config.url,
220
+ data: config.data,
221
+ params: config.params,
222
+ headers: {
223
+ "Content-Type": "multipart/form-data"
224
+ }
225
+ };
226
+ if (tokenToUse && axiosConfig.headers) {
227
+ axiosConfig.headers["Authorization"] = `Bearer ${tokenToUse}`;
228
+ }
229
+ try {
230
+ const response = await this.client.request(axiosConfig);
231
+ return response.data;
232
+ } catch (error) {
233
+ if (import_axios.default.isAxiosError(error)) {
234
+ const errorMessage = error.response?.data?.error;
235
+ if (typeof errorMessage === "string") {
236
+ throw new APIError([errorMessage], error.response?.status ?? 500);
237
+ }
238
+ throw new APIError(
239
+ ["Ocurri\xF3 un error inesperado"],
240
+ error.response?.status ?? 500
241
+ );
242
+ }
243
+ throw new Error(error);
244
+ }
245
+ }
215
246
  async download(config) {
216
247
  const tokenToUse = config.jwt || this.accessToken;
217
248
  const axiosConfig = {
@@ -443,6 +474,7 @@ var UserService = class {
443
474
  this.resendActivateOtp = this.resendActivateOtp.bind(this);
444
475
  this.UpgradePassword = this.UpgradePassword.bind(this);
445
476
  this.blockUser = this.blockUser.bind(this);
477
+ this.enrollFace = this.enrollFace.bind(this);
446
478
  this.createMedicalProfile = this.createMedicalProfile.bind(this);
447
479
  this.getMedicalProfile = this.getMedicalProfile.bind(this);
448
480
  this.updateMedicalProfile = this.updateMedicalProfile.bind(this);
@@ -559,6 +591,16 @@ var UserService = class {
559
591
  data
560
592
  });
561
593
  }
594
+ async enrollFace(jwt, photo) {
595
+ const formData = new FormData();
596
+ formData.append("selfie", photo);
597
+ const response = await this.client.upload({
598
+ url: "/face-auth/enroll",
599
+ jwt,
600
+ data: formData
601
+ });
602
+ return response;
603
+ }
562
604
  //medical
563
605
  async createMedicalProfile(userId, data, jwt) {
564
606
  await this.client.post({
@@ -1826,6 +1868,7 @@ var AccessService = class {
1826
1868
  this.client = client;
1827
1869
  this.checkIn = this.checkIn.bind(this);
1828
1870
  this.checkInManual = this.checkInManual.bind(this);
1871
+ this.checkInFace = this.checkInFace.bind(this);
1829
1872
  this.getClientAttendanceHistory = this.getClientAttendanceHistory.bind(this);
1830
1873
  this.getClientServiceUsage = this.getClientServiceUsage.bind(this);
1831
1874
  this.getClassAttendanceHistory = this.getClassAttendanceHistory.bind(this);
@@ -1846,6 +1889,17 @@ var AccessService = class {
1846
1889
  });
1847
1890
  return response;
1848
1891
  }
1892
+ async checkInFace(jwt, branchId, photo) {
1893
+ const formData = new FormData();
1894
+ formData.append("branch_id", branchId);
1895
+ formData.append("checkin_photo", photo);
1896
+ const response = await this.client.upload({
1897
+ url: "/access/check-in/face",
1898
+ jwt,
1899
+ data: formData
1900
+ });
1901
+ return response;
1902
+ }
1849
1903
  async getClientAttendanceHistory(jwt, userId, start, end, { page = 1, limit = 10, sort = "desc" } = {}) {
1850
1904
  const response = await this.client.get({
1851
1905
  url: `/clients/${userId}/attendance-history`,
@@ -2802,7 +2856,7 @@ var VitalFit = class _VitalFit {
2802
2856
  return _VitalFit.instance;
2803
2857
  }
2804
2858
  version() {
2805
- return "0.3.13";
2859
+ return "0.4.0";
2806
2860
  }
2807
2861
  };
2808
2862
  // Annotate the CommonJS export names for ESM import in node: