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

LanguageService

Extends:

AbstractServiceJsonApiService → LanguageService

Service handling Language calls with specific endpoints.

Clinical6 is available in multiple different languages.

Constructor Summary

Public Constructor
public

Update type to be languages

Member Summary

Public Members
public

Method Summary

Public Methods
public

delete(language: Language, cacheMode: String): Promise

public

get(params: Object, cacheMode: String): Promise<Language[]|Language>

public

getLanguages(getTranslations: Boolean): Promise<{ [id: String] : Language

Returns the list of available languages for an application.

public

Returns the translations for a given language.

public

insert(language: Object, cacheMode: String): Promise<Language>

public

update(language: Language, cacheMode: String): Promise<Language>

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 languages

Override:

JsonApiService#constructor

Public Members

public type: String source

Override:

AbstractService#type

Public Methods

public delete(language: Language, cacheMode: String): Promise source

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

Override:

JsonApiService#delete

Params:

NameTypeAttributeDescription
language Language

Language object in which to update

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise

Message

Example:

import { languageService } from 'clinical6';

// You will be able to delete a language using `delete`.
languageService.delete({ id: 23 });
// This will also clear the local storage of this type and id

Test:

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

Call a GET request expecting JSON API information.

Override:

JsonApiService#get

Params:

NameTypeAttributeDescription
params Object
  • optional

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

params.id Number
  • optional

Id of the language

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<Language[]|Language>

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

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { languageService } from 'clinical6';

// You will be able to access these languages using the `get` method.
languageService.get().then(languages => console.log(languages));

// Additionally, you can retrieve the subcategories for a specific language with the `get`
// method, using the ID of the desired language as a parameter.
languageService.get({ id: 23 }).then(language => console.log(language));

Test:

public getLanguages(getTranslations: Boolean): Promise<{ [id: String] : Language source

Returns the list of available languages for an application.

Users can get the list of available languages for an application using the getLanguages method.

Params:

NameTypeAttributeDescription
getTranslations Boolean
  • optional

If true, then populate the Language translation key/val

Return:

Promise<{ [id: String] : Language

| Language>}

                                 - Promise object that returns success or failure

Throw:

Clinical6Error

If missing token

Example:

import { languageService } from 'clinical6';
languageService.getLanguages();
Success Response
[
  {
    "name": "English",
    "icon": {
      "original": "/assets/default/default-4832093.png",
      "thumb": "/assets/default/thumb_default-5238439.png"
    },
    "iso": "en"
  },
  {
    "name": "non",
    "icon": {
      "original": "/assets/default/default-4832093.png",
      "thumb": "/assets/default/thumb_default-5238439.png"
    },
    "iso": "dummy_752"
  },
  {
    "name": "non",
    "icon": {
      "original": "/assets/default/default-4832093.png",
      "thumb": "/assets/default/thumb_default-5238439.png"
    },
    "iso": "dummy_753"
  }
]

public getTranslations(iso: String): Promise source

Returns the translations for a given language.

Users can get the translations for a given language using the getTranslations method. This method requires the ISO value of a language.

Params:

NameTypeAttributeDescription
iso String
  • nullable: false

ISO of the language for which the translations are needed.

Return:

Promise

Promise object that returns success or failure

Throw:

Clinical6Error

If missing token or missing required parameters

Example:

import { languageService } from 'clinical6';

// Returns the translations for a given language.
languageService.getTranslations(id);

Test:

public insert(language: Object, cacheMode: String): Promise<Language> source

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

Override:

JsonApiService#insert

Params:

NameTypeAttributeDescription
language Object
  • optional

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

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<Language>

Inserted language

Example:

import { Language, languageService } from 'clinical6';
const language = new Language({...});

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

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

Test:

public update(language: Language, cacheMode: String): Promise<Language> source

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

Override:

JsonApiService#update

Params:

NameTypeAttributeDescription
language Language

Language object in which to update

cacheMode String
  • optional

Override the caching method for this call

Return:

Promise<Language>

Updated language

Example:

import { Language, languageService } from 'clinical6';
const language = new Language({...});

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

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

Test: