@superoffice/webapi 12.1.1412 → 12.2.2072

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.
Files changed (51) hide show
  1. package/dist/cjs/Carriers.d.ts +219 -4
  2. package/dist/cjs/Carriers.d.ts.map +1 -1
  3. package/dist/cjs/Converters.d.ts +6 -0
  4. package/dist/cjs/Converters.d.ts.map +1 -1
  5. package/dist/cjs/Converters.js +129 -1
  6. package/dist/cjs/Converters.js.map +1 -1
  7. package/dist/cjs/EMailAgent.d.ts +16 -0
  8. package/dist/cjs/EMailAgent.d.ts.map +1 -1
  9. package/dist/cjs/EMailAgent.js +48 -0
  10. package/dist/cjs/EMailAgent.js.map +1 -1
  11. package/dist/cjs/Enums.d.ts +71 -1
  12. package/dist/cjs/Enums.d.ts.map +1 -1
  13. package/dist/cjs/Enums.js +75 -2
  14. package/dist/cjs/Enums.js.map +1 -1
  15. package/dist/cjs/NewsFeedAgent.d.ts +141 -0
  16. package/dist/cjs/NewsFeedAgent.d.ts.map +1 -0
  17. package/dist/cjs/NewsFeedAgent.js +292 -0
  18. package/dist/cjs/NewsFeedAgent.js.map +1 -0
  19. package/dist/cjs/WebApi.d.ts +6 -0
  20. package/dist/cjs/WebApi.d.ts.map +1 -1
  21. package/dist/cjs/WebApi.js +10 -1
  22. package/dist/cjs/WebApi.js.map +1 -1
  23. package/dist/esm/Carriers.d.ts +219 -4
  24. package/dist/esm/Carriers.d.ts.map +1 -1
  25. package/dist/esm/Converters.d.ts +6 -0
  26. package/dist/esm/Converters.d.ts.map +1 -1
  27. package/dist/esm/Converters.js +122 -0
  28. package/dist/esm/Converters.js.map +1 -1
  29. package/dist/esm/EMailAgent.d.ts +16 -0
  30. package/dist/esm/EMailAgent.d.ts.map +1 -1
  31. package/dist/esm/EMailAgent.js +48 -0
  32. package/dist/esm/EMailAgent.js.map +1 -1
  33. package/dist/esm/Enums.d.ts +71 -1
  34. package/dist/esm/Enums.d.ts.map +1 -1
  35. package/dist/esm/Enums.js +74 -1
  36. package/dist/esm/Enums.js.map +1 -1
  37. package/dist/esm/NewsFeedAgent.d.ts +141 -0
  38. package/dist/esm/NewsFeedAgent.d.ts.map +1 -0
  39. package/dist/esm/NewsFeedAgent.js +287 -0
  40. package/dist/esm/NewsFeedAgent.js.map +1 -0
  41. package/dist/esm/WebApi.d.ts +6 -0
  42. package/dist/esm/WebApi.d.ts.map +1 -1
  43. package/dist/esm/WebApi.js +9 -0
  44. package/dist/esm/WebApi.js.map +1 -1
  45. package/package.json +4 -4
  46. package/src/Carriers.ts +287 -4
  47. package/src/Converters.ts +142 -0
  48. package/src/EMailAgent.ts +76 -0
  49. package/src/Enums.ts +77 -1
  50. package/src/NewsFeedAgent.ts +481 -0
  51. package/src/WebApi.ts +12 -0
@@ -0,0 +1,481 @@
1
+ // <auto-generated>
2
+ // SuperOffice Code Generator
3
+ // modelling\templates\servicestswebapi\tswebapiagents.tt
4
+ // </auto-generated>
5
+
6
+
7
+ /* tslint:disable */
8
+ //----------------------------------------------------------------------------
9
+ // G E N E R A T E D F I L E ! D O N O T E D I T !
10
+ //----------------------------------------------------------------------------
11
+ //
12
+ // File: WebApi/NewsFeedAgent.ts
13
+ //
14
+ //----------------------------------------------------------------------------
15
+ // Copyright (C) SuperOffice AS
16
+ //----------------------------------------------------------------------------
17
+
18
+ import { AxiosRequestConfig } from 'axios';
19
+ import { Duration } from 'dayjs/plugin/duration';
20
+ import * as enums from './Enums';
21
+ import * as base from './WebApiBase';
22
+ import * as carriers from './Carriers';
23
+ import * as converters from './Converters';
24
+ import { FromBase64ToString, ToBase64 } from './Base64';
25
+
26
+ /**
27
+ * Posting and reading Newsfeed items, marking them as read or as handled.
28
+ */
29
+ export interface INewsFeedAgent {
30
+ createDefaultNewsFeedItemAsync(): Promise< carriers.NewsFeedItem >;
31
+ deleteNewsFeedItemAsync(NewsFeedItemId: number) : Promise<void>;
32
+ getNewsFeedItemAsync(newsFeedItemId: number) : Promise< carriers.NewsFeedItem >;
33
+ postNewsFeedItemAsync(request: carriers.NewsFeed_PostNewsFeedItemRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.NewsFeedItem >;
34
+ postNewsFeedItemAsync(newsFeedItem: carriers.NewsFeedItem, toAssociateIds: number[], toGroupIds: number[], toAll: boolean, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.NewsFeedItem >;
35
+ getNewsFeedItemsByIdAsync(request: carriers.NewsFeed_GetNewsFeedItemsByIdRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.NewsFeedItem[] >;
36
+ getNewsFeedItemsByIdAsync(newsFeedItemIds: number[], webapi_options?:base.WebApiRequestOptions) : Promise< carriers.NewsFeedItem[] >;
37
+ getNewsItemsForUserAsync(request: carriers.NewsFeed_GetNewsItemsForUserRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.NewsFeedItem[] >;
38
+ getNewsItemsForUserAsync(associateId: number, fromDate: Date, toDate: Date, top: number, skip: number, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.NewsFeedItem[] >;
39
+ markAsReadAsync(request: carriers.NewsFeed_MarkAsReadRequest, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
40
+ markAsReadAsync(newsFeedItemId: number, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
41
+ startHandlingAsync(request: carriers.NewsFeed_StartHandlingRequest, webapi_options?:base.WebApiRequestOptions) : Promise< boolean >;
42
+ startHandlingAsync(newsFeedItemId: number, webapi_options?:base.WebApiRequestOptions) : Promise< boolean >;
43
+ markAsHandledAsync(request: carriers.NewsFeed_MarkAsHandledRequest, webapi_options?:base.WebApiRequestOptions) : Promise< boolean >;
44
+ markAsHandledAsync(newsFeedItemId: number, webapi_options?:base.WebApiRequestOptions) : Promise< boolean >;
45
+ } // interface INewsFeedAgent
46
+
47
+
48
+
49
+
50
+ /**
51
+ * Posting and reading Newsfeed items, marking them as read or as handled.
52
+ */
53
+ export class NewsFeedAgent extends base.WebApiBase implements INewsFeedAgent {
54
+ constructor(baseUrl?: string, languageCode?:string, cultureCode?: string);
55
+ constructor(baseUrl?: string, resourceParsing?: base.ResourceParsing);
56
+ constructor(baseUrl: string, resourceManager:any);
57
+ constructor(baseUrl: string, config:AxiosRequestConfig, resourceManager:any);
58
+ constructor(baseUrl: string, config:AxiosRequestConfig, resourceParsing?: base.ResourceParsing);
59
+ constructor(baseUrl: string, config:AxiosRequestConfig, languageCode?:string, cultureCode?: string);
60
+ constructor(options: base.WebApiOptions);
61
+
62
+ constructor(baseUrlOrOptions: string|base.WebApiOptions|undefined,
63
+ langOrconfigOrRM?: string|base.ResourceParsing|AxiosRequestConfig|any,
64
+ langOrResourceOrRM?:string|base.ResourceParsing|any,
65
+ cultureCode?: string,
66
+ ) {
67
+ const options = base.WebApiBase.FigureOutOptions(baseUrlOrOptions, langOrconfigOrRM, langOrResourceOrRM, cultureCode);
68
+ options.basePath = "v1/Agents/NewsFeed/";
69
+ super(options);
70
+ }
71
+
72
+
73
+
74
+ /**
75
+ * Set default values into a new NewsFeedItem.
76
+ * NetServer calculates default values on the entity, which is required when creating/storing a new instance
77
+ * @param options - Override language/culture codes on this request. Provide cancellation and request status values.
78
+ * @returns A blank entity.
79
+ */
80
+ public async createDefaultNewsFeedItemAsync(options?:base.WebApiRequestOptions) : Promise< carriers.NewsFeedItem > {
81
+ const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
82
+ base.WebApiBase.SetPending(options);
83
+ return new Promise< carriers.NewsFeedItem >(async (resolve, reject) => {
84
+ try {
85
+ const response = await this._axios.post("CreateDefaultNewsFeedItem", null, config);
86
+ base.WebApiBase.SetCompleted(options, response);
87
+ const res : carriers.NewsFeedItem = converters.Create_NewsFeedItem_From( response.data );
88
+ resolve(res);
89
+ }
90
+ catch( err ) {
91
+ base.WebApiBase.HandleError(options, config, err);
92
+ reject(err);
93
+ }
94
+ });
95
+ }
96
+
97
+ /**
98
+ * Deletes the NewsFeedItem
99
+ * @param NewsFeedItemId - The id of the NewsFeedItem to be deleted.
100
+ * @param options - Override language/culture codes on this request. Provide cancellation and request status values.
101
+ */
102
+ public async deleteNewsFeedItemAsync(NewsFeedItemId: number, options?:base.WebApiRequestOptions) : Promise< void > {
103
+ const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
104
+ base.WebApiBase.SetPending(options);
105
+ return new Promise< void >(async (resolve, reject) => {
106
+ try {
107
+ const response = await this._axios.post("DeleteNewsFeedItem?NewsFeedItemId=" + NewsFeedItemId, null, config );
108
+ base.WebApiBase.SetCompleted(options, response);
109
+ const res = response.data;
110
+ resolve(res);
111
+ }
112
+ catch( err ) {
113
+ base.WebApiBase.HandleError(options, config, err);
114
+ reject(err);
115
+ }
116
+ });
117
+ }
118
+ /**
119
+ * Gets a NewsFeedItem object.
120
+ * @param newsFeedItemId - The primary key.
121
+ * @param options - Override language/culture codes on this request. Provide cancellation and request status values.
122
+ * @returns A single NewsFeedItem
123
+ */
124
+ public async getNewsFeedItemAsync(newsFeedItemId: number, options?:base.WebApiRequestOptions) : Promise< carriers.NewsFeedItem > {
125
+ const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
126
+ base.WebApiBase.SetPending(options);
127
+ return new Promise< carriers.NewsFeedItem >(async (resolve, reject) => {
128
+ try {
129
+ const response = await this._axios.post("GetNewsFeedItem?newsFeedItemId=" + newsFeedItemId, null, config);
130
+ base.WebApiBase.SetCompleted(options, response);
131
+ const res = converters.Create_NewsFeedItem_From( response.data );
132
+ resolve(res);
133
+ }
134
+ catch( err ) {
135
+ base.WebApiBase.HandleError(options, config, err);
136
+ reject(err);
137
+ }
138
+ });
139
+ }
140
+
141
+
142
+ private async _postNewsFeedItemAsync(request: carriers.NewsFeed_PostNewsFeedItemRequest, options?:base.WebApiRequestOptions) : Promise< carriers.NewsFeedItem > {
143
+ const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
144
+ base.WebApiBase.SetPending(options);
145
+ return new Promise< carriers.NewsFeedItem >(async (resolve, reject) => {
146
+ try {
147
+ config.baseURL = this._options.baseUrl;
148
+ const response = await this._axios.post("PostNewsFeedItem", request , config);
149
+ base.WebApiBase.SetCompleted(options, response);
150
+ const res : carriers.NewsFeedItem = converters.Create_NewsFeedItem_From( response.data );
151
+ resolve(res);
152
+ }
153
+ catch( err ) {
154
+ base.WebApiBase.HandleError(options, config, err);
155
+ reject(err);
156
+ }
157
+ });
158
+ }
159
+
160
+
161
+
162
+ /**
163
+ * Saves a new item to the newsfeed, publishing it to the specified users.
164
+ * @param request - NewsFeedItem, ToAssociateIds, ToGroupIds, ToAll
165
+ * @returns The news feed item that was posted, including its new id.
166
+ */
167
+ public async postNewsFeedItemAsync(request: carriers.NewsFeed_PostNewsFeedItemRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.NewsFeedItem >;
168
+
169
+ /**
170
+ * Saves a new item to the newsfeed, publishing it to the specified users.
171
+ * @param newsFeedItem - The news feed item to post. NewsFeedItemId is ignored, as a new id will be generated when posting to the newsfeed.
172
+ * @param toAssociateIds - List of associate ids that this news feed item is sent to.
173
+ * @param toGroupIds - List of group ids that this news feed item is sent to. This gets resolved to associate ids when posted.
174
+ * @param toAll - Indicates if this news feed item is sent to all users. Gets resolved into all users when posted.
175
+ * @returns The news feed item that was posted, including its new id.
176
+ */
177
+ public async postNewsFeedItemAsync(newsFeedItem: carriers.NewsFeedItem, toAssociateIds: number[], toGroupIds: number[], toAll: boolean, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.NewsFeedItem >;
178
+
179
+ public async postNewsFeedItemAsync(newsFeedItem:carriers.NewsFeedItem|carriers.NewsFeed_PostNewsFeedItemRequest, toAssociateIds?:number[]|base.WebApiRequestOptions, toGroupIds?:number[], toAll?:boolean, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.NewsFeedItem > {
180
+ let _request : carriers.NewsFeed_PostNewsFeedItemRequest = null;
181
+ let _options : base.WebApiRequestOptions = null;
182
+ const first : any = newsFeedItem;
183
+ if( typeof( first ) === "object" && first && ( typeof(first.newsFeedItem)!='undefined' || typeof(first.toAssociateIds)!='undefined' || typeof(first.toGroupIds)!='undefined' || typeof(first.toAll)!='undefined' ) )
184
+ {
185
+ _request = newsFeedItem as carriers.NewsFeed_PostNewsFeedItemRequest;
186
+ _options = toAssociateIds as base.WebApiRequestOptions;
187
+ }
188
+ else
189
+ {
190
+ _request = {
191
+ newsFeedItem: newsFeedItem as carriers.NewsFeedItem,
192
+ toAssociateIds: toAssociateIds as number[],
193
+ toGroupIds: toGroupIds as number[],
194
+ toAll: toAll as boolean,
195
+ };
196
+ _options = webapi_options;
197
+ }
198
+ return this._postNewsFeedItemAsync( _request, _options );
199
+ }
200
+
201
+
202
+ private async _getNewsFeedItemsByIdAsync(request: carriers.NewsFeed_GetNewsFeedItemsByIdRequest, options?:base.WebApiRequestOptions) : Promise< carriers.NewsFeedItem[] > {
203
+ const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
204
+ base.WebApiBase.SetPending(options);
205
+ return new Promise< carriers.NewsFeedItem[] >(async (resolve, reject) => {
206
+ try {
207
+ config.baseURL = this._options.baseUrl;
208
+ const response = await this._axios.post("GetNewsFeedItemsById", request , config);
209
+ base.WebApiBase.SetCompleted(options, response);
210
+ const res : carriers.NewsFeedItem[] = converters.Create_NewsFeedItemArray_From( response.data );
211
+ resolve(res);
212
+ }
213
+ catch( err ) {
214
+ base.WebApiBase.HandleError(options, config, err);
215
+ reject(err);
216
+ }
217
+ });
218
+ }
219
+
220
+
221
+
222
+ /**
223
+ * Get an array of items from the newsfeed by id. If the current user cannot access a particular item, it will be excluded from the results.
224
+ * @param request - NewsFeedItemIds
225
+ * @returns The news feed items that was posted, or null if not found/not accessible by the user.
226
+ */
227
+ public async getNewsFeedItemsByIdAsync(request: carriers.NewsFeed_GetNewsFeedItemsByIdRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.NewsFeedItem[] >;
228
+
229
+ /**
230
+ * Get an array of items from the newsfeed by id. If the current user cannot access a particular item, it will be excluded from the results.
231
+ * @param newsFeedItemIds - Ids of the news feed items to mark as seen for this user.
232
+ * @returns The news feed items that was posted, or null if not found/not accessible by the user.
233
+ */
234
+ public async getNewsFeedItemsByIdAsync(newsFeedItemIds: number[], webapi_options?:base.WebApiRequestOptions) : Promise< carriers.NewsFeedItem[] >;
235
+
236
+ public async getNewsFeedItemsByIdAsync(newsFeedItemIds:number[]|carriers.NewsFeed_GetNewsFeedItemsByIdRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.NewsFeedItem[] > {
237
+ let _request : carriers.NewsFeed_GetNewsFeedItemsByIdRequest = null;
238
+ let _options : base.WebApiRequestOptions = null;
239
+ const first : any = newsFeedItemIds;
240
+ if( typeof( first ) === "object" && first && ( typeof(first.newsFeedItemIds)!='undefined' ) )
241
+ {
242
+ _request = newsFeedItemIds as carriers.NewsFeed_GetNewsFeedItemsByIdRequest;
243
+ _options = webapi_options as base.WebApiRequestOptions;
244
+ }
245
+ else
246
+ {
247
+ _request = {
248
+ newsFeedItemIds: newsFeedItemIds as number[],
249
+ };
250
+ _options = webapi_options;
251
+ }
252
+ return this._getNewsFeedItemsByIdAsync( _request, _options );
253
+ }
254
+
255
+
256
+ private async _getNewsItemsForUserAsync(request: carriers.NewsFeed_GetNewsItemsForUserRequest, options?:base.WebApiRequestOptions) : Promise< carriers.NewsFeedItem[] > {
257
+ const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
258
+ base.WebApiBase.SetPending(options);
259
+ return new Promise< carriers.NewsFeedItem[] >(async (resolve, reject) => {
260
+ try {
261
+ config.baseURL = this._options.baseUrl;
262
+ const response = await this._axios.post("GetNewsItemsForUser", request , config);
263
+ base.WebApiBase.SetCompleted(options, response);
264
+ const res : carriers.NewsFeedItem[] = converters.Create_NewsFeedItemArray_From( response.data );
265
+ resolve(res);
266
+ }
267
+ catch( err ) {
268
+ base.WebApiBase.HandleError(options, config, err);
269
+ reject(err);
270
+ }
271
+ });
272
+ }
273
+
274
+
275
+
276
+ /**
277
+ * Get a list of newsfeed items for a particular user between two dates. If the current user cannot access a particular item, it will be excluded from the results.
278
+ * @param request - AssociateId, FromDate, ToDate, Top, Skip
279
+ * @returns The news feed items that was posted, or null if not found/not accessible by the user.
280
+ */
281
+ public async getNewsItemsForUserAsync(request: carriers.NewsFeed_GetNewsItemsForUserRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.NewsFeedItem[] >;
282
+
283
+ /**
284
+ * Get a list of newsfeed items for a particular user between two dates. If the current user cannot access a particular item, it will be excluded from the results.
285
+ * @param associateId - Id of the associate to fetch news feed items for. 0 = current user
286
+ * @param fromDate - Start date for fetching news feed items.
287
+ * @param toDate - End date for fetching news feed items.
288
+ * @param top - Maximum number of news feed items to return.
289
+ * @param skip - Number of news feed items to skip for paging.
290
+ * @returns The news feed items that was posted, or null if not found/not accessible by the user.
291
+ */
292
+ public async getNewsItemsForUserAsync(associateId: number, fromDate: Date, toDate: Date, top: number, skip: number, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.NewsFeedItem[] >;
293
+
294
+ public async getNewsItemsForUserAsync(associateId:number|carriers.NewsFeed_GetNewsItemsForUserRequest, fromDate?:Date|base.WebApiRequestOptions, toDate?:Date, top?:number, skip?:number, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.NewsFeedItem[] > {
295
+ let _request : carriers.NewsFeed_GetNewsItemsForUserRequest = null;
296
+ let _options : base.WebApiRequestOptions = null;
297
+ const first : any = associateId;
298
+ if( typeof( first ) === "object" && first && ( typeof(first.associateId)!='undefined' || typeof(first.fromDate)!='undefined' || typeof(first.toDate)!='undefined' || typeof(first.top)!='undefined' || typeof(first.skip)!='undefined' ) )
299
+ {
300
+ _request = associateId as carriers.NewsFeed_GetNewsItemsForUserRequest;
301
+ _options = fromDate as base.WebApiRequestOptions;
302
+ }
303
+ else
304
+ {
305
+ _request = {
306
+ associateId: associateId as number,
307
+ fromDate: fromDate as Date,
308
+ toDate: toDate as Date,
309
+ top: top as number,
310
+ skip: skip as number,
311
+ };
312
+ _options = webapi_options;
313
+ }
314
+ return this._getNewsItemsForUserAsync( _request, _options );
315
+ }
316
+
317
+
318
+ private async _markAsReadAsync(request: carriers.NewsFeed_MarkAsReadRequest, options?:base.WebApiRequestOptions) : Promise< void > {
319
+ const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
320
+ base.WebApiBase.SetPending(options);
321
+ return new Promise< void >(async (resolve, reject) => {
322
+ try {
323
+ config.baseURL = this._options.baseUrl;
324
+ const response = await this._axios.post("MarkAsRead", request , config);
325
+ base.WebApiBase.SetCompleted(options, response);
326
+ const res = response.data;
327
+ resolve(res);
328
+ }
329
+ catch( err ) {
330
+ base.WebApiBase.HandleError(options, config, err);
331
+ reject(err);
332
+ }
333
+ });
334
+ }
335
+
336
+
337
+
338
+ /**
339
+ * Marks the news feed item as read, so it can be un-bolded in the current user&apos;s feed.
340
+ * @param request - NewsFeedItemId
341
+ * @returns This method has no return value
342
+ */
343
+ public async markAsReadAsync(request: carriers.NewsFeed_MarkAsReadRequest, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
344
+
345
+ /**
346
+ * Marks the news feed item as read, so it can be un-bolded in the current user&apos;s feed.
347
+ * @param newsFeedItemId - Id of the news feed item to mark as seen for this user.
348
+ * @returns This method has no return value
349
+ */
350
+ public async markAsReadAsync(newsFeedItemId: number, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
351
+
352
+ public async markAsReadAsync(newsFeedItemId:number|carriers.NewsFeed_MarkAsReadRequest, webapi_options?:base.WebApiRequestOptions) : Promise< void > {
353
+ let _request : carriers.NewsFeed_MarkAsReadRequest = null;
354
+ let _options : base.WebApiRequestOptions = null;
355
+ const first : any = newsFeedItemId;
356
+ if( typeof( first ) === "object" && first && ( typeof(first.newsFeedItemId)!='undefined' ) )
357
+ {
358
+ _request = newsFeedItemId as carriers.NewsFeed_MarkAsReadRequest;
359
+ _options = webapi_options as base.WebApiRequestOptions;
360
+ }
361
+ else
362
+ {
363
+ _request = {
364
+ newsFeedItemId: newsFeedItemId as number,
365
+ };
366
+ _options = webapi_options;
367
+ }
368
+ return this._markAsReadAsync( _request, _options );
369
+ }
370
+
371
+
372
+ private async _startHandlingAsync(request: carriers.NewsFeed_StartHandlingRequest, options?:base.WebApiRequestOptions) : Promise< boolean > {
373
+ const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
374
+ base.WebApiBase.SetPending(options);
375
+ return new Promise< boolean >(async (resolve, reject) => {
376
+ try {
377
+ config.baseURL = this._options.baseUrl;
378
+ const response = await this._axios.post("StartHandling", request , config);
379
+ base.WebApiBase.SetCompleted(options, response);
380
+ const res : boolean = response.data as boolean;
381
+ resolve(res);
382
+ }
383
+ catch( err ) {
384
+ base.WebApiBase.HandleError(options, config, err);
385
+ reject(err);
386
+ }
387
+ });
388
+ }
389
+
390
+
391
+
392
+ /**
393
+ * Marks the news feed item as being handled, that CTA processing has started. i.e. other users should not start handling it also.
394
+ * @param request - NewsFeedItemId
395
+ * @returns Indicates if the news feed item was successfully marked as being handled. False if it was already being handled or was handled.
396
+ */
397
+ public async startHandlingAsync(request: carriers.NewsFeed_StartHandlingRequest, webapi_options?:base.WebApiRequestOptions) : Promise< boolean >;
398
+
399
+ /**
400
+ * Marks the news feed item as being handled, that CTA processing has started. i.e. other users should not start handling it also.
401
+ * @param newsFeedItemId - Id of the news feed item to mark as handled for all users.
402
+ * @returns Indicates if the news feed item was successfully marked as being handled. False if it was already being handled or was handled.
403
+ */
404
+ public async startHandlingAsync(newsFeedItemId: number, webapi_options?:base.WebApiRequestOptions) : Promise< boolean >;
405
+
406
+ public async startHandlingAsync(newsFeedItemId:number|carriers.NewsFeed_StartHandlingRequest, webapi_options?:base.WebApiRequestOptions) : Promise< boolean > {
407
+ let _request : carriers.NewsFeed_StartHandlingRequest = null;
408
+ let _options : base.WebApiRequestOptions = null;
409
+ const first : any = newsFeedItemId;
410
+ if( typeof( first ) === "object" && first && ( typeof(first.newsFeedItemId)!='undefined' ) )
411
+ {
412
+ _request = newsFeedItemId as carriers.NewsFeed_StartHandlingRequest;
413
+ _options = webapi_options as base.WebApiRequestOptions;
414
+ }
415
+ else
416
+ {
417
+ _request = {
418
+ newsFeedItemId: newsFeedItemId as number,
419
+ };
420
+ _options = webapi_options;
421
+ }
422
+ return this._startHandlingAsync( _request, _options );
423
+ }
424
+
425
+
426
+ private async _markAsHandledAsync(request: carriers.NewsFeed_MarkAsHandledRequest, options?:base.WebApiRequestOptions) : Promise< boolean > {
427
+ const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
428
+ base.WebApiBase.SetPending(options);
429
+ return new Promise< boolean >(async (resolve, reject) => {
430
+ try {
431
+ config.baseURL = this._options.baseUrl;
432
+ const response = await this._axios.post("MarkAsHandled", request , config);
433
+ base.WebApiBase.SetCompleted(options, response);
434
+ const res : boolean = response.data as boolean;
435
+ resolve(res);
436
+ }
437
+ catch( err ) {
438
+ base.WebApiBase.HandleError(options, config, err);
439
+ reject(err);
440
+ }
441
+ });
442
+ }
443
+
444
+
445
+
446
+ /**
447
+ * Marks the news feed item as handled, so it can be removed from the feed.
448
+ * @param request - NewsFeedItemId
449
+ * @returns Indicates if the news feed item was successfully marked as handled. False if it was already handled.
450
+ */
451
+ public async markAsHandledAsync(request: carriers.NewsFeed_MarkAsHandledRequest, webapi_options?:base.WebApiRequestOptions) : Promise< boolean >;
452
+
453
+ /**
454
+ * Marks the news feed item as handled, so it can be removed from the feed.
455
+ * @param newsFeedItemId - Id of the news feed item to mark as handled for all users.
456
+ * @returns Indicates if the news feed item was successfully marked as handled. False if it was already handled.
457
+ */
458
+ public async markAsHandledAsync(newsFeedItemId: number, webapi_options?:base.WebApiRequestOptions) : Promise< boolean >;
459
+
460
+ public async markAsHandledAsync(newsFeedItemId:number|carriers.NewsFeed_MarkAsHandledRequest, webapi_options?:base.WebApiRequestOptions) : Promise< boolean > {
461
+ let _request : carriers.NewsFeed_MarkAsHandledRequest = null;
462
+ let _options : base.WebApiRequestOptions = null;
463
+ const first : any = newsFeedItemId;
464
+ if( typeof( first ) === "object" && first && ( typeof(first.newsFeedItemId)!='undefined' ) )
465
+ {
466
+ _request = newsFeedItemId as carriers.NewsFeed_MarkAsHandledRequest;
467
+ _options = webapi_options as base.WebApiRequestOptions;
468
+ }
469
+ else
470
+ {
471
+ _request = {
472
+ newsFeedItemId: newsFeedItemId as number,
473
+ };
474
+ _options = webapi_options;
475
+ }
476
+ return this._markAsHandledAsync( _request, _options );
477
+ }
478
+
479
+ } // class v1NewsFeedAgentController
480
+
481
+
package/src/WebApi.ts CHANGED
@@ -135,6 +135,8 @@ import { IDocumentMigrationAgent, DocumentMigrationAgent } from './DocumentMigra
135
135
  export { DocumentMigrationAgent };
136
136
  import { IWorkflowAgent, WorkflowAgent } from './WorkflowAgent';
137
137
  export { WorkflowAgent };
138
+ import { INewsFeedAgent, NewsFeedAgent } from './NewsFeedAgent';
139
+ export { NewsFeedAgent };
138
140
 
139
141
  import { IContactRestApi, ContactRestApi } from './ContactRestApi';
140
142
  export { ContactRestApi };
@@ -301,6 +303,8 @@ export interface IAgentsApi extends base.WebApiBase {
301
303
  getDocumentMigrationAgent(resourceParsing?: base.ResourceParsing) : IDocumentMigrationAgent;
302
304
  /** Agent lets you configure workflow automation */
303
305
  getWorkflowAgent(resourceParsing?: base.ResourceParsing) : IWorkflowAgent;
306
+ /** Posting and reading Newsfeed items, marking them as read or as handled. */
307
+ getNewsFeedAgent(resourceParsing?: base.ResourceParsing) : INewsFeedAgent;
304
308
 
305
309
  } // interface IAgentsApi
306
310
 
@@ -879,6 +883,14 @@ export class WebApi extends base.WebApiBase implements IAgentsApi, IRestApi {
879
883
  return new WorkflowAgent( options );
880
884
  }
881
885
 
886
+ /** Posting and reading Newsfeed items, marking them as read or as handled. */
887
+ public getNewsFeedAgent(resourceParsing?: base.ResourceParsing) : INewsFeedAgent {
888
+ const options = base.WebApiBase.FigureOutOptions(this._options);
889
+ if( typeof(resourceParsing) == "number" )
890
+ options.resourceParsing = resourceParsing;
891
+ return new NewsFeedAgent( options );
892
+ }
893
+
882
894
 
883
895
  }
884
896