@superoffice/webapi 12.1.1412 → 12.3.2570

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 (96) hide show
  1. package/dist/cjs/Carriers.d.ts +585 -23
  2. package/dist/cjs/Carriers.d.ts.map +1 -1
  3. package/dist/cjs/ConfigurationAgent.d.ts +17 -0
  4. package/dist/cjs/ConfigurationAgent.d.ts.map +1 -1
  5. package/dist/cjs/ConfigurationAgent.js +35 -0
  6. package/dist/cjs/ConfigurationAgent.js.map +1 -1
  7. package/dist/cjs/Converters.d.ts +30 -0
  8. package/dist/cjs/Converters.d.ts.map +1 -1
  9. package/dist/cjs/Converters.js +445 -32
  10. package/dist/cjs/Converters.js.map +1 -1
  11. package/dist/cjs/DiagnosticsAgent.d.ts +7 -0
  12. package/dist/cjs/DiagnosticsAgent.d.ts.map +1 -1
  13. package/dist/cjs/DiagnosticsAgent.js +24 -0
  14. package/dist/cjs/DiagnosticsAgent.js.map +1 -1
  15. package/dist/cjs/EMailAgent.d.ts +16 -0
  16. package/dist/cjs/EMailAgent.d.ts.map +1 -1
  17. package/dist/cjs/EMailAgent.js +48 -0
  18. package/dist/cjs/EMailAgent.js.map +1 -1
  19. package/dist/cjs/Enums.d.ts +93 -1
  20. package/dist/cjs/Enums.d.ts.map +1 -1
  21. package/dist/cjs/Enums.js +99 -2
  22. package/dist/cjs/Enums.js.map +1 -1
  23. package/dist/cjs/ListAgent.d.ts +31 -0
  24. package/dist/cjs/ListAgent.d.ts.map +1 -1
  25. package/dist/cjs/ListAgent.js +87 -0
  26. package/dist/cjs/ListAgent.js.map +1 -1
  27. package/dist/cjs/MarketingAgent.d.ts +94 -16
  28. package/dist/cjs/MarketingAgent.d.ts.map +1 -1
  29. package/dist/cjs/MarketingAgent.js +222 -34
  30. package/dist/cjs/MarketingAgent.js.map +1 -1
  31. package/dist/cjs/NewsFeedAgent.d.ts +141 -0
  32. package/dist/cjs/NewsFeedAgent.d.ts.map +1 -0
  33. package/dist/cjs/NewsFeedAgent.js +292 -0
  34. package/dist/cjs/NewsFeedAgent.js.map +1 -0
  35. package/dist/cjs/ViewStateAgent.d.ts +34 -0
  36. package/dist/cjs/ViewStateAgent.d.ts.map +1 -1
  37. package/dist/cjs/ViewStateAgent.js +70 -0
  38. package/dist/cjs/ViewStateAgent.js.map +1 -1
  39. package/dist/cjs/WebApi.d.ts +6 -0
  40. package/dist/cjs/WebApi.d.ts.map +1 -1
  41. package/dist/cjs/WebApi.js +10 -1
  42. package/dist/cjs/WebApi.js.map +1 -1
  43. package/dist/esm/Carriers.d.ts +585 -23
  44. package/dist/esm/Carriers.d.ts.map +1 -1
  45. package/dist/esm/ConfigurationAgent.d.ts +17 -0
  46. package/dist/esm/ConfigurationAgent.d.ts.map +1 -1
  47. package/dist/esm/ConfigurationAgent.js +35 -0
  48. package/dist/esm/ConfigurationAgent.js.map +1 -1
  49. package/dist/esm/Converters.d.ts +30 -0
  50. package/dist/esm/Converters.d.ts.map +1 -1
  51. package/dist/esm/Converters.js +384 -1
  52. package/dist/esm/Converters.js.map +1 -1
  53. package/dist/esm/DiagnosticsAgent.d.ts +7 -0
  54. package/dist/esm/DiagnosticsAgent.d.ts.map +1 -1
  55. package/dist/esm/DiagnosticsAgent.js +24 -0
  56. package/dist/esm/DiagnosticsAgent.js.map +1 -1
  57. package/dist/esm/EMailAgent.d.ts +16 -0
  58. package/dist/esm/EMailAgent.d.ts.map +1 -1
  59. package/dist/esm/EMailAgent.js +48 -0
  60. package/dist/esm/EMailAgent.js.map +1 -1
  61. package/dist/esm/Enums.d.ts +93 -1
  62. package/dist/esm/Enums.d.ts.map +1 -1
  63. package/dist/esm/Enums.js +97 -1
  64. package/dist/esm/Enums.js.map +1 -1
  65. package/dist/esm/ListAgent.d.ts +31 -0
  66. package/dist/esm/ListAgent.d.ts.map +1 -1
  67. package/dist/esm/ListAgent.js +87 -0
  68. package/dist/esm/ListAgent.js.map +1 -1
  69. package/dist/esm/MarketingAgent.d.ts +94 -16
  70. package/dist/esm/MarketingAgent.d.ts.map +1 -1
  71. package/dist/esm/MarketingAgent.js +222 -34
  72. package/dist/esm/MarketingAgent.js.map +1 -1
  73. package/dist/esm/NewsFeedAgent.d.ts +141 -0
  74. package/dist/esm/NewsFeedAgent.d.ts.map +1 -0
  75. package/dist/esm/NewsFeedAgent.js +287 -0
  76. package/dist/esm/NewsFeedAgent.js.map +1 -0
  77. package/dist/esm/ViewStateAgent.d.ts +34 -0
  78. package/dist/esm/ViewStateAgent.d.ts.map +1 -1
  79. package/dist/esm/ViewStateAgent.js +70 -0
  80. package/dist/esm/ViewStateAgent.js.map +1 -1
  81. package/dist/esm/WebApi.d.ts +6 -0
  82. package/dist/esm/WebApi.d.ts.map +1 -1
  83. package/dist/esm/WebApi.js +9 -0
  84. package/dist/esm/WebApi.js.map +1 -1
  85. package/package.json +4 -4
  86. package/src/Carriers.ts +810 -27
  87. package/src/ConfigurationAgent.ts +60 -0
  88. package/src/Converters.ts +468 -1
  89. package/src/DiagnosticsAgent.ts +30 -0
  90. package/src/EMailAgent.ts +76 -0
  91. package/src/Enums.ts +101 -1
  92. package/src/ListAgent.ts +94 -0
  93. package/src/MarketingAgent.ts +324 -58
  94. package/src/NewsFeedAgent.ts +481 -0
  95. package/src/ViewStateAgent.ts +120 -0
  96. 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
+
@@ -53,8 +53,12 @@ export interface IViewStateAgent {
53
53
  saveCurrentsAsync(currents: carriers.History[], webapi_options?:base.WebApiRequestOptions) : Promise< carriers.History[] >;
54
54
  getHistoriesByNamesAndIdsAsync(request: carriers.ViewState_GetHistoriesByNamesAndIdsRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.History[] >;
55
55
  getHistoriesByNamesAndIdsAsync(requests: carriers.HistoryRequest[], webapi_options?:base.WebApiRequestOptions) : Promise< carriers.History[] >;
56
+ upsertRecentNavigationAsync(request: carriers.ViewState_UpsertRecentNavigationRequest, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
57
+ upsertRecentNavigationAsync(client: string, elements: carriers.NavigationElement[], webapi_options?:base.WebApiRequestOptions) : Promise< void >;
56
58
  publishAndRetrieveUiEventsAsync(request: carriers.ViewState_PublishAndRetrieveUiEventsRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.UiEvent[] >;
57
59
  publishAndRetrieveUiEventsAsync(latestKnownEventId: number, publishEvents: carriers.UiEvent[], metrics: carriers.MetricPair[], webapi_options?:base.WebApiRequestOptions) : Promise< carriers.UiEvent[] >;
60
+ publishAndSyncUiEventsAsync(request: carriers.ViewState_PublishAndSyncUiEventsRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.LiveUiSyncResult >;
61
+ publishAndSyncUiEventsAsync(latestKnownEventId: number, publishEvents: carriers.UiEvent[], metrics: carriers.MetricPair[], ticketVersions: carriers.TicketVersionInfo[], webapi_options?:base.WebApiRequestOptions) : Promise< carriers.LiveUiSyncResult >;
58
62
  } // interface IViewStateAgent
59
63
 
60
64
 
@@ -796,6 +800,62 @@ export class ViewStateAgent extends base.WebApiBase implements IViewStateAgent {
796
800
  }
797
801
 
798
802
 
803
+ private async _upsertRecentNavigationAsync(request: carriers.ViewState_UpsertRecentNavigationRequest, options?:base.WebApiRequestOptions) : Promise< void > {
804
+ const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
805
+ base.WebApiBase.SetPending(options);
806
+ return new Promise< void >(async (resolve, reject) => {
807
+ try {
808
+ config.baseURL = this._options.baseUrl;
809
+ const response = await this._axios.post("UpsertRecentNavigation", request , config);
810
+ base.WebApiBase.SetCompleted(options, response);
811
+ const res = response.data;
812
+ resolve(res);
813
+ }
814
+ catch( err ) {
815
+ base.WebApiBase.HandleError(options, config, err);
816
+ reject(err);
817
+ }
818
+ });
819
+ }
820
+
821
+
822
+
823
+ /**
824
+ * Upsert Recent navigation entries for the logged-in associate and the given client. The entries are ranked so that the first element in the array becomes the most recent. The list is capped by the RecentNavigationLimit preference; the oldest entries beyond the cap are removed.
825
+ * @param request - Client, Elements
826
+ * @returns This method has no return value
827
+ */
828
+ public async upsertRecentNavigationAsync(request: carriers.ViewState_UpsertRecentNavigationRequest, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
829
+
830
+ /**
831
+ * Upsert Recent navigation entries for the logged-in associate and the given client. The entries are ranked so that the first element in the array becomes the most recent. The list is capped by the RecentNavigationLimit preference; the oldest entries beyond the cap are removed.
832
+ * @param client - The client the entries belong to, e.g. Crm, Admin or Mobile
833
+ * @param elements - The navigation entries to upsert. The first element becomes the most recent; duplicate keys are collapsed keeping the first occurrence.
834
+ * @returns This method has no return value
835
+ */
836
+ public async upsertRecentNavigationAsync(client: string, elements: carriers.NavigationElement[], webapi_options?:base.WebApiRequestOptions) : Promise< void >;
837
+
838
+ public async upsertRecentNavigationAsync(client:string|carriers.ViewState_UpsertRecentNavigationRequest, elements?:carriers.NavigationElement[]|base.WebApiRequestOptions, webapi_options?:base.WebApiRequestOptions) : Promise< void > {
839
+ let _request : carriers.ViewState_UpsertRecentNavigationRequest = null;
840
+ let _options : base.WebApiRequestOptions = null;
841
+ const first : any = client;
842
+ if( typeof( first ) === "object" && first && ( typeof(first.client)!='undefined' || typeof(first.elements)!='undefined' ) )
843
+ {
844
+ _request = client as carriers.ViewState_UpsertRecentNavigationRequest;
845
+ _options = elements as base.WebApiRequestOptions;
846
+ }
847
+ else
848
+ {
849
+ _request = {
850
+ client: client as string,
851
+ elements: elements as carriers.NavigationElement[],
852
+ };
853
+ _options = webapi_options;
854
+ }
855
+ return this._upsertRecentNavigationAsync( _request, _options );
856
+ }
857
+
858
+
799
859
  private async _publishAndRetrieveUiEventsAsync(request: carriers.ViewState_PublishAndRetrieveUiEventsRequest, options?:base.WebApiRequestOptions) : Promise< carriers.UiEvent[] > {
800
860
  const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
801
861
  base.WebApiBase.SetPending(options);
@@ -853,6 +913,66 @@ export class ViewStateAgent extends base.WebApiBase implements IViewStateAgent {
853
913
  return this._publishAndRetrieveUiEventsAsync( _request, _options );
854
914
  }
855
915
 
916
+
917
+ private async _publishAndSyncUiEventsAsync(request: carriers.ViewState_PublishAndSyncUiEventsRequest, options?:base.WebApiRequestOptions) : Promise< carriers.LiveUiSyncResult > {
918
+ const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
919
+ base.WebApiBase.SetPending(options);
920
+ return new Promise< carriers.LiveUiSyncResult >(async (resolve, reject) => {
921
+ try {
922
+ config.baseURL = this._options.baseUrl;
923
+ const response = await this._axios.post("PublishAndSyncUiEvents", request , config);
924
+ base.WebApiBase.SetCompleted(options, response);
925
+ const res : carriers.LiveUiSyncResult = converters.Create_LiveUiSyncResult_From( response.data );
926
+ resolve(res);
927
+ }
928
+ catch( err ) {
929
+ base.WebApiBase.HandleError(options, config, err);
930
+ reject(err);
931
+ }
932
+ });
933
+ }
934
+
935
+
936
+
937
+ /**
938
+ * Publish zero or more events and return any new events since the given event id, exactly like PublishAndRetrieveUiEvents — and additionally answer, for each ticket version the client supplies, whether that ticket has changed since (and by whom). Requested tickets the user cannot see are omitted from the answer
939
+ * @param request - LatestKnownEventId, PublishEvents, Metrics, TicketVersions
940
+ * @returns New events since the given event id, plus the sync state of the requested tickets
941
+ */
942
+ public async publishAndSyncUiEventsAsync(request: carriers.ViewState_PublishAndSyncUiEventsRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.LiveUiSyncResult >;
943
+
944
+ /**
945
+ * Publish zero or more events and return any new events since the given event id, exactly like PublishAndRetrieveUiEvents — and additionally answer, for each ticket version the client supplies, whether that ticket has changed since (and by whom). Requested tickets the user cannot see are omitted from the answer
946
+ * @param latestKnownEventId - The last event ID that this client knows about. The return value will be any events occurring /after/ that point, numbered by the server. Clients need to keep track themselves of this number between calls
947
+ * @param publishEvents - Array of events to publish. This can be empty if the client only wants to retrieve information
948
+ * @param metrics - Optional statistical and performance metrics collected by the frontend. Can be null or empty. Metrics are sum-accumulated and reported once a minute; please do not report the same logical event twice
949
+ * @param ticketVersions - The tickets the client is showing, each with the last-changed value of the client's loaded copy (DateTime.MinValue or omitted = no copy; the current value is then returned without a staleness verdict). At most 500 entries after removing duplicates
950
+ * @returns New events since the given event id, plus the sync state of the requested tickets
951
+ */
952
+ public async publishAndSyncUiEventsAsync(latestKnownEventId: number, publishEvents: carriers.UiEvent[], metrics: carriers.MetricPair[], ticketVersions: carriers.TicketVersionInfo[], webapi_options?:base.WebApiRequestOptions) : Promise< carriers.LiveUiSyncResult >;
953
+
954
+ public async publishAndSyncUiEventsAsync(latestKnownEventId:number|carriers.ViewState_PublishAndSyncUiEventsRequest, publishEvents?:carriers.UiEvent[]|base.WebApiRequestOptions, metrics?:carriers.MetricPair[], ticketVersions?:carriers.TicketVersionInfo[], webapi_options?:base.WebApiRequestOptions) : Promise< carriers.LiveUiSyncResult > {
955
+ let _request : carriers.ViewState_PublishAndSyncUiEventsRequest = null;
956
+ let _options : base.WebApiRequestOptions = null;
957
+ const first : any = latestKnownEventId;
958
+ if( typeof( first ) === "object" && first && ( typeof(first.latestKnownEventId)!='undefined' || typeof(first.publishEvents)!='undefined' || typeof(first.metrics)!='undefined' || typeof(first.ticketVersions)!='undefined' ) )
959
+ {
960
+ _request = latestKnownEventId as carriers.ViewState_PublishAndSyncUiEventsRequest;
961
+ _options = publishEvents as base.WebApiRequestOptions;
962
+ }
963
+ else
964
+ {
965
+ _request = {
966
+ latestKnownEventId: latestKnownEventId as number,
967
+ publishEvents: publishEvents as carriers.UiEvent[],
968
+ metrics: metrics as carriers.MetricPair[],
969
+ ticketVersions: ticketVersions as carriers.TicketVersionInfo[],
970
+ };
971
+ _options = webapi_options;
972
+ }
973
+ return this._publishAndSyncUiEventsAsync( _request, _options );
974
+ }
975
+
856
976
  } // class v1ViewStateAgentController
857
977
 
858
978
 
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