Skip to main content

Facility


Find facilities

Get a list of facilities.

const response = await geocore.Facility.find({
area: {
north: 1,
south: 2,
west: 3,
east: 4,
};
});

Prerequisites

Successfully get the IdToken with companyAdmin, groupAdmin or user access level from login API.

Parameters

nametypedata typedescription
area[north]requirednumberLongitude of north west point
area[south]requirednumberLatitude of north west point
area[west]requirednumberLongitude of north east point
area[east]requirednumberLatitude of north east point
Create facility

Create a new facility.

const formData = new FormData();
formData.append('title', title);
formData.append('name', name);
formData.append('description', description);
formData.append('color', color);
formData.append('location[type]', 'Point');
formData.append('location[coordinates]', 12);
formData.append('location[coordinates]', 34);
formData.append('photo', photoFile);

const response = await geocore.Facility.create(formData);

Prerequisites

Successfully get the IdToken with companyAdmin, groupAdmin or user access level from login API.

Parameters

nametypedata typedescription
titlerequiredstringFacility title
namerequiredstringFacility name
descriptionrequiredstringFacility description
colorrequiredstringFacility color
location[type]requiredstringValue must be "Point"
location[coordinates]requiredarray<number>Location of facility
photorequiredstringPhoto files of facility

Image notes

  • Maximum number of photos allowed is 10.
  • When uploading a facility photo, that photo will be resized in 2 sizes: small (width 300px) and medium (width 1200px).
  • These resized images path will be stored in the database.
  • Only photos with width larger than these sizes will be resized.
Update facility

Update a facility.

const formData = new FormData();
formData.append('title', title);
formData.append('name', name);
formData.append('description', description);
formData.append('color', color);
formData.append('location[type]', 'Point');
formData.append('location[coordinates]', 12);
formData.append('location[coordinates]', 34);
formData.append('photo', photoFile);

const response = await geocore.Facility.update(facilityId, formData);

Prerequisites

Successfully get the IdToken with companyAdmin, groupAdmin or user access level from login API.

Parameters

nametypedata typedescription
facilityIdrequiredstringFacility ID
titlerequiredstringFacility title
namerequiredstringFacility name
descriptionrequiredstringFacility description
colorrequiredstringFacility color
location[type]requiredstringValue must be "Point"
location[coordinates]requiredarray<number>Location of facility
retainedPhotoIds[]requiredarray<string>Photo IDs that user wants to keep
photorequiredstringNew photo files of facility
Delete facility

Delete a facility.

const response = await geocore.Facility.delete(facilityId);

Prerequisites

Successfully get the IdToken with companyAdmin, groupAdmin or user access level from login API.

Parameters

nametypedata typedescription
facilityIdrequiredstringFacility ID
Import facilities

Import facilities from a CSV file.

const formData = new FormData();
formData.append('csv', csvFile);

const response = await geocore.Facility.import(formData);

Prerequisites

Successfully get the IdToken with companyAdmin access level from login API.

Parameters

nametypedata typedescription
csvrequiredstringCSV file with facility information
Export facilities

Export facilities to a CSV file.

const response = await geocore.Facility.export(query);

Prerequisites

Successfully get the IdToken with companyAdmin access level from login API.

Parameters

nametypedata typedescription
queryrequiredstringSame as get facility query params