medos-sdk 1.0.1 → 1.0.3
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 +208 -73
- package/dist/client/MedosClient.d.ts +1 -1
- package/dist/client/MedosClient.js +1 -1
- package/dist/components/AppointmentCalender.d.ts +1 -4
- package/dist/components/AppointmentCalender.js +282 -486
- package/dist/components/AppointmentDateTimeModal.d.ts +14 -0
- package/dist/components/AppointmentDateTimeModal.js +206 -0
- package/dist/components/ConfigurableCard.d.ts +12 -0
- package/dist/components/ConfigurableCard.js +29 -0
- package/dist/components/DoctorSelectModal.d.ts +7 -0
- package/dist/components/DoctorSelectModal.js +80 -0
- package/dist/components/Icons/Check.d.ts +6 -0
- package/dist/components/Icons/Check.js +2 -0
- package/dist/components/Icons/ChevronDownIcon.d.ts +4 -0
- package/dist/components/Icons/ChevronDownIcon.js +2 -0
- package/dist/components/Icons/ChevronLeft.d.ts +3 -0
- package/dist/components/Icons/ChevronLeft.js +3 -0
- package/dist/components/Icons/ChevronRight.d.ts +3 -0
- package/dist/components/Icons/ChevronRight.js +3 -0
- package/dist/components/Icons/ConfirmationCheck.d.ts +1 -0
- package/dist/components/Icons/ConfirmationCheck.js +9 -0
- package/dist/components/Icons/ConsultationType.d.ts +1 -0
- package/dist/components/Icons/ConsultationType.js +2 -0
- package/dist/components/Icons/Date&TimeIcon.d.ts +1 -0
- package/dist/components/Icons/Date&TimeIcon.js +2 -0
- package/dist/components/Icons/MapIcon.d.ts +1 -0
- package/dist/components/Icons/MapIcon.js +2 -0
- package/dist/components/Icons/PaymentMethodIcon.d.ts +1 -0
- package/dist/components/Icons/PaymentMethodIcon.js +2 -0
- package/dist/components/Icons/UserIcon.d.ts +1 -0
- package/dist/components/Icons/UserIcon.js +2 -0
- package/dist/components/PatientDetailsStep.d.ts +3 -0
- package/dist/components/PatientDetailsStep.js +76 -0
- package/dist/components/PhoneVerificationStep.d.ts +3 -0
- package/dist/components/PhoneVerificationStep.js +39 -0
- package/dist/components/SuccessStep.d.ts +3 -0
- package/dist/components/SuccessStep.js +17 -0
- package/dist/components/custom-calendar.d.ts +5 -0
- package/dist/components/custom-calendar.js +153 -0
- package/dist/components/styles.d.ts +6 -0
- package/dist/components/styles.js +257 -0
- package/dist/components/types.d.ts +182 -0
- package/dist/components/types.js +55 -0
- package/dist/components/ui/select.d.ts +10 -0
- package/dist/components/ui/select.js +21 -0
- package/dist/components/uiComponents/SelectDropdown.d.ts +41 -0
- package/dist/components/uiComponents/SelectDropdown.js +302 -0
- package/dist/components/utils.d.ts +5 -0
- package/dist/components/utils.js +15 -0
- package/dist/components/validation.d.ts +2 -0
- package/dist/components/validation.js +7 -0
- package/dist/context/TemplateContext.d.ts +12 -0
- package/dist/context/TemplateContext.js +19 -0
- package/dist/core/index.d.ts +8 -0
- package/dist/core/index.js +8 -0
- package/dist/lib/templateUtils.d.ts +3 -0
- package/dist/lib/templateUtils.js +28 -0
- package/dist/react/index.d.ts +2 -0
- package/dist/react/index.js +2 -0
- package/dist/services/AppointmentService.d.ts +9 -10
- package/dist/services/AppointmentService.js +12 -10
- package/dist/templates/registry.d.ts +12 -0
- package/dist/templates/registry.js +58 -0
- package/dist/vanilla/AppointmentCalendarWidget.d.ts +41 -0
- package/dist/vanilla/AppointmentCalendarWidget.js +848 -0
- package/dist/vanilla/appointment-calendar/provider.d.ts +13 -0
- package/dist/vanilla/appointment-calendar/types.d.ts +144 -0
- package/dist/vanilla/appointments/provider.d.ts +13 -0
- package/dist/vanilla/appointments/types.d.ts +81 -0
- package/dist/vanilla/client/MedosClient.d.ts +32 -0
- package/dist/vanilla/components/AppointmentCalender.d.ts +3 -0
- package/dist/vanilla/components/AppointmentDateTimeModal.d.ts +14 -0
- package/dist/vanilla/components/ConfigurableCard.d.ts +12 -0
- package/dist/vanilla/components/DoctorSelectModal.d.ts +7 -0
- package/dist/vanilla/components/Icons/Check.d.ts +6 -0
- package/dist/vanilla/components/Icons/ChevronDownIcon.d.ts +4 -0
- package/dist/vanilla/components/Icons/ChevronLeft.d.ts +3 -0
- package/dist/vanilla/components/Icons/ChevronRight.d.ts +3 -0
- package/dist/vanilla/components/Icons/ConfirmationCheck.d.ts +1 -0
- package/dist/vanilla/components/Icons/ConsultationType.d.ts +1 -0
- package/dist/vanilla/components/Icons/Date&TimeIcon.d.ts +1 -0
- package/dist/vanilla/components/Icons/MapIcon.d.ts +1 -0
- package/dist/vanilla/components/Icons/PaymentMethodIcon.d.ts +1 -0
- package/dist/vanilla/components/Icons/UserIcon.d.ts +1 -0
- package/dist/vanilla/components/PatientDetailsStep.d.ts +3 -0
- package/dist/vanilla/components/PhoneVerificationStep.d.ts +3 -0
- package/dist/vanilla/components/SuccessStep.d.ts +3 -0
- package/dist/vanilla/components/custom-calendar.d.ts +5 -0
- package/dist/vanilla/components/styles.d.ts +6 -0
- package/dist/vanilla/components/types.d.ts +182 -0
- package/dist/vanilla/components/ui/select.d.ts +10 -0
- package/dist/vanilla/components/uiComponents/SelectDropdown.d.ts +41 -0
- package/dist/vanilla/components/utils.d.ts +5 -0
- package/dist/vanilla/components/validation.d.ts +2 -0
- package/dist/vanilla/context/TemplateContext.d.ts +12 -0
- package/dist/vanilla/core/index.d.ts +8 -0
- package/dist/vanilla/index.d.ts +7 -0
- package/dist/vanilla/index.js +2 -0
- package/dist/vanilla/lib/templateUtils.d.ts +3 -0
- package/dist/vanilla/react/index.d.ts +2 -0
- package/dist/vanilla/services/AppointmentService.d.ts +85 -0
- package/dist/vanilla/services/AuthService.d.ts +6 -0
- package/dist/vanilla/services/PatientService.d.ts +14 -0
- package/dist/vanilla/templates/alternative.css +13 -0
- package/dist/vanilla/templates/default.css +13 -0
- package/dist/vanilla/templates/registry.d.ts +12 -0
- package/dist/vanilla/vanilla/AppointmentCalendarWidget.d.ts +41 -0
- package/dist/vanilla/vanilla/index.d.ts +2 -0
- package/dist/vanilla/vanilla/widget.d.ts +10 -0
- package/dist/vanilla/widget.css +217 -0
- package/dist/vanilla/widget.d.ts +10 -0
- package/dist/vanilla/widget.js +5084 -0
- package/package.json +40 -5
package/README.md
CHANGED
|
@@ -19,11 +19,10 @@ The SDK supports two authentication methods:
|
|
|
19
19
|
Use this method for backend services and server-side rendering.
|
|
20
20
|
|
|
21
21
|
```javascript
|
|
22
|
-
import { MedosClient } from
|
|
22
|
+
import { MedosClient } from "medos-sdk";
|
|
23
23
|
|
|
24
24
|
await MedosClient.init({
|
|
25
|
-
apiKey:
|
|
26
|
-
baseURL: 'https://api-dev.medapi.in/v1'
|
|
25
|
+
apiKey: "your-api-key",
|
|
27
26
|
});
|
|
28
27
|
```
|
|
29
28
|
|
|
@@ -32,11 +31,10 @@ await MedosClient.init({
|
|
|
32
31
|
Use this method for frontend applications. Obtain the session token from your backend.
|
|
33
32
|
|
|
34
33
|
```javascript
|
|
35
|
-
import { MedosClient } from
|
|
34
|
+
import { MedosClient } from "medos-sdk";
|
|
36
35
|
|
|
37
36
|
await MedosClient.initWithSession({
|
|
38
|
-
sessionToken:
|
|
39
|
-
baseURL: 'https://api-dev.medapi.in/v1'
|
|
37
|
+
sessionToken: "user-session-token",
|
|
40
38
|
});
|
|
41
39
|
```
|
|
42
40
|
|
|
@@ -85,10 +83,10 @@ Get available appointment time slots for a specific doctor.
|
|
|
85
83
|
|
|
86
84
|
```javascript
|
|
87
85
|
const slots = await MedosClient.fetchAppointments(
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
86
|
+
"workspace-123", // workspaceId
|
|
87
|
+
"addr-1", // addressId
|
|
88
|
+
"doc-1", // doctorId
|
|
89
|
+
"2025-11-16" // appointmentDate (YYYY-MM-DD)
|
|
92
90
|
);
|
|
93
91
|
```
|
|
94
92
|
|
|
@@ -99,14 +97,14 @@ const slots = await MedosClient.fetchAppointments(
|
|
|
99
97
|
{
|
|
100
98
|
start: "2025-11-16T10:00:00",
|
|
101
99
|
end: "2025-11-16T10:30:00",
|
|
102
|
-
id: "slot-1"
|
|
100
|
+
id: "slot-1",
|
|
103
101
|
},
|
|
104
102
|
{
|
|
105
103
|
start: "2025-11-16T11:00:00",
|
|
106
104
|
end: "2025-11-16T11:30:00",
|
|
107
|
-
id: "slot-2"
|
|
108
|
-
}
|
|
109
|
-
]
|
|
105
|
+
id: "slot-2",
|
|
106
|
+
},
|
|
107
|
+
];
|
|
110
108
|
```
|
|
111
109
|
|
|
112
110
|
### Book an Appointment
|
|
@@ -114,46 +112,46 @@ const slots = await MedosClient.fetchAppointments(
|
|
|
114
112
|
Create a new appointment booking.
|
|
115
113
|
|
|
116
114
|
```javascript
|
|
117
|
-
import { AppointmentService } from
|
|
115
|
+
import { AppointmentService } from "medos-sdk";
|
|
118
116
|
|
|
119
117
|
const appointment = await AppointmentService.createAppointment({
|
|
120
|
-
workspaceAddressId:
|
|
121
|
-
doctorId:
|
|
122
|
-
mode:
|
|
123
|
-
appointmentDate:
|
|
124
|
-
fromDateTimeTs:
|
|
125
|
-
toDateTimeTs:
|
|
126
|
-
consultationCharge:
|
|
127
|
-
type:
|
|
128
|
-
source:
|
|
118
|
+
workspaceAddressId: "addr-1",
|
|
119
|
+
doctorId: "doc-1",
|
|
120
|
+
mode: "OFFLINE",
|
|
121
|
+
appointmentDate: "2025-11-16",
|
|
122
|
+
fromDateTimeTs: "10:00",
|
|
123
|
+
toDateTimeTs: "10:30",
|
|
124
|
+
consultationCharge: "100",
|
|
125
|
+
type: "CONSULTATION",
|
|
126
|
+
source: "SDK_POWERED_WEBSITE",
|
|
129
127
|
patientPayload: {
|
|
130
|
-
firstName:
|
|
131
|
-
lastName:
|
|
132
|
-
email:
|
|
133
|
-
countryCode:
|
|
134
|
-
phoneNumber:
|
|
128
|
+
firstName: "Jane",
|
|
129
|
+
lastName: "Doe",
|
|
130
|
+
email: "jane.doe@example.com",
|
|
131
|
+
countryCode: "+1",
|
|
132
|
+
phoneNumber: "5551234567",
|
|
135
133
|
age: 30,
|
|
136
|
-
gender:
|
|
134
|
+
gender: "FEMALE",
|
|
137
135
|
},
|
|
138
136
|
patientAddress: {
|
|
139
|
-
addressLine1:
|
|
140
|
-
city:
|
|
141
|
-
state:
|
|
142
|
-
country:
|
|
143
|
-
zipcode:
|
|
144
|
-
landmark:
|
|
145
|
-
}
|
|
137
|
+
addressLine1: "456 Patient Street",
|
|
138
|
+
city: "New York",
|
|
139
|
+
state: "NY",
|
|
140
|
+
country: "USA",
|
|
141
|
+
zipcode: "10001",
|
|
142
|
+
landmark: "Near Central Park",
|
|
143
|
+
},
|
|
146
144
|
});
|
|
147
145
|
```
|
|
148
146
|
|
|
149
147
|
**Optional Fields:**
|
|
150
148
|
|
|
151
|
-
| Field
|
|
152
|
-
|
|
153
|
-
| `mode`
|
|
154
|
-
| `consultationCharge` | `"0"`
|
|
155
|
-
| `type`
|
|
156
|
-
| `source`
|
|
149
|
+
| Field | Default Value | Description |
|
|
150
|
+
| -------------------- | ----------------------- | -------------------------------------------- |
|
|
151
|
+
| `mode` | `"OFFLINE"` | Consultation mode: `"OFFLINE"` or `"ONLINE"` |
|
|
152
|
+
| `consultationCharge` | `"0"` | Consultation fee as string |
|
|
153
|
+
| `type` | `"CONSULTATION"` | Appointment type |
|
|
154
|
+
| `source` | `"SDK_POWERED_WEBSITE"` | Source identifier |
|
|
157
155
|
|
|
158
156
|
### Phone Verification
|
|
159
157
|
|
|
@@ -163,8 +161,8 @@ Implement OTP-based phone number verification for patients.
|
|
|
163
161
|
|
|
164
162
|
```javascript
|
|
165
163
|
await MedosClient.sendPhoneVerificationOtp({
|
|
166
|
-
countryCode:
|
|
167
|
-
phoneNumber:
|
|
164
|
+
countryCode: "+1",
|
|
165
|
+
phoneNumber: "5551234567",
|
|
168
166
|
});
|
|
169
167
|
```
|
|
170
168
|
|
|
@@ -172,9 +170,9 @@ await MedosClient.sendPhoneVerificationOtp({
|
|
|
172
170
|
|
|
173
171
|
```javascript
|
|
174
172
|
const result = await MedosClient.verifyPhoneVerificationOtp({
|
|
175
|
-
countryCode:
|
|
176
|
-
phoneNumber:
|
|
177
|
-
otp:
|
|
173
|
+
countryCode: "+1",
|
|
174
|
+
phoneNumber: "5551234567",
|
|
175
|
+
otp: "123456",
|
|
178
176
|
});
|
|
179
177
|
```
|
|
180
178
|
|
|
@@ -189,28 +187,28 @@ import {
|
|
|
189
187
|
BookAppointmentPayload,
|
|
190
188
|
AddressesResponse,
|
|
191
189
|
PatientPayload,
|
|
192
|
-
PatientAddressPayload
|
|
193
|
-
} from
|
|
190
|
+
PatientAddressPayload,
|
|
191
|
+
} from "medos-sdk";
|
|
194
192
|
|
|
195
193
|
const payload: BookAppointmentPayload = {
|
|
196
|
-
workspaceAddressId:
|
|
197
|
-
doctorId:
|
|
198
|
-
appointmentDate:
|
|
199
|
-
fromDateTimeTs:
|
|
200
|
-
toDateTimeTs:
|
|
194
|
+
workspaceAddressId: "addr-1",
|
|
195
|
+
doctorId: "doc-1",
|
|
196
|
+
appointmentDate: "2025-11-16",
|
|
197
|
+
fromDateTimeTs: "10:00",
|
|
198
|
+
toDateTimeTs: "10:30",
|
|
201
199
|
patientPayload: {
|
|
202
|
-
firstName:
|
|
203
|
-
lastName:
|
|
204
|
-
countryCode:
|
|
205
|
-
phoneNumber:
|
|
200
|
+
firstName: "John",
|
|
201
|
+
lastName: "Doe",
|
|
202
|
+
countryCode: "+1",
|
|
203
|
+
phoneNumber: "5551234567",
|
|
206
204
|
},
|
|
207
205
|
patientAddress: {
|
|
208
|
-
addressLine1:
|
|
209
|
-
city:
|
|
210
|
-
state:
|
|
211
|
-
country:
|
|
212
|
-
zipcode:
|
|
213
|
-
}
|
|
206
|
+
addressLine1: "123 Main Street",
|
|
207
|
+
city: "New York",
|
|
208
|
+
state: "NY",
|
|
209
|
+
country: "USA",
|
|
210
|
+
zipcode: "10001",
|
|
211
|
+
},
|
|
214
212
|
};
|
|
215
213
|
|
|
216
214
|
const appointment = await AppointmentService.createAppointment(payload);
|
|
@@ -268,7 +266,7 @@ const appointment = await AppointmentService.createAppointment(payload);
|
|
|
268
266
|
Pre-built appointment calendar component for React applications.
|
|
269
267
|
|
|
270
268
|
```jsx
|
|
271
|
-
import { AppointmentCalender } from
|
|
269
|
+
import { AppointmentCalender } from "medos-sdk";
|
|
272
270
|
|
|
273
271
|
function BookingPage() {
|
|
274
272
|
return <AppointmentCalender />;
|
|
@@ -277,6 +275,135 @@ function BookingPage() {
|
|
|
277
275
|
|
|
278
276
|
The component automatically uses the initialized `MedosClient` instance.
|
|
279
277
|
|
|
278
|
+
### Using React-specific exports
|
|
279
|
+
|
|
280
|
+
For better tree-shaking and to avoid React dependency conflicts:
|
|
281
|
+
|
|
282
|
+
```jsx
|
|
283
|
+
import { AppointmentCalender } from "medos-sdk/react";
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## Vanilla JavaScript / HTML Integration
|
|
287
|
+
|
|
288
|
+
For websites using plain HTML, CSS, and JavaScript (no React), use the vanilla widget.
|
|
289
|
+
|
|
290
|
+
### Installation
|
|
291
|
+
|
|
292
|
+
The widget is available as a bundled UMD module. After building the package, you'll find:
|
|
293
|
+
|
|
294
|
+
- `dist/vanilla/widget.js` - JavaScript bundle
|
|
295
|
+
- `dist/vanilla/widget.css` - Stylesheet
|
|
296
|
+
|
|
297
|
+
### Basic Usage
|
|
298
|
+
|
|
299
|
+
```html
|
|
300
|
+
<!DOCTYPE html>
|
|
301
|
+
<html>
|
|
302
|
+
<head>
|
|
303
|
+
<link rel="stylesheet" href="path/to/widget.css" />
|
|
304
|
+
</head>
|
|
305
|
+
<body>
|
|
306
|
+
<div id="appointment-calendar"></div>
|
|
307
|
+
|
|
308
|
+
<script src="path/to/widget.js"></script>
|
|
309
|
+
<script>
|
|
310
|
+
window.MedosAppointmentCalendar.init({
|
|
311
|
+
containerId: "appointment-calendar",
|
|
312
|
+
apiKey: "your-api-key",
|
|
313
|
+
onError: (err) => {
|
|
314
|
+
console.error("Error:", err);
|
|
315
|
+
alert("An error occurred. Please try again.");
|
|
316
|
+
},
|
|
317
|
+
onSuccess: () => {
|
|
318
|
+
console.log("Appointment booked successfully!");
|
|
319
|
+
},
|
|
320
|
+
});
|
|
321
|
+
</script>
|
|
322
|
+
</body>
|
|
323
|
+
</html>
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
### Using Session Token (Recommended for Production)
|
|
327
|
+
|
|
328
|
+
For better security, obtain the session token server-side:
|
|
329
|
+
|
|
330
|
+
```html
|
|
331
|
+
<script>
|
|
332
|
+
window.MedosAppointmentCalendar.init({
|
|
333
|
+
containerId: "appointment-calendar",
|
|
334
|
+
sessionToken: "your-session-token", // Obtained from your server
|
|
335
|
+
baseURL: "https://api-dev.medapi.in/v1",
|
|
336
|
+
onError: (err) => console.error(err),
|
|
337
|
+
});
|
|
338
|
+
</script>
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
### PHP Integration Example
|
|
342
|
+
|
|
343
|
+
```php
|
|
344
|
+
<?php
|
|
345
|
+
// Get session token from your backend
|
|
346
|
+
$sessionToken = getSessionTokenFromBackend();
|
|
347
|
+
?>
|
|
348
|
+
<!DOCTYPE html>
|
|
349
|
+
<html>
|
|
350
|
+
<head>
|
|
351
|
+
<link rel="stylesheet" href="path/to/widget.css">
|
|
352
|
+
</head>
|
|
353
|
+
<body>
|
|
354
|
+
<div id="appointment-calendar"></div>
|
|
355
|
+
<script src="path/to/widget.js"></script>
|
|
356
|
+
<script>
|
|
357
|
+
window.MedosAppointmentCalendar.init({
|
|
358
|
+
containerId: 'appointment-calendar',
|
|
359
|
+
sessionToken: '<?php echo htmlspecialchars($sessionToken); ?>',
|
|
360
|
+
onError: (err) => {
|
|
361
|
+
console.error('Error:', err);
|
|
362
|
+
alert('An error occurred. Please try again.');
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
</script>
|
|
366
|
+
</body>
|
|
367
|
+
</html>
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
### Configuration Options
|
|
371
|
+
|
|
372
|
+
- `containerId` (string, required) - ID of the HTML element where the widget will be rendered
|
|
373
|
+
- `apiKey` (string, optional) - Your Medos API key (if not using sessionToken)
|
|
374
|
+
- `sessionToken` (string, optional) - Session token obtained from your server (if not using apiKey)
|
|
375
|
+
- `baseURL` (string, optional) - API base URL (defaults to `https://api-dev.medapi.in/v1`)
|
|
376
|
+
- `onError` (function, optional) - Callback function for error handling
|
|
377
|
+
- `onSuccess` (function, optional) - Callback function called when appointment is successfully booked
|
|
378
|
+
|
|
379
|
+
### Styling
|
|
380
|
+
|
|
381
|
+
The widget comes with default styles. You can customize them by overriding CSS classes:
|
|
382
|
+
|
|
383
|
+
```css
|
|
384
|
+
.medos-appointment-btn-primary {
|
|
385
|
+
background: #your-color;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
.medos-appointment-card {
|
|
389
|
+
border-radius: 8px;
|
|
390
|
+
}
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
See `dist/vanilla/widget.css` for all available classes.
|
|
394
|
+
|
|
395
|
+
### Package Exports
|
|
396
|
+
|
|
397
|
+
The SDK provides multiple entry points:
|
|
398
|
+
|
|
399
|
+
- `medos-sdk` - Default export (includes React components)
|
|
400
|
+
- `medos-sdk/react` - React-specific exports
|
|
401
|
+
- `medos-sdk/vanilla` - Vanilla JS exports (ES modules)
|
|
402
|
+
- `medos-sdk/core` - Core services only (no framework dependencies)
|
|
403
|
+
- `medos-sdk/widget` - Widget bundle with CSS
|
|
404
|
+
|
|
405
|
+
For more details, see [Vanilla Widget Documentation](./docs/VANILLA_WIDGET.md).
|
|
406
|
+
|
|
280
407
|
## API Reference
|
|
281
408
|
|
|
282
409
|
### MedosClient
|
|
@@ -286,6 +413,7 @@ The component automatically uses the initialized `MedosClient` instance.
|
|
|
286
413
|
Initialize the SDK with an API key (server-side).
|
|
287
414
|
|
|
288
415
|
**Parameters:**
|
|
416
|
+
|
|
289
417
|
- `config.apiKey` (string, required) - Your Medos API key
|
|
290
418
|
- `config.baseURL` (string, optional) - API base URL. Defaults to dev environment
|
|
291
419
|
|
|
@@ -298,6 +426,7 @@ Initialize the SDK with an API key (server-side).
|
|
|
298
426
|
Initialize the SDK with a session token (client-side).
|
|
299
427
|
|
|
300
428
|
**Parameters:**
|
|
429
|
+
|
|
301
430
|
- `config.sessionToken` (string, required) - Session token
|
|
302
431
|
- `config.baseURL` (string, optional) - API base URL. Defaults to dev environment
|
|
303
432
|
|
|
@@ -312,6 +441,7 @@ Fetch all clinic addresses and their associated doctors.
|
|
|
312
441
|
**Returns:** `Promise<AddressesResponse>`
|
|
313
442
|
|
|
314
443
|
**Response Type:**
|
|
444
|
+
|
|
315
445
|
```typescript
|
|
316
446
|
{
|
|
317
447
|
totalAddresses?: number;
|
|
@@ -342,6 +472,7 @@ Fetch all clinic addresses and their associated doctors.
|
|
|
342
472
|
Fetch available appointment slots for a specific doctor.
|
|
343
473
|
|
|
344
474
|
**Parameters:**
|
|
475
|
+
|
|
345
476
|
- `workspaceId` (string | number) - Workspace identifier
|
|
346
477
|
- `addressId` (string | number) - Address identifier
|
|
347
478
|
- `doctorId` (string | number) - Doctor identifier
|
|
@@ -350,12 +481,13 @@ Fetch available appointment slots for a specific doctor.
|
|
|
350
481
|
**Returns:** `Promise<Slot[]>`
|
|
351
482
|
|
|
352
483
|
**Response Type:**
|
|
484
|
+
|
|
353
485
|
```typescript
|
|
354
486
|
Array<{
|
|
355
|
-
start: string;
|
|
356
|
-
end: string;
|
|
487
|
+
start: string; // ISO datetime format
|
|
488
|
+
end: string; // ISO datetime format
|
|
357
489
|
id?: string;
|
|
358
|
-
}
|
|
490
|
+
}>;
|
|
359
491
|
```
|
|
360
492
|
|
|
361
493
|
---
|
|
@@ -365,6 +497,7 @@ Array<{
|
|
|
365
497
|
Send OTP to a phone number for verification.
|
|
366
498
|
|
|
367
499
|
**Parameters:**
|
|
500
|
+
|
|
368
501
|
- `payload.countryCode` (string) - Country code with + prefix (e.g., "+1")
|
|
369
502
|
- `payload.phoneNumber` (string) - Phone number without country code
|
|
370
503
|
|
|
@@ -377,6 +510,7 @@ Send OTP to a phone number for verification.
|
|
|
377
510
|
Verify OTP for a phone number.
|
|
378
511
|
|
|
379
512
|
**Parameters:**
|
|
513
|
+
|
|
380
514
|
- `payload.countryCode` (string) - Country code with + prefix
|
|
381
515
|
- `payload.phoneNumber` (string) - Phone number without country code
|
|
382
516
|
- `payload.otp` (string) - OTP code received
|
|
@@ -392,6 +526,7 @@ Verify OTP for a phone number.
|
|
|
392
526
|
Create a new appointment booking.
|
|
393
527
|
|
|
394
528
|
**Parameters:**
|
|
529
|
+
|
|
395
530
|
- `payload` (BookAppointmentPayload) - Appointment details
|
|
396
531
|
|
|
397
532
|
**Returns:** `Promise<any>`
|
|
@@ -402,10 +537,10 @@ All SDK methods return Promises and should be wrapped in try-catch blocks.
|
|
|
402
537
|
|
|
403
538
|
```javascript
|
|
404
539
|
try {
|
|
405
|
-
await MedosClient.init({ apiKey:
|
|
540
|
+
await MedosClient.init({ apiKey: "your-api-key" });
|
|
406
541
|
const addresses = await MedosClient.fetchAllAddressesAndDoctors();
|
|
407
542
|
} catch (error) {
|
|
408
|
-
console.error(
|
|
543
|
+
console.error("Failed to fetch addresses:", error.message);
|
|
409
544
|
}
|
|
410
545
|
```
|
|
411
546
|
|
|
@@ -413,7 +548,7 @@ try {
|
|
|
413
548
|
|
|
414
549
|
- **Node.js:** v14 or higher
|
|
415
550
|
- **Browsers:** Modern browsers with ES6+ support
|
|
416
|
-
- **React:** v19 or higher (for React components)
|
|
551
|
+
- **React:** v19 or higher (only required for React components, not for vanilla widget)
|
|
417
552
|
- **TypeScript:** v5 or higher (optional)
|
|
418
553
|
|
|
419
554
|
## License
|
|
@@ -430,4 +565,4 @@ Pooranjoy Bhattacharya
|
|
|
430
565
|
|
|
431
566
|
---
|
|
432
567
|
|
|
433
|
-
|
|
568
|
+
_Built for healthcare providers worldwide._
|
|
@@ -20,7 +20,7 @@ declare class MedosClient {
|
|
|
20
20
|
static initWithSession({ sessionToken, baseURL, }: MedosClientSessionConfig): Promise<void>;
|
|
21
21
|
private static initializeAxiosInstance;
|
|
22
22
|
static fetchAllAddressesAndDoctors(): Promise<AddressesResponse>;
|
|
23
|
-
static fetchAppointments(workspaceId:
|
|
23
|
+
static fetchAppointments(workspaceId: number, addressId: number, doctorId: number, appointmentDate: string): Promise<any[]>;
|
|
24
24
|
static sendPhoneVerificationOtp(payload: SendPhoneVerificationOtpPayload): Promise<any>;
|
|
25
25
|
static verifyPhoneVerificationOtp(payload: VerifyPhoneVerificationOtpPayload): Promise<any>;
|
|
26
26
|
static get client(): AxiosInstance;
|
|
@@ -3,7 +3,7 @@ import { AuthService } from "../services/AuthService";
|
|
|
3
3
|
import { AppointmentService, } from "../services/AppointmentService";
|
|
4
4
|
import { PatientService, } from "../services/PatientService";
|
|
5
5
|
class MedosClient {
|
|
6
|
-
static async init({ apiKey, baseURL = "https://api
|
|
6
|
+
static async init({ apiKey, baseURL = "https://api.medos.one", }) {
|
|
7
7
|
if (!apiKey) {
|
|
8
8
|
throw new Error("MedosClient.init() requires 'apiKey'");
|
|
9
9
|
}
|