@trimoz/trimoz-api-wrapper 0.0.1-security → 0.9.7
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.
Potentially problematic release.
This version of @trimoz/trimoz-api-wrapper might be problematic. Click here for more details.
- package/build.js +205 -0
- package/package.json +10 -3
- package/src/apiv2.js +136 -0
- package/src/appointments/index.js +238 -0
- package/src/configuration/communications/index.js +16 -0
- package/src/configuration/places/index.js +98 -0
- package/src/configuration/resources/index.js +191 -0
- package/src/contactList/index.js +14 -0
- package/src/establishments/index.js +113 -0
- package/src/forms/index.js +77 -0
- package/src/formsAH635/index.js +63 -0
- package/src/headOffices/index.js +94 -0
- package/src/interceptors/index.js +97 -0
- package/src/journal/index.js +26 -0
- package/src/login/index.js +94 -0
- package/src/modules/index.js +15 -0
- package/src/my/index.js +164 -0
- package/src/notifications/index.js +12 -0
- package/src/oAuthWindow.js +50 -0
- package/src/other/index.js +31 -0
- package/src/patients/index.js +16 -0
- package/src/schedules/index.js +144 -0
- package/src/services/index.js +202 -0
- package/src/setOptions/index.js +31 -0
- package/src/settings/index.js +17 -0
- package/src/stats/index.js +88 -0
- package/src/store/helpers/index.js +16 -0
- package/src/store/jwt.js +172 -0
- package/src/texts/index.js +17 -0
- package/src/utils.js +71 -0
- package/README.md +0 -5
@@ -0,0 +1,97 @@
|
|
1
|
+
import { includes } from 'lodash';
|
2
|
+
|
3
|
+
export class JwtInterceptor {
|
4
|
+
constructor(API, apiTokenPromise, store) {
|
5
|
+
this.axiosInstance = API.http;
|
6
|
+
this.apiTokenPromise = apiTokenPromise;
|
7
|
+
this.store = store;
|
8
|
+
this.wrapperInstance = API;
|
9
|
+
|
10
|
+
this.requestOnFulfilled = (config) => {
|
11
|
+
if (config.url === 'v3/auth/token') return config;
|
12
|
+
if (this.store.getters['jwt/getIsInRetryMode']) {
|
13
|
+
return this.waitForAccessTokenAndRetryRequest(config);
|
14
|
+
}
|
15
|
+
this.setAuthorisationHeader(config);
|
16
|
+
return config;
|
17
|
+
};
|
18
|
+
|
19
|
+
this.requestOnRejected = (error) => {
|
20
|
+
throw error;
|
21
|
+
};
|
22
|
+
|
23
|
+
this.responseOnFulfilled = (response) => {
|
24
|
+
if (response.headers['x-trimoz-api-version']) {
|
25
|
+
this.wrapperInstance.apiVersion = response.headers['x-trimoz-api-version'];
|
26
|
+
}
|
27
|
+
if (response.headers['x-trimoz-api-version-date']) {
|
28
|
+
this.wrapperInstance.apiVersionDate = response.headers['x-trimoz-api-version-date'];
|
29
|
+
}
|
30
|
+
if (response.headers['x-trimoz-sec-whitelisted']) {
|
31
|
+
this.wrapperInstance.apiSecurityWhitelistingIp = response.headers['x-trimoz-sec-whitelisted'];
|
32
|
+
}
|
33
|
+
return response;
|
34
|
+
};
|
35
|
+
|
36
|
+
this.responseOnRejected = (error) => {
|
37
|
+
this.ensureRouteShouldRefreshAccessTokenOrThrow(error);
|
38
|
+
|
39
|
+
if (!this.store.getters['jwt/getIsInRetryMode']) {
|
40
|
+
this.store.commit('jwt/SET_IS_IN_RETRY_MODE', true);
|
41
|
+
this.apiTokenPromise()
|
42
|
+
.then(res => {
|
43
|
+
this.store.commit('jwt/SET_IS_IN_RETRY_MODE', false);
|
44
|
+
if (res.status !== 200) throw error;
|
45
|
+
this.store.commit('jwt/SET_ACCESS_TOKEN', res.data.accessToken);
|
46
|
+
this.onAccessTokenFetched(true);
|
47
|
+
})
|
48
|
+
.catch(() => {
|
49
|
+
this.store.commit('jwt/CLEAR_ACCESS_TOKEN');
|
50
|
+
this.store.commit('jwt/SET_IS_IN_RETRY_MODE', false);
|
51
|
+
this.onAccessTokenFetched(false);
|
52
|
+
throw error;
|
53
|
+
});
|
54
|
+
}
|
55
|
+
return this.waitForAccessTokenAndRetryRequest(error.config);
|
56
|
+
};
|
57
|
+
|
58
|
+
this.setAuthorisationHeader = (config) => {
|
59
|
+
const token = this.store.getters['jwt/getAccessToken'];
|
60
|
+
if (token) {
|
61
|
+
if (!config.headers) {
|
62
|
+
config.headers = {};
|
63
|
+
}
|
64
|
+
config.auth = undefined;
|
65
|
+
config.headers['Authorization'] = 'Bearer ' + token;
|
66
|
+
}
|
67
|
+
};
|
68
|
+
|
69
|
+
this.waitForAccessTokenAndRetryRequest = (config) => {
|
70
|
+
return new Promise((resolve, reject) => {
|
71
|
+
this.store.commit('jwt/ENQUEUE_REQUEST', (tokenIsRefreshed) => {
|
72
|
+
if (tokenIsRefreshed) {
|
73
|
+
resolve(this.axiosInstance(config));
|
74
|
+
}
|
75
|
+
reject(new Error('Request has been canceled because refresh token call has failed'));
|
76
|
+
});
|
77
|
+
});
|
78
|
+
};
|
79
|
+
|
80
|
+
this.onAccessTokenFetched = (tokenIsRefreshed) => {
|
81
|
+
this.store.commit('jwt/DEQUEUE_REQUEST');
|
82
|
+
while(this.store.getters['jwt/getHeadRequest']) {
|
83
|
+
const req = this.store.getters['jwt/getHeadRequest'];
|
84
|
+
req(tokenIsRefreshed);
|
85
|
+
this.store.commit('jwt/DEQUEUE_REQUEST');
|
86
|
+
}
|
87
|
+
};
|
88
|
+
|
89
|
+
this.ensureRouteShouldRefreshAccessTokenOrThrow = (error) => {
|
90
|
+
if (error.response && error.response.status !== 401) throw error;
|
91
|
+
if (includes(error.config.url, 'v3/auth/login')) throw error;
|
92
|
+
if (includes(error.config.url, 'v3/auth/token')) throw error;
|
93
|
+
if (includes(error.config.url, 'v3/auth/mfa')) throw error;
|
94
|
+
if (!includes(error.config.headers.Authorization, 'Bearer')) throw error;
|
95
|
+
};
|
96
|
+
}
|
97
|
+
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
'use strict';
|
2
|
+
import { appendQueryParams } from '../utils';
|
3
|
+
|
4
|
+
export default (API) => ({
|
5
|
+
journal: {
|
6
|
+
queryGlobal: (username = null, role = null, action = null, ipAddress = null, dateStart = null, dateStop = null) => {
|
7
|
+
let url = `v3/journal`;
|
8
|
+
let filters = { 'username': username, 'role': role, 'action': action, 'ipAddress': ipAddress, 'dateStart': dateStart, 'dateStop': dateStop };
|
9
|
+
url = appendQueryParams(url, filters);
|
10
|
+
const request = API.http.get(url);
|
11
|
+
return API.handleError(request);
|
12
|
+
},
|
13
|
+
queryByEstablishment: (establishmentId, username = null, role = null, action = null, ipAddress = null, dateStart = null, dateStop = null, appointment = null) => {
|
14
|
+
let url = `v3/establishment/` + establishmentId + `/journal`;
|
15
|
+
let filters = { 'username': username, 'role': role, 'action': action, 'ipAddress': ipAddress, 'dateStart': dateStart, 'dateStop': dateStop, 'appointmentNumber': appointment };
|
16
|
+
url = appendQueryParams(url, filters);
|
17
|
+
const request = API.http.get(url);
|
18
|
+
return API.handleError(request);
|
19
|
+
},
|
20
|
+
getJournalActions: () => {
|
21
|
+
let url = `v3/journal/actions`;
|
22
|
+
const request = API.http.get(url);
|
23
|
+
return API.handleError(request);
|
24
|
+
}
|
25
|
+
}
|
26
|
+
});
|
@@ -0,0 +1,94 @@
|
|
1
|
+
'use strict';
|
2
|
+
import 'url-search-params-polyfill'; // IE-11
|
3
|
+
|
4
|
+
export default (API) => ({
|
5
|
+
auth: {
|
6
|
+
getAccessToken: () => {
|
7
|
+
const url = 'v3/auth/token';
|
8
|
+
const request = API.http.post(url);
|
9
|
+
return API.handleError(request);
|
10
|
+
},
|
11
|
+
|
12
|
+
getUser: () => {
|
13
|
+
const request = API.http.get('v3/sessions/user');
|
14
|
+
return API.handleError(request);
|
15
|
+
},
|
16
|
+
|
17
|
+
getMyPatient: () => {
|
18
|
+
const url = 'v3/resources/current';
|
19
|
+
const request = API.http.get(url);
|
20
|
+
return API.handleError(request);
|
21
|
+
},
|
22
|
+
|
23
|
+
getMyPatientCommunication: () => {
|
24
|
+
const url = '/v3/profile/communications';
|
25
|
+
const request = API.http.get(url);
|
26
|
+
return API.handleError(request);
|
27
|
+
},
|
28
|
+
|
29
|
+
getAllPatients: () => {
|
30
|
+
const url = 'v3/profile/patients';
|
31
|
+
const request = API.http.get(url);
|
32
|
+
return API.handleError(request);
|
33
|
+
},
|
34
|
+
|
35
|
+
login: (username, password) => {
|
36
|
+
let params = new URLSearchParams();
|
37
|
+
params.append('username', username);
|
38
|
+
params.append('password', password);
|
39
|
+
|
40
|
+
const request = API.http.post('v3/login', params);
|
41
|
+
return API.handleError(request);
|
42
|
+
},
|
43
|
+
|
44
|
+
loginWithMfa: (params) => {
|
45
|
+
const request = API.http.post('v3/login/mfa', params, { headers: { 'Content-Type': 'application/json' } });
|
46
|
+
return API.handleError(request);
|
47
|
+
},
|
48
|
+
|
49
|
+
validateMfaLogin: (params) => {
|
50
|
+
const request = API.http.post('v3/login/validateMfaLogin', params, { headers: { 'Content-Type': 'application/json' } });
|
51
|
+
return API.handleError(request);
|
52
|
+
},
|
53
|
+
|
54
|
+
resendMfaCode: (params) => {
|
55
|
+
const request = API.http.post('v3/login/resendMfaCode', params, { headers: { 'Content-Type': 'application/json' } });
|
56
|
+
return API.handleError(request);
|
57
|
+
},
|
58
|
+
|
59
|
+
logout: () => {
|
60
|
+
const request = API.http.get('v3/logout');
|
61
|
+
return API.handleError(request);
|
62
|
+
},
|
63
|
+
|
64
|
+
logoutJwt: () => {
|
65
|
+
const request = API.http.post('v3/auth/logout');
|
66
|
+
return API.handleError(request);
|
67
|
+
},
|
68
|
+
|
69
|
+
heartbeat: () => {
|
70
|
+
const request = API.http.post('v3/heartbeat');
|
71
|
+
return API.handleError(request);
|
72
|
+
},
|
73
|
+
|
74
|
+
passwordResetRequest: (params) => {
|
75
|
+
const request = API.http.post('v3/passwordResetRequest', params, { headers: { 'Content-Type': 'application/json' } });
|
76
|
+
return API.handleError(request);
|
77
|
+
},
|
78
|
+
|
79
|
+
passwordResetValidate: (params) => {
|
80
|
+
const request = API.http.post('v3/passwordResetValidate', params, { headers: { 'Content-Type': 'application/json' } });
|
81
|
+
return API.handleError(request);
|
82
|
+
},
|
83
|
+
|
84
|
+
passwordReset: (params) => {
|
85
|
+
const request = API.http.post('v3/passwordReset', params, { headers: { 'Content-Type': 'application/json' } });
|
86
|
+
return API.handleError(request);
|
87
|
+
},
|
88
|
+
|
89
|
+
passwordUpdate: (params) => {
|
90
|
+
const request = API.http.post('v3/passwordUpdate', params, { headers: { 'Content-Type': 'application/json' } });
|
91
|
+
return API.handleError(request);
|
92
|
+
},
|
93
|
+
},
|
94
|
+
});
|
@@ -0,0 +1,15 @@
|
|
1
|
+
'use strict';
|
2
|
+
import 'url-search-params-polyfill'; // IE-11
|
3
|
+
|
4
|
+
export default (API) => ({
|
5
|
+
modules: {
|
6
|
+
getModules: (params) => {
|
7
|
+
const request = API.http.get('v3/modules', params);
|
8
|
+
return API.handleError(request);
|
9
|
+
},
|
10
|
+
getSubmodules: () => {
|
11
|
+
const request = API.http.get('v3/submodules');
|
12
|
+
return API.handleError(request);
|
13
|
+
}
|
14
|
+
}
|
15
|
+
});
|
package/src/my/index.js
ADDED
@@ -0,0 +1,164 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
import {join} from "lodash";
|
4
|
+
|
5
|
+
export default (API) => ({
|
6
|
+
my: {
|
7
|
+
getMyPlacesByNameByHeadOfficesByEstablishments(name, headOfficeIds, establishmentIds) {
|
8
|
+
const url = `v3/my/places?queryType=byName&name=${name}&headOffices=${headOfficeIds}&establishments=${establishmentIds}`;
|
9
|
+
const request = API.http.get(url);
|
10
|
+
return API.handleError(request);
|
11
|
+
},
|
12
|
+
|
13
|
+
getAllMyPlaces() {
|
14
|
+
const url = `v3/my/places?queryType=all`;
|
15
|
+
const request = API.http.get(url);
|
16
|
+
return API.handleError(request);
|
17
|
+
},
|
18
|
+
|
19
|
+
getMyPlacesByIds(placeIds) {
|
20
|
+
const url = `v3/my/places?queryType=byIds&ids=${placeIds}`;
|
21
|
+
const request = API.http.get(url);
|
22
|
+
return API.handleError(request);
|
23
|
+
},
|
24
|
+
|
25
|
+
getMyResourcesByNameByHeadOfficesByEstablishments(name, headOfficeIds, establishmentIds) {
|
26
|
+
const url = `v3/my/resources?queryType=byName&name=${name}&headOffices=${headOfficeIds}&establishments=${establishmentIds}`;
|
27
|
+
const request = API.http.get(url);
|
28
|
+
return API.handleError(request);
|
29
|
+
},
|
30
|
+
|
31
|
+
getAllMyResources() {
|
32
|
+
const url = `v3/my/resources?queryType=all`;
|
33
|
+
const request = API.http.get(url);
|
34
|
+
return API.handleError(request);
|
35
|
+
},
|
36
|
+
|
37
|
+
getMyResourcesByIds(resourceIds) {
|
38
|
+
const url = `v3/my/resources?queryType=byIds&ids=${resourceIds}`;
|
39
|
+
const request = API.http.get(url);
|
40
|
+
return API.handleError(request);
|
41
|
+
},
|
42
|
+
|
43
|
+
getMyServicesByNameByHeadOfficesByEstablishments(name, headOfficeIds, establishmentIds) {
|
44
|
+
const url = `v3/my/services?queryType=byName&name=${name}&headOffices=${headOfficeIds}&establishments=${establishmentIds}`;
|
45
|
+
const request = API.http.get(url);
|
46
|
+
return API.handleError(request);
|
47
|
+
},
|
48
|
+
|
49
|
+
getAllMyServices() {
|
50
|
+
const url = `v3/my/services?queryType=all`;
|
51
|
+
const request = API.http.get(url);
|
52
|
+
return API.handleError(request);
|
53
|
+
},
|
54
|
+
|
55
|
+
getMyServicesByIds(servicesIds) {
|
56
|
+
const url = `v3/my/services?queryType=byIds&ids=${servicesIds}`;
|
57
|
+
const request = API.http.get(url);
|
58
|
+
return API.handleError(request);
|
59
|
+
},
|
60
|
+
|
61
|
+
getMyEstablishments({mode, headOfficeIds, establishmentIds, partialName, page}) {
|
62
|
+
let params = new URLSearchParams();
|
63
|
+
let url = `v3/my/establishments`;
|
64
|
+
params.append('queryType', mode);
|
65
|
+
if (headOfficeIds && headOfficeIds.length) {
|
66
|
+
params.append('headOffices', join(headOfficeIds));
|
67
|
+
}
|
68
|
+
if (mode === 'byIds' && establishmentIds && establishmentIds.length) {
|
69
|
+
params.append('ids', join(establishmentIds));
|
70
|
+
}
|
71
|
+
if (mode === 'byName' && partialName && partialName.trim().length > 0) {
|
72
|
+
params.append('name', partialName);
|
73
|
+
}
|
74
|
+
if (page && page > 0) {
|
75
|
+
params.append('page', page);
|
76
|
+
}
|
77
|
+
return API.handleError(API.http.get(url + '?' + params.toString()));
|
78
|
+
},
|
79
|
+
|
80
|
+
getMyPlaces({mode, headOfficeIds, establishmentIds, placeIds, partialName, page}) {
|
81
|
+
let params = new URLSearchParams();
|
82
|
+
let url = `v3/my/places`;
|
83
|
+
params.append('queryType', mode);
|
84
|
+
if (headOfficeIds && headOfficeIds.length) {
|
85
|
+
params.append('headOffices', join(headOfficeIds));
|
86
|
+
}
|
87
|
+
if (establishmentIds && establishmentIds.length) {
|
88
|
+
params.append('establishments', join(establishmentIds));
|
89
|
+
}
|
90
|
+
if (mode === 'byIds' && placeIds && placeIds.length) {
|
91
|
+
params.append('ids', join(placeIds));
|
92
|
+
}
|
93
|
+
if (mode === 'byName' && partialName && partialName.trim().length > 0) {
|
94
|
+
params.append('name', partialName);
|
95
|
+
}
|
96
|
+
if (page && page > 0) {
|
97
|
+
params.append('page', page);
|
98
|
+
}
|
99
|
+
return API.handleError(API.http.get(url + '?' + params.toString()));
|
100
|
+
},
|
101
|
+
|
102
|
+
getMyServices({mode, headOfficeIds, establishmentIds, serviceIds, partialName, page}) {
|
103
|
+
let params = new URLSearchParams();
|
104
|
+
let url = `v3/my/services`;
|
105
|
+
params.append('queryType', mode);
|
106
|
+
if (headOfficeIds && headOfficeIds.length) {
|
107
|
+
params.append('headOffices', join(headOfficeIds));
|
108
|
+
}
|
109
|
+
if (establishmentIds && establishmentIds.length) {
|
110
|
+
params.append('establishments', join(establishmentIds));
|
111
|
+
}
|
112
|
+
if (mode === 'byIds' && serviceIds && serviceIds.length) {
|
113
|
+
params.append('ids', join(serviceIds));
|
114
|
+
}
|
115
|
+
if (mode === 'byName' && partialName && partialName.trim().length > 0) {
|
116
|
+
params.append('name', partialName);
|
117
|
+
}
|
118
|
+
if (page && page > 0) {
|
119
|
+
params.append('page', page);
|
120
|
+
}
|
121
|
+
return API.handleError(API.http.get(url + '?' + params.toString()));
|
122
|
+
},
|
123
|
+
|
124
|
+
getMyResources({mode, headOfficeIds, establishmentIds, resourceIds, partialName, page}) {
|
125
|
+
let params = new URLSearchParams();
|
126
|
+
let url = `v3/my/resources`;
|
127
|
+
params.append('queryType', mode);
|
128
|
+
if (headOfficeIds && headOfficeIds.length) {
|
129
|
+
params.append('headOffices', join(headOfficeIds));
|
130
|
+
}
|
131
|
+
if (establishmentIds && establishmentIds.length) {
|
132
|
+
params.append('establishments', join(establishmentIds));
|
133
|
+
}
|
134
|
+
if (mode === 'byIds' && resourceIds && resourceIds.length) {
|
135
|
+
params.append('ids', join(resourceIds));
|
136
|
+
}
|
137
|
+
if (mode === 'byName' && partialName && partialName.trim().length > 0) {
|
138
|
+
params.append('name', partialName);
|
139
|
+
}
|
140
|
+
if (page && page > 0) {
|
141
|
+
params.append('page', page);
|
142
|
+
}
|
143
|
+
return API.handleError(API.http.get(url + '?' + params.toString()));
|
144
|
+
},
|
145
|
+
|
146
|
+
getMyEstablishmentsByNameByHeadOffices(name, headOfficeIds) {
|
147
|
+
const url = `v3/my/establishments?queryType=byName&name=${name}&headOffices=${headOfficeIds}`;
|
148
|
+
const request = API.http.get(url);
|
149
|
+
return API.handleError(request);
|
150
|
+
},
|
151
|
+
|
152
|
+
getAllMyEstablishments() {
|
153
|
+
const url = `v3/my/establishments?queryType=all`;
|
154
|
+
const request = API.http.get(url);
|
155
|
+
return API.handleError(request);
|
156
|
+
},
|
157
|
+
|
158
|
+
getMyEstablishmentsByIds(establishmentsIds) {
|
159
|
+
const url = `v3/my/establishments?queryType=byIds&ids=${establishmentsIds}`;
|
160
|
+
const request = API.http.get(url);
|
161
|
+
return API.handleError(request);
|
162
|
+
}
|
163
|
+
}
|
164
|
+
});
|
@@ -0,0 +1,12 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
import axios from 'axios';
|
4
|
+
|
5
|
+
export default (API) => ({
|
6
|
+
notifications: {
|
7
|
+
acknowledgeNotification: (params) => {
|
8
|
+
const request = API.http.put(`/v3/establishments/${params.establishmentId}/resources/${params.resourceId}/settings`, params.resourceSettings, { headers: { 'Content-Type': 'application/json' } });
|
9
|
+
return API.handleError(request);
|
10
|
+
},
|
11
|
+
},
|
12
|
+
});
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import { includes } from 'lodash';
|
2
|
+
|
3
|
+
let authWindow;
|
4
|
+
let windowOpts = 'toolbar=0,scrollbars=1,status=1,resizable=1,location=1,menuBar=0,';
|
5
|
+
let callback;
|
6
|
+
|
7
|
+
export const signInWindow = async(url) => {
|
8
|
+
window.removeEventListener('message', callback);
|
9
|
+
|
10
|
+
const windowArea = {
|
11
|
+
width: window.outerWidth < 440 ? window.outerWidth : 440,
|
12
|
+
height: Math.floor(window.outerHeight * 0.8),
|
13
|
+
};
|
14
|
+
|
15
|
+
if (windowArea.width < 360) { windowArea.width = 360; }
|
16
|
+
if (windowArea.height < 630) { windowArea.height = 630; }
|
17
|
+
windowArea.left = Math.floor(window.screenX + ((window.outerWidth - windowArea.width) / 2));
|
18
|
+
windowArea.top = Math.floor(window.screenY + ((window.outerHeight - windowArea.height) / 8));
|
19
|
+
|
20
|
+
windowOpts += `width=${windowArea.width},`;
|
21
|
+
windowOpts += `height=${windowArea.height},`;
|
22
|
+
windowOpts += `left=${windowArea.left},`;
|
23
|
+
windowOpts += `top=${windowArea.top},`;
|
24
|
+
|
25
|
+
authWindow = window.open(url, 'profileLogin', windowOpts);
|
26
|
+
|
27
|
+
return new Promise((resolve, reject) => {
|
28
|
+
callback = receiveMessage(resolve, reject);
|
29
|
+
window.addEventListener('message', callback, false);
|
30
|
+
});
|
31
|
+
};
|
32
|
+
|
33
|
+
const receiveMessage = (resolve, reject) => (e) => {
|
34
|
+
if (!includes(e.origin, 'profile.clicsante.ca') &&
|
35
|
+
!includes(e.origin, 'profile.pharmaservices.ca') &&
|
36
|
+
!includes(e.origin, 'profile.staging4.clicsante.ca') &&
|
37
|
+
!includes(e.origin, 'profile.staging4.pharmaservices.ca') &&
|
38
|
+
!includes(e.origin, 'profile.pentest.clicsante.ca') &&
|
39
|
+
!includes(e.origin, 'profile.pentest.pharmaservices.ca') &&
|
40
|
+
!includes(e.origin, 'profile.dev.clicsante.ca') &&
|
41
|
+
!includes(e.origin, 'profile.dev.pharmaservices.ca') &&
|
42
|
+
!includes(e.origin, 'localhost:8084')
|
43
|
+
) {
|
44
|
+
authWindow.close();
|
45
|
+
return reject(new Error('Origin not allowed'));
|
46
|
+
}
|
47
|
+
|
48
|
+
authWindow.close();
|
49
|
+
return resolve();
|
50
|
+
};
|
@@ -0,0 +1,31 @@
|
|
1
|
+
'use strict';
|
2
|
+
import 'url-search-params-polyfill'; // IE-11
|
3
|
+
|
4
|
+
export default (API) => ({
|
5
|
+
other: {
|
6
|
+
sendReminders: (establishmentId, params) => {
|
7
|
+
const request = API.http.post(`/v3/establishments/${establishmentId}/reminders`, params);
|
8
|
+
return API.handleError(request);
|
9
|
+
},
|
10
|
+
confirmAppointment: (params) => {
|
11
|
+
const request = API.http.post('/v3/confirmAppointment', params);
|
12
|
+
return API.handleError(request);
|
13
|
+
},
|
14
|
+
cancelAppointment: (params) => {
|
15
|
+
const request = API.http.post('/v3/cancelAppointment', params);
|
16
|
+
return API.handleError(request);
|
17
|
+
},
|
18
|
+
sendJoinUsMail: (params) => {
|
19
|
+
const request = API.http.post('/v3/joinUs', params);
|
20
|
+
return API.handleError(request);
|
21
|
+
},
|
22
|
+
sendCouponLostMail: (establishmentId, params) => {
|
23
|
+
const request = API.http.post(`/v3/establishments/${establishmentId}/couponLost`, params);
|
24
|
+
return API.handleError(request);
|
25
|
+
},
|
26
|
+
geocode: (address) => {
|
27
|
+
const request = API.http.get(`/v3/geocode?address=${address}`);
|
28
|
+
return API.handleError(request);
|
29
|
+
}
|
30
|
+
}
|
31
|
+
});
|
@@ -0,0 +1,16 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
export default (API) => ({
|
4
|
+
patients: {
|
5
|
+
fetchAppointmentsPatients(establishmentId, requestUuid, params) {
|
6
|
+
let url = `v3/establishments/${establishmentId}/appointments/${requestUuid}/patients?${new URLSearchParams(params).toString()}`;
|
7
|
+
const request = API.http.get(url, { headers: { 'Content-Type': 'application/json' } });
|
8
|
+
return API.handleError(request);
|
9
|
+
},
|
10
|
+
updateProfileUserPatient(profileUserId, patientUuid, params) {
|
11
|
+
const url = `/v3/profile/${profileUserId}/patients/${patientUuid}`;
|
12
|
+
const request = API.http.put(url, params, { headers: { 'Content-Type': 'application/json' } });
|
13
|
+
return API.handleError(request);
|
14
|
+
},
|
15
|
+
},
|
16
|
+
});
|
@@ -0,0 +1,144 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
export default (API) => ({
|
4
|
+
schedules: {
|
5
|
+
get: (establishmentId, availabilityId) => {
|
6
|
+
const url = 'api/v5/establishments/' + establishmentId + '/availabilities/' + availabilityId;
|
7
|
+
const request = API.http.get(url);
|
8
|
+
return API.handleError(request);
|
9
|
+
},
|
10
|
+
getAll: (establishmentId, dateStart, dateStop, places = null, services = null, resources = null, clientTimeZone = null, appointmentId = null) => {
|
11
|
+
const url = 'v3/establishments/' + establishmentId +
|
12
|
+
'/availabilities?dateStart=' + dateStart +
|
13
|
+
'&dateStop=' + dateStop +
|
14
|
+
(places ? '&places=' + places.join(',') : '&places=') +
|
15
|
+
(services ? '&services=' + services.join(',') : '&services=') +
|
16
|
+
(resources ? '&resources=' + resources.join(',') : '&resources=') +
|
17
|
+
(clientTimeZone ? '&timezone=' + clientTimeZone : '') +
|
18
|
+
(appointmentId ? '&appointmentId=' + appointmentId : '');
|
19
|
+
|
20
|
+
const request = API.http.get(url);
|
21
|
+
return API.handleError(request);
|
22
|
+
},
|
23
|
+
getAllForPlace: (establishmentId, place, dateStart, dateStop, light = false, serviceId = null) => {
|
24
|
+
const url = 'v3/establishments/' + establishmentId +
|
25
|
+
'/availabilities?dateStart=' + dateStart +
|
26
|
+
'&dateStop=' + dateStop +
|
27
|
+
'&places=' + place +
|
28
|
+
'&light=' + light +
|
29
|
+
(serviceId ? '&services=' + serviceId : '');
|
30
|
+
|
31
|
+
const request = API.http.get(url);
|
32
|
+
return API.handleError(request);
|
33
|
+
},
|
34
|
+
getFirstAvailabilityNextYear: (establishmentId, places, service, filters = null, clientTimeZone = null, dateStart = null, dateStop = null, gapMode = false, gapHeadOfficeId = null) => {
|
35
|
+
const url = 'v3/establishments/' + establishmentId +
|
36
|
+
'/availabilities/first?places=' + places +
|
37
|
+
'&service=' + service +
|
38
|
+
(clientTimeZone ? '&timezone=' + clientTimeZone : '') +
|
39
|
+
(filters
|
40
|
+
? (filters[0] !== null ? '&filter1=' + filters[0] : '') +
|
41
|
+
(filters[1] !== null ? '&filter2=' + filters[1] : '') +
|
42
|
+
(filters[2] !== null ? '&filter3=' + filters[2] : '')
|
43
|
+
: ''
|
44
|
+
) +
|
45
|
+
(dateStart ? '&dateStart=' + dateStart : '') +
|
46
|
+
(dateStop ? '&dateStop=' + dateStop : '') +
|
47
|
+
'&gapMode='+ gapMode +
|
48
|
+
((gapMode && gapHeadOfficeId) ? '&gapHeadOfficeId='+ gapHeadOfficeId : '');
|
49
|
+
|
50
|
+
const request = API.http.get(url);
|
51
|
+
return API.handleError(request);
|
52
|
+
},
|
53
|
+
getPublicSchedule: (establishmentId, dateStart, dateStop, service, place = null, filters = null, clientTimeZone = null, gapMode = false, gapHeadOfficeId = null) => {
|
54
|
+
const url = 'v3/establishments/' + establishmentId +
|
55
|
+
'/schedules/public?dateStart=' + dateStart +
|
56
|
+
'&dateStop=' + dateStop +
|
57
|
+
'&service=' + service +
|
58
|
+
(clientTimeZone ? '&timezone=' + clientTimeZone : '') +
|
59
|
+
(place ? '&places=' + place : '') +
|
60
|
+
(filters ? (filters[0] !== null ? '&filter1=' + filters[0] : '') +
|
61
|
+
(filters[1] !== null ? '&filter2=' + filters[1] : '') +
|
62
|
+
(filters[2] !== null ? '&filter3=' + filters[2] : '') : '') +
|
63
|
+
'&gapMode='+ gapMode +
|
64
|
+
((gapMode && gapHeadOfficeId) ? '&gapHeadOfficeId='+ gapHeadOfficeId : '');
|
65
|
+
|
66
|
+
const request = API.http.get(url);
|
67
|
+
return API.handleError(request);
|
68
|
+
},
|
69
|
+
getClosestSchedule: (establishmentId, dateTarget, dateStart, dateStop, service, place = null, filters = null, clientTimeZone = null, limit = null, minResourceCount = null, gapMode = false, gapHeadOfficeId = null) => {
|
70
|
+
const url = 'v3/establishments/' + establishmentId +
|
71
|
+
'/schedules/next?dateTarget=' + dateTarget +
|
72
|
+
'&dateStart=' + dateStart +
|
73
|
+
'&dateStop=' + dateStop +
|
74
|
+
'&service=' + service +
|
75
|
+
(clientTimeZone ? '&timezone=' + clientTimeZone : '') +
|
76
|
+
(place ? '&places=' + place : '') +
|
77
|
+
(limit ? '&limit=' + limit : '') +
|
78
|
+
(minResourceCount ? '&resourceCount=' + minResourceCount : '') +
|
79
|
+
(filters ? (filters[0] !== null ? '&filter1=' + filters[0] : '') +
|
80
|
+
(filters[1] !== null ? '&filter2=' + filters[1] : '') +
|
81
|
+
(filters[2] !== null ? '&filter3=' + filters[2] : '') : '')+
|
82
|
+
'&gapMode='+ gapMode +
|
83
|
+
((gapMode && gapHeadOfficeId) ? '&gapHeadOfficeId='+ gapHeadOfficeId : '');
|
84
|
+
|
85
|
+
const request = API.http.get(url);
|
86
|
+
return API.handleError(request);
|
87
|
+
},
|
88
|
+
getCompletePublicPeriodSchedule: (establishmentId, dateStart, dateStop, service, place = null, filters = null, clientTimeZone = null, gapMode = false, gapHeadOfficeId = null) => {
|
89
|
+
const url = 'v3/establishments/' + establishmentId +
|
90
|
+
'/schedules/day?dateStart=' + dateStart +
|
91
|
+
'&dateStop=' + dateStop +
|
92
|
+
'&service=' + service +
|
93
|
+
(clientTimeZone ? '&timezone=' + clientTimeZone : '') +
|
94
|
+
(place ? '&places=' + place : '') +
|
95
|
+
(filters ? (filters[0] !== null ? '&filter1=' + filters[0] : '') +
|
96
|
+
(filters[1] !== null ? '&filter2=' + filters[1] : '') +
|
97
|
+
(filters[2] !== null ? '&filter3=' + filters[2] : '') : '')+
|
98
|
+
'&gapMode='+ gapMode +
|
99
|
+
((gapMode && gapHeadOfficeId) ? '&gapHeadOfficeId='+ gapHeadOfficeId : '');
|
100
|
+
|
101
|
+
const request = API.http.get(url);
|
102
|
+
return API.handleError(request);
|
103
|
+
},
|
104
|
+
createBatch(establishmentId, params) {
|
105
|
+
const url = 'v3/establishments/' + establishmentId + '/availabilities/';
|
106
|
+
const request = API.http.post(url, params, { headers: { 'Content-Type': 'application/json' } });
|
107
|
+
return API.handleError(request);
|
108
|
+
},
|
109
|
+
updateBatch(establishmentId, params) {
|
110
|
+
let url = 'v3/establishments/' + establishmentId + '/availabilities';
|
111
|
+
const request = API.http.put(url, params, { headers: { 'Content-Type': 'application/json' } });
|
112
|
+
return API.handleError(request);
|
113
|
+
},
|
114
|
+
deleteBatch(establishmentId, params) {
|
115
|
+
const url = 'v3/establishments/' + establishmentId + '/availabilities?ids=' + params;
|
116
|
+
const request = API.http.delete(url);
|
117
|
+
return API.handleError(request);
|
118
|
+
},
|
119
|
+
getDaysWithAvailability(establishmentId, place, dateStart, dateStop, timezone = null, service = null, appointmentId = null) {
|
120
|
+
let url = 'v3/establishments/' + establishmentId + '/schedules/daysWithAvailability?dateStart=' + dateStart + '&dateStop=' + dateStop + '&places=' + place;
|
121
|
+
url += timezone ? '&timezone=' + timezone : '';
|
122
|
+
url += service ? '&service=' + service : '';
|
123
|
+
url += appointmentId ? '&appointmentId=' + appointmentId : '';
|
124
|
+
const request = API.http.get(url);
|
125
|
+
return API.handleError(request);
|
126
|
+
},
|
127
|
+
getMonthInfoByPlace(establishmentId, placesIds, resourceIds, servicesIds, dateStart, dateStop, timezone = null) {
|
128
|
+
let url = `v3/establishments/${establishmentId}/schedules?dateStart=${dateStart}&dateStop=${dateStop}&places=${placesIds}&resources=${resourceIds}&services=${servicesIds}`;
|
129
|
+
url += timezone ? `&timezone=${timezone}` : '';
|
130
|
+
const request = API.http.get(url);
|
131
|
+
return API.handleError(request);
|
132
|
+
},
|
133
|
+
getReconstructedAvailsForDay(establishmentId, placeId, date, timezone) {
|
134
|
+
const url = 'v3/establishments/' + establishmentId + '/places/' + placeId + '/availabilities/reconstructed?date=' + date + '&timezone=' + timezone;
|
135
|
+
const request = API.http.get(url);
|
136
|
+
return API.handleError(request);
|
137
|
+
},
|
138
|
+
toggleDay(establishmentId, params) {
|
139
|
+
const url = 'v3/establishments/' + establishmentId + '/availabilities/toggleDay';
|
140
|
+
const request = API.http.put(url, params, { headers: { 'Content-Type': 'application/json' } });
|
141
|
+
return API.handleError(request);
|
142
|
+
}
|
143
|
+
}
|
144
|
+
});
|