This document provides a concise guide to the JunctionBox module, focusing on the JunctionBox model and its Data Transfer Objects (DTOs) for creation and update operations.
Defines the structure for junction boxes.
type JunctionBox = {
name: string;
observation?: string;
kind: "JUNCTION_BOX";
address?: string;
implanted: boolean; // default: false
project: string | Project;
junctionBoxType: string | JunctionBoxType;
color?: string | Color;
typeColor: string;
shared: boolean; // default: false
tags: (string | Tag)[];
adjacents: (string | BasePoint)[];
};
Defines the structure for creating a junction box.
type CreateJunctionBoxDTO = {
name: string;
observation?: string;
address?: string;
implanted?: boolean; // default: false
project: string;
junctionBoxType: string;
color?: string;
shared?: boolean; // default: false
tags?: string[]; // default: []
adjacents?: string[]; // default: []
};
Defines the structure for updating a junction box.
type UpdateJunctionBoxDTO = {
name?: string;
observation?: string;
address?: string;
implanted?: boolean; // default: false
junctionBoxType?: string;
color?: string;
shared?: boolean; // default: false
tags?: string[]; // default: []
adjacents?: string[]; // default: []
};
import OZMapSDK from 'ozmapsdk';
import { CreateJunctionBoxDTO } from './JunctionBox';
const sdk = new OZMapSDK('ozmapURL', { apiKey: 'yourApiKey' });
const newJunctionBoxData: CreateJunctionBoxDTO = {
name: "New Junction Box",
project: "projectId",
junctionBoxType: "junctionBoxTypeId",
};
sdk.junctionBox.create(newJunctionBoxData).then((junctionBox) => {
console.log('Junction box created:', junctionBox);
});
import OZMapSDK from 'ozmapsdk';
import { UpdateJunctionBoxDTO } from './JunctionBox';
const sdk = new OZMapSDK('ozmapURL', { apiKey: 'yourApiKey' });
const updateJunctionBoxData: UpdateJunctionBoxDTO = {
name: "Updated Junction Box",
color: "blue",
};
sdk.junctionBox.updateById('junctionBoxId', updateJunctionBoxData).then(() => {
console.log('Junction box updated');
});
import OZMapSDK from 'ozmapsdk';
const sdk = new OZMapSDK('ozmapURL', { apiKey: 'yourApiKey' });
sdk.junctionBox.find({ page: 1, limit: 10 }).then((pagination) => {
console.log('Junction boxes:', pagination);
});
import OZMapSDK from 'ozmapsdk';
const sdk = new OZMapSDK('ozmapURL', { apiKey: 'yourApiKey' });
sdk.junctionBox.findById('junctionBoxId').then((junctionBox) => {
console.log('Junction box:', junctionBox);
});
import OZMapSDK from 'ozmapsdk';
const sdk = new OZMapSDK('ozmapURL', { apiKey: 'yourApiKey' });
sdk.junctionBox.deleteById('junctionBoxId').then(() => {
console.log('Junction box deleted');
});