medos-sdk 1.1.1 → 1.1.2
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 +2 -2
- package/dist/client/MedosClient.js +3 -2
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/index.js +1 -0
- package/dist/services/AuthService.js +2 -1
- package/dist/vanilla/constants/index.d.ts +1 -0
- package/dist/vanilla/enquiry-widget.js +5 -3
- package/dist/vanilla/widget.js +5 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -406,7 +406,7 @@ For better security, obtain the session token server-side:
|
|
|
406
406
|
window.MedosAppointmentCalendar.init({
|
|
407
407
|
containerId: "appointment-calendar",
|
|
408
408
|
sessionToken: "your-session-token", // Obtained from your server
|
|
409
|
-
baseURL: "https://api
|
|
409
|
+
baseURL: "https://api.medos.one/v1",
|
|
410
410
|
onError: (err) => console.error(err),
|
|
411
411
|
});
|
|
412
412
|
</script>
|
|
@@ -446,7 +446,7 @@ $sessionToken = getSessionTokenFromBackend();
|
|
|
446
446
|
- `containerId` (string, required) - ID of the HTML element where the widget will be rendered
|
|
447
447
|
- `apiKey` (string, optional) - Your Medos API key (if not using sessionToken)
|
|
448
448
|
- `sessionToken` (string, optional) - Session token obtained from your server (if not using apiKey)
|
|
449
|
-
- `baseURL` (string, optional) - API base URL (defaults to `https://api
|
|
449
|
+
- `baseURL` (string, optional) - API base URL (defaults to `https://api.medos.one/v1`)
|
|
450
450
|
- `onError` (function, optional) - Callback function for error handling
|
|
451
451
|
- `onSuccess` (function, optional) - Callback function called when appointment is successfully booked
|
|
452
452
|
|
|
@@ -2,6 +2,7 @@ import axios from "axios";
|
|
|
2
2
|
import { AuthService } from "../services/AuthService";
|
|
3
3
|
import { AppointmentService, } from "../services/AppointmentService";
|
|
4
4
|
import { PatientService, } from "../services/PatientService";
|
|
5
|
+
import { API_BASE_URL } from "../constants";
|
|
5
6
|
class MedosClient {
|
|
6
7
|
static async init({ apiKey }) {
|
|
7
8
|
if (!apiKey) {
|
|
@@ -13,7 +14,7 @@ class MedosClient {
|
|
|
13
14
|
this.initPromise = (async () => {
|
|
14
15
|
try {
|
|
15
16
|
const sessionToken = await AuthService.init(apiKey);
|
|
16
|
-
this.initializeAxiosInstance(sessionToken,
|
|
17
|
+
this.initializeAxiosInstance(sessionToken, API_BASE_URL);
|
|
17
18
|
}
|
|
18
19
|
catch (e) {
|
|
19
20
|
this.initPromise = null;
|
|
@@ -31,7 +32,7 @@ class MedosClient {
|
|
|
31
32
|
}
|
|
32
33
|
this.initPromise = (async () => {
|
|
33
34
|
try {
|
|
34
|
-
this.initializeAxiosInstance(sessionToken,
|
|
35
|
+
this.initializeAxiosInstance(sessionToken, API_BASE_URL);
|
|
35
36
|
}
|
|
36
37
|
catch (e) {
|
|
37
38
|
this.initPromise = null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const API_BASE_URL = "https://api.medos.one";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const API_BASE_URL = "https://api.medos.one";
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import axios from "axios";
|
|
2
|
+
import { API_BASE_URL } from "../constants";
|
|
2
3
|
let sessionToken = null;
|
|
3
4
|
const AuthService = {
|
|
4
5
|
async init(apiKey) {
|
|
5
6
|
try {
|
|
6
|
-
const res = await axios.post(
|
|
7
|
+
const res = await axios.post(`${API_BASE_URL}/v1/auth/session?api_key=${apiKey}`, {});
|
|
7
8
|
const token = res.data?.access_token;
|
|
8
9
|
if (!token || typeof token !== "string") {
|
|
9
10
|
throw new Error("Invalid session token response");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const API_BASE_URL = "https://api.medos.one";
|
|
@@ -3847,11 +3847,13 @@
|
|
|
3847
3847
|
mergeConfig
|
|
3848
3848
|
} = axios;
|
|
3849
3849
|
|
|
3850
|
+
const API_BASE_URL = "https://api.medos.one";
|
|
3851
|
+
|
|
3850
3852
|
let sessionToken = null;
|
|
3851
3853
|
const AuthService = {
|
|
3852
3854
|
async init(apiKey) {
|
|
3853
3855
|
try {
|
|
3854
|
-
const res = await axios.post(
|
|
3856
|
+
const res = await axios.post(`${API_BASE_URL}/v1/auth/session?api_key=${apiKey}`, {});
|
|
3855
3857
|
const token = res.data?.access_token;
|
|
3856
3858
|
if (!token || typeof token !== "string") {
|
|
3857
3859
|
throw new Error("Invalid session token response");
|
|
@@ -4005,7 +4007,7 @@
|
|
|
4005
4007
|
this.initPromise = (async () => {
|
|
4006
4008
|
try {
|
|
4007
4009
|
const sessionToken = await AuthService.init(apiKey);
|
|
4008
|
-
this.initializeAxiosInstance(sessionToken,
|
|
4010
|
+
this.initializeAxiosInstance(sessionToken, API_BASE_URL);
|
|
4009
4011
|
}
|
|
4010
4012
|
catch (e) {
|
|
4011
4013
|
this.initPromise = null;
|
|
@@ -4023,7 +4025,7 @@
|
|
|
4023
4025
|
}
|
|
4024
4026
|
this.initPromise = (async () => {
|
|
4025
4027
|
try {
|
|
4026
|
-
this.initializeAxiosInstance(sessionToken,
|
|
4028
|
+
this.initializeAxiosInstance(sessionToken, API_BASE_URL);
|
|
4027
4029
|
}
|
|
4028
4030
|
catch (e) {
|
|
4029
4031
|
this.initPromise = null;
|
package/dist/vanilla/widget.js
CHANGED
|
@@ -3847,11 +3847,13 @@
|
|
|
3847
3847
|
mergeConfig
|
|
3848
3848
|
} = axios;
|
|
3849
3849
|
|
|
3850
|
+
const API_BASE_URL = "https://api.medos.one";
|
|
3851
|
+
|
|
3850
3852
|
let sessionToken = null;
|
|
3851
3853
|
const AuthService = {
|
|
3852
3854
|
async init(apiKey) {
|
|
3853
3855
|
try {
|
|
3854
|
-
const res = await axios.post(
|
|
3856
|
+
const res = await axios.post(`${API_BASE_URL}/v1/auth/session?api_key=${apiKey}`, {});
|
|
3855
3857
|
const token = res.data?.access_token;
|
|
3856
3858
|
if (!token || typeof token !== "string") {
|
|
3857
3859
|
throw new Error("Invalid session token response");
|
|
@@ -3895,7 +3897,7 @@
|
|
|
3895
3897
|
this.initPromise = (async () => {
|
|
3896
3898
|
try {
|
|
3897
3899
|
const sessionToken = await AuthService.init(apiKey);
|
|
3898
|
-
this.initializeAxiosInstance(sessionToken,
|
|
3900
|
+
this.initializeAxiosInstance(sessionToken, API_BASE_URL);
|
|
3899
3901
|
}
|
|
3900
3902
|
catch (e) {
|
|
3901
3903
|
this.initPromise = null;
|
|
@@ -3913,7 +3915,7 @@
|
|
|
3913
3915
|
}
|
|
3914
3916
|
this.initPromise = (async () => {
|
|
3915
3917
|
try {
|
|
3916
|
-
this.initializeAxiosInstance(sessionToken,
|
|
3918
|
+
this.initializeAxiosInstance(sessionToken, API_BASE_URL);
|
|
3917
3919
|
}
|
|
3918
3920
|
catch (e) {
|
|
3919
3921
|
this.initPromise = null;
|
package/package.json
CHANGED