DiscussService
Extends:
Constructor Summary
Public Constructor | ||
public |
Update type to be commentable__threads |
Method Summary
Public Methods | ||
public |
Get or filter threads. |
|
public |
Fetches comments associated to a specific object. |
|
public |
Insert Thread |
|
public |
Insert Comment |
Inherited Summary
From class AbstractService | ||
public get |
|
|
public set |
|
|
public |
|
|
private |
|
From class JsonApiService | ||
public |
options: * |
|
public |
Call a DELETE request on the main obj.type expecting JSON API information. |
|
public |
Call a GET request expecting JSON API information. |
|
public |
async getChildren(parent: Object, child: Object, options: String): Promise Call a GET request expecting JSON API information for children given a parent. |
|
public |
Call a POST request on the main obj.type expecting JSON API information. |
|
public |
Call a PATCH request on the main obj.type expecting JSON API information. |
Public Constructors
public constructor() source
Update type to be commentable__threads
Override:
JsonApiService#constructorPublic Members
Public Methods
public get(data: Object, cacheMode: String): Promise<Thread[]> source
Get or filter threads.
Override:
JsonApiService#getParams:
Name | Type | Attribute | Description |
data | Object |
|
Object in which to have a discussion |
data.id | Number |
|
Object id to start a discussion on |
data.type | String |
|
Object type to start a discussion on |
cacheMode | String |
|
Override the caching method for this call |
Throw:
If missing required parameters |
Example:
import { discussService } from 'clinical6';
discussService.get(); // get all threads
// Get threads from a flow
myFlow = new Flow({...});
discussService.get(myFlow);
// This is also called from other objects in the system like a flow or flowstep.
// In this case, it will use the flow/flowstep owner and object information automatically.
myFlow.getThreads();
myFlow.first.getThreads(); // FlowStep Comments
public getComments(thread: Object, cacheMode: String): Promise<Comment[]|Comment> source
Fetches comments associated to a specific object.
Throw:
If missing token or missing required parameters |
Example:
import { discussService } from 'clinical6';
const thread = new Thread({...});
discussService.getComments(thread);
public insert(data: Object, cacheMode: String): Promise<Thread> source
Insert Thread
Override:
JsonApiService#insertParams:
Name | Type | Attribute | Description |
data | Object |
|
Object in which to have a discussion |
data.id | Number |
|
Object id to start a discussion on |
data.type | String |
|
Object type to start a discussion on |
cacheMode | String |
|
Override the caching method for this call |
Throw:
If missing required parameters |
Example:
import { discussService } from 'clinical6';
const thread = await discussService.insert(myFlow);
public insertComment(text: String, thread: Object, author: Object, cacheMode: String): Promise<Comment> source
Insert Comment
Params:
Name | Type | Attribute | Description |
text | String |
|
The comment text |
thread | Object |
|
The discussion thread |
thread.id | Number |
|
Thread id to start a discussion on |
thread.type | String |
|
Thread type to start a discussion on |
author | Object |
|
The author of the comment |
author.id | Number |
|
Author id |
author.type | String |
|
Author type ('mobile_users' or 'users') |
cacheMode | String |
|
Override the caching method for this call |
Throw:
If missing required parameters |
Example:
import { discussService, Thread, MobileUser } from 'clinical6';
const thread = new Thread({...});
const author = new MobileUser({...});
const comment = await discussService.insertComment('Hello World', thread);