@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 +55 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +55 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -27,6 +27,7 @@ declare class Client {
|
|
|
27
27
|
put(config: ClientConfig): Promise<any>;
|
|
28
28
|
patch(config: ClientConfig): Promise<any>;
|
|
29
29
|
delete(config: ClientConfig): Promise<any>;
|
|
30
|
+
upload(config: ClientConfig): Promise<any>;
|
|
30
31
|
download(config: ClientConfig): Promise<{
|
|
31
32
|
blob: Blob;
|
|
32
33
|
filename?: string;
|
|
@@ -259,6 +260,7 @@ type User = {
|
|
|
259
260
|
role: Role;
|
|
260
261
|
category?: string;
|
|
261
262
|
has_active_membership?: boolean;
|
|
263
|
+
face_auth_enabled: boolean;
|
|
262
264
|
client_membership?: ClientMembership;
|
|
263
265
|
created_at: string;
|
|
264
266
|
updated_at: string;
|
|
@@ -1205,6 +1207,9 @@ declare class UserService {
|
|
|
1205
1207
|
resendActivateOtp(email: string): Promise<void>;
|
|
1206
1208
|
UpgradePassword(jwt: string, currentPassword: string, newPassword: string, confirmPassword: string): Promise<void>;
|
|
1207
1209
|
blockUser(userId: string, data: BlockUserRequest, jwt: string): Promise<void>;
|
|
1210
|
+
enrollFace(jwt: string, photo: File | Blob): Promise<{
|
|
1211
|
+
message: string;
|
|
1212
|
+
}>;
|
|
1208
1213
|
createMedicalProfile(userId: string, data: MedicalProfile, jwt: string): Promise<void>;
|
|
1209
1214
|
getMedicalProfile(userId: string, jwt: string): Promise<DataResponse<MedicalProfile>>;
|
|
1210
1215
|
updateMedicalProfile(userId: string, data: MedicalProfile, jwt: string): Promise<void>;
|
|
@@ -1400,6 +1405,7 @@ declare class AccessService {
|
|
|
1400
1405
|
constructor(client: Client);
|
|
1401
1406
|
checkIn(jwt: string, data: CheckIn): Promise<CheckInResponse>;
|
|
1402
1407
|
checkInManual(jwt: string, data: CheckIn): Promise<CheckInResponse>;
|
|
1408
|
+
checkInFace(jwt: string, branchId: string, photo: File | Blob): Promise<CheckInResponse>;
|
|
1403
1409
|
getClientAttendanceHistory(jwt: string, userId: string, start?: string, end?: string, { page, limit, sort }?: PaginationRequest): Promise<PaginatedTotal<AttendanceHistory[]>>;
|
|
1404
1410
|
getClientServiceUsage(jwt: string, userId: string, start?: string, end?: string, { page, limit, sort }?: PaginationRequest): Promise<PaginatedTotal<ServiceUsage[]>>;
|
|
1405
1411
|
getClassAttendanceHistory(jwt: string, classId: string, start?: string, end?: string, status?: 'Attended' | 'NoShow' | 'Cancelled'): Promise<DataResponse<AttendanceHistory[]>>;
|
package/dist/index.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ declare class Client {
|
|
|
27
27
|
put(config: ClientConfig): Promise<any>;
|
|
28
28
|
patch(config: ClientConfig): Promise<any>;
|
|
29
29
|
delete(config: ClientConfig): Promise<any>;
|
|
30
|
+
upload(config: ClientConfig): Promise<any>;
|
|
30
31
|
download(config: ClientConfig): Promise<{
|
|
31
32
|
blob: Blob;
|
|
32
33
|
filename?: string;
|
|
@@ -259,6 +260,7 @@ type User = {
|
|
|
259
260
|
role: Role;
|
|
260
261
|
category?: string;
|
|
261
262
|
has_active_membership?: boolean;
|
|
263
|
+
face_auth_enabled: boolean;
|
|
262
264
|
client_membership?: ClientMembership;
|
|
263
265
|
created_at: string;
|
|
264
266
|
updated_at: string;
|
|
@@ -1205,6 +1207,9 @@ declare class UserService {
|
|
|
1205
1207
|
resendActivateOtp(email: string): Promise<void>;
|
|
1206
1208
|
UpgradePassword(jwt: string, currentPassword: string, newPassword: string, confirmPassword: string): Promise<void>;
|
|
1207
1209
|
blockUser(userId: string, data: BlockUserRequest, jwt: string): Promise<void>;
|
|
1210
|
+
enrollFace(jwt: string, photo: File | Blob): Promise<{
|
|
1211
|
+
message: string;
|
|
1212
|
+
}>;
|
|
1208
1213
|
createMedicalProfile(userId: string, data: MedicalProfile, jwt: string): Promise<void>;
|
|
1209
1214
|
getMedicalProfile(userId: string, jwt: string): Promise<DataResponse<MedicalProfile>>;
|
|
1210
1215
|
updateMedicalProfile(userId: string, data: MedicalProfile, jwt: string): Promise<void>;
|
|
@@ -1400,6 +1405,7 @@ declare class AccessService {
|
|
|
1400
1405
|
constructor(client: Client);
|
|
1401
1406
|
checkIn(jwt: string, data: CheckIn): Promise<CheckInResponse>;
|
|
1402
1407
|
checkInManual(jwt: string, data: CheckIn): Promise<CheckInResponse>;
|
|
1408
|
+
checkInFace(jwt: string, branchId: string, photo: File | Blob): Promise<CheckInResponse>;
|
|
1403
1409
|
getClientAttendanceHistory(jwt: string, userId: string, start?: string, end?: string, { page, limit, sort }?: PaginationRequest): Promise<PaginatedTotal<AttendanceHistory[]>>;
|
|
1404
1410
|
getClientServiceUsage(jwt: string, userId: string, start?: string, end?: string, { page, limit, sort }?: PaginationRequest): Promise<PaginatedTotal<ServiceUsage[]>>;
|
|
1405
1411
|
getClassAttendanceHistory(jwt: string, classId: string, start?: string, end?: string, status?: 'Attended' | 'NoShow' | 'Cancelled'): Promise<DataResponse<AttendanceHistory[]>>;
|
package/dist/index.js
CHANGED
|
@@ -172,6 +172,37 @@ var Client = class {
|
|
|
172
172
|
async delete(config) {
|
|
173
173
|
return this.call("delete", config);
|
|
174
174
|
}
|
|
175
|
+
async upload(config) {
|
|
176
|
+
const tokenToUse = config.jwt || this.accessToken;
|
|
177
|
+
const axiosConfig = {
|
|
178
|
+
method: "post",
|
|
179
|
+
url: config.url,
|
|
180
|
+
data: config.data,
|
|
181
|
+
params: config.params,
|
|
182
|
+
headers: {
|
|
183
|
+
"Content-Type": "multipart/form-data"
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
if (tokenToUse && axiosConfig.headers) {
|
|
187
|
+
axiosConfig.headers["Authorization"] = `Bearer ${tokenToUse}`;
|
|
188
|
+
}
|
|
189
|
+
try {
|
|
190
|
+
const response = await this.client.request(axiosConfig);
|
|
191
|
+
return response.data;
|
|
192
|
+
} catch (error) {
|
|
193
|
+
if (axios.isAxiosError(error)) {
|
|
194
|
+
const errorMessage = error.response?.data?.error;
|
|
195
|
+
if (typeof errorMessage === "string") {
|
|
196
|
+
throw new APIError([errorMessage], error.response?.status ?? 500);
|
|
197
|
+
}
|
|
198
|
+
throw new APIError(
|
|
199
|
+
["Ocurri\xF3 un error inesperado"],
|
|
200
|
+
error.response?.status ?? 500
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
throw new Error(error);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
175
206
|
async download(config) {
|
|
176
207
|
const tokenToUse = config.jwt || this.accessToken;
|
|
177
208
|
const axiosConfig = {
|
|
@@ -403,6 +434,7 @@ var UserService = class {
|
|
|
403
434
|
this.resendActivateOtp = this.resendActivateOtp.bind(this);
|
|
404
435
|
this.UpgradePassword = this.UpgradePassword.bind(this);
|
|
405
436
|
this.blockUser = this.blockUser.bind(this);
|
|
437
|
+
this.enrollFace = this.enrollFace.bind(this);
|
|
406
438
|
this.createMedicalProfile = this.createMedicalProfile.bind(this);
|
|
407
439
|
this.getMedicalProfile = this.getMedicalProfile.bind(this);
|
|
408
440
|
this.updateMedicalProfile = this.updateMedicalProfile.bind(this);
|
|
@@ -519,6 +551,16 @@ var UserService = class {
|
|
|
519
551
|
data
|
|
520
552
|
});
|
|
521
553
|
}
|
|
554
|
+
async enrollFace(jwt, photo) {
|
|
555
|
+
const formData = new FormData();
|
|
556
|
+
formData.append("selfie", photo);
|
|
557
|
+
const response = await this.client.upload({
|
|
558
|
+
url: "/face-auth/enroll",
|
|
559
|
+
jwt,
|
|
560
|
+
data: formData
|
|
561
|
+
});
|
|
562
|
+
return response;
|
|
563
|
+
}
|
|
522
564
|
//medical
|
|
523
565
|
async createMedicalProfile(userId, data, jwt) {
|
|
524
566
|
await this.client.post({
|
|
@@ -1786,6 +1828,7 @@ var AccessService = class {
|
|
|
1786
1828
|
this.client = client;
|
|
1787
1829
|
this.checkIn = this.checkIn.bind(this);
|
|
1788
1830
|
this.checkInManual = this.checkInManual.bind(this);
|
|
1831
|
+
this.checkInFace = this.checkInFace.bind(this);
|
|
1789
1832
|
this.getClientAttendanceHistory = this.getClientAttendanceHistory.bind(this);
|
|
1790
1833
|
this.getClientServiceUsage = this.getClientServiceUsage.bind(this);
|
|
1791
1834
|
this.getClassAttendanceHistory = this.getClassAttendanceHistory.bind(this);
|
|
@@ -1806,6 +1849,17 @@ var AccessService = class {
|
|
|
1806
1849
|
});
|
|
1807
1850
|
return response;
|
|
1808
1851
|
}
|
|
1852
|
+
async checkInFace(jwt, branchId, photo) {
|
|
1853
|
+
const formData = new FormData();
|
|
1854
|
+
formData.append("branch_id", branchId);
|
|
1855
|
+
formData.append("checkin_photo", photo);
|
|
1856
|
+
const response = await this.client.upload({
|
|
1857
|
+
url: "/access/check-in/face",
|
|
1858
|
+
jwt,
|
|
1859
|
+
data: formData
|
|
1860
|
+
});
|
|
1861
|
+
return response;
|
|
1862
|
+
}
|
|
1809
1863
|
async getClientAttendanceHistory(jwt, userId, start, end, { page = 1, limit = 10, sort = "desc" } = {}) {
|
|
1810
1864
|
const response = await this.client.get({
|
|
1811
1865
|
url: `/clients/${userId}/attendance-history`,
|
|
@@ -2762,7 +2816,7 @@ var VitalFit = class _VitalFit {
|
|
|
2762
2816
|
return _VitalFit.instance;
|
|
2763
2817
|
}
|
|
2764
2818
|
version() {
|
|
2765
|
-
return "0.
|
|
2819
|
+
return "0.4.0";
|
|
2766
2820
|
}
|
|
2767
2821
|
};
|
|
2768
2822
|
export {
|