import ProjectContentService from 'clinical6/src/services/ProjectContentService.js'
ProjectContentService
Service that includes generic functions to pull, update, and create data.
This will only work with v2 content such as: Api | V2 | Agreements Api | V2 | Reminder | Rules Api | V2 | SiteStart | Addresses Api | V2 | SiteStart | LabAccreditations Api | V2 | SiteStart | LabDirectors Api | V2 | SiteStart | Labs Api | V2 | SiteStart | PrimaryLicenses Api | V2 | SiteStart | PrimaryMedicalBoards Api | V2 | SiteStart | SiteLabs Api | V2 | SiteStart | Sites Api | V2 | SiteStart | Studies Api | V2 | SiteStart | StudyAddress Api | V2 | SiteStart | StudyIrb Api | V2 | SiteStart | StudyLab
Method Summary
Public Methods | ||
public |
Generic function that deletes data on the server. |
|
public |
deleteProject(project: Object, type: String, id: Number): Promise Delete a sibling or child based on the ProjectContent type and/or child type |
|
public |
get(version: String, ownerType: String, owner: Number, contentType: String, contentId: Number): Promise Generic function that retrieves data. |
|
public |
getProject(project: Object, contentType: String, contentId: Number): Promise Get Data via ProjectContent helper class |
|
public |
insert(version: String, ownerType: String, owner: Number, contentType: String, data: Object): Promise Generic function that updates data on the server. |
|
public |
insertProject(project: Object, type: String, data: Object): Promise Insert a new sibling or child based on the ProjectContent type and/or child type |
|
public |
update(version: String, ownerType: String, owner: Number, contentType: String, contentId: Number, data: Object): Promise Generic function that updates data on the server. |
|
public |
Update ProjectContent information based on the ProjectContent Helper class. |
Public Methods
public delete(version: String, ownerType: String, owner: Number, type: String, id: Number): Promise source
Generic function that deletes data on the server.
This should not be called directly but rather be called using the ProjectContentService#deleteProject method. For this reason, no example is provided.
Throw:
If missing token or missing required parameters |
public deleteProject(project: Object, type: String, id: Number): Promise source
Delete a sibling or child based on the ProjectContent type and/or child type
Params:
Name | Type | Attribute | Description |
project | Object | ProjectContent options |
|
project.version | Object |
|
ProjectContent version |
project.ownerType | Object |
|
ProjectContent owner type |
project.owner | Object | ProjectContent owner |
|
type | String |
|
Child type |
id | Number | id to delete |
public get(version: String, ownerType: String, owner: Number, contentType: String, contentId: Number): Promise source
Generic function that retrieves data.
Handles the following URL patterns:
List: -api/version/ownerType -api/version/ownerType/owner/contentType
Show: -api/version/ownerType/owner -api/version/ownerType/owner/contentType/objectId
This should not be called directly but rather be called using the ProjectContentService#getProject method. For this reason, no example is provided.
Params:
Name | Type | Attribute | Description |
version | String | Version of the API of the API call to make |
|
ownerType | String | The owner type |
|
owner | Number |
|
The owner |
contentType | String |
|
The content type |
contentId | Number |
|
The ID value of object to show |
Throw:
If missing token or missing required parameters |
Test:
- [unit] ProjectContentService.get should exist
- [unit] ProjectContentService.get should throw an error when version is not defined
- [unit] ProjectContentService.get should throw an error when ownerType is not defined
- [unit] ProjectContentService.get should return a promise
- [unit] ProjectContentService.get should receive a valid response for a get request without contentType or an id param
- [unit] ProjectContentService.get should receive a valid response for a get request with an id param
- [unit] ProjectContentService.get should receive a valid response for a get request with version, ownerType, owner, and objectId
- [unit] ProjectContentService.get should receive a valid response for a get request with all params
public getProject(project: Object, contentType: String, contentId: Number): Promise source
Get Data via ProjectContent helper class
This should not be called directly but rather be called using the ProjectContent#getAll, ProjectContent#getChild, ProjectContent#getChildren, ProjectContent#get, and ProjectContent#getSibling method. For this reason, no examples are provided.
Params:
Name | Type | Attribute | Description |
project | Object | ProjectContent options |
|
project.version | Object |
|
ProjectContent version |
project.ownerType | Object |
|
ProjectContent owner type |
project.owner | Object | ProjectContent owner |
|
contentType | String |
|
Content type |
contentId | Number |
|
Content id |
public insert(version: String, ownerType: String, owner: Number, contentType: String, data: Object): Promise source
Generic function that updates data on the server.
This should not be called directly but rather be called using the ProjectContentService#insertProject method. For this reason, no example is provided.
Throw:
If missing token or missing required parameters |
Test:
- [unit] ProjectContentService.insert should exist method
- [unit] ProjectContentService.insert should throw an error when version is not defined
- [unit] ProjectContentService.insert should throw an error when ownerType is not defined
- [unit] ProjectContentService.insert should throw an error when owner is not defined
- [unit] ProjectContentService.insert should return a promise
- [unit] ProjectContentService.insert should receive a valid response for a POST request with the id param and no action param
- [unit] ProjectContentService.insert should receive a valid response for a POST request without contentType, id, and action params
public insertProject(project: Object, type: String, data: Object): Promise source
Insert a new sibling or child based on the ProjectContent type and/or child type
This should not be called directly but rather be called using the ProjectContent#save method and ProjectContent#addChild. For this reason, no examples are provided.
Params:
Name | Type | Attribute | Description |
project | Object | ProjectContent options |
|
project.version | Object |
|
ProjectContent version |
project.ownerType | Object |
|
ProjectContent owner type |
project.owner | Object | ProjectContent owner |
|
type | String |
|
Child type |
data | Object | data to insert |
public update(version: String, ownerType: String, owner: Number, contentType: String, contentId: Number, data: Object): Promise source
Generic function that updates data on the server.
This should not be called directly but rather be called using the ProjectContentService#updateProject method. For this reason, no example is provided.
Params:
Name | Type | Attribute | Description |
version | String | Version of the API of the API call to make |
|
ownerType | String | The owner type |
|
owner | Number | The owner |
|
contentType | String |
|
The content type |
contentId | Number |
|
The ID value of the object to update |
data | Object | The updated object to pass to the server |
Throw:
If missing token or missing required parameters |
Test:
- [unit] ProjectContentService.update should exist method
- [unit] ProjectContentService.update should throw an error when version is not defined
- [unit] ProjectContentService.update should throw an error when ownerType is not defined
- [unit] ProjectContentService.update should throw an error when owner is not defined
- [unit] ProjectContentService.update should throw an error when data is not defined
- [unit] ProjectContentService.update should return a promise
- [unit] ProjectContentService.update should receive a valid response for a PUT request
public updateProject(project: Object, type: String, id: Number, data: Object): Promise source
Update ProjectContent information based on the ProjectContent Helper class.
This should not be called directly but rather be called using the ProjectContent#save method and ProjectContent#updateChild. For this reason, no examples are provided.