@sonoransoftware/sonoran.js 1.0.69 → 1.0.70

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.
@@ -231,11 +231,14 @@ class REST extends events_1.EventEmitter {
231
231
  if (payload && typeof payload === 'object' && !Array.isArray(payload)) {
232
232
  return payload;
233
233
  }
234
+ const noteTypeOrLabel = args[3];
235
+ const isNoteType = noteTypeOrLabel === 'text' || noteTypeOrLabel === 'link';
234
236
  return {
235
237
  serverId: args[0],
236
238
  callId: args[1],
237
239
  note: args[2],
238
- label: args[3]
240
+ noteType: isNoteType ? noteTypeOrLabel : undefined,
241
+ label: isNoteType ? args[4] : noteTypeOrLabel
239
242
  };
240
243
  }
241
244
  case 'REMOVE_911': {
@@ -249,6 +249,7 @@ export interface CADAddCallNoteStruct {
249
249
  callId: number;
250
250
  note: string;
251
251
  label?: string;
252
+ noteType?: 'text' | 'link';
252
253
  }
253
254
  export interface CADRemove911Struct {
254
255
  serverId: number;
@@ -470,6 +471,11 @@ export interface RESTTypedAPIDataStructs {
470
471
  serverId: number,
471
472
  callId: number,
472
473
  note: string
474
+ ] | [
475
+ serverId: number,
476
+ callId: number,
477
+ note: string,
478
+ noteType: 'text' | 'link'
473
479
  ] | [
474
480
  data: CADAddCallNoteStruct
475
481
  ];
@@ -251,6 +251,7 @@ export declare class CADManager extends BaseManager {
251
251
  * Adds a note to an active call.
252
252
  */
253
253
  addCallNote(serverId: number, callId: number, note: string, label?: string): Promise<globalTypes.CADStandardResponse>;
254
+ addCallNote(serverId: number, callId: number, note: string, noteType: 'text' | 'link', label?: string): Promise<globalTypes.CADStandardResponse>;
254
255
  addCallNote(params: CADAddCallNoteStruct): Promise<globalTypes.CADStandardResponse>;
255
256
  /**
256
257
  * Closes a CAD call.
@@ -680,22 +680,29 @@ class CADManager extends BaseManager_1.BaseManager {
680
680
  }
681
681
  return this.executeCadRequest('SET_CALL_PRIMARY', serverId, callId, primary, trackPrimary);
682
682
  }
683
- async addCallNote(serverIdOrParams, callId, note, label) {
683
+ async addCallNote(serverIdOrParams, callId, note, noteTypeOrLabel, label) {
684
684
  let payload;
685
685
  if (serverIdOrParams && typeof serverIdOrParams === 'object') {
686
686
  payload = { ...serverIdOrParams };
687
687
  }
688
688
  else {
689
- payload = { serverId: serverIdOrParams, callId: callId, note: note, label };
689
+ const isNoteType = noteTypeOrLabel === 'text' || noteTypeOrLabel === 'link';
690
+ payload = {
691
+ serverId: serverIdOrParams,
692
+ callId: callId,
693
+ note: note,
694
+ noteType: isNoteType ? noteTypeOrLabel : undefined,
695
+ label: isNoteType ? label : noteTypeOrLabel
696
+ };
690
697
  }
691
- const { serverId, callId: resolvedCallId, note: resolvedNote, label: resolvedLabel } = payload;
698
+ const { serverId, callId: resolvedCallId, note: resolvedNote, label: resolvedLabel, noteType } = payload;
692
699
  if (!Number.isInteger(serverId) || !Number.isInteger(resolvedCallId)) {
693
700
  throw new Error('serverId and callId must be integers when adding a call note.');
694
701
  }
695
702
  if (!resolvedNote) {
696
703
  throw new Error('note is required when adding a call note.');
697
704
  }
698
- return this.executeCadRequest('ADD_CALL_NOTE', { serverId, callId: resolvedCallId, note: resolvedNote, label: resolvedLabel });
705
+ return this.executeCadRequest('ADD_CALL_NOTE', { serverId, callId: resolvedCallId, note: resolvedNote, label: resolvedLabel, noteType });
699
706
  }
700
707
  /**
701
708
  * Closes a CAD call.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonoransoftware/sonoran.js",
3
- "version": "1.0.69",
3
+ "version": "1.0.70",
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
@@ -136,7 +136,7 @@ await instance.cad.setUnitPanic({ identIds: [101, 102], isPanic: true });
136
136
  - **`createDispatch(data)`** - accepts either `units` (API IDs) or `accounts` (account UUIDs) as arrays.
137
137
  - **`attachUnits(serverId, callId, unitsOrAccount)`** / **`detachUnits(serverId, unitsOrAccount)`**
138
138
  - **`setCallPostal(serverId, callId, postal)`** / **`setCallPrimary(serverId, callId, primary, trackPrimary)`**
139
- - **`addCallNote({ serverId, callId, note, label? })`**
139
+ - **`addCallNote({ serverId, callId, note, noteType?, label? })`**
140
140
  - **`closeCall(serverId, callId)`**
141
141
 
142
142
  ```js
@@ -179,8 +179,8 @@ await instance.cad.attachUnits({ serverId: 1, callId: 1001, account: '91de0ce8-c
179
179
  await instance.cad.detachUnits({ serverId: 1, account: '91de0ce8-c571-11e9-9714-5600023b2434' });
180
180
  // Fetch the current call for an account UUID
181
181
  const myCall = await instance.cad.getMyCall({ account: '91de0ce8-c571-11e9-9714-5600023b2434' });
182
- // Add a call note with optional label
183
- await instance.cad.addCallNote({ serverId: 1, callId: 1001, note: 'This is a test!', label: 'A-10' });
182
+ // Add a call note with optional type/label
183
+ await instance.cad.addCallNote({ serverId: 1, callId: 1001, note: 'This is a test!', noteType: 'text', label: 'A-10' });
184
184
  ```
185
185
 
186
186
  ## CAD Server Functions
@@ -335,11 +335,14 @@ export class REST extends EventEmitter {
335
335
  if (payload && typeof payload === 'object' && !Array.isArray(payload)) {
336
336
  return payload;
337
337
  }
338
+ const noteTypeOrLabel = args[3];
339
+ const isNoteType = noteTypeOrLabel === 'text' || noteTypeOrLabel === 'link';
338
340
  return {
339
341
  serverId: args[0],
340
342
  callId: args[1],
341
343
  note: args[2],
342
- label: args[3]
344
+ noteType: isNoteType ? noteTypeOrLabel : undefined,
345
+ label: isNoteType ? args[4] : noteTypeOrLabel
343
346
  };
344
347
  }
345
348
  case 'REMOVE_911': {
@@ -954,6 +954,7 @@ export interface CADAddCallNoteStruct {
954
954
  callId: number;
955
955
  note: string;
956
956
  label?: string;
957
+ noteType?: 'text' | 'link';
957
958
  }
958
959
 
959
960
  export interface CADRemove911Struct {
@@ -1184,6 +1185,11 @@ export interface RESTTypedAPIDataStructs {
1184
1185
  serverId: number,
1185
1186
  callId: number,
1186
1187
  note: string
1188
+ ] | [
1189
+ serverId: number,
1190
+ callId: number,
1191
+ note: string,
1192
+ noteType: 'text' | 'link'
1187
1193
  ] | [
1188
1194
  data: CADAddCallNoteStruct
1189
1195
  ];
@@ -766,27 +766,36 @@ export class CADManager extends BaseManager {
766
766
  * Adds a note to an active call.
767
767
  */
768
768
  public async addCallNote(serverId: number, callId: number, note: string, label?: string): Promise<globalTypes.CADStandardResponse>;
769
+ public async addCallNote(serverId: number, callId: number, note: string, noteType: 'text' | 'link', label?: string): Promise<globalTypes.CADStandardResponse>;
769
770
  public async addCallNote(params: CADAddCallNoteStruct): Promise<globalTypes.CADStandardResponse>;
770
771
  public async addCallNote(
771
772
  serverIdOrParams: number | CADAddCallNoteStruct,
772
773
  callId?: number,
773
774
  note?: string,
775
+ noteTypeOrLabel?: 'text' | 'link' | string,
774
776
  label?: string
775
777
  ): Promise<globalTypes.CADStandardResponse> {
776
778
  let payload: CADAddCallNoteStruct;
777
779
  if (serverIdOrParams && typeof serverIdOrParams === 'object') {
778
780
  payload = { ...serverIdOrParams };
779
781
  } else {
780
- payload = { serverId: serverIdOrParams as number, callId: callId as number, note: note as string, label };
782
+ const isNoteType = noteTypeOrLabel === 'text' || noteTypeOrLabel === 'link';
783
+ payload = {
784
+ serverId: serverIdOrParams as number,
785
+ callId: callId as number,
786
+ note: note as string,
787
+ noteType: isNoteType ? (noteTypeOrLabel as 'text' | 'link') : undefined,
788
+ label: isNoteType ? label : (noteTypeOrLabel as string | undefined)
789
+ };
781
790
  }
782
- const { serverId, callId: resolvedCallId, note: resolvedNote, label: resolvedLabel } = payload;
791
+ const { serverId, callId: resolvedCallId, note: resolvedNote, label: resolvedLabel, noteType } = payload;
783
792
  if (!Number.isInteger(serverId) || !Number.isInteger(resolvedCallId)) {
784
793
  throw new Error('serverId and callId must be integers when adding a call note.');
785
794
  }
786
795
  if (!resolvedNote) {
787
796
  throw new Error('note is required when adding a call note.');
788
797
  }
789
- return this.executeCadRequest('ADD_CALL_NOTE', { serverId, callId: resolvedCallId, note: resolvedNote, label: resolvedLabel });
798
+ return this.executeCadRequest('ADD_CALL_NOTE', { serverId, callId: resolvedCallId, note: resolvedNote, label: resolvedLabel, noteType });
790
799
  }
791
800
 
792
801
  /**