@eway-crm/connector 1.0.66 → 1.0.70
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/lib/ApiConnection.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { AxiosRequestConfig } from 'axios';
|
|
1
2
|
import { IApiResult } from './data/IApiResult';
|
|
2
3
|
import { ISessionHandler } from './ISessionHandler';
|
|
3
4
|
import { HttpMethod } from './HttpMethod';
|
|
@@ -18,6 +19,26 @@ export declare class ApiConnection {
|
|
|
18
19
|
static createUsingOAuth(apiServiceUri: string, username: string, clientId: string, clientSecret: string, refreshToken: string, accessToken: string, appVersion: string, errorCallback?: (error: TUnionError) => void, refreshTokenCallback?: (tokenData: ITokenData) => void, supportGetItemPreviewMethod?: boolean): ApiConnection;
|
|
19
20
|
get wsUrl(): string;
|
|
20
21
|
readonly createOpenLink: (folderName: TFolderName, guid?: string | undefined, fileAs?: string | undefined) => string;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a promise for async file upload using binary stream
|
|
24
|
+
* @param itemGuid Item identificator. Ex. '9ac561be-9b7d-4938-8e55-4cce97142483'.
|
|
25
|
+
* @param fileName File name, ex. 'picture.img'.
|
|
26
|
+
* @param data Single file to be uploaded.
|
|
27
|
+
* @param config Optional. Additional config for the request.
|
|
28
|
+
* @param catchGlobally Optional. If true, raises this the global error handler each time the promise is rejected.
|
|
29
|
+
*/
|
|
30
|
+
readonly askUploadMethod: (itemGuid: string, fileName: string, data: File, config?: AxiosRequestConfig | undefined, catchGlobally?: boolean | undefined) => Promise<IApiResult>;
|
|
31
|
+
/**
|
|
32
|
+
* Asynchronously uploads file using binary stream
|
|
33
|
+
* @param itemGuid Item identificator. Ex. '9ac561be-9b7d-4938-8e55-4cce97142483'.
|
|
34
|
+
* @param fileName File name, ex. 'picture.img'.
|
|
35
|
+
* @param data Single file to be uploaded.
|
|
36
|
+
* @param successCallback Handler callback when the method executes well. Gets the whole response JSON object as the only argument.
|
|
37
|
+
* @param unsuccessCallback Optional. Handler callback for eWay-API app level failures. Gets the whole response JSON object as the only argument. If not supplied, the global error handler is used.
|
|
38
|
+
* @param errorCallback Optional. Handler callback for any other failures. If not supplied, the global error handler is used.
|
|
39
|
+
* @param config Optional. Additional config for the request.
|
|
40
|
+
*/
|
|
41
|
+
readonly callUploadMethod: (itemGuid: string, fileName: string, data: File, successCallback: (res: IApiResult) => void, unsuccessCallback?: ((e: IApiResult) => void) | undefined, errorCallback?: ((e: TUnionError) => void) | undefined, config?: AxiosRequestConfig | undefined) => void;
|
|
21
42
|
/**
|
|
22
43
|
* Creates a promise for async API method call.
|
|
23
44
|
* @param methodName API method name. Ex. 'GetUsers'.
|
package/lib/ApiConnection.js
CHANGED
|
@@ -26,6 +26,85 @@ var ApiConnection = /** @class */ (function () {
|
|
|
26
26
|
}
|
|
27
27
|
return url;
|
|
28
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* Creates a promise for async file upload using binary stream
|
|
31
|
+
* @param itemGuid Item identificator. Ex. '9ac561be-9b7d-4938-8e55-4cce97142483'.
|
|
32
|
+
* @param fileName File name, ex. 'picture.img'.
|
|
33
|
+
* @param data Single file to be uploaded.
|
|
34
|
+
* @param config Optional. Additional config for the request.
|
|
35
|
+
* @param catchGlobally Optional. If true, raises this the global error handler each time the promise is rejected.
|
|
36
|
+
*/
|
|
37
|
+
this.askUploadMethod = function (itemGuid, fileName, data, config, catchGlobally) {
|
|
38
|
+
return new Promise(function (resolve, reject) {
|
|
39
|
+
var errClb = catchGlobally
|
|
40
|
+
? function (e) {
|
|
41
|
+
reject(e);
|
|
42
|
+
throw e;
|
|
43
|
+
}
|
|
44
|
+
: reject;
|
|
45
|
+
_this.callUploadMethod(itemGuid, fileName, data, resolve, errClb, errClb, config);
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Asynchronously uploads file using binary stream
|
|
50
|
+
* @param itemGuid Item identificator. Ex. '9ac561be-9b7d-4938-8e55-4cce97142483'.
|
|
51
|
+
* @param fileName File name, ex. 'picture.img'.
|
|
52
|
+
* @param data Single file to be uploaded.
|
|
53
|
+
* @param successCallback Handler callback when the method executes well. Gets the whole response JSON object as the only argument.
|
|
54
|
+
* @param unsuccessCallback Optional. Handler callback for eWay-API app level failures. Gets the whole response JSON object as the only argument. If not supplied, the global error handler is used.
|
|
55
|
+
* @param errorCallback Optional. Handler callback for any other failures. If not supplied, the global error handler is used.
|
|
56
|
+
* @param config Optional. Additional config for the request.
|
|
57
|
+
*/
|
|
58
|
+
this.callUploadMethod = function (itemGuid, fileName, data, successCallback, unsuccessCallback, errorCallback, config) {
|
|
59
|
+
var noSessionCallback = function () {
|
|
60
|
+
_this.sessionHandler.getSessionId(_this, function (newSessionId) {
|
|
61
|
+
_this.sessionId = newSessionId;
|
|
62
|
+
_this.callUploadMethod(itemGuid, fileName, data, successCallback, unsuccessCallback, errorCallback, config);
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
var sessionId = _this.sessionId;
|
|
66
|
+
if (!sessionId) {
|
|
67
|
+
noSessionCallback();
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
var unsuccessClb = function (result) {
|
|
71
|
+
if (result.ReturnCode === ReturnCodes_1.ReturnCodes.rcBadSession) {
|
|
72
|
+
_this.sessionId = null;
|
|
73
|
+
_this.sessionHandler.invalidateSessionId(sessionId, noSessionCallback);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
if (unsuccessCallback) {
|
|
77
|
+
unsuccessCallback(result);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
var error = new Error('Unhandled connection return code ' + result.ReturnCode + ': ' + result.Description);
|
|
81
|
+
if (_this.errorCallback) {
|
|
82
|
+
_this.errorCallback(error);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
throw error;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
var errorClb = function (error) {
|
|
90
|
+
var err = new Error('Unhandled connection error when calling ' + methodUrl + ': ' + JSON.stringify(error));
|
|
91
|
+
if ('statusCode' in error && error.statusCode === 413) {
|
|
92
|
+
err = new Error('The file has exceeded the maximum allowed file size for uploading. You can contact eWay-CRM support if you wish to increase the limit.');
|
|
93
|
+
}
|
|
94
|
+
if (errorCallback) {
|
|
95
|
+
errorCallback(err);
|
|
96
|
+
}
|
|
97
|
+
else if (_this.errorCallback) {
|
|
98
|
+
_this.errorCallback(err);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
throw err;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
var methodUrl = _this.svcUri + "/SaveBinaryAttachment?sessionId=" + _this.sessionId + "&itemGuid=" + itemGuid + "&fileName=" + fileName;
|
|
105
|
+
var promise = axios_1.default.post(methodUrl, data, config);
|
|
106
|
+
ApiConnection.handleCallPromise(promise, successCallback, unsuccessClb, errorClb);
|
|
107
|
+
};
|
|
29
108
|
/**
|
|
30
109
|
* Creates a promise for async API method call.
|
|
31
110
|
* @param methodName API method name. Ex. 'GetUsers'.
|
|
@@ -156,7 +156,6 @@ export default class FieldNames {
|
|
|
156
156
|
readonly EstimatedRevenueDefaultCurrency: "EstimatedRevenueDefaultCurrency";
|
|
157
157
|
};
|
|
158
158
|
static readonly Documents: {
|
|
159
|
-
readonly File: "File";
|
|
160
159
|
readonly FileAs: "FileAs";
|
|
161
160
|
readonly DocName: "DocName";
|
|
162
161
|
readonly Preview: "Preview";
|
|
@@ -20,6 +20,7 @@ declare class GlobalSettingsNames {
|
|
|
20
20
|
static exchangeRatesAdminGroupName: string;
|
|
21
21
|
static forcedEmailTrackingGroups: string;
|
|
22
22
|
static groupsForAllUnpaidInvoicesNotification: string;
|
|
23
|
+
static itemPreviewMaxHeight: string;
|
|
23
24
|
static lastActivityAttributes: string;
|
|
24
25
|
static leadsCompletedState: string;
|
|
25
26
|
static leadDeadlineAlertGroups: string;
|
|
@@ -24,6 +24,7 @@ var GlobalSettingsNames = /** @class */ (function () {
|
|
|
24
24
|
GlobalSettingsNames.exchangeRatesAdminGroupName = 'ExchangeRatesAdminGroupName';
|
|
25
25
|
GlobalSettingsNames.forcedEmailTrackingGroups = 'ForcedEmailTrackingGroups';
|
|
26
26
|
GlobalSettingsNames.groupsForAllUnpaidInvoicesNotification = 'GroupsForAllUnpaidInvoicesNotification';
|
|
27
|
+
GlobalSettingsNames.itemPreviewMaxHeight = 'ItemPreviewMaxHeight';
|
|
27
28
|
GlobalSettingsNames.lastActivityAttributes = 'LastActivityAttributes';
|
|
28
29
|
GlobalSettingsNames.leadsCompletedState = 'LeadsCompletedState';
|
|
29
30
|
GlobalSettingsNames.leadDeadlineAlertGroups = 'LeadDeadlineAlertGroups';
|