@getjones/test-infra 1.1.4 → 1.1.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.
Files changed (28) hide show
  1. package/README.md +73 -88
  2. package/package.json +3 -2
  3. package/src/common/httpResponseStatusCodes.json +12 -0
  4. package/src/common/validations/errorValidation.js +16 -0
  5. package/src/env.js +2 -2
  6. package/src/index.js +2 -1
  7. package/src/saas/internal-api/accounts/api/core/accounts.core.setup.js +2 -2
  8. package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.api.js +29 -13
  9. package/src/saas/internal-api/accounts/api/openapi/accounts.openapi.setup.js +46 -21
  10. package/src/saas/internal-api/common/requests.js +28 -9
  11. package/src/saas/internal-api/compliance/api/coverage/coverage.api.js +5 -5
  12. package/src/saas/internal-api/compliance/api/coverage/coverage.setup.js +4 -4
  13. package/src/saas/internal-api/contractors/api/contractors.api.js +24 -3
  14. package/src/saas/internal-api/contractors/api/contractors.setup.js +15 -5
  15. package/src/saas/internal-api/contractors/models/create.contractor.model.js +2 -1
  16. package/src/saas/internal-api/contractors/models/edit.contractor.model.js +60 -5
  17. package/src/saas/internal-api/projects/api/core/projects.api.js +13 -2
  18. package/src/saas/internal-api/projects/api/core/projects.setup.js +14 -1
  19. package/src/saas/internal-api/projects/index.js +2 -1
  20. package/src/saas/internal-api/projects/models/core/create.project.model.js +1 -1
  21. package/src/saas/internal-api/projects/models/core/update.project.model.js +27 -0
  22. package/src/saas/internal-api/tabs/api/tabs.setup.js +1 -1
  23. package/src/saas/openapi/accounts/accounts.api.js +17 -0
  24. package/src/saas/openapi/accounts/accounts.setup.js +11 -0
  25. package/src/saas/openapi/common/requests.js +11 -10
  26. package/src/saas/openapi/projects/projects.api.js +16 -2
  27. package/src/saas/openapi/projects/projects.setup.js +11 -1
  28. package/src/common/exceptions/notFoundError.js +0 -10
package/README.md CHANGED
@@ -2,22 +2,22 @@
2
2
 
3
3
  ## Package Goal
4
4
 
5
- * Providing an easy and reusable interface for the backend system. Means, both by the OpenAPI, and the internal API.
5
+ - Providing an easy and reusable interface for the backend system. Means, both by the OpenAPI, and the internal API.
6
6
 
7
7
  ## Interface
8
8
 
9
9
  ### init
10
10
 
11
- * require the package with settled up configuration json
11
+ - require the package with settled up configuration json
12
12
 
13
13
  ```node
14
- const { internalAPI } = require('@getjones/test-infra')(conf);
14
+ const { internalAPI } = require("@getjones/test-infra")(conf);
15
15
  ```
16
16
 
17
- * configuration example
17
+ - configuration example
18
18
 
19
19
  ```node
20
- const dotenv = require('dotenv');
20
+ const dotenv = require("dotenv");
21
21
 
22
22
  dotenv.config();
23
23
 
@@ -36,12 +36,12 @@ module.exports = {
36
36
 
37
37
  ### internalAPI
38
38
 
39
- * internalAPI contains the next services:
40
- * auth
41
- * accounts
42
- * accountSettings
43
- * projects
44
- * projectSettings
39
+ - internalAPI contains the next services:
40
+ - auth
41
+ - accounts
42
+ - accountSettings
43
+ - projects
44
+ - projectSettings
45
45
 
46
46
  ```node
47
47
  const { auth, accounts, accountSettings, projects } = internalAPI;
@@ -50,32 +50,28 @@ const { auth, accounts, accountSettings, projects } = internalAPI;
50
50
  ### auth
51
51
 
52
52
  ```node
53
-
54
53
  /**
55
54
  *
56
55
  * @param email (string)
57
56
  * @param password (string)
58
57
  * @return Auth cookie (string) with given email privileges.
59
58
  */
60
- const getAuthCookie = async (email, password) => {
61
- };
59
+ const getAuthCookie = async (email, password) => {};
62
60
 
63
61
  /**
64
62
  *
65
63
  * Required Configuration: {
66
64
  * credentials.superUser,
67
- * credentials.superUserPassword
65
+ * credentials.superUserPassword
68
66
  * }
69
67
  * @return ICS cookie (String)
70
68
  */
71
- const getIcsCookie = async () => {
72
- };
69
+ const getIcsCookie = async () => {};
73
70
  ```
74
71
 
75
72
  ### accounts
76
73
 
77
74
  ```node
78
-
79
75
  /**
80
76
  *
81
77
  * Required Configuration: {
@@ -92,10 +88,13 @@ const getIcsCookie = async () => {
92
88
  * @return Account (object)
93
89
  */
94
90
 
95
- const createAccount = async (email, accountName, context,
91
+ const createAccount = async (
92
+ email,
93
+ accountName,
94
+ context,
96
95
  password = credentials.strongPassword,
97
- propertyType = PROPERTY_TYPE) => {
98
- };
96
+ propertyType = PROPERTY_TYPE
97
+ ) => {};
99
98
 
100
99
  /**
101
100
  *
@@ -103,8 +102,7 @@ const createAccount = async (email, accountName, context,
103
102
  * @param context (string): Should contains ICS cookie
104
103
  * @return Account (object)
105
104
  */
106
- const getAccount = async (accountName, context) => {
107
- };
105
+ const getAccount = async (accountName, context) => {};
108
106
 
109
107
  /**
110
108
  *
@@ -114,8 +112,12 @@ const getAccount = async (accountName, context) => {
114
112
  * @param password (string)
115
113
  * @return Account (object)
116
114
  */
117
- const getOrCreateAccount = async (email, accountName, context, password = credentials.strongPassword) => {
118
- };
115
+ const getOrCreateAccount = async (
116
+ email,
117
+ accountName,
118
+ context,
119
+ password = credentials.strongPassword
120
+ ) => {};
119
121
 
120
122
  /**
121
123
  *
@@ -123,8 +125,7 @@ const getOrCreateAccount = async (email, accountName, context, password = creden
123
125
  * @param context (string): Should contain ICS cookie
124
126
  * @return Account ID (String)
125
127
  */
126
- const getAccountId = async (accountName, context) => {
127
- };
128
+ const getAccountId = async (accountName, context) => {};
128
129
 
129
130
  /**
130
131
  *
@@ -132,8 +133,7 @@ const getAccountId = async (accountName, context) => {
132
133
  * @param context (string): Should contains ICS cookie
133
134
  * @return Http Response
134
135
  */
135
- const deleteAccountByName = async (accountName, context) => {
136
- };
136
+ const deleteAccountByName = async (accountName, context) => {};
137
137
 
138
138
  /**
139
139
  *
@@ -141,22 +141,19 @@ const deleteAccountByName = async (accountName, context) => {
141
141
  * @param context (string): Should contain ICS cookie
142
142
  * @return Http Response
143
143
  */
144
- const deleteAccountById = async (accountId, context) => {
145
- };
144
+ const deleteAccountById = async (accountId, context) => {};
146
145
  ```
147
146
 
148
147
  ### accountSettings
149
148
 
150
149
  ```node
151
-
152
150
  /**
153
151
  *
154
152
  * @param accountId (string)
155
153
  * @param context (string): Should contain ICS cookie
156
154
  * @return Account Settings (object)
157
155
  */
158
- const getAccountSettings = async (accountId, context) => {
159
- };
156
+ const getAccountSettings = async (accountId, context) => {};
160
157
 
161
158
  /**
162
159
  *
@@ -167,8 +164,12 @@ const getAccountSettings = async (accountId, context) => {
167
164
  * @param context (string): Should contain ICS cookie
168
165
  * @return Http Response
169
166
  */
170
- const updateAccountSettings = async (accountId, isMultiPropertyTenants, isHighPriority, context) => {
171
- };
167
+ const updateAccountSettings = async (
168
+ accountId,
169
+ isMultiPropertyTenants,
170
+ isHighPriority,
171
+ context
172
+ ) => {};
172
173
 
173
174
  /**
174
175
  * Summary: Change account settings to default
@@ -180,15 +181,12 @@ const updateAccountSettings = async (accountId, isMultiPropertyTenants, isHighPr
180
181
  * @param context (string): Should Contain ICS cookie
181
182
  * @return Http Response
182
183
  */
183
- const restoreAccountSettings = async (accountId, context) => {
184
- };
185
-
184
+ const restoreAccountSettings = async (accountId, context) => {};
186
185
  ```
187
186
 
188
187
  ### projects
189
188
 
190
189
  ```node
191
-
192
190
  /**
193
191
  *
194
192
  * @param accountName (string)
@@ -196,8 +194,7 @@ const restoreAccountSettings = async (accountId, context) => {
196
194
  * User's cookie that is related to this account or ICS cookie
197
195
  * @return List of projects ([objects])
198
196
  */
199
- const getProjectsByAccountName = async (accountName, context) => {
200
- };
197
+ const getProjectsByAccountName = async (accountName, context) => {};
201
198
 
202
199
  /**
203
200
  *
@@ -206,8 +203,7 @@ const getProjectsByAccountName = async (accountName, context) => {
206
203
  * User's cookie that is related to this account or ICS cookie
207
204
  * @return List of projects ([objects])
208
205
  */
209
- const getProjectsByAccountId = async (accountId, context) => {
210
- };
206
+ const getProjectsByAccountId = async (accountId, context) => {};
211
207
 
212
208
  /**
213
209
  *
@@ -217,8 +213,7 @@ const getProjectsByAccountId = async (accountId, context) => {
217
213
  * User's cookie that is related to this account or ICS cookie
218
214
  * @return List of projects ([objects])
219
215
  */
220
- const getProjectsByName = async (accountId, projectName, context) => {
221
- };
216
+ const getProjectsByName = async (accountId, projectName, context) => {};
222
217
 
223
218
  /**
224
219
  * Summary: Delete project by given details
@@ -228,8 +223,7 @@ const getProjectsByName = async (accountId, projectName, context) => {
228
223
  * User's cookie that is related to this account or ICS cookie
229
224
  * @return List of projects ([objects])
230
225
  */
231
- const deleteProjectByName = async (accountId, projectName, context) => {
232
- };
226
+ const deleteProjectByName = async (accountId, projectName, context) => {};
233
227
 
234
228
  /**
235
229
  *
@@ -242,40 +236,37 @@ const deleteProjectByName = async (accountId, projectName, context) => {
242
236
 
243
237
  // Example for project input (Not all of them are required):
244
238
  const createProjectInput = {
245
- 'projectName': project.name,
246
- 'userId': '',
247
- 'projectDescription': project.description,
248
- 'address': project.address,
249
- 'projectNumber': project.number,
250
- 'projectStartDate': project.startDate,
251
- 'projectEndDate': project.endDate,
252
- 'city': project.city,
253
- 'state': project.state,
254
- 'zipCode': project.zipCode,
255
- 'companyNameForProject': project.companyNameForProject,
256
- 'certificateHolder': '',
257
- 'additionalInsured': '',
258
- 'tenantSolutionEnabled': '',
259
- 'onboardingEnabled': '',
260
- 'automaticRenewalEnabled': ''
239
+ projectName: project.name,
240
+ userId: "",
241
+ regionOrDivision: project.description,
242
+ address: project.address,
243
+ projectNumber: project.number,
244
+ projectStartDate: project.startDate,
245
+ projectEndDate: project.endDate,
246
+ city: project.city,
247
+ state: project.state,
248
+ zipCode: project.zipCode,
249
+ companyNameForProject: project.companyNameForProject,
250
+ certificateHolder: "",
251
+ additionalInsured: "",
252
+ tenantSolutionEnabled: "",
253
+ onboardingEnabled: "",
254
+ automaticRenewalEnabled: "",
261
255
  };
262
256
 
263
- const createProject = async (project, accountName, context) => {
264
- };
257
+ const createProject = async (project, accountName, context) => {};
265
258
  ```
266
259
 
267
260
  ### projectSettings
268
261
 
269
262
  ```node
270
-
271
263
  /**
272
264
  *
273
265
  * @param accountName (string)
274
266
  * @param context (string): Should contain cookie
275
267
  */
276
-
277
- const getProjectsByAccountName = async (accountName, context) => {
278
- };
268
+
269
+ const getProjectsByAccountName = async (accountName, context) => {};
279
270
 
280
271
  /**
281
272
  *
@@ -283,31 +274,25 @@ const getProjectsByAccountName = async (accountName, context) => {
283
274
  * @param context (string): Should contain cookie
284
275
  */
285
276
 
286
- const updateProjectSettingsByProjectId = async (settings, context) => {
287
- };
277
+ const updateProjectSettingsByProjectId = async (settings, context) => {};
288
278
 
289
279
  // Example for settings input (Not all of them are required):
290
280
  const updateProjectSettingsInput = {
291
281
  autoGaps: {
292
282
  Guests: false,
293
283
  Tenants: false,
294
- Vendors: false
295
- },
296
- autoRenewels: false,
297
- marketplace: {
284
+ Vendors: false,
285
+ },
286
+ autoRenewels: false,
287
+ marketplace: {
298
288
  marketplaceEnabled: false,
299
289
  marketplacePreApproved: false,
300
- marketplacePublicLink: false
301
- },
302
- ocrEnabled: false,
303
- onboardingPhase: false,
304
- projectId: null,
305
- qrEnabled: false,
306
- tenantSolution: false
290
+ marketplacePublicLink: false,
291
+ },
292
+ ocrEnabled: false,
293
+ onboardingPhase: false,
294
+ projectId: null,
295
+ qrEnabled: false,
296
+ tenantSolution: false,
307
297
  };
308
-
309
298
  ```
310
-
311
-
312
-
313
-
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@getjones/test-infra",
3
- "version": "1.1.4",
3
+ "version": "1.1.7",
4
4
  "description": "Providing internal and openapi interface",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
7
- "test": "mocha \"./tests/**/*.test.js\" --slow 3000 --timeout 10000 --exit --inlineDiffs --bail"
7
+ "test": "mocha \"./tests/**/*.test.js\" --slow 3000 --timeout 10000 --exit --inlineDiffs --bail",
8
+ "eslint-fix": "eslint \"./src/**/*.js\" --fix"
8
9
  },
9
10
  "author": "",
10
11
  "license": "ISC",
@@ -0,0 +1,12 @@
1
+ {
2
+ "OK": 200,
3
+ "NO_CONTENT": 204,
4
+ "IM_USED": 226,
5
+ "BAD_REQUEST": 400,
6
+ "UNAUTHORIZED": 401,
7
+ "FORBIDDEN": 403,
8
+ "NOT_FOUND": 404,
9
+ "CONFLICT": 409,
10
+ "TOO_MANY_REQUESTS": 429,
11
+ "CLIENT_CLOSED_REQUEST": 499
12
+ }
@@ -0,0 +1,16 @@
1
+ const responseStatusCodes = require('../httpResponseStatusCodes.json');
2
+
3
+ const validateError = error=> {
4
+ if (!error.response || !isClientErrorCode(error.response.status)) {
5
+ throw error;
6
+ }
7
+ };
8
+
9
+ const isClientErrorCode = httpStatusCode =>{
10
+ const minClientErrorCode = responseStatusCodes.BAD_REQUEST;
11
+ const maxClientErrorCode = responseStatusCodes.CLIENT_CLOSED_REQUEST;
12
+
13
+ return httpStatusCode >= minClientErrorCode && httpStatusCode <= maxClientErrorCode;
14
+ };
15
+
16
+ module.exports = { validateError };
package/src/env.js CHANGED
@@ -23,12 +23,12 @@ const requiredValidation = object => {
23
23
  const invalidKeys = [];
24
24
  Object.keys(object).forEach(key => {
25
25
  if (!object[key]) {
26
- invalidKeys.push(key);
26
+ invalidKeys.push(` '${key}'`);
27
27
  }
28
28
  });
29
29
 
30
30
  if (invalidKeys.length > 0) {
31
- throw `Missing required configuration on your environment variables. The missing env-vars are "${invalidKeys}".`;
31
+ throw Error(`Missing required configuration on your environment variables.\nThe missing env-vars are:${invalidKeys}`);
32
32
  }
33
33
  };
34
34
 
package/src/index.js CHANGED
@@ -42,11 +42,12 @@ const getInternalAPI = () => {
42
42
  };
43
43
 
44
44
  const getOpenAPI = () => {
45
+ const accounts = require('./saas/openapi/accounts/accounts.setup');
45
46
  const tabs = require('./saas/openapi/tabs/tabs.setup');
46
47
  const contractors = require('./saas/openapi/contractors/contractors.setup');
47
48
  const projects = require('./saas/openapi/projects/projects.setup');
48
49
  const requirements = require('./saas/openapi/requirements');
49
- const openAPI = { tabs, contractors, projects, requirements };
50
+ const openAPI = { accounts, tabs, contractors, projects, requirements };
50
51
  return openAPI;
51
52
 
52
53
  };
@@ -4,7 +4,6 @@ const CreateAccountModel = require('../../models/core/create.account.model');
4
4
  const { validateType } = require('../../../../../common/validations/typeValidations');
5
5
 
6
6
  const { accountCreationSecret } = env.getEnv();
7
- const { NotFoundError } = require('../../../../../common/exceptions/notFoundError');
8
7
 
9
8
  const createAccount = async (createAccountModel, context) => {
10
9
  validateType(createAccountModel, CreateAccountModel);
@@ -46,7 +45,8 @@ const getAccountId = async (accountName, context) => {
46
45
  const account = await getAccount(accountName, context);
47
46
 
48
47
  if (!account) {
49
- throw new NotFoundError(`Account ${accountName} does not exist`);
48
+ console.error(`Account ${accountName} does not exist`);
49
+ return null;
50
50
  }
51
51
 
52
52
  return account.userId;
@@ -3,30 +3,46 @@ const { backendUrl } = require('../../../../../env').getEnv();
3
3
 
4
4
  const Endpoints = {
5
5
  createApiKey: `${backendUrl}/saas/api-keys`,
6
- initializeApiKeyOnAws: `${backendUrl}/saas/api-keys/aws`,
7
- getApiKeyByAccountId: accountId => `${backendUrl}/saas/accounts/${accountId}/api-keys`,
8
- getApiKeyDetails: `${backendUrl}/saas/api-keys`,
9
- removeApiKey: `${backendUrl}/saas/api-keys`
6
+ getStaticApiKeyByAccountId: accountId => `${backendUrl}/saas/accounts/${accountId}/static-api-keys`,
7
+ getApiKeyByKeyValue: `${backendUrl}/saas/api-keys`,
8
+ removeStaticApiKey: accountId => `${backendUrl}/saas/accounts/${accountId}/static-api-keys`,
9
+ dynamicApiKey: accountId =>`${backendUrl}/saas/accounts/${accountId}/dynamic-api-key`
10
10
  };
11
11
 
12
- const createApiKey = async (data, context) => {
12
+ const createStaticApiKey = async (data, context) => {
13
13
  return requests.postRequestHandler(Endpoints.createApiKey, data, context).then(res => res.data);
14
14
  };
15
15
 
16
- const initializeApiKeyOnAws = async (data, context) => {
17
- return requests.postRequestHandler(Endpoints.initializeApiKeyOnAws, data, context).then(res => res.data);
16
+ const createGeneratorApiKey = async (data, context) => {
17
+ return requests.postRequestHandler(Endpoints.createApiKey, data, context).then(res => res.data);
18
18
  };
19
19
 
20
- const getApiKeyByAccountId = async (accountId, context) => {
21
- return requests.getRequestHandler(Endpoints.getApiKeyByAccountId(accountId), {}, context).then(res => res.data);
20
+ const getStaticApiKeyByAccountId = async (accountId, context) => {
21
+ return requests.getRequestHandler(Endpoints.getStaticApiKeyByAccountId(accountId), {}, context).then(res => res.data);
22
22
  };
23
23
 
24
24
  const getApiKeyDetails = async (apiKeyValue, context) => {
25
- return requests.getRequestHandler(Endpoints.getApiKeyDetails, { apiKeyValue }, context).then(res => res.data);
25
+ return requests.getRequestHandler(Endpoints.getApiKeyByKeyValue, { apiKeyValue }, context).then(res => res.data);
26
+ };
27
+
28
+ const deleteStaticApiKey = async (accountId, context) => {
29
+ return requests.deleteRequestHandler(Endpoints.removeStaticApiKey(accountId), context).then(res=>res.data);
26
30
  };
27
31
 
28
- const deleteApiKey = async (data, context) => {
29
- return requests.deleteRequestHandler(Endpoints.removeApiKey, context, {}, {}, data);
32
+ const deleteDynamicApiKey = async (accountId, context) => {
33
+ return requests.deleteRequestHandler(Endpoints.dynamicApiKey(accountId), context).then(res => res.data);
30
34
  };
31
35
 
32
- module.exports = { createApiKey, getApiKeyByAccountId, getApiKeyDetails, deleteApiKey, initializeApiKeyOnAws };
36
+ const makeDynamicApiKeyExpired = async (accountId, context) => {
37
+ return requests.patchRequestHandler(Endpoints.dynamicApiKey(accountId), context, {}).then(res => res.data);
38
+ };
39
+
40
+ module.exports = {
41
+ createStaticApiKey,
42
+ createGeneratorApiKey,
43
+ getStaticApiKeyByAccountId,
44
+ getApiKeyDetails,
45
+ makeDynamicApiKeyExpired,
46
+ deleteStaticApiKey,
47
+ deleteDynamicApiKey
48
+ };
@@ -5,45 +5,70 @@ const generateApiKeyValue = accountName => {
5
5
  return crypto.createHash('sha256').update(accountName).digest('base64');
6
6
  };
7
7
 
8
- const createApiKey = async (accountId, apiKeyValue, context) => {
9
- const data = { apiKeyValue, accountId };
10
- return accountsAPI.createApiKey(data, context);
8
+ const createStaticApiKey = async (accountId, apiKeyValue, context, { apiKeyType = 'ACCOUNT_STATIC', apiKeyName = null } = {}) => {
9
+ const data = { accountId, apiKeyValue, apiKeyName, apiKeyType };
10
+ return accountsAPI.createStaticApiKey(data, context);
11
11
  };
12
12
 
13
- const initializeApiKeyOnAws = async (accountId, apiKeyValue, context) => {
14
- const data = { apiKeyValue, accountId };
15
- return accountsAPI.initializeApiKeyOnAws(data, context);
13
+ const createGeneratorApiKey = async (accountId, apiKeyValue, context, { apiKeyType = 'GENERATOR', apiKeyName = null } = {}) => {
14
+ const data = { accountId, apiKeyValue, apiKeyName, apiKeyType };
15
+ return accountsAPI.createGeneratorApiKey(data, context);
16
16
  };
17
17
 
18
- const getApiKeyByAccountId = async (accountId, context) => {
19
- return accountsAPI.getApiKeyByAccountId(accountId, context);
18
+ const getStaticApiKeyByAccountId = async (accountId, context) => {
19
+ return accountsAPI.getStaticApiKeyByAccountId(accountId, context);
20
20
  };
21
21
 
22
22
  const getApiKeyDetails = async (apiKeyValue, context) => {
23
23
  return accountsAPI.getApiKeyDetails(apiKeyValue, context);
24
24
  };
25
25
 
26
- const deleteApiKey = async (apiKeyValue, context) => {
27
- const data = { apiKeyValue };
28
- return accountsAPI.deleteApiKey(data, context);
26
+ const deleteStaticApiKey = async (accountId, context) => {
27
+ return accountsAPI.deleteStaticApiKey(accountId, context);
29
28
  };
30
29
 
31
- const getOrCreateApiKey = async (accountId, apiKey, context) => {
32
- const existingApiKey = await getApiKeyByAccountId(accountId, context);
30
+ const getOrCreateStaticApiKey = async (accountId, apiKeyValue, context, { apiKeyType = 'ACCOUNT_STATIC', apiKeyName = null } = {}) => {
31
+ let existingApiKey = await getStaticApiKeyByAccountId(accountId, context);
32
+
33
+ if (existingApiKey.apiKeyValue) {
34
+ return existingApiKey;
35
+ }
36
+
37
+ existingApiKey = await getApiKeyDetails(apiKeyValue, context);
33
38
 
34
39
  if (!existingApiKey.apiKeyValue) {
35
- return createApiKey(accountId, apiKey, context);
40
+ return createStaticApiKey(accountId, apiKeyValue, context, { apiKeyType, apiKeyName });
36
41
  }
37
42
 
38
43
  return existingApiKey;
39
44
  };
40
45
 
46
+ const getOrCreateGeneratorApiKey = async (accountId, apiKeyValue, context, { apiKeyType = 'GENERATOR', apiKeyName = null } = {}) => {
47
+ const existingApiKey = await getApiKeyDetails(apiKeyValue, context);
48
+
49
+ if (!existingApiKey.apiKeyValue) {
50
+ return createGeneratorApiKey(accountId, apiKeyValue, context, { apiKeyType, apiKeyName });
51
+ }
52
+
53
+ return existingApiKey;
54
+ };
55
+
56
+ const deleteDynamicApiKey= async (accountId, context) => {
57
+ return accountsAPI.deleteDynamicApiKey(accountId, context);
58
+ };
59
+
60
+ const makeDynamicApiKeyExpired= async (accountId, context) => {
61
+ return accountsAPI.makeDynamicApiKeyExpired(accountId, context);
62
+ };
63
+
41
64
  module.exports = {
42
- createApiKey,
43
- getApiKeyByAccountId,
65
+ createStaticApiKey,
66
+ generateApiKeyValue,
67
+ getOrCreateStaticApiKey,
68
+ getOrCreateGeneratorApiKey,
69
+ getStaticApiKeyByAccountId,
44
70
  getApiKeyDetails,
45
- deleteApiKey,
46
- getOrCreateApiKey,
47
- initializeApiKeyOnAws,
48
- generateApiKeyValue
49
- };
71
+ makeDynamicApiKeyExpired,
72
+ deleteStaticApiKey,
73
+ deleteDynamicApiKey
74
+ };
@@ -1,4 +1,5 @@
1
1
  const axios = require('axios');
2
+ const errorValidation = require('../../../common/validations/errorValidation');
2
3
 
3
4
  const getRequestHandler = async (url, params = {}, context = null, headers = {}) => {
4
5
  enrichCookie(headers, context);
@@ -6,8 +7,8 @@ const getRequestHandler = async (url, params = {}, context = null, headers = {})
6
7
  const response = await axios.get(url, { params, headers });
7
8
  return response;
8
9
  } catch (error) {
9
- const message = error.response.data && JSON.stringify(error.response.data) || error.message;
10
- throw Error(message);
10
+ errorValidation.validateError(error);
11
+ return error.response;
11
12
  }
12
13
 
13
14
  };
@@ -18,8 +19,8 @@ const postRequestHandler = async (url, body, context = null, headers = {}, param
18
19
  const response = await axios.post(url, body, { headers, params });
19
20
  return response;
20
21
  } catch (error) {
21
- const message = error.response.data && JSON.stringify(error.response.data) || error.message;
22
- throw Error(message);
22
+ errorValidation.validateError(error);
23
+ return error.response;
23
24
  }
24
25
 
25
26
  };
@@ -30,8 +31,20 @@ const putRequestHandler = async (url, body, context = null, headers = {}) => {
30
31
  const response = await axios.put(url, body, { headers });
31
32
  return response;
32
33
  } catch (error) {
33
- const message = error.response.data && JSON.stringify(error.response.data) || error.message;
34
- throw Error(message);
34
+ errorValidation.validateError(error);
35
+ return error.response;
36
+ }
37
+
38
+ };
39
+
40
+ const patchRequestHandler = async (url, context, body, headers = {}) => {
41
+ enrichCookie(headers, context);
42
+ try {
43
+ const response = await axios.patch(url, body, { headers });
44
+ return response;
45
+ } catch (error) {
46
+ errorValidation.validateError(error);
47
+ return error.response;
35
48
  }
36
49
 
37
50
  };
@@ -42,8 +55,8 @@ const deleteRequestHandler = async (url, context = null, headers = {}, params =
42
55
  const response = await axios.delete(url, { params, headers, data });
43
56
  return response;
44
57
  } catch (error) {
45
- const message = error.response.data && JSON.stringify(error.response.data) || error.message;
46
- throw Error(message);
58
+ errorValidation.validateError(error);
59
+ return error.response;
47
60
  }
48
61
 
49
62
  };
@@ -54,4 +67,10 @@ const enrichCookie = (headers, context) => {
54
67
  }
55
68
  };
56
69
 
57
- module.exports = { getRequestHandler, postRequestHandler, putRequestHandler, deleteRequestHandler };
70
+ module.exports = {
71
+ getRequestHandler,
72
+ postRequestHandler,
73
+ putRequestHandler,
74
+ patchRequestHandler,
75
+ deleteRequestHandler
76
+ };
@@ -1,4 +1,4 @@
1
- const requests = require('../../../common/requests');
1
+ const requests = require('../../../../openapi/common/requests');
2
2
  const { nodeBackendUrl } = require('../../../../../env').getEnv();
3
3
 
4
4
  const Endpoints = {
@@ -6,12 +6,12 @@ const Endpoints = {
6
6
  getCoverageByCoiId: coiId => `${nodeBackendUrl}/coverage/${coiId}`
7
7
  };
8
8
 
9
- const saveCoverage = async (coverage, context) => {
10
- return requests.postRequestHandler(Endpoints.saveCoverage, coverage, context);
9
+ const saveCoverage = async (coverage, nodeBackendSecret) => {
10
+ return requests.postRequestHandler(Endpoints.saveCoverage, nodeBackendSecret, coverage);
11
11
  };
12
12
 
13
- const getCoverageByCoiId = async (coiId, context) => {
14
- return requests.getRequestHandler(Endpoints.getCoverageByCoiId(coiId), {}, context);
13
+ const getCoverageByCoiId = async (coiId, nodeBackendSecret) => {
14
+ return requests.getRequestHandler(Endpoints.getCoverageByCoiId(coiId), nodeBackendSecret);
15
15
  };
16
16
 
17
17
  module.exports = { saveCoverage, getCoverageByCoiId };
@@ -1,11 +1,11 @@
1
1
  const coverageApi = require('./coverage.api');
2
2
 
3
- const saveCoverage = async (coverage, context) => {
4
- return coverageApi.saveCoverage(coverage, context);
3
+ const saveCoverage = async (coverage, nodeBackendSecret) => {
4
+ return coverageApi.saveCoverage(coverage, nodeBackendSecret);
5
5
  };
6
6
 
7
- const getCoverageByCoiId = async (coiId, context) => {
8
- return coverageApi.getCoverageByCoiId(coiId, context).then(res => res && res.data);
7
+ const getCoverageByCoiId = async (coiId, nodeBackendSecret) => {
8
+ return coverageApi.getCoverageByCoiId(coiId, nodeBackendSecret).then(res => res && res.data);
9
9
  };
10
10
 
11
11
  module.exports = { saveCoverage, getCoverageByCoiId };
@@ -9,11 +9,12 @@ const Endpoints = {
9
9
  archive: contractorId => `${backendUrl}/saas/contractor/${contractorId}/archive`,
10
10
  restore: contractorId => `${backendUrl}/saas/contractor/${contractorId}/restore`,
11
11
  edit: contractorId => `${backendUrl}/saas/contractors/${contractorId}/update`,
12
- updateVendorExpiryDate: contractorId => `${backendUrl}/_saas/automation/contractor/${contractorId}/expiry-date`
12
+ updateVendorExpiryDate: contractorId => `${backendUrl}/_saas/automation/contractor/${contractorId}/expiry-date`,
13
+ assignMptToProperties: (accountId, tenantId) => `${backendUrl}/saas/account/${accountId}/multi-properties/${tenantId}`
13
14
  };
14
15
 
15
16
  const createContractors = async (createContractorModel, context) => {
16
- return requests.postRequestHandler(Endpoints.create, createContractorModel, context).then(res => res.data);
17
+ return requests.postRequestHandler(Endpoints.create, createContractorModel, context).then(res => res.data || res);
17
18
  };
18
19
 
19
20
  const getContractorsByAccountId = async (params, context) => {
@@ -46,6 +47,24 @@ const updateExpiryDate = async (contractorId, expiryDate, policyName) => {
46
47
  return requests.postRequestHandler(Endpoints.updateVendorExpiryDate(contractorId), data);
47
48
  };
48
49
 
50
+ const assignMptToProperties = async (assignToMptModel, context) => {
51
+ const params = { updateInfoUser: 'EditVendor' };
52
+ const response = await requests.postRequestHandler(
53
+ Endpoints.assignMptToProperties(assignToMptModel.accountId, assignToMptModel.tenantId),
54
+ assignToMptModel.properties,
55
+ context,
56
+ {},
57
+ params
58
+ );
59
+ return response;
60
+ };
61
+
62
+ const getContractorsByTabId = async (tabId, activityStatus, context) => {
63
+ const body = { tabId, activityStatus };
64
+ const response = await requests.postRequestHandler(Endpoints.get, body, context);
65
+ return response.data;
66
+ };
67
+
49
68
  module.exports = {
50
69
  createContractors,
51
70
  getContractorsByAccountId,
@@ -54,5 +73,7 @@ module.exports = {
54
73
  archiveByContractorId,
55
74
  restoreByContractorId,
56
75
  editContractor,
57
- updateExpiryDate
76
+ updateExpiryDate,
77
+ assignMptToProperties,
78
+ getContractorsByTabId
58
79
  };
@@ -1,8 +1,7 @@
1
1
  const contractorsAPI = require('./contractors.api');
2
2
  const { CreateContractorModel } = require('../models/create.contractor.model');
3
- const { ContractorModel } = require('../models/edit.contractor.model');
3
+ const { ContractorModel, MptModel } = require('../models/edit.contractor.model');
4
4
  const { validateType } = require('../../../../common/validations/typeValidations');
5
- const requests = require('../../common/requests');
6
5
 
7
6
  const createContractors = async (createContractorsModel, context) => {
8
7
  validateType(createContractorsModel, CreateContractorModel);
@@ -33,15 +32,24 @@ const restoreByContractorId = (contractorId, context) => {
33
32
  return contractorsAPI.restoreByContractorId(contractorId, context);
34
33
  };
35
34
 
36
- const editContractor = async (editContractorModel, context) => {
35
+ const editContractor = (editContractorModel, context) => {
37
36
  validateType(editContractorModel, ContractorModel);
38
37
  return contractorsAPI.editContractor(editContractorModel, context);
39
38
  };
40
39
 
41
- const updateExpiryDate = async (contractorId, expiryDate, policyName) => {
40
+ const updateExpiryDate = (contractorId, expiryDate, policyName) => {
42
41
  return contractorsAPI.updateExpiryDate(contractorId, expiryDate, policyName);
43
42
  };
44
43
 
44
+ const getContractorsByTabId = (tabId, context, activityStatus = 'ACTIVE') => {
45
+ return contractorsAPI.getContractorsByTabId(tabId, activityStatus, context);
46
+ };
47
+
48
+ const assignMptToProperties = (assignToMptModel, context) => {
49
+ validateType(assignToMptModel, MptModel);
50
+ return contractorsAPI.assignMptToProperties(assignToMptModel, context);
51
+ };
52
+
45
53
  module.exports = {
46
54
  createContractors,
47
55
  getContractorsByAccountId,
@@ -50,5 +58,7 @@ module.exports = {
50
58
  archiveByContractorId,
51
59
  restoreByContractorId,
52
60
  editContractor,
53
- updateExpiryDate
61
+ updateExpiryDate,
62
+ getContractorsByTabId,
63
+ assignMptToProperties
54
64
  };
@@ -1,11 +1,12 @@
1
1
  const { validateType } = require('../../../../common/validations/typeValidations');
2
2
 
3
- function CreateContractorModel(requirementId, inviterEmail, vendorsInfo) {
3
+ function CreateContractorModel(requirementId, inviterEmail, vendorsInfo, { tabId = null } = {}) {
4
4
  this.reqId = requirementId;
5
5
  this.inviterEmail = inviterEmail;
6
6
  this.vendorInfo = vendorsInfo;
7
7
  this.disableMail = true;
8
8
  this.sendCovid19Form = false;
9
+ this.tabId = tabId;
9
10
 
10
11
  validateType(vendorsInfo, Array);
11
12
  vendorsInfo && validateType(vendorsInfo[0], ContractorInfo);
@@ -1,15 +1,56 @@
1
1
  const { validateType } = require('../../../../common/validations/typeValidations');
2
2
 
3
- function ContractorModel(contractorId, company, emailAddress, tab, tenantRecord, additionalEmails) {
3
+ function ContractorModel(contractorId, company, emailAddress, tab, additionalDetails ) {
4
+ validateType(tab, VendorTabModel);
5
+ validateType(additionalDetails, ContractorDetailsModel);
6
+
4
7
  this.contractorId = contractorId;
5
8
  this.company = company;
6
9
  this.emailAddress = emailAddress;
7
10
  this.tab = tab;
8
- this.tenantRecord = tenantRecord;
11
+
12
+ for (const detail in additionalDetails) {
13
+ if (additionalDetails[detail]){
14
+ this[detail] = additionalDetails[detail];
15
+ }
16
+ }
17
+
18
+ }
19
+
20
+ function ContractorDetailsModel({
21
+ additionalEmails = [],
22
+ dba = null,
23
+ firstName = null,
24
+ lastName = null,
25
+ address = null,
26
+ city = null,
27
+ state = null,
28
+ zipCode = null,
29
+ phoneNumber = null,
30
+ agreementNumber = null,
31
+ projectDescription = null,
32
+ startDate = null,
33
+ endDate = null,
34
+ tenantRecord = {}
35
+ } = {}){
9
36
  this.additionalEmails = additionalEmails;
37
+ this.dba = dba;
38
+ this.fName = firstName;
39
+ this.lName = lastName;
40
+ this.location = address;
41
+ this.city = city;
42
+ this.state = state;
43
+ this.zipCode = zipCode;
44
+ this.phoneNumber = phoneNumber;
45
+ this.recordId = agreementNumber;
46
+ this.descriptionOfOperations = projectDescription;
47
+ this.startDate = startDate;
48
+ this.endDate = endDate;
10
49
 
11
- validateType(tenantRecord, TenantRecordModel);
12
- validateType(tab, VendorTabModel);
50
+ if (tenantRecord && Object.keys(tenantRecord).length > 0){
51
+ validateType(tenantRecord, TenantRecordModel);
52
+ this.tenantRecord = tenantRecord;
53
+ }
13
54
  }
14
55
 
15
56
  function TenantRecordModel(id, companyName, emailAddress) {
@@ -22,4 +63,18 @@ function VendorTabModel(type){
22
63
  this.type = type;
23
64
  }
24
65
 
25
- module.exports = { ContractorModel, TenantRecordModel, VendorTabModel };
66
+ class MptModel {
67
+ constructor(accountId, tenantId, properties) {
68
+ this.accountId = accountId;
69
+ this.tenantId = tenantId;
70
+ this.properties = properties;
71
+ }
72
+ }
73
+
74
+ module.exports = {
75
+ ContractorModel,
76
+ TenantRecordModel,
77
+ VendorTabModel,
78
+ ContractorDetailsModel,
79
+ MptModel
80
+ };
@@ -4,7 +4,9 @@ const { backendUrl } = require('../../../../../env').getEnv();
4
4
  const Endpoints = {
5
5
  create: `${backendUrl}/saas/project`,
6
6
  delete: projectId => `${backendUrl}/saas/project/${projectId}`,
7
- getByAccountId: `${backendUrl}/saas/project/list`
7
+ getByAccountId: `${backendUrl}/saas/project/list`,
8
+ update: `${backendUrl}/saas/project`,
9
+ getProjectByProjectId: projectId => `${backendUrl}/saas/project/${projectId}`
8
10
  };
9
11
 
10
12
  const create = async (project, context) => {
@@ -16,8 +18,17 @@ const getProjectsByAccountId = async (accountId, context) => {
16
18
  return requests.getRequestHandler(Endpoints.getByAccountId, params, context).then(res => res.data);
17
19
  };
18
20
 
21
+ const getProjectByProjectId = async (projectId, context) => {
22
+ const params = { };
23
+ return requests.getRequestHandler(Endpoints.getProjectByProjectId(projectId), params, context).then(res => res.data);
24
+ };
25
+
19
26
  const deleteProjectById = async (projectId, context) => {
20
27
  return requests.deleteRequestHandler(Endpoints.delete(projectId), context);
21
28
  };
22
29
 
23
- module.exports = { create, getProjectsByAccountId, deleteProjectById };
30
+ const update = async (project, context) => {
31
+ return requests.postRequestHandler(Endpoints.update, project, context);
32
+ };
33
+
34
+ module.exports = { create, getProjectsByAccountId, deleteProjectById, update, getProjectByProjectId };
@@ -2,6 +2,7 @@ const projectsApi = require('./projects.api');
2
2
  const accounts = require('../../../accounts/api/core/accounts.core.setup');
3
3
  const { validateType } = require('../../../../../common/validations/typeValidations');
4
4
  const CreateProjectModel = require('../../models/core/create.project.model');
5
+ const UpdateProjectModel = require('../../models/core/update.project.model');
5
6
 
6
7
  const getProjectsByAccountName = async (accountName, context) => {
7
8
  const accountId = accounts.getAccountId(accountName, context);
@@ -12,6 +13,10 @@ const getProjectsByAccountId = async (accountId, context) => {
12
13
  return projectsApi.getProjectsByAccountId(accountId, context);
13
14
  };
14
15
 
16
+ const getProjectByProjectId = async (projectId, context) => {
17
+ return projectsApi.getProjectByProjectId(projectId, context);
18
+ };
19
+
15
20
  const getProjectsByName = async (accountId, projectName, context) => {
16
21
  const projects = await getProjectsByAccountId(accountId, context);
17
22
  const filteredProjects = projects.filter(project => project.projectName === projectName);
@@ -38,10 +43,18 @@ const getOrCreateProject = async (createProjectModel, context) => {
38
43
  return createProject(createProjectModel, context);
39
44
  };
40
45
 
46
+ const updateProject = async (updateProjectModel, context) => {
47
+ validateType(updateProjectModel, UpdateProjectModel);
48
+ return projectsApi.update(updateProjectModel, context);
49
+ };
50
+
41
51
  module.exports = {
42
52
  getProjectsByAccountName,
43
53
  getProjectsByAccountId,
44
54
  createProject,
45
55
  deleteProjectByName,
46
- getOrCreateProject
56
+ getOrCreateProject,
57
+ updateProject,
58
+ getProjectsByName,
59
+ getProjectByProjectId
47
60
  };
@@ -1,9 +1,10 @@
1
1
  const projectService = require('./api/core/projects.setup');
2
2
  const projectSettingsService = require('./api/settings/project.settings.setup');
3
3
  const CreateProjectModel = require('./models/core/create.project.model');
4
+ const UpdateProjectModel = require('./models/core/update.project.model');
4
5
  const UpdateProjectSettingsModel = require('./models/settings/update.project.settings.model');
5
6
 
6
- const coreModels = { CreateProjectModel };
7
+ const coreModels = { CreateProjectModel, UpdateProjectModel };
7
8
  const settingsModels = { UpdateProjectSettingsModel };
8
9
 
9
10
  const services = {
@@ -3,7 +3,7 @@ function CreateProjectModel(accountId, name, description, address, number, start
3
3
  tenantSolutionEnabled = 0, onboardingEnabled = 0, automaticRenewalEnabled = 0) {
4
4
  this.projectName = name;
5
5
  this.userId = accountId;
6
- this.projectDescription = description;
6
+ this.regionOrDivision = description;
7
7
 
8
8
  this.address = address;
9
9
  this.projectNumber = number;
@@ -0,0 +1,27 @@
1
+ function UpdateProjectModel(accountId, projectId, name, description, address, number, startDate, endDate,
2
+ city, state, zipCode, companyNameForProject, certificateHolder = '', additionalInsured = '',
3
+ tenantSolutionEnabled = 0, onboardingEnabled = 0, automaticRenewalEnabled = 0) {
4
+ this.projectId = projectId;
5
+ this.projectName = name;
6
+ this.userId = accountId;
7
+ this.regionOrDivision = description;
8
+
9
+ this.address = address;
10
+ this.projectNumber = number;
11
+ this.projectStartDate = startDate;
12
+ this.projectEndDate = endDate;
13
+
14
+ this.city = city;
15
+ this.state = state;
16
+ this.zipCode = zipCode;
17
+ this.companyNameForProject = companyNameForProject;
18
+
19
+ this.certificateHolder = certificateHolder;
20
+ this.additionalInsured = additionalInsured;
21
+
22
+ this.tenantSolutionEnabled = tenantSolutionEnabled;
23
+ this.onboardingEnabled = onboardingEnabled;
24
+ this.automaticRenewalEnabled = automaticRenewalEnabled;
25
+ }
26
+
27
+ module.exports = UpdateProjectModel;
@@ -14,7 +14,7 @@ const getTabsByProjectId = async (projectId, context) => {
14
14
  return tabsAPI.getTabsByProjectId(projectId, context);
15
15
  };
16
16
 
17
- const getTabsByName = async (projectId, tabName, context,{ tabType }={}) => {
17
+ const getTabsByName = async (projectId, tabName, context, { tabType } = {}) => {
18
18
  const tabs = await tabsAPI.getTabsByProjectId(projectId, context);
19
19
  const requestedTab = tabType?
20
20
  tabs.find(tab => tab.tabName === tabName && tab.type === tabType):
@@ -0,0 +1,17 @@
1
+ const requests = require('../common/requests');
2
+ const { openapiUrl } = require('../../../env').getEnv();
3
+
4
+ const Endpoints = {
5
+ getAccountList: `${openapiUrl}/accounts`,
6
+ dynamicApiKey: accountId =>`${openapiUrl}/accounts/${accountId}/dynamic-api-key`
7
+ };
8
+
9
+ const getAccountList = async apiKey => {
10
+ return requests.getRequestHandler(Endpoints.getAccountList, apiKey).then(res => res.data);
11
+ };
12
+
13
+ const generateDynamicApiKey = async (accountId, masterApiKey) => {
14
+ return requests.getRequestHandler(Endpoints.dynamicApiKey(accountId), masterApiKey).then(res => res.data);
15
+ };
16
+
17
+ module.exports = { getAccountList, generateDynamicApiKey };
@@ -0,0 +1,11 @@
1
+ const accountsApi = require('./accounts.api');
2
+
3
+ const getAccountList = async apiKey => {
4
+ return accountsApi.getAccountList(apiKey);
5
+ };
6
+
7
+ const generateDynamicApiKey= async (accountId, masterApiKey) => {
8
+ return accountsApi.generateDynamicApiKey(accountId, masterApiKey);
9
+ };
10
+
11
+ module.exports = { getAccountList,generateDynamicApiKey };
@@ -1,4 +1,5 @@
1
1
  const axios = require('axios');
2
+ const errorValidation = require('../../../common/validations/errorValidation');
2
3
 
3
4
  const getRequestHandler = async (url, apiKey, params = {}, headers = {}) => {
4
5
  enrichApiKey(headers, apiKey);
@@ -6,8 +7,8 @@ const getRequestHandler = async (url, apiKey, params = {}, headers = {}) => {
6
7
  const response = await axios.get(url, { params, headers });
7
8
  return response;
8
9
  } catch (error) {
9
- const message = error.response.data && JSON.stringify(error.response.data) || error.message;
10
- throw Error(message);
10
+ errorValidation.validateError(error);
11
+ return error.response;
11
12
  }
12
13
 
13
14
  };
@@ -18,8 +19,8 @@ const postRequestHandler = async (url, apiKey, body, headers = {}) => {
18
19
  const response = await axios.post(url, body, { headers });
19
20
  return response;
20
21
  } catch (error) {
21
- const message = error.response.data && JSON.stringify(error.response.data) || error.message;
22
- throw Error(message);
22
+ errorValidation.validateError(error);
23
+ return error.response;
23
24
  }
24
25
 
25
26
  };
@@ -30,8 +31,8 @@ const putRequestHandler = async (url, apiKey, body, headers = {}) => {
30
31
  const response = await axios.put(url, body, { headers });
31
32
  return response;
32
33
  } catch (error) {
33
- const message = error.response.data && JSON.stringify(error.response.data) || error.message;
34
- throw Error(message);
34
+ errorValidation.validateError(error);
35
+ return error.response;
35
36
  }
36
37
 
37
38
  };
@@ -42,8 +43,8 @@ const patchRequestHandler = async (url, apiKey, body, headers = {}) => {
42
43
  const response = await axios.patch(url, body, { headers });
43
44
  return response;
44
45
  } catch (error) {
45
- const message = error.response.data && JSON.stringify(error.response.data) || error.message;
46
- throw Error(message);
46
+ errorValidation.validateError(error);
47
+ return error.response;
47
48
  }
48
49
 
49
50
  };
@@ -54,8 +55,8 @@ const deleteRequestHandler = async (url, apiKey, headers = {}, params = {}, data
54
55
  const response = await axios.delete(url, { params, headers, data });
55
56
  return response;
56
57
  } catch (error) {
57
- const message = error.response.data && JSON.stringify(error.response.data) || error.message;
58
- throw Error(message);
58
+ errorValidation.validateError(error);
59
+ return error.response;
59
60
  }
60
61
 
61
62
  };
@@ -6,7 +6,9 @@ const Endpoints = {
6
6
  getAllProjects: `${openapiUrl}/properties/all`,
7
7
  getModifiedProjects: `${openapiUrl}/properties/modified`,
8
8
  createProject: `${openapiUrl}/properties`,
9
- updateProject: projectId => `${openapiUrl}/properties/${projectId}`
9
+ updateProject: projectId => `${openapiUrl}/properties/${projectId}`,
10
+ getProjectSettings: projectId => `${openapiUrl}/properties/${projectId}/settings`,
11
+ updateProjectSettings: projectId => `${openapiUrl}/properties/${projectId}/settings`
10
12
  };
11
13
 
12
14
  const getProjectsByName = async (apiKey, params) => {
@@ -29,10 +31,22 @@ const updateProject = async (apiKey, projectId, projectData) => {
29
31
  return requests.patchRequestHandler(Endpoints.updateProject(projectId), apiKey, projectData).then(res => res.data);
30
32
  };
31
33
 
34
+ const updateProjectSettings = async (apiKey, projectId, projectSettings) => {
35
+ return requests.patchRequestHandler(Endpoints.updateProjectSettings(projectId),
36
+ apiKey, projectSettings).then(res => res.data);
37
+ };
38
+
39
+ const getProjectSettings = async (apiKey, projectId) => {
40
+ return requests.getRequestHandler(Endpoints.getProjectSettings(projectId),
41
+ apiKey).then(res => res.data);
42
+ };
43
+
32
44
  module.exports = {
33
45
  getProjectsByName,
34
46
  getAllProjects,
35
47
  getModifiedProjects,
36
48
  createProject,
37
- updateProject
49
+ updateProject,
50
+ updateProjectSettings,
51
+ getProjectSettings
38
52
  };
@@ -20,10 +20,20 @@ const getModifiedProjects = async (apiKey, timestamp) => {
20
20
  return projectsApi.getModifiedProjects(apiKey, { timestamp });
21
21
  };
22
22
 
23
+ const updateProjectSettings = async (apiKey, projectId, projectSettings) => {
24
+ return projectsApi.updateProjectSettings(apiKey, projectId, projectSettings);
25
+ };
26
+
27
+ const getProjectSettings = async (apiKey, projectId) => {
28
+ return projectsApi.getProjectSettings(apiKey, projectId);
29
+ };
30
+
23
31
  module.exports = {
24
32
  getProjectsByName,
25
33
  createProject,
26
34
  updateProject,
27
35
  getAllProjects,
28
- getModifiedProjects
36
+ getModifiedProjects,
37
+ updateProjectSettings,
38
+ getProjectSettings
29
39
  };
@@ -1,10 +0,0 @@
1
- const { StatusCodes } = require('http-status-code');
2
-
3
- class NotFoundError extends Error {
4
- constructor(message) {
5
- const { NOT_FOUND } = StatusCodes;
6
- super(message, NOT_FOUND);
7
- }
8
- }
9
-
10
- module.exports = { NotFoundError };