generated from compucorp/template-repo
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
195 additions
and
171 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import cvApiBatch from '../utils/cv-api.service'; | ||
|
||
/** | ||
* Base Entity Service | ||
*/ | ||
export default class BaseEntityService { | ||
entityName: string; | ||
entityIds: string[]; | ||
|
||
/** | ||
* @param {string} entityName name of the entity | ||
*/ | ||
constructor (entityName: string) { | ||
this.entityName = entityName; | ||
} | ||
|
||
/** | ||
* Create Entity. | ||
* | ||
* @param {any} params parameters | ||
* @returns {object[]} created entities | ||
*/ | ||
create (params: any[]): object[] { | ||
this.entityIds = []; | ||
|
||
const apiCalls = params.map((param): [string, string, object] => { | ||
return [this.entityName, 'create', param]; | ||
}); | ||
|
||
const apiReturnValue = cvApiBatch(apiCalls).map((caseType) => { | ||
return caseType.values[0]; | ||
}); | ||
|
||
this.entityIds = apiReturnValue.map((caseType) => { | ||
return caseType.id; | ||
}); | ||
|
||
return apiReturnValue; | ||
} | ||
|
||
/** | ||
* Cleanup Entities created by this instance of the class. | ||
*/ | ||
cleanUp (): void { | ||
const apiCalls = this.entityIds.map((entityId): [string, string, object] => { | ||
return [this.entityName, 'delete', { id: entityId }]; | ||
}); | ||
|
||
cvApiBatch(apiCalls); | ||
|
||
this.entityIds = []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import BaseEntityService from './base-entity.service'; | ||
|
||
/** | ||
* Case Entity Service | ||
*/ | ||
export default class CaseTypeService extends BaseEntityService { | ||
/** | ||
* Constructor. | ||
*/ | ||
constructor () { | ||
super('CaseType'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import BaseEntityService from './base-entity.service'; | ||
|
||
/** | ||
* Case Entity Service | ||
*/ | ||
export default class CaseService extends BaseEntityService { | ||
/** | ||
* Constructor. | ||
*/ | ||
constructor () { | ||
super('Case'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.