This document provides a concise guide to the Building module, focusing on the Building model and its Data Transfer Objects (DTOs) for creation and update operations.
Defines the structure for buildings.
type Building = {
kind: "Building";
name: string;
address?: string;
implanted?: boolean; // default: true
hasProblem?: boolean; // default: false
tags?: (string | Tag)[]; // default: []
project: string | Project;
cables?: string[]; // default: []
};
Defines the structure for creating a building.
type CreateBuildingDTO = {
kind?: "Building";
name?: string;
address?: string;
implanted?: boolean; // default: true
tags?: string[]; // default: []
external_id?: any;
};
Defines the structure for updating a building.
type UpdateBuildingDTO = {
kind?: "Building";
name?: string;
address?: string;
implanted?: boolean; // default: true
tags?: string[]; // default: []
external_id?: any;
};
import OZMapSDK from 'ozmapsdk';
import { CreateBuildingDTO } from './Building';
const sdk = new OZMapSDK('ozmapURL', { apiKey: 'yourApiKey' });
const newBuildingData: CreateBuildingDTO = {
name: "New Building",
kind: "Building",
implanted: true,
};
sdk.building.create(newBuildingData).then((building) => {
console.log('Building created:', building);
});
import OZMapSDK from 'ozmapsdk';
import { UpdateBuildingDTO } from './Building';
const sdk = new OZMapSDK('ozmapURL', { apiKey: 'yourApiKey' });
const updateBuildingData: UpdateBuildingDTO = {
name: "Updated Building",
address: "123 Main St",
};
sdk.building.updateById('buildingId', updateBuildingData).then(() => {
console.log('Building updated');
});
import OZMapSDK from 'ozmapsdk';
const sdk = new OZMapSDK('ozmapURL', { apiKey: 'yourApiKey' });
sdk.building.find({ page: 1, limit: 10 }).then((pagination) => {
console.log('Buildings:', pagination);
});
import OZMapSDK from 'ozmapsdk';
const sdk = new OZMapSDK('ozmapURL', { apiKey: 'yourApiKey' });
sdk.building.findById('buildingId').then((building) => {
console.log('Building:', building);
});
import OZMapSDK from 'ozmapsdk';
const sdk = new OZMapSDK('ozmapURL', { apiKey: 'yourApiKey' });
sdk.building.deleteById('buildingId').then(() => {
console.log('Building deleted');
});