@superoffice/webapi 11.7.727 → 11.8.788
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.
- package/LICENSE.md +15 -15
- package/README.md +184 -184
- package/__tests__/Appointment63-notz.json +1925 -1925
- package/__tests__/Appointment63-utctz.json +1925 -1925
- package/__tests__/Appointment63.json +1925 -1925
- package/__tests__/AppointmentTzTest.ts +115 -115
- package/__tests__/AxiosNockTest.ts +28 -28
- package/__tests__/ContactDefault.json +699 -699
- package/__tests__/ContactEntity.json +272 -272
- package/__tests__/ContactRestTest.ts +144 -144
- package/__tests__/ContactTest.ts +395 -395
- package/__tests__/ConvertersTest.ts +97 -97
- package/__tests__/DocumentTest.ts +101 -101
- package/__tests__/Person210-notz.json +1932 -1932
- package/__tests__/Person210-utctz.json +1932 -1932
- package/__tests__/Person210.json +1932 -1932
- package/__tests__/PersonImageData.nock +22 -22
- package/__tests__/PersonTest.ts +41 -41
- package/__tests__/PersonTzTest.ts +113 -113
- package/__tests__/RecurrenceInfo.json +55 -55
- package/__tests__/ResponseCallbackTest.ts +23 -23
- package/__tests__/TableRights.json +441 -441
- package/__tests__/WebapiTest.ts +264 -264
- package/__tests__/Webhook.json +16 -16
- package/__tests__/WebhookTest.ts +209 -209
- package/dist/cjs/Carriers.d.ts +367 -4
- package/dist/cjs/Carriers.d.ts.map +1 -1
- package/dist/cjs/Converters.d.ts +9 -0
- package/dist/cjs/Converters.d.ts.map +1 -1
- package/dist/cjs/Converters.js +185 -17
- package/dist/cjs/Converters.js.map +1 -1
- package/dist/cjs/DiagnosticsAgent.d.ts +38 -0
- package/dist/cjs/DiagnosticsAgent.d.ts.map +1 -1
- package/dist/cjs/DiagnosticsAgent.js +91 -0
- package/dist/cjs/DiagnosticsAgent.js.map +1 -1
- package/dist/cjs/Enums.d.ts +18 -0
- package/dist/cjs/Enums.d.ts.map +1 -1
- package/dist/cjs/Enums.js +20 -1
- package/dist/cjs/Enums.js.map +1 -1
- package/dist/cjs/ListAgent.d.ts +71 -6
- package/dist/cjs/ListAgent.d.ts.map +1 -1
- package/dist/cjs/ListAgent.js +157 -0
- package/dist/cjs/ListAgent.js.map +1 -1
- package/dist/cjs/TicketAgent.d.ts +23 -0
- package/dist/cjs/TicketAgent.d.ts.map +1 -1
- package/dist/cjs/TicketAgent.js +65 -0
- package/dist/cjs/TicketAgent.js.map +1 -1
- package/dist/esm/Carriers.d.ts +367 -4
- package/dist/esm/Carriers.d.ts.map +1 -1
- package/dist/esm/Converters.d.ts +9 -0
- package/dist/esm/Converters.d.ts.map +1 -1
- package/dist/esm/Converters.js +159 -0
- package/dist/esm/Converters.js.map +1 -1
- package/dist/esm/DiagnosticsAgent.d.ts +38 -0
- package/dist/esm/DiagnosticsAgent.d.ts.map +1 -1
- package/dist/esm/DiagnosticsAgent.js +91 -0
- package/dist/esm/DiagnosticsAgent.js.map +1 -1
- package/dist/esm/Enums.d.ts +18 -0
- package/dist/esm/Enums.d.ts.map +1 -1
- package/dist/esm/Enums.js +19 -0
- package/dist/esm/Enums.js.map +1 -1
- package/dist/esm/ListAgent.d.ts +71 -6
- package/dist/esm/ListAgent.d.ts.map +1 -1
- package/dist/esm/ListAgent.js +157 -0
- package/dist/esm/ListAgent.js.map +1 -1
- package/dist/esm/TicketAgent.d.ts +23 -0
- package/dist/esm/TicketAgent.d.ts.map +1 -1
- package/dist/esm/TicketAgent.js +65 -0
- package/dist/esm/TicketAgent.js.map +1 -1
- package/examples-js/hello.js +12 -12
- package/examples-ts/hello.ts +8 -8
- package/package.json +93 -93
- package/scripts/postbuild.js +22 -22
- package/scripts/setVersion.js +44 -44
- package/src/AIAgent.ts +1992 -1992
- package/src/AppointmentAgent.ts +6263 -6263
- package/src/AppointmentRestApi.ts +225 -225
- package/src/ArchiveAgent.ts +1950 -1950
- package/src/AssociateAgent.ts +422 -422
- package/src/AxiosCacheHandler.ts +74 -74
- package/src/BLOBAgent.ts +2100 -2100
- package/src/Base64.ts +285 -285
- package/src/BatchAgent.ts +910 -910
- package/src/BulkUpdateAgent.ts +504 -504
- package/src/CRMScriptAgent.ts +1390 -1390
- package/src/Carriers.ts +52750 -52274
- package/src/ChatAgent.ts +1422 -1422
- package/src/ConfigurationAgent.ts +2228 -2228
- package/src/ContactAgent.ts +1756 -1756
- package/src/ContactRestApi.ts +237 -237
- package/src/Converters.ts +23271 -23090
- package/src/CustomerServiceAgent.ts +1799 -1799
- package/src/DashAgent.ts +1674 -1674
- package/src/DatabaseAgent.ts +120 -120
- package/src/DatabaseTableAgent.ts +534 -534
- package/src/Day_js.ts +41 -41
- package/src/DiagnosticsAgent.ts +1384 -1240
- package/src/DocumentAgent.ts +5079 -5079
- package/src/DocumentMigrationAgent.ts +524 -524
- package/src/DocumentRestApi.ts +259 -259
- package/src/EMailAgent.ts +5328 -5328
- package/src/Enums.ts +6936 -6916
- package/src/ErpSyncAgent.ts +2658 -2658
- package/src/FavouriteAgent.ts +720 -720
- package/src/FindAgent.ts +2330 -2330
- package/src/ForeignSystemAgent.ts +1710 -1710
- package/src/FreeTextAgent.ts +372 -372
- package/src/ImportAgent.ts +304 -304
- package/src/LicenseAgent.ts +1230 -1230
- package/src/ListAgent.ts +11451 -11237
- package/src/MDOAgent.ts +748 -748
- package/src/MarketingAgent.ts +890 -890
- package/src/MessagingAgent.ts +384 -384
- package/src/NavigatorAgent.ts +140 -140
- package/src/NumberAllocationAgent.ts +296 -296
- package/src/PersonAgent.ts +3287 -3287
- package/src/PersonRestApi.ts +241 -241
- package/src/PhoneListAgent.ts +458 -458
- package/src/PocketAgent.ts +780 -780
- package/src/PreferenceAgent.ts +1900 -1900
- package/src/PreviewsAgent.ts +116 -116
- package/src/ProjectAgent.ts +2391 -2391
- package/src/ProjectRestApi.ts +239 -239
- package/src/QuoteAgent.ts +5159 -5159
- package/src/RelationAgent.ts +220 -220
- package/src/ReportAgent.ts +154 -154
- package/src/ResourceAgent.ts +358 -358
- package/src/SaintAgent.ts +601 -601
- package/src/SaleAgent.ts +2034 -2034
- package/src/SaleRestApi.ts +233 -233
- package/src/SelectionAgent.ts +3195 -3195
- package/src/SentryAgent.ts +462 -462
- package/src/SoApiConstants.ts +8 -8
- package/src/TargetsAgent.ts +1104 -1104
- package/src/TicketAgent.ts +3708 -3638
- package/src/TimeZoneAgent.ts +528 -528
- package/src/TooltipsAgent.ts +116 -116
- package/src/UserAgent.ts +4856 -4856
- package/src/UserDefinedFieldInfoAgent.ts +1764 -1764
- package/src/ViewStateAgent.ts +858 -858
- package/src/WebApi.ts +872 -872
- package/src/WebApiBase.ts +565 -565
- package/src/WebhookAgent.ts +388 -388
- package/src/WorkflowAgent.ts +1338 -1338
- package/tsconfig.esm.json +8 -8
- package/tsconfig.jest.json +8 -8
- package/tsconfig.json +34 -34
package/src/WebhookAgent.ts
CHANGED
|
@@ -1,388 +1,388 @@
|
|
|
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/WebhookAgent.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
|
-
* Webhook definitions - webhooks signal other systems about events inside NetServer
|
|
28
|
-
*
|
|
29
|
-
* **Online Restricted:** This agent is not available in Online by default. Access must be requested specifically when app is registered.
|
|
30
|
-
*/
|
|
31
|
-
export interface IWebhookAgent {
|
|
32
|
-
createDefaultWebhookAsync(): Promise< carriers.Webhook >;
|
|
33
|
-
saveWebhookAsync(entity: carriers.Webhook) : Promise< carriers.Webhook >;
|
|
34
|
-
deleteWebhookAsync(WebhookId: number) : Promise<void>;
|
|
35
|
-
getWebhookAsync(webhookId: number) : Promise< carriers.Webhook >;
|
|
36
|
-
getAllWebhooksAsync(request: carriers.Webhook_GetAllWebhooksRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.Webhook[] >;
|
|
37
|
-
getAllWebhooksAsync(nameFilter: string, eventFilter: string, statusFilter: enums.WebhookState, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.Webhook[] >;
|
|
38
|
-
testWebhookAsync(request: carriers.Webhook_TestWebhookRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.WebhookResult >;
|
|
39
|
-
testWebhookAsync(webhook: carriers.Webhook, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.WebhookResult >;
|
|
40
|
-
signalEventAsync(request: carriers.Webhook_SignalEventRequest, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
|
|
41
|
-
signalEventAsync(eventName: string, primaryKey: number, data: carriers.StringObjectDictionary, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
|
|
42
|
-
getLastErrorAsync(request: carriers.Webhook_GetLastErrorRequest, webapi_options?:base.WebApiRequestOptions) : Promise< string >;
|
|
43
|
-
getLastErrorAsync(webhookId: number, webapi_options?:base.WebApiRequestOptions) : Promise< string >;
|
|
44
|
-
} // interface IWebhookAgent
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Webhook definitions - webhooks signal other systems about events inside NetServer
|
|
51
|
-
*/
|
|
52
|
-
export class WebhookAgent extends base.WebApiBase implements IWebhookAgent {
|
|
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/Webhook/";
|
|
68
|
-
super(options);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Set default values into a new Webhook.
|
|
75
|
-
* NetServer calculates default values on the entity, which is required when creating/storing a new instance
|
|
76
|
-
* @param options - Override language/culture codes on this request. Provide cancellation and request status values.
|
|
77
|
-
* @returns A blank entity.
|
|
78
|
-
*/
|
|
79
|
-
public async createDefaultWebhookAsync(options?:base.WebApiRequestOptions) : Promise< carriers.Webhook > {
|
|
80
|
-
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
81
|
-
base.WebApiBase.SetPending(options);
|
|
82
|
-
return new Promise< carriers.Webhook >(async (resolve, reject) => {
|
|
83
|
-
try {
|
|
84
|
-
const response = await this._axios.post("CreateDefaultWebhook", null, config);
|
|
85
|
-
base.WebApiBase.SetCompleted(options, response);
|
|
86
|
-
const res : carriers.Webhook = converters.Create_Webhook_From( response.data );
|
|
87
|
-
resolve(res);
|
|
88
|
-
}
|
|
89
|
-
catch( err ) {
|
|
90
|
-
base.WebApiBase.HandleError(options, config, err);
|
|
91
|
-
reject(err);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
/**
|
|
96
|
-
* Replace the existing Webhook or creates a new Webhook if the id parameter is empty
|
|
97
|
-
* @param entity - The Webhook to be saved.
|
|
98
|
-
* @param options - Override language/culture codes on this request. Provide cancellation and request status values.
|
|
99
|
-
* @returns New or updated Webhook
|
|
100
|
-
*/
|
|
101
|
-
public async saveWebhookAsync(entity: carriers.Webhook, options?:base.WebApiRequestOptions) : Promise< carriers.Webhook > {
|
|
102
|
-
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
103
|
-
base.WebApiBase.SetPending(options);
|
|
104
|
-
return new Promise< carriers.Webhook >(async (resolve, reject) => {
|
|
105
|
-
try {
|
|
106
|
-
const response = await this._axios.post("SaveWebhook", entity, config);
|
|
107
|
-
base.WebApiBase.SetCompleted(options, response);
|
|
108
|
-
const res : carriers.Webhook = converters.Create_Webhook_From( response.data );
|
|
109
|
-
resolve(res);
|
|
110
|
-
}
|
|
111
|
-
catch( err ) {
|
|
112
|
-
base.WebApiBase.HandleError(options, config, err);
|
|
113
|
-
reject(err);
|
|
114
|
-
}
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Deletes the Webhook
|
|
120
|
-
* @param WebhookId - The id of the Webhook to be deleted.
|
|
121
|
-
* @param options - Override language/culture codes on this request. Provide cancellation and request status values.
|
|
122
|
-
*/
|
|
123
|
-
public async deleteWebhookAsync(WebhookId: number, options?:base.WebApiRequestOptions) : Promise< void > {
|
|
124
|
-
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
125
|
-
base.WebApiBase.SetPending(options);
|
|
126
|
-
return new Promise< void >(async (resolve, reject) => {
|
|
127
|
-
try {
|
|
128
|
-
const response = await this._axios.post("DeleteWebhook?WebhookId=" + WebhookId, null, config );
|
|
129
|
-
base.WebApiBase.SetCompleted(options, response);
|
|
130
|
-
const res = response.data;
|
|
131
|
-
resolve(res);
|
|
132
|
-
}
|
|
133
|
-
catch( err ) {
|
|
134
|
-
base.WebApiBase.HandleError(options, config, err);
|
|
135
|
-
reject(err);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* Gets a Webhook object.
|
|
141
|
-
* @param webhookId - The primary key.
|
|
142
|
-
* @param options - Override language/culture codes on this request. Provide cancellation and request status values.
|
|
143
|
-
* @returns A single Webhook
|
|
144
|
-
*/
|
|
145
|
-
public async getWebhookAsync(webhookId: number, options?:base.WebApiRequestOptions) : Promise< carriers.Webhook > {
|
|
146
|
-
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
147
|
-
base.WebApiBase.SetPending(options);
|
|
148
|
-
return new Promise< carriers.Webhook >(async (resolve, reject) => {
|
|
149
|
-
try {
|
|
150
|
-
const response = await this._axios.post("GetWebhook?webhookId=" + webhookId, null, config);
|
|
151
|
-
base.WebApiBase.SetCompleted(options, response);
|
|
152
|
-
const res = converters.Create_Webhook_From( response.data );
|
|
153
|
-
resolve(res);
|
|
154
|
-
}
|
|
155
|
-
catch( err ) {
|
|
156
|
-
base.WebApiBase.HandleError(options, config, err);
|
|
157
|
-
reject(err);
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
private async _getAllWebhooksAsync(request: carriers.Webhook_GetAllWebhooksRequest, options?:base.WebApiRequestOptions) : Promise< carriers.Webhook[] > {
|
|
164
|
-
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
165
|
-
base.WebApiBase.SetPending(options);
|
|
166
|
-
return new Promise< carriers.Webhook[] >(async (resolve, reject) => {
|
|
167
|
-
try {
|
|
168
|
-
config.baseURL = this._options.baseUrl;
|
|
169
|
-
const response = await this._axios.post("GetAllWebhooks", request , config);
|
|
170
|
-
base.WebApiBase.SetCompleted(options, response);
|
|
171
|
-
const res : carriers.Webhook[] = converters.Create_WebhookArray_From( response.data );
|
|
172
|
-
resolve(res);
|
|
173
|
-
}
|
|
174
|
-
catch( err ) {
|
|
175
|
-
base.WebApiBase.HandleError(options, config, err);
|
|
176
|
-
reject(err);
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Returns all webhooks, according to filter criteria
|
|
185
|
-
* @param request - NameFilter, EventFilter, StatusFilter
|
|
186
|
-
* @returns Array of all webhooks, filtered according to given criteria.
|
|
187
|
-
*/
|
|
188
|
-
public async getAllWebhooksAsync(request: carriers.Webhook_GetAllWebhooksRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.Webhook[] >;
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Returns all webhooks, according to filter criteria
|
|
192
|
-
* @param nameFilter - Only return hooks with this name. Default NULL = no filter
|
|
193
|
-
* @param eventFilter - Only return hooks responding to this event name. Default NULL = no filter
|
|
194
|
-
* @param statusFilter - Only return hooks with this status. Default Unknown = no filter, returns all.
|
|
195
|
-
* @returns Array of all webhooks, filtered according to given criteria.
|
|
196
|
-
*/
|
|
197
|
-
public async getAllWebhooksAsync(nameFilter: string, eventFilter: string, statusFilter: enums.WebhookState, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.Webhook[] >;
|
|
198
|
-
|
|
199
|
-
public async getAllWebhooksAsync(nameFilter:string|carriers.Webhook_GetAllWebhooksRequest, eventFilter?:string|base.WebApiRequestOptions, statusFilter?:enums.WebhookState, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.Webhook[] > {
|
|
200
|
-
let _request : carriers.Webhook_GetAllWebhooksRequest = null;
|
|
201
|
-
let _options : base.WebApiRequestOptions = null;
|
|
202
|
-
const first : any = nameFilter;
|
|
203
|
-
if( typeof( first ) === "object" && first && ( typeof(first.nameFilter)!='undefined' || typeof(first.eventFilter)!='undefined' || typeof(first.statusFilter)!='undefined' ) )
|
|
204
|
-
{
|
|
205
|
-
_request = nameFilter as carriers.Webhook_GetAllWebhooksRequest;
|
|
206
|
-
_options = eventFilter as base.WebApiRequestOptions;
|
|
207
|
-
}
|
|
208
|
-
else
|
|
209
|
-
{
|
|
210
|
-
_request = {
|
|
211
|
-
nameFilter: nameFilter as string,
|
|
212
|
-
eventFilter: eventFilter as string,
|
|
213
|
-
statusFilter: statusFilter as enums.WebhookState,
|
|
214
|
-
};
|
|
215
|
-
_options = webapi_options;
|
|
216
|
-
}
|
|
217
|
-
return this._getAllWebhooksAsync( _request, _options );
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
private async _testWebhookAsync(request: carriers.Webhook_TestWebhookRequest, options?:base.WebApiRequestOptions) : Promise< carriers.WebhookResult > {
|
|
222
|
-
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
223
|
-
base.WebApiBase.SetPending(options);
|
|
224
|
-
return new Promise< carriers.WebhookResult >(async (resolve, reject) => {
|
|
225
|
-
try {
|
|
226
|
-
config.baseURL = this._options.baseUrl;
|
|
227
|
-
const response = await this._axios.post("TestWebhook", request , config);
|
|
228
|
-
base.WebApiBase.SetCompleted(options, response);
|
|
229
|
-
const res : carriers.WebhookResult = converters.Create_WebhookResult_From( response.data );
|
|
230
|
-
resolve(res);
|
|
231
|
-
}
|
|
232
|
-
catch( err ) {
|
|
233
|
-
base.WebApiBase.HandleError(options, config, err);
|
|
234
|
-
reject(err);
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
/**
|
|
242
|
-
* Pings a webhook with a 'test' event, returns SUCCESS(true) or FAILURE(false) + the response from the webhook target.
|
|
243
|
-
* @param request - Webhook
|
|
244
|
-
* @returns Result of calling webhook. Sucess=true/false + Error message
|
|
245
|
-
*/
|
|
246
|
-
public async testWebhookAsync(request: carriers.Webhook_TestWebhookRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.WebhookResult >;
|
|
247
|
-
|
|
248
|
-
/**
|
|
249
|
-
* Pings a webhook with a 'test' event, returns SUCCESS(true) or FAILURE(false) + the response from the webhook target.
|
|
250
|
-
* @param webhook - Webhook definition to ping. Must contain a valid TargetUrl.
|
|
251
|
-
* @returns Result of calling webhook. Sucess=true/false + Error message
|
|
252
|
-
*/
|
|
253
|
-
public async testWebhookAsync(webhook: carriers.Webhook, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.WebhookResult >;
|
|
254
|
-
|
|
255
|
-
public async testWebhookAsync(webhook:carriers.Webhook|carriers.Webhook_TestWebhookRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.WebhookResult > {
|
|
256
|
-
let _request : carriers.Webhook_TestWebhookRequest = null;
|
|
257
|
-
let _options : base.WebApiRequestOptions = null;
|
|
258
|
-
const first : any = webhook;
|
|
259
|
-
if( typeof( first ) === "object" && first && ( typeof(first.webhook)!='undefined' ) )
|
|
260
|
-
{
|
|
261
|
-
_request = webhook as carriers.Webhook_TestWebhookRequest;
|
|
262
|
-
_options = webapi_options as base.WebApiRequestOptions;
|
|
263
|
-
}
|
|
264
|
-
else
|
|
265
|
-
{
|
|
266
|
-
_request = {
|
|
267
|
-
webhook: webhook as carriers.Webhook,
|
|
268
|
-
};
|
|
269
|
-
_options = webapi_options;
|
|
270
|
-
}
|
|
271
|
-
return this._testWebhookAsync( _request, _options );
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
private async _signalEventAsync(request: carriers.Webhook_SignalEventRequest, options?:base.WebApiRequestOptions) : Promise< void > {
|
|
276
|
-
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
277
|
-
base.WebApiBase.SetPending(options);
|
|
278
|
-
return new Promise< void >(async (resolve, reject) => {
|
|
279
|
-
try {
|
|
280
|
-
config.baseURL = this._options.baseUrl;
|
|
281
|
-
const response = await this._axios.post("SignalEvent", request , config);
|
|
282
|
-
base.WebApiBase.SetCompleted(options, response);
|
|
283
|
-
const res = response.data;
|
|
284
|
-
resolve(res);
|
|
285
|
-
}
|
|
286
|
-
catch( err ) {
|
|
287
|
-
base.WebApiBase.HandleError(options, config, err);
|
|
288
|
-
reject(err);
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
/**
|
|
296
|
-
* Signal webhooks that an event has occurred. All webhooks listening for the event will be notified.
|
|
297
|
-
* @param request - EventName, PrimaryKey, Data
|
|
298
|
-
* @returns This method has no return value
|
|
299
|
-
*/
|
|
300
|
-
public async signalEventAsync(request: carriers.Webhook_SignalEventRequest, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* Signal webhooks that an event has occurred. All webhooks listening for the event will be notified.
|
|
304
|
-
* @param eventName - Name of event to fire. 'entity.verb' For example: 'window.closed', 'button.clicked'.
|
|
305
|
-
* @param primaryKey - (Optional) Id of entity that is firing event. Can be 0 if not used.
|
|
306
|
-
* @param data - Event data. Not all the data values may be posted to the webhook, depending in webhook type: { 'windowName': 'foo', 'widgets': 123 }
|
|
307
|
-
* @returns This method has no return value
|
|
308
|
-
*/
|
|
309
|
-
public async signalEventAsync(eventName: string, primaryKey: number, data: carriers.StringObjectDictionary, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
|
|
310
|
-
|
|
311
|
-
public async signalEventAsync(eventName:string|carriers.Webhook_SignalEventRequest, primaryKey?:number|base.WebApiRequestOptions, data?:carriers.StringObjectDictionary, webapi_options?:base.WebApiRequestOptions) : Promise< void > {
|
|
312
|
-
let _request : carriers.Webhook_SignalEventRequest = null;
|
|
313
|
-
let _options : base.WebApiRequestOptions = null;
|
|
314
|
-
const first : any = eventName;
|
|
315
|
-
if( typeof( first ) === "object" && first && ( typeof(first.eventName)!='undefined' || typeof(first.primaryKey)!='undefined' || typeof(first.data)!='undefined' ) )
|
|
316
|
-
{
|
|
317
|
-
_request = eventName as carriers.Webhook_SignalEventRequest;
|
|
318
|
-
_options = primaryKey as base.WebApiRequestOptions;
|
|
319
|
-
}
|
|
320
|
-
else
|
|
321
|
-
{
|
|
322
|
-
_request = {
|
|
323
|
-
eventName: eventName as string,
|
|
324
|
-
primaryKey: primaryKey as number,
|
|
325
|
-
data: data as carriers.StringObjectDictionary,
|
|
326
|
-
};
|
|
327
|
-
_options = webapi_options;
|
|
328
|
-
}
|
|
329
|
-
return this._signalEventAsync( _request, _options );
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
private async _getLastErrorAsync(request: carriers.Webhook_GetLastErrorRequest, options?:base.WebApiRequestOptions) : Promise< string > {
|
|
334
|
-
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
335
|
-
base.WebApiBase.SetPending(options);
|
|
336
|
-
return new Promise< string >(async (resolve, reject) => {
|
|
337
|
-
try {
|
|
338
|
-
config.baseURL = this._options.baseUrl;
|
|
339
|
-
const response = await this._axios.post("GetLastError", request , config);
|
|
340
|
-
base.WebApiBase.SetCompleted(options, response);
|
|
341
|
-
const res : string = response.data as string;
|
|
342
|
-
resolve(res);
|
|
343
|
-
}
|
|
344
|
-
catch( err ) {
|
|
345
|
-
base.WebApiBase.HandleError(options, config, err);
|
|
346
|
-
reject(err);
|
|
347
|
-
}
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* Return the most recent error message received when calling this webhook.
|
|
355
|
-
* @param request - WebhookId
|
|
356
|
-
* @returns Error message, or empty string if no errors received
|
|
357
|
-
*/
|
|
358
|
-
public async getLastErrorAsync(request: carriers.Webhook_GetLastErrorRequest, webapi_options?:base.WebApiRequestOptions) : Promise< string >;
|
|
359
|
-
|
|
360
|
-
/**
|
|
361
|
-
* Return the most recent error message received when calling this webhook.
|
|
362
|
-
* @param webhookId - Webhook to get error message for.
|
|
363
|
-
* @returns Error message, or empty string if no errors received
|
|
364
|
-
*/
|
|
365
|
-
public async getLastErrorAsync(webhookId: number, webapi_options?:base.WebApiRequestOptions) : Promise< string >;
|
|
366
|
-
|
|
367
|
-
public async getLastErrorAsync(webhookId:number|carriers.Webhook_GetLastErrorRequest, webapi_options?:base.WebApiRequestOptions) : Promise< string > {
|
|
368
|
-
let _request : carriers.Webhook_GetLastErrorRequest = null;
|
|
369
|
-
let _options : base.WebApiRequestOptions = null;
|
|
370
|
-
const first : any = webhookId;
|
|
371
|
-
if( typeof( first ) === "object" && first && ( typeof(first.webhookId)!='undefined' ) )
|
|
372
|
-
{
|
|
373
|
-
_request = webhookId as carriers.Webhook_GetLastErrorRequest;
|
|
374
|
-
_options = webapi_options as base.WebApiRequestOptions;
|
|
375
|
-
}
|
|
376
|
-
else
|
|
377
|
-
{
|
|
378
|
-
_request = {
|
|
379
|
-
webhookId: webhookId as number,
|
|
380
|
-
};
|
|
381
|
-
_options = webapi_options;
|
|
382
|
-
}
|
|
383
|
-
return this._getLastErrorAsync( _request, _options );
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
} // class v1WebhookAgentController
|
|
387
|
-
|
|
388
|
-
|
|
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/WebhookAgent.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
|
+
* Webhook definitions - webhooks signal other systems about events inside NetServer
|
|
28
|
+
*
|
|
29
|
+
* **Online Restricted:** This agent is not available in Online by default. Access must be requested specifically when app is registered.
|
|
30
|
+
*/
|
|
31
|
+
export interface IWebhookAgent {
|
|
32
|
+
createDefaultWebhookAsync(): Promise< carriers.Webhook >;
|
|
33
|
+
saveWebhookAsync(entity: carriers.Webhook) : Promise< carriers.Webhook >;
|
|
34
|
+
deleteWebhookAsync(WebhookId: number) : Promise<void>;
|
|
35
|
+
getWebhookAsync(webhookId: number) : Promise< carriers.Webhook >;
|
|
36
|
+
getAllWebhooksAsync(request: carriers.Webhook_GetAllWebhooksRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.Webhook[] >;
|
|
37
|
+
getAllWebhooksAsync(nameFilter: string, eventFilter: string, statusFilter: enums.WebhookState, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.Webhook[] >;
|
|
38
|
+
testWebhookAsync(request: carriers.Webhook_TestWebhookRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.WebhookResult >;
|
|
39
|
+
testWebhookAsync(webhook: carriers.Webhook, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.WebhookResult >;
|
|
40
|
+
signalEventAsync(request: carriers.Webhook_SignalEventRequest, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
|
|
41
|
+
signalEventAsync(eventName: string, primaryKey: number, data: carriers.StringObjectDictionary, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
|
|
42
|
+
getLastErrorAsync(request: carriers.Webhook_GetLastErrorRequest, webapi_options?:base.WebApiRequestOptions) : Promise< string >;
|
|
43
|
+
getLastErrorAsync(webhookId: number, webapi_options?:base.WebApiRequestOptions) : Promise< string >;
|
|
44
|
+
} // interface IWebhookAgent
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Webhook definitions - webhooks signal other systems about events inside NetServer
|
|
51
|
+
*/
|
|
52
|
+
export class WebhookAgent extends base.WebApiBase implements IWebhookAgent {
|
|
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/Webhook/";
|
|
68
|
+
super(options);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Set default values into a new Webhook.
|
|
75
|
+
* NetServer calculates default values on the entity, which is required when creating/storing a new instance
|
|
76
|
+
* @param options - Override language/culture codes on this request. Provide cancellation and request status values.
|
|
77
|
+
* @returns A blank entity.
|
|
78
|
+
*/
|
|
79
|
+
public async createDefaultWebhookAsync(options?:base.WebApiRequestOptions) : Promise< carriers.Webhook > {
|
|
80
|
+
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
81
|
+
base.WebApiBase.SetPending(options);
|
|
82
|
+
return new Promise< carriers.Webhook >(async (resolve, reject) => {
|
|
83
|
+
try {
|
|
84
|
+
const response = await this._axios.post("CreateDefaultWebhook", null, config);
|
|
85
|
+
base.WebApiBase.SetCompleted(options, response);
|
|
86
|
+
const res : carriers.Webhook = converters.Create_Webhook_From( response.data );
|
|
87
|
+
resolve(res);
|
|
88
|
+
}
|
|
89
|
+
catch( err ) {
|
|
90
|
+
base.WebApiBase.HandleError(options, config, err);
|
|
91
|
+
reject(err);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Replace the existing Webhook or creates a new Webhook if the id parameter is empty
|
|
97
|
+
* @param entity - The Webhook to be saved.
|
|
98
|
+
* @param options - Override language/culture codes on this request. Provide cancellation and request status values.
|
|
99
|
+
* @returns New or updated Webhook
|
|
100
|
+
*/
|
|
101
|
+
public async saveWebhookAsync(entity: carriers.Webhook, options?:base.WebApiRequestOptions) : Promise< carriers.Webhook > {
|
|
102
|
+
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
103
|
+
base.WebApiBase.SetPending(options);
|
|
104
|
+
return new Promise< carriers.Webhook >(async (resolve, reject) => {
|
|
105
|
+
try {
|
|
106
|
+
const response = await this._axios.post("SaveWebhook", entity, config);
|
|
107
|
+
base.WebApiBase.SetCompleted(options, response);
|
|
108
|
+
const res : carriers.Webhook = converters.Create_Webhook_From( response.data );
|
|
109
|
+
resolve(res);
|
|
110
|
+
}
|
|
111
|
+
catch( err ) {
|
|
112
|
+
base.WebApiBase.HandleError(options, config, err);
|
|
113
|
+
reject(err);
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Deletes the Webhook
|
|
120
|
+
* @param WebhookId - The id of the Webhook to be deleted.
|
|
121
|
+
* @param options - Override language/culture codes on this request. Provide cancellation and request status values.
|
|
122
|
+
*/
|
|
123
|
+
public async deleteWebhookAsync(WebhookId: number, options?:base.WebApiRequestOptions) : Promise< void > {
|
|
124
|
+
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
125
|
+
base.WebApiBase.SetPending(options);
|
|
126
|
+
return new Promise< void >(async (resolve, reject) => {
|
|
127
|
+
try {
|
|
128
|
+
const response = await this._axios.post("DeleteWebhook?WebhookId=" + WebhookId, null, config );
|
|
129
|
+
base.WebApiBase.SetCompleted(options, response);
|
|
130
|
+
const res = response.data;
|
|
131
|
+
resolve(res);
|
|
132
|
+
}
|
|
133
|
+
catch( err ) {
|
|
134
|
+
base.WebApiBase.HandleError(options, config, err);
|
|
135
|
+
reject(err);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Gets a Webhook object.
|
|
141
|
+
* @param webhookId - The primary key.
|
|
142
|
+
* @param options - Override language/culture codes on this request. Provide cancellation and request status values.
|
|
143
|
+
* @returns A single Webhook
|
|
144
|
+
*/
|
|
145
|
+
public async getWebhookAsync(webhookId: number, options?:base.WebApiRequestOptions) : Promise< carriers.Webhook > {
|
|
146
|
+
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
147
|
+
base.WebApiBase.SetPending(options);
|
|
148
|
+
return new Promise< carriers.Webhook >(async (resolve, reject) => {
|
|
149
|
+
try {
|
|
150
|
+
const response = await this._axios.post("GetWebhook?webhookId=" + webhookId, null, config);
|
|
151
|
+
base.WebApiBase.SetCompleted(options, response);
|
|
152
|
+
const res = converters.Create_Webhook_From( response.data );
|
|
153
|
+
resolve(res);
|
|
154
|
+
}
|
|
155
|
+
catch( err ) {
|
|
156
|
+
base.WebApiBase.HandleError(options, config, err);
|
|
157
|
+
reject(err);
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
private async _getAllWebhooksAsync(request: carriers.Webhook_GetAllWebhooksRequest, options?:base.WebApiRequestOptions) : Promise< carriers.Webhook[] > {
|
|
164
|
+
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
165
|
+
base.WebApiBase.SetPending(options);
|
|
166
|
+
return new Promise< carriers.Webhook[] >(async (resolve, reject) => {
|
|
167
|
+
try {
|
|
168
|
+
config.baseURL = this._options.baseUrl;
|
|
169
|
+
const response = await this._axios.post("GetAllWebhooks", request , config);
|
|
170
|
+
base.WebApiBase.SetCompleted(options, response);
|
|
171
|
+
const res : carriers.Webhook[] = converters.Create_WebhookArray_From( response.data );
|
|
172
|
+
resolve(res);
|
|
173
|
+
}
|
|
174
|
+
catch( err ) {
|
|
175
|
+
base.WebApiBase.HandleError(options, config, err);
|
|
176
|
+
reject(err);
|
|
177
|
+
}
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Returns all webhooks, according to filter criteria
|
|
185
|
+
* @param request - NameFilter, EventFilter, StatusFilter
|
|
186
|
+
* @returns Array of all webhooks, filtered according to given criteria.
|
|
187
|
+
*/
|
|
188
|
+
public async getAllWebhooksAsync(request: carriers.Webhook_GetAllWebhooksRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.Webhook[] >;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Returns all webhooks, according to filter criteria
|
|
192
|
+
* @param nameFilter - Only return hooks with this name. Default NULL = no filter
|
|
193
|
+
* @param eventFilter - Only return hooks responding to this event name. Default NULL = no filter
|
|
194
|
+
* @param statusFilter - Only return hooks with this status. Default Unknown = no filter, returns all.
|
|
195
|
+
* @returns Array of all webhooks, filtered according to given criteria.
|
|
196
|
+
*/
|
|
197
|
+
public async getAllWebhooksAsync(nameFilter: string, eventFilter: string, statusFilter: enums.WebhookState, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.Webhook[] >;
|
|
198
|
+
|
|
199
|
+
public async getAllWebhooksAsync(nameFilter:string|carriers.Webhook_GetAllWebhooksRequest, eventFilter?:string|base.WebApiRequestOptions, statusFilter?:enums.WebhookState, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.Webhook[] > {
|
|
200
|
+
let _request : carriers.Webhook_GetAllWebhooksRequest = null;
|
|
201
|
+
let _options : base.WebApiRequestOptions = null;
|
|
202
|
+
const first : any = nameFilter;
|
|
203
|
+
if( typeof( first ) === "object" && first && ( typeof(first.nameFilter)!='undefined' || typeof(first.eventFilter)!='undefined' || typeof(first.statusFilter)!='undefined' ) )
|
|
204
|
+
{
|
|
205
|
+
_request = nameFilter as carriers.Webhook_GetAllWebhooksRequest;
|
|
206
|
+
_options = eventFilter as base.WebApiRequestOptions;
|
|
207
|
+
}
|
|
208
|
+
else
|
|
209
|
+
{
|
|
210
|
+
_request = {
|
|
211
|
+
nameFilter: nameFilter as string,
|
|
212
|
+
eventFilter: eventFilter as string,
|
|
213
|
+
statusFilter: statusFilter as enums.WebhookState,
|
|
214
|
+
};
|
|
215
|
+
_options = webapi_options;
|
|
216
|
+
}
|
|
217
|
+
return this._getAllWebhooksAsync( _request, _options );
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
private async _testWebhookAsync(request: carriers.Webhook_TestWebhookRequest, options?:base.WebApiRequestOptions) : Promise< carriers.WebhookResult > {
|
|
222
|
+
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
223
|
+
base.WebApiBase.SetPending(options);
|
|
224
|
+
return new Promise< carriers.WebhookResult >(async (resolve, reject) => {
|
|
225
|
+
try {
|
|
226
|
+
config.baseURL = this._options.baseUrl;
|
|
227
|
+
const response = await this._axios.post("TestWebhook", request , config);
|
|
228
|
+
base.WebApiBase.SetCompleted(options, response);
|
|
229
|
+
const res : carriers.WebhookResult = converters.Create_WebhookResult_From( response.data );
|
|
230
|
+
resolve(res);
|
|
231
|
+
}
|
|
232
|
+
catch( err ) {
|
|
233
|
+
base.WebApiBase.HandleError(options, config, err);
|
|
234
|
+
reject(err);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Pings a webhook with a 'test' event, returns SUCCESS(true) or FAILURE(false) + the response from the webhook target.
|
|
243
|
+
* @param request - Webhook
|
|
244
|
+
* @returns Result of calling webhook. Sucess=true/false + Error message
|
|
245
|
+
*/
|
|
246
|
+
public async testWebhookAsync(request: carriers.Webhook_TestWebhookRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.WebhookResult >;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Pings a webhook with a 'test' event, returns SUCCESS(true) or FAILURE(false) + the response from the webhook target.
|
|
250
|
+
* @param webhook - Webhook definition to ping. Must contain a valid TargetUrl.
|
|
251
|
+
* @returns Result of calling webhook. Sucess=true/false + Error message
|
|
252
|
+
*/
|
|
253
|
+
public async testWebhookAsync(webhook: carriers.Webhook, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.WebhookResult >;
|
|
254
|
+
|
|
255
|
+
public async testWebhookAsync(webhook:carriers.Webhook|carriers.Webhook_TestWebhookRequest, webapi_options?:base.WebApiRequestOptions) : Promise< carriers.WebhookResult > {
|
|
256
|
+
let _request : carriers.Webhook_TestWebhookRequest = null;
|
|
257
|
+
let _options : base.WebApiRequestOptions = null;
|
|
258
|
+
const first : any = webhook;
|
|
259
|
+
if( typeof( first ) === "object" && first && ( typeof(first.webhook)!='undefined' ) )
|
|
260
|
+
{
|
|
261
|
+
_request = webhook as carriers.Webhook_TestWebhookRequest;
|
|
262
|
+
_options = webapi_options as base.WebApiRequestOptions;
|
|
263
|
+
}
|
|
264
|
+
else
|
|
265
|
+
{
|
|
266
|
+
_request = {
|
|
267
|
+
webhook: webhook as carriers.Webhook,
|
|
268
|
+
};
|
|
269
|
+
_options = webapi_options;
|
|
270
|
+
}
|
|
271
|
+
return this._testWebhookAsync( _request, _options );
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
private async _signalEventAsync(request: carriers.Webhook_SignalEventRequest, options?:base.WebApiRequestOptions) : Promise< void > {
|
|
276
|
+
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
277
|
+
base.WebApiBase.SetPending(options);
|
|
278
|
+
return new Promise< void >(async (resolve, reject) => {
|
|
279
|
+
try {
|
|
280
|
+
config.baseURL = this._options.baseUrl;
|
|
281
|
+
const response = await this._axios.post("SignalEvent", request , config);
|
|
282
|
+
base.WebApiBase.SetCompleted(options, response);
|
|
283
|
+
const res = response.data;
|
|
284
|
+
resolve(res);
|
|
285
|
+
}
|
|
286
|
+
catch( err ) {
|
|
287
|
+
base.WebApiBase.HandleError(options, config, err);
|
|
288
|
+
reject(err);
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Signal webhooks that an event has occurred. All webhooks listening for the event will be notified.
|
|
297
|
+
* @param request - EventName, PrimaryKey, Data
|
|
298
|
+
* @returns This method has no return value
|
|
299
|
+
*/
|
|
300
|
+
public async signalEventAsync(request: carriers.Webhook_SignalEventRequest, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Signal webhooks that an event has occurred. All webhooks listening for the event will be notified.
|
|
304
|
+
* @param eventName - Name of event to fire. 'entity.verb' For example: 'window.closed', 'button.clicked'.
|
|
305
|
+
* @param primaryKey - (Optional) Id of entity that is firing event. Can be 0 if not used.
|
|
306
|
+
* @param data - Event data. Not all the data values may be posted to the webhook, depending in webhook type: { 'windowName': 'foo', 'widgets': 123 }
|
|
307
|
+
* @returns This method has no return value
|
|
308
|
+
*/
|
|
309
|
+
public async signalEventAsync(eventName: string, primaryKey: number, data: carriers.StringObjectDictionary, webapi_options?:base.WebApiRequestOptions) : Promise< void >;
|
|
310
|
+
|
|
311
|
+
public async signalEventAsync(eventName:string|carriers.Webhook_SignalEventRequest, primaryKey?:number|base.WebApiRequestOptions, data?:carriers.StringObjectDictionary, webapi_options?:base.WebApiRequestOptions) : Promise< void > {
|
|
312
|
+
let _request : carriers.Webhook_SignalEventRequest = null;
|
|
313
|
+
let _options : base.WebApiRequestOptions = null;
|
|
314
|
+
const first : any = eventName;
|
|
315
|
+
if( typeof( first ) === "object" && first && ( typeof(first.eventName)!='undefined' || typeof(first.primaryKey)!='undefined' || typeof(first.data)!='undefined' ) )
|
|
316
|
+
{
|
|
317
|
+
_request = eventName as carriers.Webhook_SignalEventRequest;
|
|
318
|
+
_options = primaryKey as base.WebApiRequestOptions;
|
|
319
|
+
}
|
|
320
|
+
else
|
|
321
|
+
{
|
|
322
|
+
_request = {
|
|
323
|
+
eventName: eventName as string,
|
|
324
|
+
primaryKey: primaryKey as number,
|
|
325
|
+
data: data as carriers.StringObjectDictionary,
|
|
326
|
+
};
|
|
327
|
+
_options = webapi_options;
|
|
328
|
+
}
|
|
329
|
+
return this._signalEventAsync( _request, _options );
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
|
|
333
|
+
private async _getLastErrorAsync(request: carriers.Webhook_GetLastErrorRequest, options?:base.WebApiRequestOptions) : Promise< string > {
|
|
334
|
+
const config : AxiosRequestConfig = base.WebApiBase.GetAxiosRequestConfig(options, this._options);
|
|
335
|
+
base.WebApiBase.SetPending(options);
|
|
336
|
+
return new Promise< string >(async (resolve, reject) => {
|
|
337
|
+
try {
|
|
338
|
+
config.baseURL = this._options.baseUrl;
|
|
339
|
+
const response = await this._axios.post("GetLastError", request , config);
|
|
340
|
+
base.WebApiBase.SetCompleted(options, response);
|
|
341
|
+
const res : string = response.data as string;
|
|
342
|
+
resolve(res);
|
|
343
|
+
}
|
|
344
|
+
catch( err ) {
|
|
345
|
+
base.WebApiBase.HandleError(options, config, err);
|
|
346
|
+
reject(err);
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Return the most recent error message received when calling this webhook.
|
|
355
|
+
* @param request - WebhookId
|
|
356
|
+
* @returns Error message, or empty string if no errors received
|
|
357
|
+
*/
|
|
358
|
+
public async getLastErrorAsync(request: carriers.Webhook_GetLastErrorRequest, webapi_options?:base.WebApiRequestOptions) : Promise< string >;
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Return the most recent error message received when calling this webhook.
|
|
362
|
+
* @param webhookId - Webhook to get error message for.
|
|
363
|
+
* @returns Error message, or empty string if no errors received
|
|
364
|
+
*/
|
|
365
|
+
public async getLastErrorAsync(webhookId: number, webapi_options?:base.WebApiRequestOptions) : Promise< string >;
|
|
366
|
+
|
|
367
|
+
public async getLastErrorAsync(webhookId:number|carriers.Webhook_GetLastErrorRequest, webapi_options?:base.WebApiRequestOptions) : Promise< string > {
|
|
368
|
+
let _request : carriers.Webhook_GetLastErrorRequest = null;
|
|
369
|
+
let _options : base.WebApiRequestOptions = null;
|
|
370
|
+
const first : any = webhookId;
|
|
371
|
+
if( typeof( first ) === "object" && first && ( typeof(first.webhookId)!='undefined' ) )
|
|
372
|
+
{
|
|
373
|
+
_request = webhookId as carriers.Webhook_GetLastErrorRequest;
|
|
374
|
+
_options = webapi_options as base.WebApiRequestOptions;
|
|
375
|
+
}
|
|
376
|
+
else
|
|
377
|
+
{
|
|
378
|
+
_request = {
|
|
379
|
+
webhookId: webhookId as number,
|
|
380
|
+
};
|
|
381
|
+
_options = webapi_options;
|
|
382
|
+
}
|
|
383
|
+
return this._getLastErrorAsync( _request, _options );
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
} // class v1WebhookAgentController
|
|
387
|
+
|
|
388
|
+
|