Manual Reference Source Test
import RelatedUserService from 'clinical6/src/services/RelatedUserService.js'
public class | source

RelatedUserService

Extends:

AbstractServiceJsonApiService → RelatedUserService

Service handling RelatedUser calls with specific endpoints.

Constructor Summary

Public Constructor
public

Update type to be related_users

Method Summary

Public Methods
public

delete(relatedUser: RelatedUser, cacheMode: String): Promise

public
public

insert(relatedUser: RelatedUser, cacheMode: String): Promise<RelatedUser>

public

update(relatedUser: RelatedUser, cacheMode: String): Promise<RelatedUser>

Inherited Summary

From class AbstractService
public get
public set
public
private
From class JsonApiService
public

options: *

public

async delete(obj: Object, options: String): Promise

Call a DELETE request on the main obj.type expecting JSON API information.

public

async get(params: Object, options: String): Promise

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

async insert(obj: Object, options: String): Promise

Call a POST request on the main obj.type expecting JSON API information.

public

async update(obj: Object, options: String): Promise

Call a PATCH request on the main obj.type expecting JSON API information.

Public Constructors

public constructor() source

Update type to be related_users

Override:

JsonApiService#constructor

Public Methods

public delete(relatedUser: RelatedUser, cacheMode: String): Promise source

Call a DELETE request on the main obj.type expecting JSON API information.

Override:

JsonApiService#delete

Params:

NameTypeAttributeDescription
relatedUser RelatedUser

RelatedUser in which to delete

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise

Message

Test:

public getByUser(params: Object, cacheMode: String): Promise<RelatedUser[]|RelatedUser> source

Params:

NameTypeAttributeDescription
params Object
  • optional

Parameters used to get information from server (such as id)

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<RelatedUser[]|RelatedUser>

Promise object that returns one relatedUser or a key:relatedUser hashtable

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { relatedUserService } from 'clinical6';

// You will be able to access these relatedUsers using the `getByUser` method.
relatedUserService.getByUser().then(relatedUsers => console.log(relatedUsers));

// Additionally, you can retrieve a specific relatedUser with the `get`
// method, using the ID, user type and relationship ('follower' || 'followed') of the desired relatedUser as a parameter.
relatedUser.getByUser({id: 23, type: 'mobile_users', relationship: 'follower'}).then(relatedUser => console.log(relatedUser));

public insert(relatedUser: RelatedUser, cacheMode: String): Promise<RelatedUser> source

Call a POST request on the main obj.type expecting JSON API information.

Override:

JsonApiService#insert

Params:

NameTypeAttributeDescription
relatedUser RelatedUser

RelatedUser object in which to insert

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<RelatedUser>

Inserted relatedUser

Example:

import { RelatedUser, relatedUserService } from 'clinical6';
const relatedUser = new RelatedUser({...});

// you can insert a relatedUser using the `insert` method.
relatedUserService.insert(relatedUser).then(relatedUser => console.log(relatedUser));

// you could also just call `save` on the relatedUser if it doesn't have an id, which will also
// invoke the `insert` method
relatedUser.save();

Test:

public update(relatedUser: RelatedUser, cacheMode: String): Promise<RelatedUser> source

Call a PATCH request on the main obj.type expecting JSON API information.

Override:

JsonApiService#update

Params:

NameTypeAttributeDescription
relatedUser RelatedUser

RelatedUser object in which to update

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<RelatedUser>

Updated relatedUser

Example:

import { RelatedUser, relatedUserService } from 'clinical6';
const relatedUser = new RelatedUser({...});

// you can update a relatedUser using the `update` method.
relatedUserService.update(relatedUser).then(relatedUser => console.log(relatedUser));

// you could also just call `save` on the relatedUser if it has an id, which will also
// invoke the `update` method
relatedUser.save();

Test: