@sonoransoftware/sonoran.js 1.0.48 → 1.0.49

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.
@@ -504,7 +504,7 @@ export interface RadioTonePlayTarget {
504
504
  color?: string;
505
505
  }
506
506
  export interface RadioSetUserChannelsOptions {
507
- transmit?: number;
507
+ transmit?: number[];
508
508
  scan?: number[];
509
509
  }
510
510
  export type RadioSubscriptionLevel = 0 | 1 | 2;
@@ -403,11 +403,26 @@ class RequestManager extends events_1.EventEmitter {
403
403
  path = `${apiType.path}/${auth.encodedId}/${auth.encodedKey}/${encodeSegment(roomIdNumeric)}/${encodeSegment(identity)}`;
404
404
  method = 'POST';
405
405
  const requestBody = {};
406
- if ((options === null || options === void 0 ? void 0 : options.transmit) !== undefined) {
407
- requestBody.transmit = options.transmit;
406
+ const normalizeNumberArray = (label, value) => {
407
+ if (value === undefined)
408
+ return undefined;
409
+ const asArray = Array.isArray(value) ? value : [value];
410
+ const numbers = asArray.map((entry) => {
411
+ const numeric = typeof entry === 'number' ? entry : Number(entry);
412
+ if (Number.isNaN(numeric)) {
413
+ throw new Error(`${label} must be a number or array of numbers for RADIO_SET_USER_CHANNELS requests.`);
414
+ }
415
+ return numeric;
416
+ });
417
+ return numbers;
418
+ };
419
+ const transmit = normalizeNumberArray('transmit', options === null || options === void 0 ? void 0 : options.transmit);
420
+ if (transmit !== undefined) {
421
+ requestBody.transmit = transmit;
408
422
  }
409
- if ((options === null || options === void 0 ? void 0 : options.scan) !== undefined) {
410
- requestBody.scan = options.scan;
423
+ const scan = normalizeNumberArray('scan', options === null || options === void 0 ? void 0 : options.scan);
424
+ if (scan !== undefined) {
425
+ requestBody.scan = scan;
411
426
  }
412
427
  body = requestBody;
413
428
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sonoransoftware/sonoran.js",
3
- "version": "1.0.48",
3
+ "version": "1.0.49",
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
@@ -470,7 +470,7 @@ const user = await instance.radio.getConnectedUser(1, 'account-uuid');
470
470
  ### setUserChannels(roomId, identity, options)
471
471
  Updates a user's transmit or scan channels for a specific radio room.
472
472
  ```js
473
- await instance.radio.setUserChannels(1, 'account-uuid', { transmit: 12, scan: [10, 11, 12] });
473
+ await instance.radio.setUserChannels(1, 'account-uuid', { transmit: [12], scan: [10, 11, 12] });
474
474
  ```
475
475
 
476
476
  ### setUserDisplayName(accId, displayName)
package/src/constants.ts CHANGED
@@ -569,7 +569,7 @@ export interface RadioTonePlayTarget {
569
569
  }
570
570
 
571
571
  export interface RadioSetUserChannelsOptions {
572
- transmit?: number;
572
+ transmit?: number[];
573
573
  scan?: number[];
574
574
  }
575
575
 
@@ -470,11 +470,25 @@ export class RequestManager extends EventEmitter {
470
470
  path = `${apiType.path}/${auth.encodedId}/${auth.encodedKey}/${encodeSegment(roomIdNumeric)}/${encodeSegment(identity)}`;
471
471
  method = 'POST';
472
472
  const requestBody: Record<string, unknown> = {};
473
- if (options?.transmit !== undefined) {
474
- requestBody.transmit = options.transmit;
473
+ const normalizeNumberArray = (label: string, value: unknown) => {
474
+ if (value === undefined) return undefined;
475
+ const asArray = Array.isArray(value) ? value : [value];
476
+ const numbers = asArray.map((entry) => {
477
+ const numeric = typeof entry === 'number' ? entry : Number(entry);
478
+ if (Number.isNaN(numeric)) {
479
+ throw new Error(`${label} must be a number or array of numbers for RADIO_SET_USER_CHANNELS requests.`);
480
+ }
481
+ return numeric;
482
+ });
483
+ return numbers;
484
+ };
485
+ const transmit = normalizeNumberArray('transmit', options?.transmit);
486
+ if (transmit !== undefined) {
487
+ requestBody.transmit = transmit;
475
488
  }
476
- if (options?.scan !== undefined) {
477
- requestBody.scan = options.scan;
489
+ const scan = normalizeNumberArray('scan', options?.scan);
490
+ if (scan !== undefined) {
491
+ requestBody.scan = scan;
478
492
  }
479
493
  body = requestBody;
480
494
  break;