@sonoransoftware/sonoran.js 1.0.49 → 1.0.50

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -272,7 +272,7 @@ export declare enum CADDispatchStatusEnums {
272
272
  Active = 1,
273
273
  Closed = 2
274
274
  }
275
- export interface CADNewDispatchStruct {
275
+ interface CADNewDispatchBaseStruct {
276
276
  serverId: number;
277
277
  origin: CADDispatchOriginEnums;
278
278
  status: CADDispatchStatusEnums;
@@ -286,8 +286,14 @@ export interface CADNewDispatchStruct {
286
286
  trackPrimary: boolean;
287
287
  description: string;
288
288
  metaData: Record<string, string>;
289
- units: string[];
290
289
  }
290
+ export type CADNewDispatchStruct = (CADNewDispatchBaseStruct & {
291
+ units: string[];
292
+ accounts?: string[];
293
+ }) | (CADNewDispatchBaseStruct & {
294
+ units?: string[];
295
+ accounts: string[];
296
+ });
291
297
  export interface CADStreetSignStruct {
292
298
  id: number;
293
299
  label: string;
@@ -768,3 +774,4 @@ export type PossibleRequestData = undefined | {
768
774
  add?: string[];
769
775
  remove?: string[];
770
776
  };
777
+ export {};
@@ -513,7 +513,14 @@ class CADManager extends BaseManager_1.BaseManager {
513
513
  * Creates a new dispatch call.
514
514
  */
515
515
  async createDispatch(data) {
516
- return this.executeCadRequest('NEW_DISPATCH', data);
516
+ const hasUnits = Array.isArray(data.units);
517
+ const hasAccounts = Array.isArray(data.accounts);
518
+ const payload = {
519
+ ...data,
520
+ ...(hasUnits ? { units: data.units } : {}),
521
+ ...(hasAccounts ? { accounts: data.accounts } : {})
522
+ };
523
+ return this.executeCadRequest('NEW_DISPATCH', payload);
517
524
  }
518
525
  async attachUnits(serverIdOrParams, callId, unitsOrAccount) {
519
526
  let payload;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonoransoftware/sonoran.js",
3
- "version": "1.0.49",
3
+ "version": "1.0.50",
4
4
  "description": "Sonoran.js is a library that allows you to interact with the Sonoran CAD and Sonoran CMS API. Based off of and utilizes several Discord.js library techniques for ease of use.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/readme.md CHANGED
@@ -128,7 +128,7 @@ await instance.cad.setUnitPanic({ account: '91de0ce8-c571-11e9-9714-5600023b2434
128
128
  - **`create911Call(details)`** / **`remove911Call(callId)`**
129
129
  - **`getCalls(options)`**
130
130
  - **`getMyCall({ account })`**
131
- - **`createDispatch(data)`**
131
+ - **`createDispatch(data)`** - accepts either `units` (API IDs) or `accounts` (account UUIDs) as arrays.
132
132
  - **`attachUnits(serverId, callId, unitsOrAccount)`** / **`detachUnits(serverId, unitsOrAccount)`**
133
133
  - **`setCallPostal(serverId, callId, postal)`** / **`setCallPrimary(serverId, callId, primary, trackPrimary)`**
134
134
  - **`addCallNote({ serverId, callId, note, label? })`**
@@ -151,6 +151,22 @@ const dispatch = await instance.cad.createDispatch({
151
151
  metaData: {},
152
152
  units: ['unit-1']
153
153
  });
154
+ const dispatchByAccount = await instance.cad.createDispatch({
155
+ serverId: 1,
156
+ origin: Sonoran.CADDispatchOriginEnums.WalkUp,
157
+ status: Sonoran.CADDispatchStatusEnums.Active,
158
+ priority: 2,
159
+ block: '456',
160
+ address: '2nd St',
161
+ postal: '200',
162
+ title: 'Suspicious Person',
163
+ code: 'SP',
164
+ primary: 43,
165
+ trackPrimary: false,
166
+ description: 'Individual loitering near storefront',
167
+ metaData: {},
168
+ accounts: ['91de0ce8-c571-11e9-9714-5600023b2434']
169
+ });
154
170
  await instance.cad.attachUnits(1, 1001, ['unit-2']);
155
171
  // Or attach a single unit by account UUID
156
172
  await instance.cad.attachUnits({ serverId: 1, callId: 1001, account: '91de0ce8-c571-11e9-9714-5600023b2434' });
@@ -910,7 +910,7 @@ export enum CADDispatchStatusEnums {
910
910
  Closed
911
911
  }
912
912
 
913
- export interface CADNewDispatchStruct {
913
+ interface CADNewDispatchBaseStruct {
914
914
  serverId: number;
915
915
  origin: CADDispatchOriginEnums;
916
916
  status: CADDispatchStatusEnums;
@@ -924,9 +924,12 @@ export interface CADNewDispatchStruct {
924
924
  trackPrimary: boolean;
925
925
  description: string;
926
926
  metaData: Record<string, string>;
927
- units: string[];
928
927
  }
929
928
 
929
+ export type CADNewDispatchStruct =
930
+ | (CADNewDispatchBaseStruct & { units: string[]; accounts?: string[] })
931
+ | (CADNewDispatchBaseStruct & { units?: string[]; accounts: string[] });
932
+
930
933
  export interface CADStreetSignStruct {
931
934
  id: number;
932
935
  label: string;
@@ -562,7 +562,14 @@ export class CADManager extends BaseManager {
562
562
  * Creates a new dispatch call.
563
563
  */
564
564
  public async createDispatch(data: CADNewDispatchStruct): Promise<globalTypes.CADStandardResponse> {
565
- return this.executeCadRequest('NEW_DISPATCH', data);
565
+ const hasUnits = Array.isArray(data.units);
566
+ const hasAccounts = Array.isArray(data.accounts);
567
+ const payload: CADNewDispatchStruct = {
568
+ ...data,
569
+ ...(hasUnits ? { units: data.units } : {}),
570
+ ...(hasAccounts ? { accounts: data.accounts } : {})
571
+ };
572
+ return this.executeCadRequest('NEW_DISPATCH', payload);
566
573
  }
567
574
 
568
575
  /**