@studyportals/campaign-management-api-interface 0.13.1 → 0.13.2
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/{index.ts → index.d.ts} +1 -21
- package/index.js +20 -0
- package/index.js.map +1 -0
- package/package.json +3 -3
- package/src/auditor-campaign-management-api.client.d.ts +12 -0
- package/src/auditor-campaign-management-api.client.js +56 -0
- package/src/auditor-campaign-management-api.client.js.map +1 -0
- package/src/campaign-management-api.client.d.ts +13 -0
- package/src/campaign-management-api.client.js +68 -0
- package/src/campaign-management-api.client.js.map +1 -0
- package/src/domain/auditor/campaigns/geotargeting.entities.d.ts +14 -0
- package/src/domain/auditor/campaigns/geotargeting.entities.js +11 -0
- package/src/domain/auditor/campaigns/geotargeting.entities.js.map +1 -0
- package/src/domain/auditor/enums/auditor-entity-type.enum.d.ts +3 -0
- package/src/domain/auditor/enums/auditor-entity-type.enum.js +8 -0
- package/src/domain/auditor/enums/auditor-entity-type.enum.js.map +1 -0
- package/src/domain/auditor/enums/{auditor-operation.enum.ts → auditor-operation.enum.d.ts} +2 -2
- package/src/domain/auditor/enums/auditor-operation.enum.js +14 -0
- package/src/domain/auditor/enums/auditor-operation.enum.js.map +1 -0
- package/src/domain/auditor/get-auditor.dto.d.ts +13 -0
- package/src/domain/auditor/get-auditor.dto.js +17 -0
- package/src/domain/auditor/get-auditor.dto.js.map +1 -0
- package/src/domain/campaign/CampaignsEntitiesConfig.dto.d.ts +7 -0
- package/src/domain/campaign/CampaignsEntitiesConfig.dto.js +10 -0
- package/src/domain/campaign/CampaignsEntitiesConfig.dto.js.map +1 -0
- package/src/private-campaign-management-api.client.d.ts +18 -0
- package/src/private-campaign-management-api.client.js +79 -0
- package/src/private-campaign-management-api.client.js.map +1 -0
- package/.vscode/launch.json +0 -36
- package/.vscode/settings.json +0 -4
- package/.vscode/tasks.json +0 -41
- package/README.md +0 -2
- package/jest.config.single-file.json +0 -20
- package/jest.config.unit.json +0 -19
- package/src/auditor-campaign-management-api.client.ts +0 -54
- package/src/campaign-management-api.client.ts +0 -68
- package/src/domain/auditor/campaigns/geotargeting.entities.ts +0 -20
- package/src/domain/auditor/enums/auditor-entity-type.enum.ts +0 -3
- package/src/domain/auditor/get-auditor.dto.ts +0 -33
- package/src/domain/campaign/CampaignsEntitiesConfig.dto.ts +0 -7
- package/src/private-campaign-management-api.client.ts +0 -80
- package/tests-u/domain/auditor/auditor-campaign-management-api-client.test.ts +0 -99
- package/tests-u/domain/auditor/enums/auditor-entity-type-enum.test.ts +0 -22
- package/tests-u/domain/auditor/enums/auditor-operation-enum.test.ts +0 -34
- package/tests-u/domain/auditor/get-auditor-entity.test.ts +0 -34
- package/tests-u/domain/campaign/campaign-management-api-client.test.ts +0 -111
- package/tests-u/domain/campaign/private-campaign-management-api-client.test.ts +0 -114
- package/tsconfig.json +0 -39
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
import { suite, test } from "@testdeck/jest";
|
|
2
|
-
import { MockProxy, mock } from "jest-mock-extended";
|
|
3
|
-
import { assert } from "chai";
|
|
4
|
-
import { ISuperAgentRequestFactory, SignedRequestSender } from "@studyportals/mb-platform-http-requests";
|
|
5
|
-
import { SuperAgentRequest } from "superagent";
|
|
6
|
-
import * as superagent from "superagent";
|
|
7
|
-
import { CampaignsEntitiesConfigDto } from "../../../src/domain/campaign/CampaignsEntitiesConfig.dto";
|
|
8
|
-
import { PrivateCampaignManagementAPIClient } from "../../../src/private-campaign-management-api.client";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const superagentMock = require("superagent-mocker")(superagent);
|
|
12
|
-
|
|
13
|
-
@suite
|
|
14
|
-
class PrivateCampaignManagementAPIClientTest {
|
|
15
|
-
private privateCampaignManagementAPIClient: PrivateCampaignManagementAPIClient;
|
|
16
|
-
private mockedRequest: MockProxy<SuperAgentRequest> = mock<SuperAgentRequest>();
|
|
17
|
-
private mockedSuperAgentRequestFactory: MockProxy<ISuperAgentRequestFactory> = mock<ISuperAgentRequestFactory>();
|
|
18
|
-
private mockedResponse: MockProxy<superagent.Response> = mock<superagent.Response>();
|
|
19
|
-
private mockedSignedRequestSender: MockProxy<SignedRequestSender> = mock<SignedRequestSender>();
|
|
20
|
-
private mockedBaseUrl = "SomeBaseUrl";
|
|
21
|
-
|
|
22
|
-
public before() {
|
|
23
|
-
this.mockedSuperAgentRequestFactory.post.mockReturnValue(this.mockedRequest);
|
|
24
|
-
this.mockedSignedRequestSender.send.mockReturnValue(Promise.resolve(this.mockedResponse));
|
|
25
|
-
|
|
26
|
-
this.privateCampaignManagementAPIClient = new PrivateCampaignManagementAPIClient(this.mockedSuperAgentRequestFactory, this.mockedSignedRequestSender, this.mockedBaseUrl);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
@test()
|
|
30
|
-
public async addCampaignsEntitiesConfigs__CorrectlyCalled() {
|
|
31
|
-
const postData: CampaignsEntitiesConfigDto = {
|
|
32
|
-
campaign_id: 1,
|
|
33
|
-
sp_id: 1,
|
|
34
|
-
product_id: 12,
|
|
35
|
-
product2_id: null,
|
|
36
|
-
type: "study"
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
superagentMock.post(`${this.mockedBaseUrl}/private/campaigns/add-campaigns-entities-configs`, () => {});
|
|
40
|
-
|
|
41
|
-
try {
|
|
42
|
-
const result = await this.privateCampaignManagementAPIClient.addCampaignsEntitiesConfigs(1, [postData]);
|
|
43
|
-
} catch {
|
|
44
|
-
assert.fail();
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
assert.ok(true);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
@test()
|
|
51
|
-
public async removeCampaignsEntitiesConfigsByID__CorrectlyCalled() {
|
|
52
|
-
const campaignID = 1;
|
|
53
|
-
const entityIDs = [ 1 ];
|
|
54
|
-
|
|
55
|
-
superagentMock.post(`${this.mockedBaseUrl}/private/campaigns/remove-campaigns-entities-configs`, () => {});
|
|
56
|
-
|
|
57
|
-
try {
|
|
58
|
-
const result = await this.privateCampaignManagementAPIClient.removeCampaignsEntitiesConfigsByID(campaignID, entityIDs);
|
|
59
|
-
} catch {
|
|
60
|
-
assert.fail();
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
assert.ok(true);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
@test()
|
|
67
|
-
public async clearCampaignsEntitiesConfigsByCampaignID__CorrectlyCalled() {
|
|
68
|
-
const postData = 1;
|
|
69
|
-
|
|
70
|
-
superagentMock.post(`${this.mockedBaseUrl}/private/campaigns/clear-campaigns-entities-configs`, () => {});
|
|
71
|
-
|
|
72
|
-
try {
|
|
73
|
-
const result = await this.privateCampaignManagementAPIClient.clearCampaignsEntitiesConfigsByCampaignID(postData);
|
|
74
|
-
} catch {
|
|
75
|
-
assert.fail();
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
assert.ok(true);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
@test()
|
|
82
|
-
public async setEntitiesBasic__CorrectlyCalled() {
|
|
83
|
-
const campaignID = 1;
|
|
84
|
-
const organisationIDs = [1];
|
|
85
|
-
const studyIDs = [5];
|
|
86
|
-
|
|
87
|
-
superagentMock.post(`${this.mockedBaseUrl}/private/campaigns/set-entities-basic`, () => {});
|
|
88
|
-
|
|
89
|
-
try {
|
|
90
|
-
const result = await this.privateCampaignManagementAPIClient.setEntitiesBasic(campaignID, organisationIDs, studyIDs);
|
|
91
|
-
} catch {
|
|
92
|
-
assert.fail();
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
assert.ok(true);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
@test()
|
|
99
|
-
public async setEntitiesPremium__CorrectlyCalled() {
|
|
100
|
-
const campaignID = 1;
|
|
101
|
-
const organisationIDs = [1];
|
|
102
|
-
const studyIDs = [5];
|
|
103
|
-
|
|
104
|
-
superagentMock.post(`${this.mockedBaseUrl}/private/campaigns/set-entities-premium`, () => {});
|
|
105
|
-
|
|
106
|
-
try {
|
|
107
|
-
const result = await this.privateCampaignManagementAPIClient.setEntitiesPremium(campaignID, organisationIDs, studyIDs);
|
|
108
|
-
} catch {
|
|
109
|
-
assert.fail();
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
assert.ok(true);
|
|
113
|
-
}
|
|
114
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
|
|
4
|
-
"outDir": "bin",
|
|
5
|
-
"rootDir": ".",
|
|
6
|
-
"moduleResolution": "node",
|
|
7
|
-
|
|
8
|
-
"alwaysStrict": true,
|
|
9
|
-
"strictNullChecks": true,
|
|
10
|
-
|
|
11
|
-
"allowJs": false,
|
|
12
|
-
"allowUnreachableCode": false,
|
|
13
|
-
"allowUnusedLabels": false,
|
|
14
|
-
|
|
15
|
-
"noUnusedLocals": false,
|
|
16
|
-
"noUnusedParameters": false,
|
|
17
|
-
|
|
18
|
-
"noFallthroughCasesInSwitch": true,
|
|
19
|
-
"noImplicitAny": true,
|
|
20
|
-
"noImplicitReturns": true,
|
|
21
|
-
"noImplicitThis": true,
|
|
22
|
-
|
|
23
|
-
"sourceMap": true,
|
|
24
|
-
"declaration": true,
|
|
25
|
-
|
|
26
|
-
"target": "es2017",
|
|
27
|
-
"lib": ["es2017", "dom"],
|
|
28
|
-
"module": "commonjs",
|
|
29
|
-
|
|
30
|
-
"experimentalDecorators": true,
|
|
31
|
-
"emitDecoratorMetadata": true,
|
|
32
|
-
|
|
33
|
-
"types": [ ]
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
"typeRoots": [ "node_modules/@types/" ],
|
|
37
|
-
|
|
38
|
-
"exclude": [ "node_modules", "bin" ]
|
|
39
|
-
}
|