@@ -66,13 +66,15 @@ export default class Client {
66
66
to : string ,
67
67
messages : Types . Message | Types . Message [ ] ,
68
68
notificationDisabled : boolean = false ,
69
+ customAggregationUnits ?: string [ ] ,
69
70
) : Promise < Types . MessageAPIResponseBase > {
70
71
return this . http . post (
71
72
`${ MESSAGING_API_PREFIX } /message/push` ,
72
73
{
73
74
messages : toArray ( messages ) ,
74
75
to,
75
76
notificationDisabled,
77
+ customAggregationUnits,
76
78
} ,
77
79
this . generateRequestConfig ( ) ,
78
80
) ;
@@ -94,13 +96,15 @@ export default class Client {
94
96
to : string [ ] ,
95
97
messages : Types . Message | Types . Message [ ] ,
96
98
notificationDisabled : boolean = false ,
99
+ customAggregationUnits ?: string [ ] ,
97
100
) : Promise < Types . MessageAPIResponseBase > {
98
101
return this . http . post (
99
102
`${ MESSAGING_API_PREFIX } /message/multicast` ,
100
103
{
101
104
messages : toArray ( messages ) ,
102
105
to,
103
106
notificationDisabled,
107
+ customAggregationUnits,
104
108
} ,
105
109
this . generateRequestConfig ( ) ,
106
110
) ;
@@ -196,6 +200,33 @@ export default class Client {
196
200
) ;
197
201
}
198
202
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
+
199
230
public async getProfile ( userId : string ) : Promise < Types . Profile > {
200
231
const profile = await this . http . get < Types . Profile > (
201
232
`${ MESSAGING_API_PREFIX } /profile/${ userId } ` ,
0 commit comments