@superoffice/webapi 11.7.727 → 11.9.1204

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 (163) hide show
  1. package/LICENSE.md +15 -15
  2. package/README.md +184 -184
  3. package/__tests__/Appointment63-notz.json +1925 -1925
  4. package/__tests__/Appointment63-utctz.json +1925 -1925
  5. package/__tests__/Appointment63.json +1925 -1925
  6. package/__tests__/AppointmentTzTest.ts +115 -115
  7. package/__tests__/AxiosNockTest.ts +28 -28
  8. package/__tests__/ContactDefault.json +699 -699
  9. package/__tests__/ContactEntity.json +272 -272
  10. package/__tests__/ContactRestTest.ts +144 -144
  11. package/__tests__/ContactTest.ts +395 -395
  12. package/__tests__/ConvertersTest.ts +97 -97
  13. package/__tests__/DocumentTest.ts +101 -101
  14. package/__tests__/Person210-notz.json +1932 -1932
  15. package/__tests__/Person210-utctz.json +1932 -1932
  16. package/__tests__/Person210.json +1932 -1932
  17. package/__tests__/PersonImageData.nock +22 -22
  18. package/__tests__/PersonTest.ts +41 -41
  19. package/__tests__/PersonTzTest.ts +113 -113
  20. package/__tests__/RecurrenceInfo.json +55 -55
  21. package/__tests__/ResponseCallbackTest.ts +23 -23
  22. package/__tests__/TableRights.json +441 -441
  23. package/__tests__/WebapiTest.ts +264 -264
  24. package/__tests__/Webhook.json +16 -16
  25. package/__tests__/WebhookTest.ts +209 -209
  26. package/dist/cjs/AIAgent.d.ts +62 -0
  27. package/dist/cjs/AIAgent.d.ts.map +1 -1
  28. package/dist/cjs/AIAgent.js +149 -0
  29. package/dist/cjs/AIAgent.js.map +1 -1
  30. package/dist/cjs/Carriers.d.ts +640 -14
  31. package/dist/cjs/Carriers.d.ts.map +1 -1
  32. package/dist/cjs/Converters.d.ts +24 -0
  33. package/dist/cjs/Converters.d.ts.map +1 -1
  34. package/dist/cjs/Converters.js +388 -17
  35. package/dist/cjs/Converters.js.map +1 -1
  36. package/dist/cjs/DiagnosticsAgent.d.ts +38 -0
  37. package/dist/cjs/DiagnosticsAgent.d.ts.map +1 -1
  38. package/dist/cjs/DiagnosticsAgent.js +91 -0
  39. package/dist/cjs/DiagnosticsAgent.js.map +1 -1
  40. package/dist/cjs/Enums.d.ts +77 -1
  41. package/dist/cjs/Enums.d.ts.map +1 -1
  42. package/dist/cjs/Enums.js +83 -4
  43. package/dist/cjs/Enums.js.map +1 -1
  44. package/dist/cjs/ListAgent.d.ts +71 -6
  45. package/dist/cjs/ListAgent.d.ts.map +1 -1
  46. package/dist/cjs/ListAgent.js +157 -0
  47. package/dist/cjs/ListAgent.js.map +1 -1
  48. package/dist/cjs/MarketingAgent.d.ts +68 -0
  49. package/dist/cjs/MarketingAgent.d.ts.map +1 -1
  50. package/dist/cjs/MarketingAgent.js +157 -0
  51. package/dist/cjs/MarketingAgent.js.map +1 -1
  52. package/dist/cjs/TicketAgent.d.ts +23 -0
  53. package/dist/cjs/TicketAgent.d.ts.map +1 -1
  54. package/dist/cjs/TicketAgent.js +65 -0
  55. package/dist/cjs/TicketAgent.js.map +1 -1
  56. package/dist/esm/AIAgent.d.ts +62 -0
  57. package/dist/esm/AIAgent.d.ts.map +1 -1
  58. package/dist/esm/AIAgent.js +150 -1
  59. package/dist/esm/AIAgent.js.map +1 -1
  60. package/dist/esm/Carriers.d.ts +640 -14
  61. package/dist/esm/Carriers.d.ts.map +1 -1
  62. package/dist/esm/Converters.d.ts +24 -0
  63. package/dist/esm/Converters.d.ts.map +1 -1
  64. package/dist/esm/Converters.js +346 -0
  65. package/dist/esm/Converters.js.map +1 -1
  66. package/dist/esm/DiagnosticsAgent.d.ts +38 -0
  67. package/dist/esm/DiagnosticsAgent.d.ts.map +1 -1
  68. package/dist/esm/DiagnosticsAgent.js +91 -0
  69. package/dist/esm/DiagnosticsAgent.js.map +1 -1
  70. package/dist/esm/Enums.d.ts +77 -1
  71. package/dist/esm/Enums.d.ts.map +1 -1
  72. package/dist/esm/Enums.js +79 -0
  73. package/dist/esm/Enums.js.map +1 -1
  74. package/dist/esm/ListAgent.d.ts +71 -6
  75. package/dist/esm/ListAgent.d.ts.map +1 -1
  76. package/dist/esm/ListAgent.js +157 -0
  77. package/dist/esm/ListAgent.js.map +1 -1
  78. package/dist/esm/MarketingAgent.d.ts +68 -0
  79. package/dist/esm/MarketingAgent.d.ts.map +1 -1
  80. package/dist/esm/MarketingAgent.js +157 -0
  81. package/dist/esm/MarketingAgent.js.map +1 -1
  82. package/dist/esm/TicketAgent.d.ts +23 -0
  83. package/dist/esm/TicketAgent.d.ts.map +1 -1
  84. package/dist/esm/TicketAgent.js +65 -0
  85. package/dist/esm/TicketAgent.js.map +1 -1
  86. package/examples-js/hello.js +12 -12
  87. package/examples-ts/hello.ts +8 -8
  88. package/package.json +93 -93
  89. package/scripts/postbuild.js +22 -22
  90. package/scripts/setVersion.js +44 -44
  91. package/src/AIAgent.ts +2239 -1992
  92. package/src/AppointmentAgent.ts +6263 -6263
  93. package/src/AppointmentRestApi.ts +225 -225
  94. package/src/ArchiveAgent.ts +1950 -1950
  95. package/src/AssociateAgent.ts +422 -422
  96. package/src/AxiosCacheHandler.ts +74 -74
  97. package/src/BLOBAgent.ts +2100 -2100
  98. package/src/Base64.ts +285 -285
  99. package/src/BatchAgent.ts +910 -910
  100. package/src/BulkUpdateAgent.ts +504 -504
  101. package/src/CRMScriptAgent.ts +1390 -1390
  102. package/src/Carriers.ts +53121 -52274
  103. package/src/ChatAgent.ts +1422 -1422
  104. package/src/ConfigurationAgent.ts +2228 -2228
  105. package/src/ContactAgent.ts +1756 -1756
  106. package/src/ContactRestApi.ts +237 -237
  107. package/src/Converters.ts +23496 -23090
  108. package/src/CustomerServiceAgent.ts +1799 -1799
  109. package/src/DashAgent.ts +1674 -1674
  110. package/src/DatabaseAgent.ts +120 -120
  111. package/src/DatabaseTableAgent.ts +534 -534
  112. package/src/Day_js.ts +41 -41
  113. package/src/DiagnosticsAgent.ts +1384 -1240
  114. package/src/DocumentAgent.ts +5079 -5079
  115. package/src/DocumentMigrationAgent.ts +524 -524
  116. package/src/DocumentRestApi.ts +259 -259
  117. package/src/EMailAgent.ts +5328 -5328
  118. package/src/Enums.ts +6998 -6916
  119. package/src/ErpSyncAgent.ts +2658 -2658
  120. package/src/FavouriteAgent.ts +720 -720
  121. package/src/FindAgent.ts +2330 -2330
  122. package/src/ForeignSystemAgent.ts +1710 -1710
  123. package/src/FreeTextAgent.ts +372 -372
  124. package/src/ImportAgent.ts +304 -304
  125. package/src/LicenseAgent.ts +1230 -1230
  126. package/src/ListAgent.ts +11451 -11237
  127. package/src/MDOAgent.ts +748 -748
  128. package/src/MarketingAgent.ts +1146 -890
  129. package/src/MessagingAgent.ts +384 -384
  130. package/src/NavigatorAgent.ts +140 -140
  131. package/src/NumberAllocationAgent.ts +296 -296
  132. package/src/PersonAgent.ts +3287 -3287
  133. package/src/PersonRestApi.ts +241 -241
  134. package/src/PhoneListAgent.ts +458 -458
  135. package/src/PocketAgent.ts +780 -780
  136. package/src/PreferenceAgent.ts +1900 -1900
  137. package/src/PreviewsAgent.ts +116 -116
  138. package/src/ProjectAgent.ts +2391 -2391
  139. package/src/ProjectRestApi.ts +239 -239
  140. package/src/QuoteAgent.ts +5159 -5159
  141. package/src/RelationAgent.ts +220 -220
  142. package/src/ReportAgent.ts +154 -154
  143. package/src/ResourceAgent.ts +358 -358
  144. package/src/SaintAgent.ts +601 -601
  145. package/src/SaleAgent.ts +2034 -2034
  146. package/src/SaleRestApi.ts +233 -233
  147. package/src/SelectionAgent.ts +3195 -3195
  148. package/src/SentryAgent.ts +462 -462
  149. package/src/SoApiConstants.ts +8 -8
  150. package/src/TargetsAgent.ts +1104 -1104
  151. package/src/TicketAgent.ts +3708 -3638
  152. package/src/TimeZoneAgent.ts +528 -528
  153. package/src/TooltipsAgent.ts +116 -116
  154. package/src/UserAgent.ts +4856 -4856
  155. package/src/UserDefinedFieldInfoAgent.ts +1764 -1764
  156. package/src/ViewStateAgent.ts +858 -858
  157. package/src/WebApi.ts +872 -872
  158. package/src/WebApiBase.ts +565 -565
  159. package/src/WebhookAgent.ts +388 -388
  160. package/src/WorkflowAgent.ts +1338 -1338
  161. package/tsconfig.esm.json +8 -8
  162. package/tsconfig.jest.json +8 -8
  163. package/tsconfig.json +34 -34
@@ -1,458 +1,458 @@
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/PhoneListAgent.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
- * Collection of all services for searching for person or contact (company) phone numbers.
28
- */
29
- export interface IPhoneListAgent {
30
- searchAsync(request: carriers.PhoneList_SearchRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
31
- searchAsync(searchString: string, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
32
- searchWithPreferencesAsync(request: carriers.PhoneList_SearchWithPreferencesRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
33
- searchWithPreferencesAsync(searchString: string, preferences: carriers.PhoneListPreferences, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
34
- getDepartmentPhonesAsync(request: carriers.PhoneList_GetDepartmentPhonesRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
35
- getDepartmentPhonesAsync(departmentId: number, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
36
- getFavoritesPhonesAsync(webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
37
- getContactPhonesAsync(request: carriers.PhoneList_GetContactPhonesRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
38
- getContactPhonesAsync(contactId: number, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
39
- addToFavoritesAsync(request: carriers.PhoneList_AddToFavoritesRequest, webapi_options?:base.WebApiRequestOptions) : Promise< number >;
40
- addToFavoritesAsync(contactId: number, webapi_options?:base.WebApiRequestOptions) : Promise< number >;
41
- getPreferencesAsync(webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListPreferences >;
42
- setPreferencesAsync(request: carriers.PhoneList_SetPreferencesRequest, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
43
- setPreferencesAsync(preferences: carriers.PhoneListPreferences, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
44
- } // interface IPhoneListAgent
45
-
46
-
47
-
48
-
49
- /**
50
- * Collection of all services for searching for person or contact (company) phone numbers.
51
- */
52
- export class PhoneListAgent extends base.WebApiBase implements IPhoneListAgent {
53
- constructor(baseUrl?: string, languageCode?:string, cultureCode?: string);
54
- constructor(baseUrl?: string, resourceParsing?: base.ResourceParsing);
55
- constructor(baseUrl: string, resourceManager:any);
56
- constructor(baseUrl: string, config:AxiosRequestConfig, resourceManager:any);
57
- constructor(baseUrl: string, config:AxiosRequestConfig, resourceParsing?: base.ResourceParsing);
58
- constructor(baseUrl: string, config:AxiosRequestConfig, languageCode?:string, cultureCode?: string);
59
- constructor(options: base.WebApiOptions);
60
-
61
- constructor(baseUrlOrOptions: string|base.WebApiOptions|undefined,
62
- langOrconfigOrRM?: string|base.ResourceParsing|AxiosRequestConfig|any,
63
- langOrResourceOrRM?:string|base.ResourceParsing|any,
64
- cultureCode?: string,
65
- ) {
66
- const options = base.WebApiBase.FigureOutOptions(baseUrlOrOptions, langOrconfigOrRM, langOrResourceOrRM, cultureCode);
67
- options.basePath = "v1/Agents/PhoneList/";
68
- super(options);
69
- }
70
-
71
-
72
-
73
- private async _searchAsync(request: carriers.PhoneList_SearchRequest, options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] > {
74
- const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
75
- base.WebApiBase.SetPending(options);
76
- return new Promise< carriers.PhoneListItem[] >(async (resolve, reject) => {
77
- try {
78
- config.baseURL = this._options.baseUrl;
79
- const response = await this._axios.post("Search", request , config);
80
- base.WebApiBase.SetCompleted(options, response);
81
- const res : carriers.PhoneListItem[] = converters.Create_PhoneListItemArray_From( response.data );
82
- resolve(res);
83
- }
84
- catch( err ) {
85
- base.WebApiBase.HandleError(options, config, err);
86
- reject(err);
87
- }
88
- });
89
- }
90
-
91
-
92
-
93
- /**
94
- * Searching the phone list. Using default search preferences or the preferences already set by the PhoneListPreferences Service
95
- * @param request - SearchString
96
- * @returns The resulting phone list
97
- */
98
- public async searchAsync(request: carriers.PhoneList_SearchRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
99
-
100
- /**
101
- * Searching the phone list. Using default search preferences or the preferences already set by the PhoneListPreferences Service
102
- * @param searchString - The search string
103
- * @returns The resulting phone list
104
- */
105
- public async searchAsync(searchString: string, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
106
-
107
- public async searchAsync(searchString:string|carriers.PhoneList_SearchRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] > {
108
- let _request : carriers.PhoneList_SearchRequest = null;
109
- let _options : base.WebApiRequestOptions = null;
110
- const first : any = searchString;
111
- if( typeof( first ) === "object" && first && ( typeof(first.searchString)!='undefined' ) )
112
- {
113
- _request = searchString as carriers.PhoneList_SearchRequest;
114
- _options = webapi_options as base.WebApiRequestOptions;
115
- }
116
- else
117
- {
118
- _request = {
119
- searchString: searchString as string,
120
- };
121
- _options = webapi_options;
122
- }
123
- return this._searchAsync( _request, _options );
124
- }
125
-
126
-
127
- private async _searchWithPreferencesAsync(request: carriers.PhoneList_SearchWithPreferencesRequest, options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] > {
128
- const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
129
- base.WebApiBase.SetPending(options);
130
- return new Promise< carriers.PhoneListItem[] >(async (resolve, reject) => {
131
- try {
132
- config.baseURL = this._options.baseUrl;
133
- const response = await this._axios.post("SearchWithPreferences", request , config);
134
- base.WebApiBase.SetCompleted(options, response);
135
- const res : carriers.PhoneListItem[] = converters.Create_PhoneListItemArray_From( response.data );
136
- resolve(res);
137
- }
138
- catch( err ) {
139
- base.WebApiBase.HandleError(options, config, err);
140
- reject(err);
141
- }
142
- });
143
- }
144
-
145
-
146
-
147
- /**
148
- * Searching the phone list. Search is based on the supplied preferences.
149
- * @param request - SearchString, Preferences
150
- * @returns The resulting phone list.
151
- */
152
- public async searchWithPreferencesAsync(request: carriers.PhoneList_SearchWithPreferencesRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
153
-
154
- /**
155
- * Searching the phone list. Search is based on the supplied preferences.
156
- * @param searchString - The search string.
157
- * @param preferences - The search preferences
158
- * @returns The resulting phone list.
159
- */
160
- public async searchWithPreferencesAsync(searchString: string, preferences: carriers.PhoneListPreferences, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
161
-
162
- public async searchWithPreferencesAsync(searchString:string|carriers.PhoneList_SearchWithPreferencesRequest, preferences?:carriers.PhoneListPreferences|base.WebApiRequestOptions, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] > {
163
- let _request : carriers.PhoneList_SearchWithPreferencesRequest = null;
164
- let _options : base.WebApiRequestOptions = null;
165
- const first : any = searchString;
166
- if( typeof( first ) === "object" && first && ( typeof(first.searchString)!='undefined' || typeof(first.preferences)!='undefined' ) )
167
- {
168
- _request = searchString as carriers.PhoneList_SearchWithPreferencesRequest;
169
- _options = preferences as base.WebApiRequestOptions;
170
- }
171
- else
172
- {
173
- _request = {
174
- searchString: searchString as string,
175
- preferences: preferences as carriers.PhoneListPreferences,
176
- };
177
- _options = webapi_options;
178
- }
179
- return this._searchWithPreferencesAsync( _request, _options );
180
- }
181
-
182
-
183
- private async _getDepartmentPhonesAsync(request: carriers.PhoneList_GetDepartmentPhonesRequest, options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] > {
184
- const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
185
- base.WebApiBase.SetPending(options);
186
- return new Promise< carriers.PhoneListItem[] >(async (resolve, reject) => {
187
- try {
188
- config.baseURL = this._options.baseUrl;
189
- const response = await this._axios.post("GetDepartmentPhones", request , config);
190
- base.WebApiBase.SetCompleted(options, response);
191
- const res : carriers.PhoneListItem[] = converters.Create_PhoneListItemArray_From( response.data );
192
- resolve(res);
193
- }
194
- catch( err ) {
195
- base.WebApiBase.HandleError(options, config, err);
196
- reject(err);
197
- }
198
- });
199
- }
200
-
201
-
202
-
203
- /**
204
- * Returns an array of phone list items with the in-parameter as restriction. The in-parameter must be a valid department id (UserGroupId).
205
- * @param request - DepartmentId
206
- * @returns The department phone list
207
- */
208
- public async getDepartmentPhonesAsync(request: carriers.PhoneList_GetDepartmentPhonesRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
209
-
210
- /**
211
- * Returns an array of phone list items with the in-parameter as restriction. The in-parameter must be a valid department id (UserGroupId).
212
- * @param departmentId - The department to get the phone list for
213
- * @returns The department phone list
214
- */
215
- public async getDepartmentPhonesAsync(departmentId: number, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
216
-
217
- public async getDepartmentPhonesAsync(departmentId:number|carriers.PhoneList_GetDepartmentPhonesRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] > {
218
- let _request : carriers.PhoneList_GetDepartmentPhonesRequest = null;
219
- let _options : base.WebApiRequestOptions = null;
220
- const first : any = departmentId;
221
- if( typeof( first ) === "object" && first && ( typeof(first.departmentId)!='undefined' ) )
222
- {
223
- _request = departmentId as carriers.PhoneList_GetDepartmentPhonesRequest;
224
- _options = webapi_options as base.WebApiRequestOptions;
225
- }
226
- else
227
- {
228
- _request = {
229
- departmentId: departmentId as number,
230
- };
231
- _options = webapi_options;
232
- }
233
- return this._getDepartmentPhonesAsync( _request, _options );
234
- }
235
-
236
-
237
- private async _getFavoritesPhonesAsync( options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] > {
238
- const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
239
- base.WebApiBase.SetPending(options);
240
- return new Promise< carriers.PhoneListItem[] >(async (resolve, reject) => {
241
- try {
242
- config.baseURL = this._options.baseUrl;
243
- const response = await this._axios.post("GetFavoritesPhones", undefined , config);
244
- base.WebApiBase.SetCompleted(options, response);
245
- const res : carriers.PhoneListItem[] = converters.Create_PhoneListItemArray_From( response.data );
246
- resolve(res);
247
- }
248
- catch( err ) {
249
- base.WebApiBase.HandleError(options, config, err);
250
- reject(err);
251
- }
252
- });
253
- }
254
-
255
-
256
- /**
257
- * Returns an array of phone list items with the Contacts in the users favorites dropdown list.
258
- * @returns The favorite contact phone list
259
- */
260
- public async getFavoritesPhonesAsync(webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >
261
- {
262
- return this._getFavoritesPhonesAsync(webapi_options);
263
- }
264
-
265
-
266
- private async _getContactPhonesAsync(request: carriers.PhoneList_GetContactPhonesRequest, options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] > {
267
- const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
268
- base.WebApiBase.SetPending(options);
269
- return new Promise< carriers.PhoneListItem[] >(async (resolve, reject) => {
270
- try {
271
- config.baseURL = this._options.baseUrl;
272
- const response = await this._axios.post("GetContactPhones", request , config);
273
- base.WebApiBase.SetCompleted(options, response);
274
- const res : carriers.PhoneListItem[] = converters.Create_PhoneListItemArray_From( response.data );
275
- resolve(res);
276
- }
277
- catch( err ) {
278
- base.WebApiBase.HandleError(options, config, err);
279
- reject(err);
280
- }
281
- });
282
- }
283
-
284
-
285
-
286
- /**
287
- * Returns an array of phone list items for all the persons belonging to a contact (company). The in-parameter must be a valid contact-id.
288
- * @param request - ContactId
289
- * @returns The contacts phone list.
290
- */
291
- public async getContactPhonesAsync(request: carriers.PhoneList_GetContactPhonesRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
292
-
293
- /**
294
- * Returns an array of phone list items for all the persons belonging to a contact (company). The in-parameter must be a valid contact-id.
295
- * @param contactId - The contact id
296
- * @returns The contacts phone list.
297
- */
298
- public async getContactPhonesAsync(contactId: number, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
299
-
300
- public async getContactPhonesAsync(contactId:number|carriers.PhoneList_GetContactPhonesRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] > {
301
- let _request : carriers.PhoneList_GetContactPhonesRequest = null;
302
- let _options : base.WebApiRequestOptions = null;
303
- const first : any = contactId;
304
- if( typeof( first ) === "object" && first && ( typeof(first.contactId)!='undefined' ) )
305
- {
306
- _request = contactId as carriers.PhoneList_GetContactPhonesRequest;
307
- _options = webapi_options as base.WebApiRequestOptions;
308
- }
309
- else
310
- {
311
- _request = {
312
- contactId: contactId as number,
313
- };
314
- _options = webapi_options;
315
- }
316
- return this._getContactPhonesAsync( _request, _options );
317
- }
318
-
319
-
320
- private async _addToFavoritesAsync(request: carriers.PhoneList_AddToFavoritesRequest, options?:base.WebApiRequestOptions) : Promise< number > {
321
- const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
322
- base.WebApiBase.SetPending(options);
323
- return new Promise< number >(async (resolve, reject) => {
324
- try {
325
- config.baseURL = this._options.baseUrl;
326
- const response = await this._axios.post("AddToFavorites", request , config);
327
- base.WebApiBase.SetCompleted(options, response);
328
- const res : number = response.data as number;
329
- resolve(res);
330
- }
331
- catch( err ) {
332
- base.WebApiBase.HandleError(options, config, err);
333
- reject(err);
334
- }
335
- });
336
- }
337
-
338
-
339
-
340
- /**
341
- * Adds a new contact to the history/favorites. Returns the rank of the new history item. If the contact already existed in the history, it isn&apos;t added but the rank is updated.
342
- * @param request - ContactId
343
- * @returns The rank of the history item
344
- */
345
- public async addToFavoritesAsync(request: carriers.PhoneList_AddToFavoritesRequest, webapi_options?:base.WebApiRequestOptions) : Promise< number >;
346
-
347
- /**
348
- * Adds a new contact to the history/favorites. Returns the rank of the new history item. If the contact already existed in the history, it isn&apos;t added but the rank is updated.
349
- * @param contactId - The contact id
350
- * @returns The rank of the history item
351
- */
352
- public async addToFavoritesAsync(contactId: number, webapi_options?:base.WebApiRequestOptions) : Promise< number >;
353
-
354
- public async addToFavoritesAsync(contactId:number|carriers.PhoneList_AddToFavoritesRequest, webapi_options?:base.WebApiRequestOptions) : Promise< number > {
355
- let _request : carriers.PhoneList_AddToFavoritesRequest = null;
356
- let _options : base.WebApiRequestOptions = null;
357
- const first : any = contactId;
358
- if( typeof( first ) === "object" && first && ( typeof(first.contactId)!='undefined' ) )
359
- {
360
- _request = contactId as carriers.PhoneList_AddToFavoritesRequest;
361
- _options = webapi_options as base.WebApiRequestOptions;
362
- }
363
- else
364
- {
365
- _request = {
366
- contactId: contactId as number,
367
- };
368
- _options = webapi_options;
369
- }
370
- return this._addToFavoritesAsync( _request, _options );
371
- }
372
-
373
-
374
- private async _getPreferencesAsync( options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListPreferences > {
375
- const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
376
- base.WebApiBase.SetPending(options);
377
- return new Promise< carriers.PhoneListPreferences >(async (resolve, reject) => {
378
- try {
379
- config.baseURL = this._options.baseUrl;
380
- const response = await this._axios.post("GetPreferences", undefined , config);
381
- base.WebApiBase.SetCompleted(options, response);
382
- const res : carriers.PhoneListPreferences = converters.Create_PhoneListPreferences_From( response.data );
383
- resolve(res);
384
- }
385
- catch( err ) {
386
- base.WebApiBase.HandleError(options, config, err);
387
- reject(err);
388
- }
389
- });
390
- }
391
-
392
-
393
- /**
394
- * Getting Phone List Preferences from the CRM 5 user preferences
395
- * @returns The Phone List Preferences
396
- */
397
- public async getPreferencesAsync(webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListPreferences >
398
- {
399
- return this._getPreferencesAsync(webapi_options);
400
- }
401
-
402
-
403
- private async _setPreferencesAsync(request: carriers.PhoneList_SetPreferencesRequest, options?:base.WebApiRequestOptions) : Promise< void > {
404
- const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
405
- base.WebApiBase.SetPending(options);
406
- return new Promise< void >(async (resolve, reject) => {
407
- try {
408
- config.baseURL = this._options.baseUrl;
409
- const response = await this._axios.post("SetPreferences", request , config);
410
- base.WebApiBase.SetCompleted(options, response);
411
- const res = response.data;
412
- resolve(res);
413
- }
414
- catch( err ) {
415
- base.WebApiBase.HandleError(options, config, err);
416
- reject(err);
417
- }
418
- });
419
- }
420
-
421
-
422
-
423
- /**
424
- * Setting Phone List Preferences to the CRM 5 user preferences
425
- * @param request - Preferences
426
- * @returns
427
- */
428
- public async setPreferencesAsync(request: carriers.PhoneList_SetPreferencesRequest, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
429
-
430
- /**
431
- * Setting Phone List Preferences to the CRM 5 user preferences
432
- * @param preferences - The preference that is set as user preferences
433
- * @returns
434
- */
435
- public async setPreferencesAsync(preferences: carriers.PhoneListPreferences, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
436
-
437
- public async setPreferencesAsync(preferences:carriers.PhoneListPreferences|carriers.PhoneList_SetPreferencesRequest, webapi_options?:base.WebApiRequestOptions) : Promise< void > {
438
- let _request : carriers.PhoneList_SetPreferencesRequest = null;
439
- let _options : base.WebApiRequestOptions = null;
440
- const first : any = preferences;
441
- if( typeof( first ) === "object" && first && ( typeof(first.preferences)!='undefined' ) )
442
- {
443
- _request = preferences as carriers.PhoneList_SetPreferencesRequest;
444
- _options = webapi_options as base.WebApiRequestOptions;
445
- }
446
- else
447
- {
448
- _request = {
449
- preferences: preferences as carriers.PhoneListPreferences,
450
- };
451
- _options = webapi_options;
452
- }
453
- return this._setPreferencesAsync( _request, _options );
454
- }
455
-
456
- } // class v1PhoneListAgentController
457
-
458
-
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/PhoneListAgent.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
+ * Collection of all services for searching for person or contact (company) phone numbers.
28
+ */
29
+ export interface IPhoneListAgent {
30
+ searchAsync(request: carriers.PhoneList_SearchRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
31
+ searchAsync(searchString: string, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
32
+ searchWithPreferencesAsync(request: carriers.PhoneList_SearchWithPreferencesRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
33
+ searchWithPreferencesAsync(searchString: string, preferences: carriers.PhoneListPreferences, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
34
+ getDepartmentPhonesAsync(request: carriers.PhoneList_GetDepartmentPhonesRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
35
+ getDepartmentPhonesAsync(departmentId: number, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
36
+ getFavoritesPhonesAsync(webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
37
+ getContactPhonesAsync(request: carriers.PhoneList_GetContactPhonesRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
38
+ getContactPhonesAsync(contactId: number, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
39
+ addToFavoritesAsync(request: carriers.PhoneList_AddToFavoritesRequest, webapi_options?:base.WebApiRequestOptions) : Promise< number >;
40
+ addToFavoritesAsync(contactId: number, webapi_options?:base.WebApiRequestOptions) : Promise< number >;
41
+ getPreferencesAsync(webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListPreferences >;
42
+ setPreferencesAsync(request: carriers.PhoneList_SetPreferencesRequest, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
43
+ setPreferencesAsync(preferences: carriers.PhoneListPreferences, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
44
+ } // interface IPhoneListAgent
45
+
46
+
47
+
48
+
49
+ /**
50
+ * Collection of all services for searching for person or contact (company) phone numbers.
51
+ */
52
+ export class PhoneListAgent extends base.WebApiBase implements IPhoneListAgent {
53
+ constructor(baseUrl?: string, languageCode?:string, cultureCode?: string);
54
+ constructor(baseUrl?: string, resourceParsing?: base.ResourceParsing);
55
+ constructor(baseUrl: string, resourceManager:any);
56
+ constructor(baseUrl: string, config:AxiosRequestConfig, resourceManager:any);
57
+ constructor(baseUrl: string, config:AxiosRequestConfig, resourceParsing?: base.ResourceParsing);
58
+ constructor(baseUrl: string, config:AxiosRequestConfig, languageCode?:string, cultureCode?: string);
59
+ constructor(options: base.WebApiOptions);
60
+
61
+ constructor(baseUrlOrOptions: string|base.WebApiOptions|undefined,
62
+ langOrconfigOrRM?: string|base.ResourceParsing|AxiosRequestConfig|any,
63
+ langOrResourceOrRM?:string|base.ResourceParsing|any,
64
+ cultureCode?: string,
65
+ ) {
66
+ const options = base.WebApiBase.FigureOutOptions(baseUrlOrOptions, langOrconfigOrRM, langOrResourceOrRM, cultureCode);
67
+ options.basePath = "v1/Agents/PhoneList/";
68
+ super(options);
69
+ }
70
+
71
+
72
+
73
+ private async _searchAsync(request: carriers.PhoneList_SearchRequest, options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] > {
74
+ const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
75
+ base.WebApiBase.SetPending(options);
76
+ return new Promise< carriers.PhoneListItem[] >(async (resolve, reject) => {
77
+ try {
78
+ config.baseURL = this._options.baseUrl;
79
+ const response = await this._axios.post("Search", request , config);
80
+ base.WebApiBase.SetCompleted(options, response);
81
+ const res : carriers.PhoneListItem[] = converters.Create_PhoneListItemArray_From( response.data );
82
+ resolve(res);
83
+ }
84
+ catch( err ) {
85
+ base.WebApiBase.HandleError(options, config, err);
86
+ reject(err);
87
+ }
88
+ });
89
+ }
90
+
91
+
92
+
93
+ /**
94
+ * Searching the phone list. Using default search preferences or the preferences already set by the PhoneListPreferences Service
95
+ * @param request - SearchString
96
+ * @returns The resulting phone list
97
+ */
98
+ public async searchAsync(request: carriers.PhoneList_SearchRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
99
+
100
+ /**
101
+ * Searching the phone list. Using default search preferences or the preferences already set by the PhoneListPreferences Service
102
+ * @param searchString - The search string
103
+ * @returns The resulting phone list
104
+ */
105
+ public async searchAsync(searchString: string, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
106
+
107
+ public async searchAsync(searchString:string|carriers.PhoneList_SearchRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] > {
108
+ let _request : carriers.PhoneList_SearchRequest = null;
109
+ let _options : base.WebApiRequestOptions = null;
110
+ const first : any = searchString;
111
+ if( typeof( first ) === "object" && first && ( typeof(first.searchString)!='undefined' ) )
112
+ {
113
+ _request = searchString as carriers.PhoneList_SearchRequest;
114
+ _options = webapi_options as base.WebApiRequestOptions;
115
+ }
116
+ else
117
+ {
118
+ _request = {
119
+ searchString: searchString as string,
120
+ };
121
+ _options = webapi_options;
122
+ }
123
+ return this._searchAsync( _request, _options );
124
+ }
125
+
126
+
127
+ private async _searchWithPreferencesAsync(request: carriers.PhoneList_SearchWithPreferencesRequest, options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] > {
128
+ const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
129
+ base.WebApiBase.SetPending(options);
130
+ return new Promise< carriers.PhoneListItem[] >(async (resolve, reject) => {
131
+ try {
132
+ config.baseURL = this._options.baseUrl;
133
+ const response = await this._axios.post("SearchWithPreferences", request , config);
134
+ base.WebApiBase.SetCompleted(options, response);
135
+ const res : carriers.PhoneListItem[] = converters.Create_PhoneListItemArray_From( response.data );
136
+ resolve(res);
137
+ }
138
+ catch( err ) {
139
+ base.WebApiBase.HandleError(options, config, err);
140
+ reject(err);
141
+ }
142
+ });
143
+ }
144
+
145
+
146
+
147
+ /**
148
+ * Searching the phone list. Search is based on the supplied preferences.
149
+ * @param request - SearchString, Preferences
150
+ * @returns The resulting phone list.
151
+ */
152
+ public async searchWithPreferencesAsync(request: carriers.PhoneList_SearchWithPreferencesRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
153
+
154
+ /**
155
+ * Searching the phone list. Search is based on the supplied preferences.
156
+ * @param searchString - The search string.
157
+ * @param preferences - The search preferences
158
+ * @returns The resulting phone list.
159
+ */
160
+ public async searchWithPreferencesAsync(searchString: string, preferences: carriers.PhoneListPreferences, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
161
+
162
+ public async searchWithPreferencesAsync(searchString:string|carriers.PhoneList_SearchWithPreferencesRequest, preferences?:carriers.PhoneListPreferences|base.WebApiRequestOptions, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] > {
163
+ let _request : carriers.PhoneList_SearchWithPreferencesRequest = null;
164
+ let _options : base.WebApiRequestOptions = null;
165
+ const first : any = searchString;
166
+ if( typeof( first ) === "object" && first && ( typeof(first.searchString)!='undefined' || typeof(first.preferences)!='undefined' ) )
167
+ {
168
+ _request = searchString as carriers.PhoneList_SearchWithPreferencesRequest;
169
+ _options = preferences as base.WebApiRequestOptions;
170
+ }
171
+ else
172
+ {
173
+ _request = {
174
+ searchString: searchString as string,
175
+ preferences: preferences as carriers.PhoneListPreferences,
176
+ };
177
+ _options = webapi_options;
178
+ }
179
+ return this._searchWithPreferencesAsync( _request, _options );
180
+ }
181
+
182
+
183
+ private async _getDepartmentPhonesAsync(request: carriers.PhoneList_GetDepartmentPhonesRequest, options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] > {
184
+ const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
185
+ base.WebApiBase.SetPending(options);
186
+ return new Promise< carriers.PhoneListItem[] >(async (resolve, reject) => {
187
+ try {
188
+ config.baseURL = this._options.baseUrl;
189
+ const response = await this._axios.post("GetDepartmentPhones", request , config);
190
+ base.WebApiBase.SetCompleted(options, response);
191
+ const res : carriers.PhoneListItem[] = converters.Create_PhoneListItemArray_From( response.data );
192
+ resolve(res);
193
+ }
194
+ catch( err ) {
195
+ base.WebApiBase.HandleError(options, config, err);
196
+ reject(err);
197
+ }
198
+ });
199
+ }
200
+
201
+
202
+
203
+ /**
204
+ * Returns an array of phone list items with the in-parameter as restriction. The in-parameter must be a valid department id (UserGroupId).
205
+ * @param request - DepartmentId
206
+ * @returns The department phone list
207
+ */
208
+ public async getDepartmentPhonesAsync(request: carriers.PhoneList_GetDepartmentPhonesRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
209
+
210
+ /**
211
+ * Returns an array of phone list items with the in-parameter as restriction. The in-parameter must be a valid department id (UserGroupId).
212
+ * @param departmentId - The department to get the phone list for
213
+ * @returns The department phone list
214
+ */
215
+ public async getDepartmentPhonesAsync(departmentId: number, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
216
+
217
+ public async getDepartmentPhonesAsync(departmentId:number|carriers.PhoneList_GetDepartmentPhonesRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] > {
218
+ let _request : carriers.PhoneList_GetDepartmentPhonesRequest = null;
219
+ let _options : base.WebApiRequestOptions = null;
220
+ const first : any = departmentId;
221
+ if( typeof( first ) === "object" && first && ( typeof(first.departmentId)!='undefined' ) )
222
+ {
223
+ _request = departmentId as carriers.PhoneList_GetDepartmentPhonesRequest;
224
+ _options = webapi_options as base.WebApiRequestOptions;
225
+ }
226
+ else
227
+ {
228
+ _request = {
229
+ departmentId: departmentId as number,
230
+ };
231
+ _options = webapi_options;
232
+ }
233
+ return this._getDepartmentPhonesAsync( _request, _options );
234
+ }
235
+
236
+
237
+ private async _getFavoritesPhonesAsync( options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] > {
238
+ const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
239
+ base.WebApiBase.SetPending(options);
240
+ return new Promise< carriers.PhoneListItem[] >(async (resolve, reject) => {
241
+ try {
242
+ config.baseURL = this._options.baseUrl;
243
+ const response = await this._axios.post("GetFavoritesPhones", undefined , config);
244
+ base.WebApiBase.SetCompleted(options, response);
245
+ const res : carriers.PhoneListItem[] = converters.Create_PhoneListItemArray_From( response.data );
246
+ resolve(res);
247
+ }
248
+ catch( err ) {
249
+ base.WebApiBase.HandleError(options, config, err);
250
+ reject(err);
251
+ }
252
+ });
253
+ }
254
+
255
+
256
+ /**
257
+ * Returns an array of phone list items with the Contacts in the users favorites dropdown list.
258
+ * @returns The favorite contact phone list
259
+ */
260
+ public async getFavoritesPhonesAsync(webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >
261
+ {
262
+ return this._getFavoritesPhonesAsync(webapi_options);
263
+ }
264
+
265
+
266
+ private async _getContactPhonesAsync(request: carriers.PhoneList_GetContactPhonesRequest, options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] > {
267
+ const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
268
+ base.WebApiBase.SetPending(options);
269
+ return new Promise< carriers.PhoneListItem[] >(async (resolve, reject) => {
270
+ try {
271
+ config.baseURL = this._options.baseUrl;
272
+ const response = await this._axios.post("GetContactPhones", request , config);
273
+ base.WebApiBase.SetCompleted(options, response);
274
+ const res : carriers.PhoneListItem[] = converters.Create_PhoneListItemArray_From( response.data );
275
+ resolve(res);
276
+ }
277
+ catch( err ) {
278
+ base.WebApiBase.HandleError(options, config, err);
279
+ reject(err);
280
+ }
281
+ });
282
+ }
283
+
284
+
285
+
286
+ /**
287
+ * Returns an array of phone list items for all the persons belonging to a contact (company). The in-parameter must be a valid contact-id.
288
+ * @param request - ContactId
289
+ * @returns The contacts phone list.
290
+ */
291
+ public async getContactPhonesAsync(request: carriers.PhoneList_GetContactPhonesRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
292
+
293
+ /**
294
+ * Returns an array of phone list items for all the persons belonging to a contact (company). The in-parameter must be a valid contact-id.
295
+ * @param contactId - The contact id
296
+ * @returns The contacts phone list.
297
+ */
298
+ public async getContactPhonesAsync(contactId: number, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] >;
299
+
300
+ public async getContactPhonesAsync(contactId:number|carriers.PhoneList_GetContactPhonesRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListItem[] > {
301
+ let _request : carriers.PhoneList_GetContactPhonesRequest = null;
302
+ let _options : base.WebApiRequestOptions = null;
303
+ const first : any = contactId;
304
+ if( typeof( first ) === "object" && first && ( typeof(first.contactId)!='undefined' ) )
305
+ {
306
+ _request = contactId as carriers.PhoneList_GetContactPhonesRequest;
307
+ _options = webapi_options as base.WebApiRequestOptions;
308
+ }
309
+ else
310
+ {
311
+ _request = {
312
+ contactId: contactId as number,
313
+ };
314
+ _options = webapi_options;
315
+ }
316
+ return this._getContactPhonesAsync( _request, _options );
317
+ }
318
+
319
+
320
+ private async _addToFavoritesAsync(request: carriers.PhoneList_AddToFavoritesRequest, options?:base.WebApiRequestOptions) : Promise< number > {
321
+ const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
322
+ base.WebApiBase.SetPending(options);
323
+ return new Promise< number >(async (resolve, reject) => {
324
+ try {
325
+ config.baseURL = this._options.baseUrl;
326
+ const response = await this._axios.post("AddToFavorites", request , config);
327
+ base.WebApiBase.SetCompleted(options, response);
328
+ const res : number = response.data as number;
329
+ resolve(res);
330
+ }
331
+ catch( err ) {
332
+ base.WebApiBase.HandleError(options, config, err);
333
+ reject(err);
334
+ }
335
+ });
336
+ }
337
+
338
+
339
+
340
+ /**
341
+ * Adds a new contact to the history/favorites. Returns the rank of the new history item. If the contact already existed in the history, it isn&apos;t added but the rank is updated.
342
+ * @param request - ContactId
343
+ * @returns The rank of the history item
344
+ */
345
+ public async addToFavoritesAsync(request: carriers.PhoneList_AddToFavoritesRequest, webapi_options?:base.WebApiRequestOptions) : Promise< number >;
346
+
347
+ /**
348
+ * Adds a new contact to the history/favorites. Returns the rank of the new history item. If the contact already existed in the history, it isn&apos;t added but the rank is updated.
349
+ * @param contactId - The contact id
350
+ * @returns The rank of the history item
351
+ */
352
+ public async addToFavoritesAsync(contactId: number, webapi_options?:base.WebApiRequestOptions) : Promise< number >;
353
+
354
+ public async addToFavoritesAsync(contactId:number|carriers.PhoneList_AddToFavoritesRequest, webapi_options?:base.WebApiRequestOptions) : Promise< number > {
355
+ let _request : carriers.PhoneList_AddToFavoritesRequest = null;
356
+ let _options : base.WebApiRequestOptions = null;
357
+ const first : any = contactId;
358
+ if( typeof( first ) === "object" && first && ( typeof(first.contactId)!='undefined' ) )
359
+ {
360
+ _request = contactId as carriers.PhoneList_AddToFavoritesRequest;
361
+ _options = webapi_options as base.WebApiRequestOptions;
362
+ }
363
+ else
364
+ {
365
+ _request = {
366
+ contactId: contactId as number,
367
+ };
368
+ _options = webapi_options;
369
+ }
370
+ return this._addToFavoritesAsync( _request, _options );
371
+ }
372
+
373
+
374
+ private async _getPreferencesAsync( options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListPreferences > {
375
+ const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
376
+ base.WebApiBase.SetPending(options);
377
+ return new Promise< carriers.PhoneListPreferences >(async (resolve, reject) => {
378
+ try {
379
+ config.baseURL = this._options.baseUrl;
380
+ const response = await this._axios.post("GetPreferences", undefined , config);
381
+ base.WebApiBase.SetCompleted(options, response);
382
+ const res : carriers.PhoneListPreferences = converters.Create_PhoneListPreferences_From( response.data );
383
+ resolve(res);
384
+ }
385
+ catch( err ) {
386
+ base.WebApiBase.HandleError(options, config, err);
387
+ reject(err);
388
+ }
389
+ });
390
+ }
391
+
392
+
393
+ /**
394
+ * Getting Phone List Preferences from the CRM 5 user preferences
395
+ * @returns The Phone List Preferences
396
+ */
397
+ public async getPreferencesAsync(webapi_options?:base.WebApiRequestOptions) : Promise< carriers.PhoneListPreferences >
398
+ {
399
+ return this._getPreferencesAsync(webapi_options);
400
+ }
401
+
402
+
403
+ private async _setPreferencesAsync(request: carriers.PhoneList_SetPreferencesRequest, options?:base.WebApiRequestOptions) : Promise< void > {
404
+ const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
405
+ base.WebApiBase.SetPending(options);
406
+ return new Promise< void >(async (resolve, reject) => {
407
+ try {
408
+ config.baseURL = this._options.baseUrl;
409
+ const response = await this._axios.post("SetPreferences", request , config);
410
+ base.WebApiBase.SetCompleted(options, response);
411
+ const res = response.data;
412
+ resolve(res);
413
+ }
414
+ catch( err ) {
415
+ base.WebApiBase.HandleError(options, config, err);
416
+ reject(err);
417
+ }
418
+ });
419
+ }
420
+
421
+
422
+
423
+ /**
424
+ * Setting Phone List Preferences to the CRM 5 user preferences
425
+ * @param request - Preferences
426
+ * @returns
427
+ */
428
+ public async setPreferencesAsync(request: carriers.PhoneList_SetPreferencesRequest, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
429
+
430
+ /**
431
+ * Setting Phone List Preferences to the CRM 5 user preferences
432
+ * @param preferences - The preference that is set as user preferences
433
+ * @returns
434
+ */
435
+ public async setPreferencesAsync(preferences: carriers.PhoneListPreferences, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
436
+
437
+ public async setPreferencesAsync(preferences:carriers.PhoneListPreferences|carriers.PhoneList_SetPreferencesRequest, webapi_options?:base.WebApiRequestOptions) : Promise< void > {
438
+ let _request : carriers.PhoneList_SetPreferencesRequest = null;
439
+ let _options : base.WebApiRequestOptions = null;
440
+ const first : any = preferences;
441
+ if( typeof( first ) === "object" && first && ( typeof(first.preferences)!='undefined' ) )
442
+ {
443
+ _request = preferences as carriers.PhoneList_SetPreferencesRequest;
444
+ _options = webapi_options as base.WebApiRequestOptions;
445
+ }
446
+ else
447
+ {
448
+ _request = {
449
+ preferences: preferences as carriers.PhoneListPreferences,
450
+ };
451
+ _options = webapi_options;
452
+ }
453
+ return this._setPreferencesAsync( _request, _options );
454
+ }
455
+
456
+ } // class v1PhoneListAgentController
457
+
458
+