medos-sdk 1.0.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/README.md ADDED
@@ -0,0 +1,15 @@
1
+ # How to test this package
2
+
3
+ #### Go to your package directory (medos-sdk-js):
4
+
5
+ - `cd c:\harsh\projects\medos\medos-sdk-js`
6
+ - `npm link`
7
+
8
+ #### Go to your test project directory (where you want to use the package):
9
+
10
+ - `cd path\to\your\test-project`
11
+ - `npm link medos-sdk-js`
12
+
13
+ ### If you still get errors, you can also use the folder path directly:
14
+
15
+ `npm install --save-dev c:\harsh\projects\medos\medos-sdk-js`
@@ -0,0 +1,13 @@
1
+ import { CreateAppointmentPayload, AppointmentListPayload, AppointmentListResponse, AvailableSlotsPayload, UpdateAppointmentPayload, AvailableSlot, RescheduleAppointmentPayload, CreateMeetingPayload, CreateMeetingResponse, EndMeetingPayload } from "./types";
2
+ export declare const createAppointment: (appointmentPayload: Partial<CreateAppointmentPayload>) => Promise<any>;
3
+ export declare const updateAppointment: (appointmentPayload: UpdateAppointmentPayload) => Promise<any>;
4
+ export declare const rescheduleAppointment: (appointmentPayload: RescheduleAppointmentPayload) => Promise<any>;
5
+ export declare const deleteAppointment: (payload: {
6
+ appointmentId: number;
7
+ workspaceId: number;
8
+ addressId: number;
9
+ }) => Promise<any>;
10
+ export declare const fetchAppointments: (payload: AppointmentListPayload) => Promise<AppointmentListResponse[]>;
11
+ export declare const fetchAvailableSlots: (payload: AvailableSlotsPayload) => Promise<AvailableSlot[]>;
12
+ export declare const createMeeting: (payload: CreateMeetingPayload) => Promise<CreateMeetingResponse>;
13
+ export declare const endMeeting: (payload: EndMeetingPayload) => Promise<any>;
@@ -0,0 +1,60 @@
1
+ import { MedosClient } from "../client/MedosClient";
2
+ export const createAppointment = async (appointmentPayload) => {
3
+ const formData = new FormData();
4
+ const blob = new Blob([JSON.stringify(appointmentPayload)], {
5
+ type: "application/json",
6
+ });
7
+ formData.append("payload", blob);
8
+ const response = await MedosClient.client.post("/appointments/book-appointment", formData, { headers: { "Content-Type": "multipart/form-data" } });
9
+ return response.data;
10
+ };
11
+ export const updateAppointment = async (appointmentPayload) => {
12
+ const response = await MedosClient.client.put("/appointments/update-appointment", appointmentPayload);
13
+ return response.data;
14
+ };
15
+ export const rescheduleAppointment = async (appointmentPayload) => {
16
+ const response = await MedosClient.client.put(`/appointments/${appointmentPayload.id}/reschedule`, {
17
+ appointmentDate: appointmentPayload.appointmentDate,
18
+ fromDateTimeTs: appointmentPayload.fromDateTimeTs,
19
+ toDateTimeTs: appointmentPayload.toDateTimeTs,
20
+ }, {
21
+ params: {
22
+ workspaceId: appointmentPayload.workspaceId,
23
+ addressId: appointmentPayload.addressId,
24
+ doctorId: appointmentPayload.doctorId,
25
+ },
26
+ });
27
+ return response.data;
28
+ };
29
+ export const deleteAppointment = async (payload) => {
30
+ const response = await MedosClient.client.delete(`/appointments/${payload.appointmentId}/delete`, {
31
+ params: {
32
+ workspaceId: payload.workspaceId,
33
+ addressId: payload.addressId,
34
+ },
35
+ });
36
+ return response.data;
37
+ };
38
+ export const fetchAppointments = async (payload) => {
39
+ const response = await MedosClient.client.post("/appointments/list-with-details", payload);
40
+ return response.data;
41
+ };
42
+ export const fetchAvailableSlots = async (payload) => {
43
+ const response = await MedosClient.client.get("/appointments/available-slots", { params: payload });
44
+ return response.data;
45
+ };
46
+ export const createMeeting = async (payload) => {
47
+ const response = await MedosClient.client.post("/meeting/create", null, {
48
+ params: {
49
+ hostId: payload.hostId,
50
+ channelName: payload.channelName,
51
+ appointmentId: payload.appointmentId,
52
+ joinerId: payload.joinerId,
53
+ },
54
+ });
55
+ return response.data;
56
+ };
57
+ export const endMeeting = async (payload) => {
58
+ const response = await MedosClient.client.put(`/meeting/${payload.id}/end-meeting`);
59
+ return response.data;
60
+ };
@@ -0,0 +1,144 @@
1
+ export declare enum PaymentMode {
2
+ CASH = "CASH",
3
+ CARD = "CARD",
4
+ UPI = "UPI"
5
+ }
6
+ export declare enum AppointmentType {
7
+ CONSULTATION = "CONSULTATION",
8
+ FOLLOW_UP = "FOLLOW_UP",
9
+ LAB_TEST = "LAB_TEST",
10
+ SURGERY = "SURGERY",
11
+ VIRTUAL = "VIRTUAL",
12
+ IN_PERSON = "IN_PERSON"
13
+ }
14
+ export declare enum AppointmentStatus {
15
+ SCHEDULED = "SCHEDULED",
16
+ CANCELLED = "CANCELLED",
17
+ COMPLETED = "COMPLETED",
18
+ NO_SHOW = "NO_SHOW"
19
+ }
20
+ export declare enum AppointmentMode {
21
+ ONLINE = "ONLINE",
22
+ OFFLINE = "OFFLINE"
23
+ }
24
+ export declare enum AppointmentAction {
25
+ EDIT = "EDIT",
26
+ RESCHEDULE = "RESCHEDULE",
27
+ CANCEL = "CANCEL"
28
+ }
29
+ export declare enum AppointmentSource {
30
+ MEDOS_WEBSITE = "MEDOS_WEBSITE",
31
+ WEBSITE = "WEBSITE",
32
+ ANDROID = "ANDROID",
33
+ IOS = "IOS",
34
+ MEDOS_APP_ANDROID = "MEDOS_APP_ANDROID",
35
+ MEDOS_APP_IOS = "MEDOS_APP_IOS"
36
+ }
37
+ export interface CreateAppointmentPayload {
38
+ workspaceId: number;
39
+ addressId: number;
40
+ doctorId: number;
41
+ patientId: number;
42
+ mode: AppointmentMode;
43
+ appointmentDate: string;
44
+ fromDateTimeTs: string;
45
+ toDateTimeTs: string;
46
+ consultationCharge: number;
47
+ appointmentNotes?: string;
48
+ paymentMode: PaymentMode;
49
+ type: AppointmentType;
50
+ patientCheckedIn?: boolean;
51
+ isNoShow?: boolean;
52
+ source: AppointmentSource;
53
+ attachments?: File[];
54
+ }
55
+ export interface UpdateAppointmentPayload {
56
+ id: number;
57
+ workspaceId: number;
58
+ addressId: number;
59
+ mode: AppointmentMode;
60
+ consultationCharge: number;
61
+ appointmentNotes?: string;
62
+ paymentMode: PaymentMode;
63
+ type: AppointmentType;
64
+ patientCheckedIn?: boolean;
65
+ isNoShow?: boolean;
66
+ source: AppointmentSource;
67
+ }
68
+ export interface RescheduleAppointmentPayload {
69
+ id: number;
70
+ workspaceId: number;
71
+ addressId: number;
72
+ doctorId: number;
73
+ appointmentDate: string;
74
+ fromDateTimeTs: string;
75
+ toDateTimeTs: string;
76
+ }
77
+ export interface AppointmentListPayload {
78
+ workspaceId: number;
79
+ addressId: number;
80
+ doctorId?: number;
81
+ patientId?: number;
82
+ appointmentDate: string;
83
+ startDate: string;
84
+ endDate: string;
85
+ status: string;
86
+ }
87
+ export interface Appointment {
88
+ id: number;
89
+ createdAt: string;
90
+ deleted: boolean;
91
+ createdAtEpoch: number;
92
+ workspaceId: number;
93
+ addressId: number;
94
+ doctorId: number;
95
+ patientId: number;
96
+ fromDateTimeTs: number;
97
+ toDateTimeTs: number;
98
+ appointmentDate: string;
99
+ status: AppointmentStatus;
100
+ appointmentNotes: string;
101
+ type: string;
102
+ durationInSeconds: number;
103
+ mode: AppointmentMode;
104
+ reminderSent: boolean;
105
+ paymentMode: string;
106
+ patientCheckedIn: boolean;
107
+ consultationCharge: number;
108
+ isNoShow: boolean;
109
+ source: AppointmentSource;
110
+ }
111
+ export interface AppointmentListResponse {
112
+ appointment: Appointment;
113
+ patient?: any;
114
+ }
115
+ export interface AvailableSlot {
116
+ appointmentDate: string;
117
+ fromDateTimeTs: string;
118
+ toDateTimeTs: string;
119
+ }
120
+ export interface AvailableSlotsPayload {
121
+ workspaceId: number;
122
+ addressId: number;
123
+ doctorId: number;
124
+ appointmentDate?: string;
125
+ }
126
+ export interface CreateMeetingPayload {
127
+ hostId: number;
128
+ channelName: string;
129
+ appointmentId: number;
130
+ joinerId: number;
131
+ }
132
+ export interface CreateMeetingResponse {
133
+ meetingId: number;
134
+ hostToken: string;
135
+ appId: string;
136
+ channelName: string;
137
+ joinerTokens: {
138
+ userId: number;
139
+ token: string;
140
+ }[];
141
+ }
142
+ export interface EndMeetingPayload {
143
+ id: number;
144
+ }
@@ -0,0 +1,42 @@
1
+ export var PaymentMode;
2
+ (function (PaymentMode) {
3
+ PaymentMode["CASH"] = "CASH";
4
+ PaymentMode["CARD"] = "CARD";
5
+ PaymentMode["UPI"] = "UPI";
6
+ })(PaymentMode || (PaymentMode = {}));
7
+ export var AppointmentType;
8
+ (function (AppointmentType) {
9
+ AppointmentType["CONSULTATION"] = "CONSULTATION";
10
+ AppointmentType["FOLLOW_UP"] = "FOLLOW_UP";
11
+ AppointmentType["LAB_TEST"] = "LAB_TEST";
12
+ AppointmentType["SURGERY"] = "SURGERY";
13
+ AppointmentType["VIRTUAL"] = "VIRTUAL";
14
+ AppointmentType["IN_PERSON"] = "IN_PERSON";
15
+ })(AppointmentType || (AppointmentType = {}));
16
+ export var AppointmentStatus;
17
+ (function (AppointmentStatus) {
18
+ AppointmentStatus["SCHEDULED"] = "SCHEDULED";
19
+ AppointmentStatus["CANCELLED"] = "CANCELLED";
20
+ AppointmentStatus["COMPLETED"] = "COMPLETED";
21
+ AppointmentStatus["NO_SHOW"] = "NO_SHOW";
22
+ })(AppointmentStatus || (AppointmentStatus = {}));
23
+ export var AppointmentMode;
24
+ (function (AppointmentMode) {
25
+ AppointmentMode["ONLINE"] = "ONLINE";
26
+ AppointmentMode["OFFLINE"] = "OFFLINE";
27
+ })(AppointmentMode || (AppointmentMode = {}));
28
+ export var AppointmentAction;
29
+ (function (AppointmentAction) {
30
+ AppointmentAction["EDIT"] = "EDIT";
31
+ AppointmentAction["RESCHEDULE"] = "RESCHEDULE";
32
+ AppointmentAction["CANCEL"] = "CANCEL";
33
+ })(AppointmentAction || (AppointmentAction = {}));
34
+ export var AppointmentSource;
35
+ (function (AppointmentSource) {
36
+ AppointmentSource["MEDOS_WEBSITE"] = "MEDOS_WEBSITE";
37
+ AppointmentSource["WEBSITE"] = "WEBSITE";
38
+ AppointmentSource["ANDROID"] = "ANDROID";
39
+ AppointmentSource["IOS"] = "IOS";
40
+ AppointmentSource["MEDOS_APP_ANDROID"] = "MEDOS_APP_ANDROID";
41
+ AppointmentSource["MEDOS_APP_IOS"] = "MEDOS_APP_IOS";
42
+ })(AppointmentSource || (AppointmentSource = {}));
@@ -0,0 +1,13 @@
1
+ import { FetchWorkspaceAddressDoctorResponse, AppointmentConfig } from "./types";
2
+ export declare const createAppointmentConfig: (payload: AppointmentConfig) => Promise<AppointmentConfig>;
3
+ export declare const updateAppointmentConfig: ({ id, payload, }: {
4
+ id: string;
5
+ payload: Omit<AppointmentConfig, "userId" | "workspaceId" | "addressId">;
6
+ }) => Promise<AppointmentConfig>;
7
+ export declare const deleteAppointmentConfig: ({ id, }: {
8
+ id: number;
9
+ workspaceId?: number;
10
+ addressId?: number;
11
+ userId?: number;
12
+ }) => Promise<void>;
13
+ export declare const fetchWorkspaceAddressesDoctor: (workspaceId: string) => Promise<FetchWorkspaceAddressDoctorResponse>;
@@ -0,0 +1,16 @@
1
+ import { MedosClient } from "../client/MedosClient";
2
+ export const createAppointmentConfig = async (payload) => {
3
+ const response = await MedosClient.client.post("/appointment/configs", payload);
4
+ return response.data;
5
+ };
6
+ export const updateAppointmentConfig = async ({ id, payload, }) => {
7
+ const response = await MedosClient.client.put(`/appointment/configs/${id}`, payload);
8
+ return response.data;
9
+ };
10
+ export const deleteAppointmentConfig = async ({ id, }) => {
11
+ await MedosClient.client.delete(`/appointment/configs/${id}`);
12
+ };
13
+ export const fetchWorkspaceAddressesDoctor = async (workspaceId) => {
14
+ const response = await MedosClient.client.get(`/workspaces/${workspaceId}/addresses/appointments-configs`);
15
+ return response.data;
16
+ };
@@ -0,0 +1,81 @@
1
+ export interface DoctorAddress {
2
+ id: number;
3
+ completeAddress: string;
4
+ phoneNumber: string;
5
+ doctorsCount: number;
6
+ totalConfiguredAppointments: number;
7
+ doctors: Doctor[];
8
+ }
9
+ export interface AppointmentFeeConfigurationDTO {
10
+ offlineConsultationFee: number;
11
+ onlineConsultationFee: number;
12
+ currency: string;
13
+ }
14
+ export interface AppointmentTypeAndPermissionDTO {
15
+ allowOnline: boolean;
16
+ allowOffline: boolean;
17
+ allowCancellation: boolean;
18
+ allowRescheduling: boolean;
19
+ cancellationAllowedBeforeInHours: number;
20
+ }
21
+ export interface BasicAppointmentSettingDTO {
22
+ defaultDuration: number;
23
+ bufferTime: number;
24
+ bookingLimitPerDay: number;
25
+ maximumConsecutiveAppointment: number;
26
+ }
27
+ export interface AppointmentConsultationValidityAndFollowUpPolicyDTO {
28
+ enableConsultationValidity: boolean;
29
+ consultationValidityDays: number;
30
+ followUpConsultationFee: number;
31
+ maximumFollowUpVisits: number;
32
+ followUpFeeType: string;
33
+ followUpFeePercentage: number;
34
+ validityAppliesToSameComplaint: boolean;
35
+ validityResetOnNewComplaint: boolean;
36
+ }
37
+ export interface AppointmentWorkingHourSlot {
38
+ id?: number;
39
+ startTime: string;
40
+ endTime: string;
41
+ duration: number;
42
+ }
43
+ export interface AppointmentConfigWorkingHours {
44
+ id?: number;
45
+ dayOfWeek: string;
46
+ workingHours: AppointmentWorkingHourSlot[];
47
+ }
48
+ export interface SpecialDayConfig {
49
+ eventDayDate: string;
50
+ eventDayType: string;
51
+ eventDayName: string;
52
+ }
53
+ export interface AppointmentConfig {
54
+ id?: number;
55
+ workspaceId: number;
56
+ addressId: number;
57
+ userId: number;
58
+ status?: string;
59
+ appointmentConfigWorkingHours: AppointmentConfigWorkingHours[];
60
+ appointmentConsultationValidityAndFollowUpPolicyDTO: AppointmentConsultationValidityAndFollowUpPolicyDTO;
61
+ appointmentFeeConfigurationDTO: AppointmentFeeConfigurationDTO;
62
+ appointmentTypeAndPermissionDTO: AppointmentTypeAndPermissionDTO;
63
+ basicAppointmentSettingDTO: BasicAppointmentSettingDTO;
64
+ specialDayConfigs: SpecialDayConfig[];
65
+ }
66
+ export interface Doctor {
67
+ id: number;
68
+ email: string;
69
+ name: string;
70
+ specialization: string[];
71
+ phoneNumber: string;
72
+ profilePic: string | null;
73
+ appointmentConfig: AppointmentConfig | null;
74
+ }
75
+ export interface FetchWorkspaceAddressDoctorResponse {
76
+ totalAddresses: number;
77
+ totalConfiguredAppointments: number;
78
+ totalPartialConfiguredAppointments: number;
79
+ totalNotConfiguredAppointments: number;
80
+ addresses: DoctorAddress[];
81
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,32 @@
1
+ import { AxiosInstance } from "axios";
2
+ import { AddressesResponse } from "../services/AppointmentService";
3
+ import { SendPhoneVerificationOtpPayload, VerifyPhoneVerificationOtpPayload } from "../services/PatientService";
4
+ interface MedosClientConfig {
5
+ apiKey: string;
6
+ baseURL?: string;
7
+ }
8
+ interface MedosClientSessionConfig {
9
+ sessionToken: string;
10
+ baseURL?: string;
11
+ }
12
+ declare class MedosClient {
13
+ private static instance;
14
+ private static token;
15
+ private static refreshHandler;
16
+ private static isRefreshing;
17
+ private static pendingRequests;
18
+ private static initPromise;
19
+ static init({ apiKey, baseURL, }: MedosClientConfig): Promise<void>;
20
+ static initWithSession({ sessionToken, baseURL, }: MedosClientSessionConfig): Promise<void>;
21
+ private static initializeAxiosInstance;
22
+ static fetchAllAddressesAndDoctors(): Promise<AddressesResponse>;
23
+ static fetchAppointments(workspaceId: string | number, addressId: string | number, doctorId: string | number, appointmentDate: string): Promise<any[]>;
24
+ static sendPhoneVerificationOtp(payload: SendPhoneVerificationOtpPayload): Promise<any>;
25
+ static verifyPhoneVerificationOtp(payload: VerifyPhoneVerificationOtpPayload): Promise<any>;
26
+ static get client(): AxiosInstance;
27
+ static ensureInitialized(): Promise<AxiosInstance>;
28
+ static isInitialized(): boolean;
29
+ private static setToken;
30
+ static setRefreshHandler(handler: () => Promise<string | null>): void;
31
+ }
32
+ export { MedosClient };
@@ -0,0 +1,181 @@
1
+ import axios from "axios";
2
+ import { AuthService } from "../services/AuthService";
3
+ import { AppointmentService, } from "../services/AppointmentService";
4
+ import { PatientService, } from "../services/PatientService";
5
+ class MedosClient {
6
+ static async init({ apiKey, baseURL = "https://api-dev.medapi.in/v1", }) {
7
+ if (!apiKey) {
8
+ throw new Error("MedosClient.init() requires 'apiKey'");
9
+ }
10
+ if (this.initPromise) {
11
+ return this.initPromise;
12
+ }
13
+ this.initPromise = (async () => {
14
+ try {
15
+ const sessionToken = await AuthService.init(apiKey);
16
+ this.initializeAxiosInstance(sessionToken, baseURL);
17
+ }
18
+ catch (e) {
19
+ this.initPromise = null;
20
+ throw new Error(`MedosClient.init failed: ${e.message}`);
21
+ }
22
+ })();
23
+ return this.initPromise;
24
+ }
25
+ static async initWithSession({ sessionToken, baseURL = "https://api-dev.medapi.in/v1", }) {
26
+ if (!sessionToken) {
27
+ throw new Error("MedosClient.initWithSession() requires 'sessionToken'");
28
+ }
29
+ if (this.initPromise) {
30
+ return this.initPromise;
31
+ }
32
+ this.initPromise = (async () => {
33
+ try {
34
+ this.initializeAxiosInstance(sessionToken, baseURL);
35
+ }
36
+ catch (e) {
37
+ this.initPromise = null;
38
+ throw new Error(`MedosClient.initWithSession failed: ${e.message}`);
39
+ }
40
+ })();
41
+ return this.initPromise;
42
+ }
43
+ static initializeAxiosInstance(sessionToken, baseURL) {
44
+ this.token = sessionToken;
45
+ this.instance = axios.create({
46
+ baseURL,
47
+ headers: {
48
+ "Content-Type": "application/json",
49
+ Authorization: `Bearer ${sessionToken}`,
50
+ },
51
+ });
52
+ this.instance.interceptors.request.use((config) => {
53
+ if (!config.headers)
54
+ config.headers = {};
55
+ const headersAny = config.headers;
56
+ const isFormData = config.data instanceof FormData ||
57
+ (config.data &&
58
+ typeof config.data === "object" &&
59
+ config.data.constructor &&
60
+ config.data.constructor.name === "FormData");
61
+ if (isFormData) {
62
+ delete headersAny["Content-Type"];
63
+ if (config.headers.common) {
64
+ delete config.headers.common["Content-Type"];
65
+ }
66
+ }
67
+ if (this.token) {
68
+ headersAny["Authorization"] = `Bearer ${this.token}`;
69
+ }
70
+ return config;
71
+ });
72
+ this.instance.interceptors.response.use((response) => response, async (error) => {
73
+ const originalRequest = error.config;
74
+ if (error.response?.status === 401 &&
75
+ !originalRequest._retry &&
76
+ this.refreshHandler) {
77
+ originalRequest._retry = true;
78
+ if (this.isRefreshing) {
79
+ return new Promise((resolve, reject) => {
80
+ this.pendingRequests.push((token) => {
81
+ if (token && originalRequest.headers) {
82
+ originalRequest.headers["Authorization"] = `Bearer ${token}`;
83
+ }
84
+ resolve(this.instance.request(originalRequest));
85
+ });
86
+ });
87
+ }
88
+ this.isRefreshing = true;
89
+ try {
90
+ const newToken = await this.refreshHandler();
91
+ this.isRefreshing = false;
92
+ if (newToken) {
93
+ this.setToken(newToken);
94
+ }
95
+ this.pendingRequests.forEach((cb) => cb(newToken));
96
+ this.pendingRequests = [];
97
+ if (newToken && originalRequest.headers) {
98
+ originalRequest.headers["Authorization"] = `Bearer ${newToken}`;
99
+ }
100
+ return this.instance.request(originalRequest);
101
+ }
102
+ catch (refreshErr) {
103
+ this.isRefreshing = false;
104
+ this.pendingRequests.forEach((cb) => cb(null));
105
+ this.pendingRequests = [];
106
+ return Promise.reject(refreshErr);
107
+ }
108
+ }
109
+ return Promise.reject(error);
110
+ });
111
+ }
112
+ static async fetchAllAddressesAndDoctors() {
113
+ if (!this.instance) {
114
+ throw new Error("MedosClient not initialized. Call MedosClient.init() first.");
115
+ }
116
+ return AppointmentService.getAddresses();
117
+ }
118
+ static async fetchAppointments(workspaceId, addressId, doctorId, appointmentDate) {
119
+ if (!this.instance) {
120
+ throw new Error("MedosClient not initialized. Call MedosClient.init() first.");
121
+ }
122
+ return AppointmentService.fetchSlots(workspaceId, addressId, doctorId, appointmentDate);
123
+ }
124
+ static async sendPhoneVerificationOtp(payload) {
125
+ if (!this.instance) {
126
+ throw new Error("MedosClient not initialized. Call MedosClient.init() first.");
127
+ }
128
+ return PatientService.sendPhoneVerificationOtp(payload);
129
+ }
130
+ static async verifyPhoneVerificationOtp(payload) {
131
+ if (!this.instance) {
132
+ throw new Error("MedosClient not initialized. Call MedosClient.init() first.");
133
+ }
134
+ return PatientService.verifyPhoneVerificationOtp(payload);
135
+ }
136
+ static get client() {
137
+ if (!this.instance && !this.initPromise) {
138
+ throw new Error("MedosClient not initialized. Call MedosClient.init() or MedosClient.initWithSession() first.");
139
+ }
140
+ if (!this.instance && this.initPromise) {
141
+ throw new Error("MedosClient initialization is in progress. Please wait for initialization to complete before accessing the client.");
142
+ }
143
+ return this.instance;
144
+ }
145
+ static async ensureInitialized() {
146
+ if (this.instance) {
147
+ return this.instance;
148
+ }
149
+ if (this.initPromise) {
150
+ await this.initPromise;
151
+ if (this.instance) {
152
+ return this.instance;
153
+ }
154
+ }
155
+ throw new Error("MedosClient not initialized. Call MedosClient.init() or MedosClient.initWithSession() first.");
156
+ }
157
+ static isInitialized() {
158
+ return this.instance !== null;
159
+ }
160
+ static setToken(token) {
161
+ this.token = token;
162
+ if (this.instance) {
163
+ const defaults = this.instance.defaults;
164
+ if (!defaults.headers)
165
+ defaults.headers = {};
166
+ if (!defaults.headers.common)
167
+ defaults.headers.common = {};
168
+ defaults.headers.common["Authorization"] = `Bearer ${token}`;
169
+ }
170
+ }
171
+ static setRefreshHandler(handler) {
172
+ this.refreshHandler = handler;
173
+ }
174
+ }
175
+ MedosClient.instance = null;
176
+ MedosClient.token = null;
177
+ MedosClient.refreshHandler = null;
178
+ MedosClient.isRefreshing = false;
179
+ MedosClient.pendingRequests = [];
180
+ MedosClient.initPromise = null;
181
+ export { MedosClient };
@@ -0,0 +1,6 @@
1
+ import React from "react";
2
+ type AppointmentCalenderProps = {
3
+ onError?: (err: Error) => void;
4
+ };
5
+ export declare const AppointmentCalender: React.FC<AppointmentCalenderProps>;
6
+ export {};