LanguageService
Extends:
Service handling Language calls with specific endpoints.
Clinical6 is available in multiple different languages.
Constructor Summary
Public Constructor | ||
public |
Update type to be languages |
Method Summary
Public Methods | ||
public |
|
|
public |
|
|
public |
getLanguages(getTranslations: Boolean): Promise<{ [id: String] : Language Returns the list of available languages for an application. |
|
public |
getTranslations(iso: String): Promise Returns the translations for a given language. |
|
public |
|
|
public |
|
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 Members
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#deleteExample:
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
public get(params: Object, cacheMode: String): Promise<Language[]|Language> source
Call a GET request expecting JSON API information.
Override:
JsonApiService#getReturn:
Promise<Language[]|Language> | Promise object that returns one language or a key:language hashtable |
Throw:
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));
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:
Name | Type | Attribute | Description |
getTranslations | Boolean |
|
If true, then populate the Language translation key/val |
Return:
Promise<{ [id: String] : Language | | Language>}
|
Throw:
If missing token |
Example:
import { languageService } from 'clinical6';
languageService.getLanguages();
[
{
"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:
Name | Type | Attribute | Description |
iso | String |
|
ISO of the language for which the translations are needed. |
Throw:
If missing token or missing required parameters |
Example:
import { languageService } from 'clinical6';
// Returns the translations for a given language.
languageService.getTranslations(id);
public insert(language: Object, cacheMode: String): Promise<Language> source
Call a POST request on the main obj.type expecting JSON API information.
Override:
JsonApiService#insertExample:
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();
public update(language: Language, cacheMode: String): Promise<Language> source
Call a PATCH request on the main obj.type expecting JSON API information.
Override:
JsonApiService#updateExample:
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();