LocationService
Extends:
Service handling Location calls.
Clinical6 has a couple of built-in methods that make it easy to get a user's current location, and update the location to the server.
Constructor Summary
Public Constructor | ||
public |
Update type to be locations |
Method Summary
Public Methods | ||
public |
|
|
public |
|
|
public |
Gets the current location using the browser navigator.geolocation.getCurrentPosition method |
|
public |
getTimezones(params: Object, cacheMode: String): Promise<Timezone[]> |
|
public |
|
|
public |
Calls insertV2 method with the current location latitude and longitude. |
|
public |
Update user location |
|
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 Methods
public delete(object: Object, cacheMode: String): Promise source
Call a DELETE request on the main obj.type expecting JSON API information.
Override:
JsonApiService#deletepublic get(params: Object, cacheMode: String): Promise<Location[]|Location> source
Call a GET request expecting JSON API information.
Override:
JsonApiService#getReturn:
Promise<Location[]|Location> | Promise object that returns one location or a key:location hashtable |
Throw:
If missing token or missing required parameters |
Example:
import { locationService } from 'clinical6';
// You will be able to access these locations using the `get` method.
locationService.get().then(locations => console.log(locations));
public getCurrent(): Promise source
Gets the current location using the browser navigator.geolocation.getCurrentPosition method
Example:
import { locationService } from 'clinical6';
// gets a Promise the current location with the specific latitude or longitude
var location;
locationService.getCurrent().then((location) => location = data );
public getTimezones(params: Object, cacheMode: String): Promise<Timezone[]> source
Throw:
If missing token or missing required parameters |
Example:
import { locationService } from 'clinical6';
// You will be able to access these timezones using the `getTimezones` method.
locationService.getTimezones().then(timezones => console.log(timezones));
// Additionally, you can pass params.offset to sort the returned timezones
locationService.getTimezones({ sort: '-offset' }).then(timezones => console.log(timezones));
public insert(location: Object, cacheMode: String): Promise<Location> source
Call a POST request on the main obj.type expecting JSON API information.
Override:
JsonApiService#insertExample:
import { Location, locationService } from 'clinical6';
const location = new Location({...});
// you can insert a location using the `insert` method.
locationService.insert(location).then(location => console.log(location));
// you could also just call `save` on the location if it doesn't have an id, which will also
// invoke the `insert` method
location.save();
public insertCurrent(): Promise source
Calls insertV2 method with the current location latitude and longitude.
Example:
import { locationService } from 'clinical6';
// gets a Promise that posts the current location to the server
locationService.updateCurrentLocation();
public insertV2(location: Object): Promise source
Update user location
Params:
Name | Type | Attribute | Description |
location | Object | Object including the following location-based fields: |
|
location.latitude | Float | Latitude |
|
location.longitude | Float | Longitude |
|
location.country | String | Country |
|
location.state | String | State |
|
location.city | String | City |
|
location.street | String | Street |
|
location.zip_code | String | Zip Code |
Throw:
If missing token or missing required parameters |
Example:
import { locationService } from 'clinical6';
// gets a Promise the current location with the specific latitude or longitude
var location;
locationService.getCurrent().then((location) => location = data );
// gets a Promise that posts a location to the server
locationService.updateLocation(location);
public async update(location: Location, options: Object): Promise source
Call a PATCH request on the main obj.type expecting JSON API information.
Override:
JsonApiService#updateExample:
import { Location, locationService } from 'clinical6';
const location = new Location({...});
// you can update a location using the `update` method.
locationService.update(location).then(location => console.log(location));
// you could also just call `save` on the location if it has an id, which will also
// invoke the `update` method
location.save();