Clinical6
Client to the Clinical6 instance
Example:
Clinical6 client = new Clinical6("https://mysite.captivereach.com");
await client.guestSignIn('thisismydeviceid', 'ios', 'thisismypushid');
console.log(client.authToken);
Constructor Summary
Public Constructor | ||
public |
constructor(apiBaseUrl: String) Constructs the class with baseUrl provided |
Member Summary
Public Members | ||
public |
Client: Class |
|
public get |
Gets the apiBaseUrl |
|
public set |
Sets the apiBaseUrl |
|
public get |
Gets the authToken from Client.instance.authToken |
|
public set |
Sets the authToken for Client.instance.authToken |
|
public set |
Sets the configuration information |
|
public get |
Gets the configuration information |
|
public get |
Gets the device from Client.instance.device |
|
public set |
Sets the device for Client.instance.device |
|
public set |
Gets the mobileApplicationKey from Client.instance.mobileApplicationKey |
|
public get |
mobileApplicationKey(device: String): String Sets the mobileApplicationKey for Client.instance.mobileApplicationKey |
|
public |
|
|
public get |
Gets the user from Client.instance.user |
|
public set |
Sets the user for Client.instance.user |
Private Members | ||
private |
|
|
private |
|
Method Summary
Public Methods | ||
public |
Deletes an object |
|
public |
Prepare and Fetch HTTP request to API |
|
public |
Updates an object |
|
public |
async getChildren(parent: Object, child: Object, options: Object): Promise Updates an object |
|
public |
Retrieves the profile of the current, authenticated mobile user. |
|
public |
Inserts an object |
|
public |
Tracks a new event in the log. |
|
public |
Register a device for guest, a username, or email |
|
public |
requestPasswordReset(account: String): Promise Starts the reset password process and sends an email to the user with instructions. |
|
public |
resetPassword(token: String, password: String, device: Device): Promise Sends user's account name via email. This method does not require an access token. |
|
public |
Sign in with device info |
|
public |
async signInGuest(): Promise Sign in with device info |
|
public |
Detaches the device from the mobile_user. |
|
public |
Updates an object |
|
public |
Submits the provided JSON to the server. |
Public Constructors
public constructor(apiBaseUrl: String) source
Constructs the class with baseUrl provided
Params:
Name | Type | Attribute | Description |
apiBaseUrl | String |
|
Base URL the (sub)domain of the Captive Reach server. Example: 'https://dhsadobe.captivereach.com' |
Public Members
public Client: Class source
public get authToken(authToken: String): String source
Gets the authToken from Client.instance.authToken
public set authToken(authToken: String): String source
Sets the authToken for Client.instance.authToken
public set mobileApplicationKey: String source
Gets the mobileApplicationKey from Client.instance.mobileApplicationKey
public get mobileApplicationKey(device: String): String source
Sets the mobileApplicationKey for Client.instance.mobileApplicationKey
Private Members
Public Methods
public async delete(obj: Object, cacheMode: String): Promise source
Deletes an object
Example:
import { clinical6, Site, Client } from 'clinical6';
// Removes obj from server and local storage
const obj = new Site({...}); // Site for example
clinical6.delete(obj);
// No longer in storage
Client.instance.storageUtility.has('sites', { id: obj.id });
// Can also be done using a json description
clinical6.delete({ id: 5, type: '23', options: { cascading: true }});
Test:
- [unit] Clinical6.delete should throw errors for invalid parameters
- [unit] Clinical6.delete should receive a valid response for a delete request
- [unit] AgreementTemplateFieldService.delete should throw errors for invalid parameters
- [unit] AgreementTemplateFieldService.delete should make a properly formatted delete request
- [unit] AgreementTemplateFieldService.delete should receive a valid response for a delete request
- [unit] AllowedActionService.delete should make a properly formatted delete request
- [unit] AllowedActionService.delete should receive a valid response for a delete request
- [unit] AllowedActionService.delete should remove the element from local storage
- [unit] ApproverAssignmentService.delete should throw errors for invalid parameters
- [unit] ApproverAssignmentService.delete should receive a valid response for a delete request
- [unit] ApproverGroupAssignmentService.delete should throw errors for invalid parameters
- [unit] ApproverGroupAssignmentService.delete should receive a valid response for a delete request
- [unit] BadgeService.delete should throw errors for invalid parameters
- [unit] BadgeService.delete should make a properly formatted delete request and response
- [unit] BadgeService.delete should remove the element from local storage
- [unit] CohortAssignmentService.delete should throw errors for invalid parameters
- [unit] CohortAssignmentService.delete should receive a valid response for a delete request
- [unit] CohortService.delete should throw errors for invalid parameters
- [unit] CohortService.delete should receive a valid response for a delete request
- [unit] ConsentStrategyService.delete should throw errors for invalid parameters
- [unit] ConsentStrategyService.delete should receive a valid response for a delete request
- [unit] ConsultationParticipantService.delete should throw errors for invalid parameters
- [unit] ConsultationParticipantService.delete should receive a valid response for a delete request
- [unit] ConsultationService.delete should throw errors for invalid parameters
- [unit] ConsultationService.delete should receive a valid response for a delete request
- [unit] ContentAttributeService.delete should throw errors for invalid parameters
- [unit] ContentAttributeService.delete should make a properly formatted delete request and response
- [unit] ContentAttributeService.delete should remove the element from local storage
- [unit] KittenService.delete should throw errors for invalid parameters
- [unit] KittenService.delete should receive a valid response for a delete request
- [unit] SignAccountService.delete should throw errors for invalid parameters
- [unit] SignAccountService.delete should receive a valid response for a delete request
- [unit] SiteLanguageService.delete should throw errors for invalid parameters
- [unit] SiteLanguageService.delete should receive a valid response for a delete request
- [unit] SiteMemberService.delete should throw errors for invalid parameters
- [unit] SiteMemberService.delete should receive a valid response for a delete request
- [unit] SiteMemberService.delete should remove the element from local storage
- [unit] SiteService.delete should throw errors for invalid parameters
- [unit] SiteService.delete should receive a valid response for a delete request
public fetch(url: String, method: String, data: Object): Promise source
Prepare and Fetch HTTP request to API
public async get(params: Object, options: Object): Promise source
Updates an object
Params:
Name | Type | Attribute | Description |
params | Object |
|
Parameters used to get information from server |
params.id | Number |
|
Id to get data from the server |
params.type | String |
|
Type to be used for storage |
params.filters | Object |
|
Filters to be used for get |
options | Object |
|
Options to modify or change behavior/results of the call |
options.cacheMode | String |
|
Override the caching method for this call |
options.meta | String |
|
Pass through and update by reference meta data |
Throw:
If missing token or missing required parameters |
Example:
import { clinical6, Setting, Site, Client } from 'clinical6';
// You can get sites using an existing instantiated object
const obj = new Site({...}); // Site for example
clinical6.get(obj).then(sites => console.log(sites)); // will get all sites
// If id exists, it will return only one site
obj.id = 5;
clinical6.get(obj).then(site => console.log(site)); // will get site where id = 5
// Using the string of the type
clinical6.get('mobile_users').then(users => console.log(users)); // will return all mobile users
// Using the class name directly
clinical6.get(Setting).then(settings => console.log(settings)); // will return all settings
// Adding filters and cache mode
clinical6.get({ type: 'some_object_type', filters: {}}, 'networkOnly').then(obj => console.log(obj));
Test:
- [unit] Clinical6.get should receive a valid response for a get request without an id
- [unit] Clinical6.get should receive a valid response for a get request with an id
- [unit] ApproverGroupService.get should make a properly formatted get request and response without an id
- [unit] BadgeService.get should make a properly formatted get request and response without an id
- [unit] BadgeService.get should receive a valid response for a get request with an id
- [unit] CohortService.get should make a properly formatted get request and response without an id
- [unit] CohortService.get should receive a valid response for a get request with an id
- [unit] ConsentApproverService.get should make a properly formatted get request and response without an id
- [unit] ConsentFormVesrionService.get should make a properly formatted get request
- [unit] ConsentFormVersionService.get should receive a valid response for a get request without an id
- [unit] ConsentFormVersionService.get should receive a valid response for a get request with an id
- [unit] ConsentFormService.get should make a properly formatted get request
- [unit] ConsentFormService.get should receive a valid response for a get request without an id
- [unit] ConsentFormService.get should receive a valid response for a get request with an id
- [unit] ConsentStrategyService.get should make a properly formatted get request
- [unit] ConsentStrategyService.get should receive a valid response for a get request without an id
- [unit] ConsentStrategyService.get should receive a valid response for a get request with an id
- [unit] Clinical6.get(ContentType) should make a properly formatted GET request and response
- [unit] Clinical6.get(ContentType) should receive a valid response for a get request
- [unit] Clinical6.get({type: 'dynamic_content__public_contents' }) should get a valid response for a GET request
- test/unit/services.custom-class.genisis.site.v3.js
- [unit] KittenService.get should receive a valid response for a get request without an id
- [unit] KittenService.get should receive a valid response for a get request with an id
- [unit] VersionService.get should receive a valid response for a get request without an id
- [unit] FlowService.get should make a properly formatted get request
- [unit] SettingService.get should receive a valid response for a get request without an id
- [unit] SignAccountService.get should make a properly formatted get request
- [unit] SignAccountService.get should receive a valid response for a get request without an id
- [unit] SiteMemberService.get should receive a valid response for a get request without an id
- [unit] SiteMemberService.get should receive a valid response for a get request with an id
- [unit] SiteService.get should receive a valid response for a get request without an id
- [unit] SiteService.get should receive a valid response for a get request with an id
- [unit] SsoOptionService.get should make a properly formatted get request
- [unit] SsoOptionService.get should receive a valid response for a get request without an id
- [unit] VersionService.get should make a properly formatted get request
- [unit] VersionService.get should receive a valid response for a get request without an id
public async getChildren(parent: Object, child: Object, options: Object): Promise source
Updates an object
Params:
Name | Type | Attribute | Description |
parent | Object | Parameters used to get information from server |
|
parent.id | Number | Id to get data from the server |
|
parent.type | String | Type to be used for storage |
|
child | Object |
|
Parameters used to get information from server |
child.id | Number |
|
Id to get data from the server |
child.type | String |
|
Type to be used for storage |
child.filters | Object |
|
Filters to be used for get |
options | Object |
|
Options to modify or change behavior/results of the call |
options.cacheMode | String |
|
Override the caching method for this call |
options.meta | String |
|
Pass through and update by reference meta data |
Throw:
If missing token or missing required parameters |
Example:
import { clinical6, SiteMember } from 'clinical6';
clinical6.getChildren(site, { type: 'trials/site_members' });
clinical6.getChildren(site, new SiteMember());
clinical6.getChildren(user, { type: 'ediary/entries' }); // generates /v3/mobile_users/:id/ediary/entries
Test:
- test/unit/clinical6.js
- [unit] Clinical6.getChildren should receive a valid response for a get request with an id
- test/unit/services.cohort.js
- [unit] CohortService.getChildren should receive a valid response for a get request with an id
- test/unit/services.consent-form-version.js
- [unit] ConsentFormVersionService.getChildren should receive a valid response for a get request with an id
- test/unit/services.consent-form.js
- [unit] Clinical6.getChildren(ContentType) should make a properly formatted GET request and response
- test/unit/services.custom-class.user.genisis.v3.js
- test/unit/services.custom.user.genisis.v3.js
- test/unit/services.site.v3.js
- [unit] SiteService.getChildren should receive a valid response for a get request with an id
- [unit] SiteService.getChildren should receive a valid response for a get request with sort parameter
- [unit] SiteService.getChildren should throw an error for a get request with invalid sort parameter
- test/unit/services.site.v3.js
- test/unit/services.site.v3.js
public getProfile(): Promise source
Retrieves the profile of the current, authenticated mobile user.
public async insert(obj: Object, cacheMode: String): Promise source
Inserts an object
Example:
import { clinical6, Site, Client } from 'clinical6';
// Removes obj from server and local storage
const obj = new Site({...}); // Site for example
clinical6.insert(obj);
// Now in storage
Client.instance.storageUtility.has('sites', { id: obj.id });
Test:
- [unit] Clinical6.insert should successfully insert a site with a site object
- [unit] Clinical6.insert should throw an error with an invalid token
- [unit] AgreementTemplateFieldService.insert should successfully insert an agreement template field with an agreement template object
- [unit] AgreementTemplateFieldService.insert should throw an error without the necessary attributes
- [unit] AgreementTemplateService.insert should successfully insert an agreement template with an agreement template object
- [unit] AgreementTemplateService.insert should throw an error without the necessary attributes
- [unit] AllowedActionService.insert should successfully insert an allowed action with an allowed action object
- [unit] ApproverAssignmentService.insert should successfully insert a cohort with a cohort object
- [unit] ApproverGroupAssignmentService.insert should successfully insert an approver group assignment with an approver group assignment object
- [unit] ApproverGroupService.insert should successfully insert a approverGroup with a approverGroup object
- [unit] BadgeService.insert should successfully insert a badge with a badge object
- [unit] CohortAssignmentService.insert should successfully insert a cohort with a cohort object
- [unit] CohortService.insert should successfully insert a cohort with a cohort object
- [unit] ConsentAdditionalSignerService.insert should successfully insert a consentAdditionalSigner with a consentAdditionalSigner object
- [unit] ConsentFormVersion.insert should successfully insert a consentFormVersion with a consentFormVersion object
- [unit] ConsentFormService.insert should successfully insert a consentForm with a consentForm object
- [unit] ConsentGrantService.insert should successfully insert a consentGrant with a consentGrant object
- [unit] ConsentStrategyService.insert should successfully insert a consentStrategy with a consentStrategy object
- [unit] ConsultationParticipantService.insert should successfully insert a participant with a participant object
- [unit] ConsultationService.insert should successfully insert a consultation with a consultation object
- [unit] ContentAttributeService.insert should successfully insert a content attribute with a content attribute object
- [unit] KittenService.insert should successfully insert a kitten with a kitten object
- [unit] KittenService.insert should throw an error with an invalid token
- [unit] FilterGroupService.insert should successfully insert a filterGroup with a filterGroup object
- [unit] ImportService.insert should successfully insert a bulkImport with a bulkImport object
- [unit] ImportService.insert should throw an error with an invalid token
- [unit] ConsentStrategyService.insert should successfully insert a consentStrategy with a consentStrategy object
- [unit] SiteContactService.insert should successfully insert a siteContact with a siteContact object
- [unit] SiteLanguageService.insert should successfully insert a siteLanguage with a siteLanguage object
- [unit] SiteMemberService.insert should successfully insert a site with a site object
- [unit] SiteService.insert should successfully insert a site with a site object
- [unit] SiteService.insert should throw an error with an invalid token
public log(logEntry: Object, requestInformation: Object, deviceInformation: Object): Promise source
Tracks a new event in the log.
Params:
Name | Type | Attribute | Description |
logEntry | Object |
|
The new log entry to track. (optional) |
logEntry.message | String |
|
The message of the log entry. (optional) |
logEntry.tag | String |
|
The tag value of the log entry. (optional) |
logEntry.level | String | Indicates the level of importance of the log entry. (required) |
|
requestInformation | Object |
|
The request information of the API call. (optional) |
requestInformation.method | String |
|
The method of the request. (optional) |
requestInformation.params | String |
|
The body or parameters that were sent on the failing/debugging request. (optional) |
requestInformationtry.status_code | String |
|
The response of the request. (optional) |
requestInformationtry.url | String |
|
The URL of the request. (optional) |
deviceInformation | Object |
|
The device information of the device that made the request. (optional) |
deviceInformation.app_version | String |
|
The version of the app that was running on the device. (optional) |
deviceInformation.brand | String |
|
The brand of the device. (optional) |
deviceInformation.carrier | String |
|
The carrier of the device . (optional) |
deviceInformation.gps_status | String |
|
The gps status of the device. (optional) |
deviceInformation.latitude | Number |
|
The latitude value where the device was. (optional) |
deviceInformation.longitude | Number |
|
The longitude value where the device was. (optional) |
deviceInformation.manufacturer | String |
|
The manufacturer of the device. (optional) |
deviceInformation.network_status | String |
|
The network status of the device. (optional) |
deviceInformation.os_version | String |
|
The OS version of the device. (optional) |
deviceInformation.push_id | String |
|
The push ID value of the device. (optional) |
deviceInformation.token | String |
|
The token value of the device. (optional) |
deviceInformation.udid | String |
|
The UDID value of the device. (optional) |
deviceInformation.technology | String |
|
The technology of the device. (optional) |
Example:
import { systemService } from 'Clinical6';
systemService.log({
"message": "MyText",
"tag": "MyString",
"level": "Error"
}, {
"url": "MyString",
"method": "MyString",
"params": "MyText",
"status_code": "MyString"
}, {
"udid": "MyString",
"token": "MyString",
"push_id": "MyString",
"app_version": "MyString",
"os_version": "MyString",
"network_status": "MyString",
"gps_status": "MyString",
"latitude": "1.5",
"longitude": "1.5",
"brand": "MyString",
"manufacturer": "MyString",
"carrier": "MyString"
});
{
"status": "ok",
"message": "Debug Log was successfully created"
}
public async register(account: String, password: String, device: Device): Promise<MobileUser> source
Register a device for guest, a username, or email
Example:
import { clinical6 } from 'clinical6';
const mobileUser = new MobileUser({...});
// you can register a guest using the `register` method.
clinical6.register()
.then(mobileUser => console.log(mobileUser));
// Register using an account name
clinical6.register('abc', 'asdf', device)
.then(mobileUser => console.log(mobileUser));
// Register using an email address
clinical6.register('test@test.com', 'asdf', device)
.then(mobileUser => console.log(mobileUser));
public requestPasswordReset(account: String): Promise source
Starts the reset password process and sends an email to the user with instructions.
Params:
Name | Type | Attribute | Description |
account | String | Either the account name or email address |
Throw:
If missing required parameters |
Example:
import { clinical6 } from 'clinical6';
clinical6.requestPasswordReset('test@test.com'); // email
clinical6.requestPasswordReset('jsmith'); // account
public resetPassword(token: String, password: String, device: Device): Promise source
Sends user's account name via email. This method does not require an access token.
public signOut(): Promise source
Detaches the device from the mobile_user. If the current mobile_user is a guest, his information will be destroyed. After this method is executed the device won't have any access_token associated and won't be able to make other requests until it signs in.
This method does not require access token.
public async update(obj: Object, options: Object): Promise source
Updates an object
Example:
import { clinical6, Site, Client } from 'clinical6';
// Updates a site
const obj = new Site({...}); // Site for example
obj.data = `Updated Data`;
clinical6.update(obj);
// Updates a site and applies meta data
const obj = new Site({...}); // Site for example
obj.data = `Updated Data`;
clinical6.update(obj, { cacheMode: 'networkOnly', meta: { something: 23 }});
Test:
- [unit] Clinical6.update should throw errors for invalid parameters
- [unit] Clinical6.update should successfully update a site with a site object
- [unit] Clinical6.update should successfully update a site with reason for change
- [unit] ApproverGroupService.update should successfully update an approverGroup with an approverGroup object
- [unit] BadgeService.update should successfully update a badge with a badge object
- [unit] CohortService.update should successfully update a cohort with a cohort object
- [unit] ConsentApproverService.update should successfully update a consentApprover with a consentApprover object
- [unit] ConsentFormVersionService.update should successfully update a consentApprover with a consentApprover object
- [unit] ConsentFormService.update should successfully update a consentForm with a consentForm object
- [unit] ConsentStrategyService.update should successfully update a consentStrategy with a consentStrategy object
- [unit] ConsultationParticipantService.update should successfully update a participant with a participant object
- [unit] ConsultationService.update should successfully update a consultation with a consultation object
- [unit] ContentAttributeService.update should successfully update a contentAttribute with a contentAttribute object
- [unit] KittenService.update should successfully update a kitten with a kitten object
- [unit] SettingService.update should successfully update a setting with a setting object
- [unit] SiteMemberService.update should successfully update a site member with a site object
- [unit] SiteService.update should successfully update a site with a site object