@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.
- 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/AIAgent.d.ts +62 -0
- package/dist/cjs/AIAgent.d.ts.map +1 -1
- package/dist/cjs/AIAgent.js +149 -0
- package/dist/cjs/AIAgent.js.map +1 -1
- package/dist/cjs/Carriers.d.ts +640 -14
- package/dist/cjs/Carriers.d.ts.map +1 -1
- package/dist/cjs/Converters.d.ts +24 -0
- package/dist/cjs/Converters.d.ts.map +1 -1
- package/dist/cjs/Converters.js +388 -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 +77 -1
- package/dist/cjs/Enums.d.ts.map +1 -1
- package/dist/cjs/Enums.js +83 -4
- 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/MarketingAgent.d.ts +68 -0
- package/dist/cjs/MarketingAgent.d.ts.map +1 -1
- package/dist/cjs/MarketingAgent.js +157 -0
- package/dist/cjs/MarketingAgent.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/AIAgent.d.ts +62 -0
- package/dist/esm/AIAgent.d.ts.map +1 -1
- package/dist/esm/AIAgent.js +150 -1
- package/dist/esm/AIAgent.js.map +1 -1
- package/dist/esm/Carriers.d.ts +640 -14
- package/dist/esm/Carriers.d.ts.map +1 -1
- package/dist/esm/Converters.d.ts +24 -0
- package/dist/esm/Converters.d.ts.map +1 -1
- package/dist/esm/Converters.js +346 -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 +77 -1
- package/dist/esm/Enums.d.ts.map +1 -1
- package/dist/esm/Enums.js +79 -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/MarketingAgent.d.ts +68 -0
- package/dist/esm/MarketingAgent.d.ts.map +1 -1
- package/dist/esm/MarketingAgent.js +157 -0
- package/dist/esm/MarketingAgent.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 +2239 -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 +53121 -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 +23496 -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 +6998 -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 +1146 -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
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
import { Create_RecurrenceWeekPattern_From, Create_RecurrenceMonthPattern_From, Create_AppointmentArray_From, Create_ContactEntity_From } from "../src/Converters";
|
|
2
|
-
import { RecurrenceInfo, Appointment, ContactEntity } from "../src/Carriers";
|
|
3
|
-
import { Weekday, ETableRight, EFieldRight } from "../src/Enums";
|
|
4
|
-
import * as assert from "assert";
|
|
5
|
-
|
|
6
|
-
describe("Converter tests", () => {
|
|
7
|
-
|
|
8
|
-
it("Test RecurrenceWeekPattern with [Flags] support", (done) => {
|
|
9
|
-
const data = require("./RecurrenceInfo.json");
|
|
10
|
-
|
|
11
|
-
const result = Create_RecurrenceWeekPattern_From(
|
|
12
|
-
data.WeekPattern
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
// Server response contains "Monday, Wednesday, Friday"
|
|
16
|
-
assert.ok((result.weekdays & Weekday.Monday) === Weekday.Monday);
|
|
17
|
-
assert.ok((result.weekdays & Weekday.Wednesday) === Weekday.Wednesday);
|
|
18
|
-
assert.ok((result.weekdays & Weekday.Friday) === Weekday.Friday);
|
|
19
|
-
|
|
20
|
-
// Remaining should not be in the result
|
|
21
|
-
assert.ok((result.weekdays & Weekday.Tuesday) !== Weekday.Tuesday);
|
|
22
|
-
assert.ok((result.weekdays & Weekday.Thursday) !== Weekday.Thursday);
|
|
23
|
-
assert.ok((result.weekdays & Weekday.Saturday) !== Weekday.Saturday);
|
|
24
|
-
assert.ok((result.weekdays & Weekday.Sunday) !== Weekday.Sunday);
|
|
25
|
-
|
|
26
|
-
done();
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("Test RecurrenceMonthPattern with [Flags] support", (done) => {
|
|
30
|
-
const serverResponse = require("./RecurrenceInfo.json");
|
|
31
|
-
|
|
32
|
-
const result = Create_RecurrenceMonthPattern_From(
|
|
33
|
-
serverResponse.MonthPattern
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
// Server response contains "Monday, Friday"
|
|
37
|
-
assert.ok((result.weekday & Weekday.Monday) === Weekday.Monday);
|
|
38
|
-
assert.ok((result.weekday & Weekday.Friday) === Weekday.Friday);
|
|
39
|
-
|
|
40
|
-
// Remaining should not be in the result
|
|
41
|
-
assert.ok((result.weekday & Weekday.Tuesday) !== Weekday.Tuesday);
|
|
42
|
-
assert.ok((result.weekday & Weekday.Wednesday) !== Weekday.Wednesday);
|
|
43
|
-
assert.ok((result.weekday & Weekday.Thursday) !== Weekday.Thursday);
|
|
44
|
-
assert.ok((result.weekday & Weekday.Saturday) !== Weekday.Saturday);
|
|
45
|
-
assert.ok((result.weekday & Weekday.Sunday) !== Weekday.Sunday);
|
|
46
|
-
|
|
47
|
-
done();
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("Test Appointment with TableRights with [Flags] support", (done) => {
|
|
51
|
-
const data: Appointment[] = require("./TableRights.json");
|
|
52
|
-
|
|
53
|
-
const result = Create_AppointmentArray_From(data);
|
|
54
|
-
|
|
55
|
-
// First appointment in response has select and update
|
|
56
|
-
assert.ok((result[0].tableRight.mask & ETableRight.Select) === ETableRight.Select);
|
|
57
|
-
assert.ok((result[0].tableRight.mask & ETableRight.Update) === ETableRight.Update);
|
|
58
|
-
// Not insert
|
|
59
|
-
assert.ok(((result[0].tableRight.mask & ETableRight.Insert) !== ETableRight.Insert));
|
|
60
|
-
|
|
61
|
-
// Second appointment in response has FULL
|
|
62
|
-
assert.ok((result[1].tableRight.mask & ETableRight.Select) === ETableRight.Select);
|
|
63
|
-
assert.ok((result[1].tableRight.mask & ETableRight.Update) === ETableRight.Update);
|
|
64
|
-
assert.ok((result[1].tableRight.mask & ETableRight.Insert) === ETableRight.Insert);
|
|
65
|
-
assert.ok((result[1].tableRight.mask & ETableRight.Delete) === ETableRight.Delete);
|
|
66
|
-
assert.ok((result[1].tableRight.mask & ETableRight.FULL) === ETableRight.FULL);
|
|
67
|
-
|
|
68
|
-
done();
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
it("Test Contact with FieldRights with [Flags] support", (done) => {
|
|
72
|
-
const data: any = require("./ContactEntity.json");
|
|
73
|
-
|
|
74
|
-
const result = Create_ContactEntity_From(data);
|
|
75
|
-
|
|
76
|
-
// First appointment in response has select and update
|
|
77
|
-
assert.ok((result.tableRight.mask & ETableRight.Select) === ETableRight.Select);
|
|
78
|
-
assert.ok((result.tableRight.mask & ETableRight.Insert) === ETableRight.Insert);
|
|
79
|
-
assert.ok((result.tableRight.mask & ETableRight.RI) === ETableRight.RI);
|
|
80
|
-
assert.ok((result.tableRight.mask & ETableRight.RestrictedUpdate) === ETableRight.RestrictedUpdate);
|
|
81
|
-
// Not delete
|
|
82
|
-
assert.ok(((result.tableRight.mask & ETableRight.Delete) !== ETableRight.Delete));
|
|
83
|
-
|
|
84
|
-
// Check field rights
|
|
85
|
-
assert.ok((result.fieldProperties["ContactId"].fieldRight.mask & EFieldRight.Read) === EFieldRight.Read);
|
|
86
|
-
assert.ok((result.fieldProperties["ContactId"].fieldRight.mask & EFieldRight.Write) === EFieldRight.Write);
|
|
87
|
-
assert.ok((result.fieldProperties["ContactId"].fieldRight.mask & EFieldRight.UIHintMandatory) !== EFieldRight.UIHintMandatory);
|
|
88
|
-
assert.ok((result.fieldProperties["ContactId"].fieldRight.mask & EFieldRight.UIHintReadOnly) !== EFieldRight.UIHintReadOnly);
|
|
89
|
-
assert.ok((result.fieldProperties["Name"].fieldRight.mask & EFieldRight.Read) === EFieldRight.Read);
|
|
90
|
-
assert.ok((result.fieldProperties["Name"].fieldRight.mask & EFieldRight.Update) === EFieldRight.Update);
|
|
91
|
-
assert.ok((result.fieldProperties["Name"].fieldRight.mask & EFieldRight.UIHintMandatory) === EFieldRight.UIHintMandatory);
|
|
92
|
-
assert.ok((result.fieldProperties["Name"].fieldRight.mask & EFieldRight.UIHintReadOnly) !== EFieldRight.UIHintReadOnly);
|
|
93
|
-
assert.ok((result.fieldProperties["Name"].fieldRight.reason === "[SR_MANDATORY_FIELD_1281]"));
|
|
94
|
-
|
|
95
|
-
done();
|
|
96
|
-
});
|
|
97
|
-
});
|
|
1
|
+
import { Create_RecurrenceWeekPattern_From, Create_RecurrenceMonthPattern_From, Create_AppointmentArray_From, Create_ContactEntity_From } from "../src/Converters";
|
|
2
|
+
import { RecurrenceInfo, Appointment, ContactEntity } from "../src/Carriers";
|
|
3
|
+
import { Weekday, ETableRight, EFieldRight } from "../src/Enums";
|
|
4
|
+
import * as assert from "assert";
|
|
5
|
+
|
|
6
|
+
describe("Converter tests", () => {
|
|
7
|
+
|
|
8
|
+
it("Test RecurrenceWeekPattern with [Flags] support", (done) => {
|
|
9
|
+
const data = require("./RecurrenceInfo.json");
|
|
10
|
+
|
|
11
|
+
const result = Create_RecurrenceWeekPattern_From(
|
|
12
|
+
data.WeekPattern
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
// Server response contains "Monday, Wednesday, Friday"
|
|
16
|
+
assert.ok((result.weekdays & Weekday.Monday) === Weekday.Monday);
|
|
17
|
+
assert.ok((result.weekdays & Weekday.Wednesday) === Weekday.Wednesday);
|
|
18
|
+
assert.ok((result.weekdays & Weekday.Friday) === Weekday.Friday);
|
|
19
|
+
|
|
20
|
+
// Remaining should not be in the result
|
|
21
|
+
assert.ok((result.weekdays & Weekday.Tuesday) !== Weekday.Tuesday);
|
|
22
|
+
assert.ok((result.weekdays & Weekday.Thursday) !== Weekday.Thursday);
|
|
23
|
+
assert.ok((result.weekdays & Weekday.Saturday) !== Weekday.Saturday);
|
|
24
|
+
assert.ok((result.weekdays & Weekday.Sunday) !== Weekday.Sunday);
|
|
25
|
+
|
|
26
|
+
done();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
it("Test RecurrenceMonthPattern with [Flags] support", (done) => {
|
|
30
|
+
const serverResponse = require("./RecurrenceInfo.json");
|
|
31
|
+
|
|
32
|
+
const result = Create_RecurrenceMonthPattern_From(
|
|
33
|
+
serverResponse.MonthPattern
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
// Server response contains "Monday, Friday"
|
|
37
|
+
assert.ok((result.weekday & Weekday.Monday) === Weekday.Monday);
|
|
38
|
+
assert.ok((result.weekday & Weekday.Friday) === Weekday.Friday);
|
|
39
|
+
|
|
40
|
+
// Remaining should not be in the result
|
|
41
|
+
assert.ok((result.weekday & Weekday.Tuesday) !== Weekday.Tuesday);
|
|
42
|
+
assert.ok((result.weekday & Weekday.Wednesday) !== Weekday.Wednesday);
|
|
43
|
+
assert.ok((result.weekday & Weekday.Thursday) !== Weekday.Thursday);
|
|
44
|
+
assert.ok((result.weekday & Weekday.Saturday) !== Weekday.Saturday);
|
|
45
|
+
assert.ok((result.weekday & Weekday.Sunday) !== Weekday.Sunday);
|
|
46
|
+
|
|
47
|
+
done();
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it("Test Appointment with TableRights with [Flags] support", (done) => {
|
|
51
|
+
const data: Appointment[] = require("./TableRights.json");
|
|
52
|
+
|
|
53
|
+
const result = Create_AppointmentArray_From(data);
|
|
54
|
+
|
|
55
|
+
// First appointment in response has select and update
|
|
56
|
+
assert.ok((result[0].tableRight.mask & ETableRight.Select) === ETableRight.Select);
|
|
57
|
+
assert.ok((result[0].tableRight.mask & ETableRight.Update) === ETableRight.Update);
|
|
58
|
+
// Not insert
|
|
59
|
+
assert.ok(((result[0].tableRight.mask & ETableRight.Insert) !== ETableRight.Insert));
|
|
60
|
+
|
|
61
|
+
// Second appointment in response has FULL
|
|
62
|
+
assert.ok((result[1].tableRight.mask & ETableRight.Select) === ETableRight.Select);
|
|
63
|
+
assert.ok((result[1].tableRight.mask & ETableRight.Update) === ETableRight.Update);
|
|
64
|
+
assert.ok((result[1].tableRight.mask & ETableRight.Insert) === ETableRight.Insert);
|
|
65
|
+
assert.ok((result[1].tableRight.mask & ETableRight.Delete) === ETableRight.Delete);
|
|
66
|
+
assert.ok((result[1].tableRight.mask & ETableRight.FULL) === ETableRight.FULL);
|
|
67
|
+
|
|
68
|
+
done();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("Test Contact with FieldRights with [Flags] support", (done) => {
|
|
72
|
+
const data: any = require("./ContactEntity.json");
|
|
73
|
+
|
|
74
|
+
const result = Create_ContactEntity_From(data);
|
|
75
|
+
|
|
76
|
+
// First appointment in response has select and update
|
|
77
|
+
assert.ok((result.tableRight.mask & ETableRight.Select) === ETableRight.Select);
|
|
78
|
+
assert.ok((result.tableRight.mask & ETableRight.Insert) === ETableRight.Insert);
|
|
79
|
+
assert.ok((result.tableRight.mask & ETableRight.RI) === ETableRight.RI);
|
|
80
|
+
assert.ok((result.tableRight.mask & ETableRight.RestrictedUpdate) === ETableRight.RestrictedUpdate);
|
|
81
|
+
// Not delete
|
|
82
|
+
assert.ok(((result.tableRight.mask & ETableRight.Delete) !== ETableRight.Delete));
|
|
83
|
+
|
|
84
|
+
// Check field rights
|
|
85
|
+
assert.ok((result.fieldProperties["ContactId"].fieldRight.mask & EFieldRight.Read) === EFieldRight.Read);
|
|
86
|
+
assert.ok((result.fieldProperties["ContactId"].fieldRight.mask & EFieldRight.Write) === EFieldRight.Write);
|
|
87
|
+
assert.ok((result.fieldProperties["ContactId"].fieldRight.mask & EFieldRight.UIHintMandatory) !== EFieldRight.UIHintMandatory);
|
|
88
|
+
assert.ok((result.fieldProperties["ContactId"].fieldRight.mask & EFieldRight.UIHintReadOnly) !== EFieldRight.UIHintReadOnly);
|
|
89
|
+
assert.ok((result.fieldProperties["Name"].fieldRight.mask & EFieldRight.Read) === EFieldRight.Read);
|
|
90
|
+
assert.ok((result.fieldProperties["Name"].fieldRight.mask & EFieldRight.Update) === EFieldRight.Update);
|
|
91
|
+
assert.ok((result.fieldProperties["Name"].fieldRight.mask & EFieldRight.UIHintMandatory) === EFieldRight.UIHintMandatory);
|
|
92
|
+
assert.ok((result.fieldProperties["Name"].fieldRight.mask & EFieldRight.UIHintReadOnly) !== EFieldRight.UIHintReadOnly);
|
|
93
|
+
assert.ok((result.fieldProperties["Name"].fieldRight.reason === "[SR_MANDATORY_FIELD_1281]"));
|
|
94
|
+
|
|
95
|
+
done();
|
|
96
|
+
});
|
|
97
|
+
});
|
|
@@ -1,101 +1,101 @@
|
|
|
1
|
-
import * as assert from "assert";
|
|
2
|
-
import axios from "axios";
|
|
3
|
-
import nock from "nock";
|
|
4
|
-
import { ReturnBlobType } from "../src/WebApiBase";
|
|
5
|
-
import { DocumentAgent } from "../src/DocumentAgent";
|
|
6
|
-
import { Document_GetTemplateStreamRequest } from "../src/Carriers";
|
|
7
|
-
|
|
8
|
-
const host: string = "http://localhost/";
|
|
9
|
-
|
|
10
|
-
axios.defaults.baseURL = host;
|
|
11
|
-
|
|
12
|
-
const responseJson = require("./DocumentGetTemplateStream.json");
|
|
13
|
-
const responseBinary = require("./DocumentGetTemplateStreamBinary.json");
|
|
14
|
-
|
|
15
|
-
describe("WebAPI Document tests", () => {
|
|
16
|
-
it("Can get a personal template using params", done => {
|
|
17
|
-
let scope = nock(host)
|
|
18
|
-
.post("/api/v1/Agents/Document/GetTemplateStream")
|
|
19
|
-
.reply(200, responseBinary);
|
|
20
|
-
|
|
21
|
-
let agent = new DocumentAgent(host);
|
|
22
|
-
agent.getTemplateStreamAsync("agent1.txt", true, "en").then(response => {
|
|
23
|
-
let res = response as ArrayBuffer;
|
|
24
|
-
assert.equal(res.byteLength, 33);
|
|
25
|
-
assert.equal(res[0], 65);
|
|
26
|
-
assert.equal(res[1], 103);
|
|
27
|
-
assert.equal(res[2], 101);
|
|
28
|
-
|
|
29
|
-
done();
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it("Can get a personal template using request", done => {
|
|
34
|
-
let scope = nock(host)
|
|
35
|
-
.post("/api/v1/Agents/Document/GetTemplateStream")
|
|
36
|
-
.reply(200, responseBinary);
|
|
37
|
-
|
|
38
|
-
let agent = new DocumentAgent(host);
|
|
39
|
-
let req: Document_GetTemplateStreamRequest = {
|
|
40
|
-
templateName: "agent1.txt",
|
|
41
|
-
allowPersonal: true,
|
|
42
|
-
uiCulture: "en"
|
|
43
|
-
};
|
|
44
|
-
agent.getTemplateStreamAsync(req).then(response => {
|
|
45
|
-
response = response as ArrayBuffer;
|
|
46
|
-
assert.equal(response.byteLength, 33);
|
|
47
|
-
assert.equal(response[0], 65);
|
|
48
|
-
assert.equal(response[1], 103);
|
|
49
|
-
assert.equal(response[2], 101);
|
|
50
|
-
done();
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
it("Can get a personal template as base64", done => {
|
|
55
|
-
let scope = nock(host)
|
|
56
|
-
.post("/api/v1/Agents/Document/GetTemplateStream")
|
|
57
|
-
.reply(200, responseJson);
|
|
58
|
-
|
|
59
|
-
let agent = new DocumentAgent(host);
|
|
60
|
-
agent
|
|
61
|
-
.getTemplateStreamAsync("agent1.txt", true, "en", { returnBlobAs: ReturnBlobType.AsBase64 })
|
|
62
|
-
.then(response => {
|
|
63
|
-
let res = response as string;
|
|
64
|
-
assert.equal(res, responseJson);
|
|
65
|
-
done();
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it("Can get a personal template as string", done => {
|
|
70
|
-
let scope = nock(host)
|
|
71
|
-
.post("/api/v1/Agents/Document/GetTemplateStream")
|
|
72
|
-
.reply(200, responseJson);
|
|
73
|
-
|
|
74
|
-
let agent = new DocumentAgent(host);
|
|
75
|
-
agent
|
|
76
|
-
.getTemplateStreamAsync("agent1.txt", true, "en", { returnBlobAs: ReturnBlobType.AsString })
|
|
77
|
-
.then(response => {
|
|
78
|
-
let res = response as string;
|
|
79
|
-
assert.equal(res, responseBinary);
|
|
80
|
-
done();
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
it("Can get a personal template as array buffer", done => {
|
|
85
|
-
let scope = nock(host)
|
|
86
|
-
.post("/api/v1/Agents/Document/GetTemplateStream")
|
|
87
|
-
.reply(200, responseBinary);
|
|
88
|
-
|
|
89
|
-
let agent = new DocumentAgent(host);
|
|
90
|
-
agent
|
|
91
|
-
.getTemplateStreamAsync("agent1.txt", true, "en", { returnBlobAs: ReturnBlobType.AsArrayBuffer })
|
|
92
|
-
.then(response => {
|
|
93
|
-
response = response as ArrayBuffer;
|
|
94
|
-
assert.equal(response.byteLength, 33);
|
|
95
|
-
assert.equal(response[0], 65);
|
|
96
|
-
assert.equal(response[1], 103);
|
|
97
|
-
assert.equal(response[2], 101);
|
|
98
|
-
done();
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
});
|
|
1
|
+
import * as assert from "assert";
|
|
2
|
+
import axios from "axios";
|
|
3
|
+
import nock from "nock";
|
|
4
|
+
import { ReturnBlobType } from "../src/WebApiBase";
|
|
5
|
+
import { DocumentAgent } from "../src/DocumentAgent";
|
|
6
|
+
import { Document_GetTemplateStreamRequest } from "../src/Carriers";
|
|
7
|
+
|
|
8
|
+
const host: string = "http://localhost/";
|
|
9
|
+
|
|
10
|
+
axios.defaults.baseURL = host;
|
|
11
|
+
|
|
12
|
+
const responseJson = require("./DocumentGetTemplateStream.json");
|
|
13
|
+
const responseBinary = require("./DocumentGetTemplateStreamBinary.json");
|
|
14
|
+
|
|
15
|
+
describe("WebAPI Document tests", () => {
|
|
16
|
+
it("Can get a personal template using params", done => {
|
|
17
|
+
let scope = nock(host)
|
|
18
|
+
.post("/api/v1/Agents/Document/GetTemplateStream")
|
|
19
|
+
.reply(200, responseBinary);
|
|
20
|
+
|
|
21
|
+
let agent = new DocumentAgent(host);
|
|
22
|
+
agent.getTemplateStreamAsync("agent1.txt", true, "en").then(response => {
|
|
23
|
+
let res = response as ArrayBuffer;
|
|
24
|
+
assert.equal(res.byteLength, 33);
|
|
25
|
+
assert.equal(res[0], 65);
|
|
26
|
+
assert.equal(res[1], 103);
|
|
27
|
+
assert.equal(res[2], 101);
|
|
28
|
+
|
|
29
|
+
done();
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("Can get a personal template using request", done => {
|
|
34
|
+
let scope = nock(host)
|
|
35
|
+
.post("/api/v1/Agents/Document/GetTemplateStream")
|
|
36
|
+
.reply(200, responseBinary);
|
|
37
|
+
|
|
38
|
+
let agent = new DocumentAgent(host);
|
|
39
|
+
let req: Document_GetTemplateStreamRequest = {
|
|
40
|
+
templateName: "agent1.txt",
|
|
41
|
+
allowPersonal: true,
|
|
42
|
+
uiCulture: "en"
|
|
43
|
+
};
|
|
44
|
+
agent.getTemplateStreamAsync(req).then(response => {
|
|
45
|
+
response = response as ArrayBuffer;
|
|
46
|
+
assert.equal(response.byteLength, 33);
|
|
47
|
+
assert.equal(response[0], 65);
|
|
48
|
+
assert.equal(response[1], 103);
|
|
49
|
+
assert.equal(response[2], 101);
|
|
50
|
+
done();
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it("Can get a personal template as base64", done => {
|
|
55
|
+
let scope = nock(host)
|
|
56
|
+
.post("/api/v1/Agents/Document/GetTemplateStream")
|
|
57
|
+
.reply(200, responseJson);
|
|
58
|
+
|
|
59
|
+
let agent = new DocumentAgent(host);
|
|
60
|
+
agent
|
|
61
|
+
.getTemplateStreamAsync("agent1.txt", true, "en", { returnBlobAs: ReturnBlobType.AsBase64 })
|
|
62
|
+
.then(response => {
|
|
63
|
+
let res = response as string;
|
|
64
|
+
assert.equal(res, responseJson);
|
|
65
|
+
done();
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it("Can get a personal template as string", done => {
|
|
70
|
+
let scope = nock(host)
|
|
71
|
+
.post("/api/v1/Agents/Document/GetTemplateStream")
|
|
72
|
+
.reply(200, responseJson);
|
|
73
|
+
|
|
74
|
+
let agent = new DocumentAgent(host);
|
|
75
|
+
agent
|
|
76
|
+
.getTemplateStreamAsync("agent1.txt", true, "en", { returnBlobAs: ReturnBlobType.AsString })
|
|
77
|
+
.then(response => {
|
|
78
|
+
let res = response as string;
|
|
79
|
+
assert.equal(res, responseBinary);
|
|
80
|
+
done();
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("Can get a personal template as array buffer", done => {
|
|
85
|
+
let scope = nock(host)
|
|
86
|
+
.post("/api/v1/Agents/Document/GetTemplateStream")
|
|
87
|
+
.reply(200, responseBinary);
|
|
88
|
+
|
|
89
|
+
let agent = new DocumentAgent(host);
|
|
90
|
+
agent
|
|
91
|
+
.getTemplateStreamAsync("agent1.txt", true, "en", { returnBlobAs: ReturnBlobType.AsArrayBuffer })
|
|
92
|
+
.then(response => {
|
|
93
|
+
response = response as ArrayBuffer;
|
|
94
|
+
assert.equal(response.byteLength, 33);
|
|
95
|
+
assert.equal(response[0], 65);
|
|
96
|
+
assert.equal(response[1], 103);
|
|
97
|
+
assert.equal(response[2], 101);
|
|
98
|
+
done();
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
});
|