@@ -66,13 +66,15 @@ export default class Client {
6666 to : string ,
6767 messages : Types . Message | Types . Message [ ] ,
6868 notificationDisabled : boolean = false ,
69+ customAggregationUnits ?: string [ ] ,
6970 ) : Promise < Types . MessageAPIResponseBase > {
7071 return this . http . post (
7172 `${ MESSAGING_API_PREFIX } /message/push` ,
7273 {
7374 messages : toArray ( messages ) ,
7475 to,
7576 notificationDisabled,
77+ customAggregationUnits,
7678 } ,
7779 this . generateRequestConfig ( ) ,
7880 ) ;
@@ -94,13 +96,15 @@ export default class Client {
9496 to : string [ ] ,
9597 messages : Types . Message | Types . Message [ ] ,
9698 notificationDisabled : boolean = false ,
99+ customAggregationUnits ?: string [ ] ,
97100 ) : Promise < Types . MessageAPIResponseBase > {
98101 return this . http . post (
99102 `${ MESSAGING_API_PREFIX } /message/multicast` ,
100103 {
101104 messages : toArray ( messages ) ,
102105 to,
103106 notificationDisabled,
107+ customAggregationUnits,
104108 } ,
105109 this . generateRequestConfig ( ) ,
106110 ) ;
@@ -196,6 +200,33 @@ export default class Client {
196200 ) ;
197201 }
198202
203+ public validateCustomAggregationUnits ( units : string [ ] ) : {
204+ messages : string [ ] ;
205+ valid : boolean ;
206+ } {
207+ const messages : string [ ] = [ ] ;
208+ if ( units . length > 1 ) {
209+ messages . push ( "customAggregationUnits can only contain one unit" ) ;
210+ }
211+ units . forEach ( ( unit , index ) => {
212+ if ( unit . length > 30 ) {
213+ messages . push (
214+ `customAggregationUnits[${ index } ] must be less than or equal to 30 characters` ,
215+ ) ;
216+ }
217+ if ( ! / ^ [ a - z A - Z 0 - 9 _ ] + $ / . test ( unit ) ) {
218+ messages . push (
219+ `customAggregationUnits[${ index } ] must be alphanumeric characters or underscores` ,
220+ ) ;
221+ }
222+ } ) ;
223+
224+ return {
225+ messages,
226+ valid : messages . length === 0 ,
227+ } ;
228+ }
229+
199230 public async getProfile ( userId : string ) : Promise < Types . Profile > {
200231 const profile = await this . http . get < Types . Profile > (
201232 `${ MESSAGING_API_PREFIX } /profile/${ userId } ` ,
0 commit comments